/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*
*
* This file incorporates work covered by the following copyright and
* permission notice:
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Connection to a JNDI directory context.
* <p/>
* Note: All the object attribute names are the WebDAV names, not the HTTP
* names, so this class overrides some methods from URLConnection to do the
* queries using the right names. Content handler is also not used; the
* content is directly returned.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
* @version $Revision: 1.3 $
*/
public class DirContextURLConnection
extends URLConnection {
// ----------------------------------------------------------- Constructors
super(url);
throw new IllegalArgumentException
("Directory context can't be null");
if (IS_SECURITY_ENABLED) {
}
}
// ----------------------------------------------------- Instance Variables
/**
* Directory context.
*/
/**
* Associated resource.
*/
/**
* Associated DirContext.
*/
/**
* Other unknown object.
*/
/**
* Attributes.
*/
/**
* Date.
*/
protected long date;
/**
* Permission
*/
/**
* Is the Java SecurityManager enabled?
*/
public static final boolean IS_SECURITY_ENABLED =
// ------------------------------------------------------------- Properties
/**
* Connect to the DirContext, and retrive the bound object, as well as
* its attributes. If no object is bound with the name specified in the
* URL, then an IOException is thrown.
*
* @throws IOException Object not found
*/
public void connect()
throws IOException {
if (!connected) {
try {
if (context instanceof ProxyDirContext) {
return;
}
if (contextName != null) {
return;
} else {
}
}
}
if (object instanceof DirContext)
} catch (NamingException e) {
// Object not found
}
connected = true;
}
}
/**
* Return the content length value.
*/
public int getContentLength() {
}
/**
* Return the content type value.
*/
}
/**
* Return the last modified date.
*/
public long getDate() {
return date;
}
/**
* Return the last modified date.
*/
public long getLastModified() {
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
}
}
if (attributes == null)
return 0;
if (lastModified != null) {
try {
} catch (Exception e) {
}
}
return 0;
}
/**
* Returns an unmodifiable Map of the header fields.
*/
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
}
}
if (attributes == null)
return (Collections.emptyMap());
try {
while (attributeEnum.hasMore()) {
while (attributeValues.hasMore()) {
}
}
} catch (NamingException ne) {
// Shouldn't happen
}
}
/**
* Returns the name of the specified header field.
*/
if (!connected) {
// Try to connect (silently)
try {
connect();
} catch (IOException e) {
}
}
if (attributes == null)
return (null);
try {
while (attributeEnum.hasMore()) {
}
}
} catch (NamingException ne) {
// Shouldn't happen
}
return (null);
}
/**
* Get object content.
*/
throws IOException {
if (!connected)
connect();
return getInputStream();
if (collection != null)
return collection;
return object;
throw new FileNotFoundException();
}
/**
* Get object content.
*/
throws IOException {
return object;
}
return null;
}
/**
* Get input stream.
*/
throws IOException {
if (!connected)
connect();
throw new FileNotFoundException();
} else {
// Reopen resource
try {
} catch (NamingException e) {
}
}
return (resource.streamContent());
}
/**
* Get the Permission for this URL
*/
return permission;
}
// --------------------------------------------------------- Public Methods
/**
* List children of this collection. The names given are relative to this
* URI's path. The full uri of the children is then : path + "/" + name.
*/
throws IOException {
if (!connected) {
connect();
}
throw new FileNotFoundException(
}
if (collection != null) {
try {
while (enumeration.hasMoreElements()) {
}
} catch (NamingException e) {
// Unexpected exception
throw new FileNotFoundException(
}
}
}
}