costin 2002/10/01 11:49:49 Added: naming/src/org/apache/naming/res LocalStrings.properties LocalStrings_es.properties LocalStrings_ja.properties naming/src/org/apache/naming/util AttributeHelper.java DomXml.java RecyclableNamingEnumeration.java Log: Other imported files Revision Changes Path 1.1 jakarta-tomcat-connectors/naming/src/org/apache/naming/res/LocalStrings.properties Index: LocalStrings.properties =================================================================== contextBindings.unknownContext=Unknown context name : {0} contextBindings.noContextBoundToThread=No naming context bound to this thread contextBindings.noContextBoundToCL=No naming context bound to this class loader selectorContext.noJavaUrl=This context must be accessed throught a java: URL namingContext.contextExpected=Name is not bound to a Context namingContext.nameNotBound=Name {0} is not bound in this Context namingContext.readOnly=Context is read only namingContext.invalidName=Name is not valid namingContext.alreadyBound=Name {0} is already bound in this Context namingContext.noAbsoluteName=Can't generate an absolute name for this namespace 1.1 jakarta-tomcat-connectors/naming/src/org/apache/naming/res/LocalStrings_es.properties Index: LocalStrings_es.properties =================================================================== # $Id: LocalStrings_es.properties,v 1.1 2002/10/01 18:49:49 costin Exp $ # language es # package org.apache.naming contextBindings.unknownContext=Contexto {0} desconocido contextBindings.noContextBoundToThread=No hay contexto de nombres asociado a este hilo selectorContext.noJavaUrl=Este contexto debe de ser accedido a traves de una URL de tipo java: namingContext.contextExpected=El nombre no esta asociado a ningun Contexto namingContext.nameNotBound=El nombre {0} no este asociado a este contexto namingContext.readOnly=El contexto es de solo lectura namingContext.invalidName=Nombre no valido namingContext.noAbsoluteName=No se puede generar un nombre absoluto para este espacio de nombres namingContext.alreadyBound=El nombre {0} este ya asociado en este Contexto 1.1 jakarta-tomcat-connectors/naming/src/org/apache/naming/res/LocalStrings_ja.properties Index: LocalStrings_ja.properties =================================================================== contextBindings.unknownContext=\u672a\u77e5\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u540d\u3067\u3059 : {0} contextBindings.noContextBoundToThread=\u3053\u306e\u30b9\u30ec\u30c3\u30c9\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u308b\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u306f\u540d\u524d\u304c\u3042\u308a\u307e\u305b\u3093 contextBindings.noContextBoundToCL=\u3053\u306e\u30af\u30e9\u30b9\u30ed\u30fc\u30c0\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u308b\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u306f\u540d\u524d\u304c\u3042\u308a\u307e\u305b\u3093 selectorContext.noJavaUrl=\u3053\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306fjava: URL\u3092\u7528\u3044\u3066\u30a2\u30af\u30bb\u30b9\u3055\u308c\u306d\u3070\u306a\u308a\u307e\u305b\u3093 namingContext.contextExpected=\u540d\u524d\u304c\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u3066\u3044\u307e\u305b\u3093 namingContext.nameNotBound=\u540d\u524d {0} \u306f\u3053\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u3066\u3044\u307e\u305b\u3093 namingContext.readOnly=\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306f\u30ea\u30fc\u30c9\u30aa\u30f3\u30ea\u30fc\u3067\u3059 namingContext.invalidName=\u540d\u524d\u306f\u7121\u52b9\u3067\u3059 namingContext.alreadyBound=\u540d\u524d {0} \u306f\u3059\u3067\u306b\u3053\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u3066\u3044\u307e\u3059 namingContext.noAbsoluteName=\u3053\u306e\u540d\u524d\u7a7a\u9593\u306b\u7d76\u5bfe\u540d\u3092\u751f\u6210\u3067\u304d\u307e\u305b\u3093 1.1 jakarta-tomcat-connectors/naming/src/org/apache/naming/util/AttributeHelper.java Index: AttributeHelper.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.naming.util; import java.io.*; import java.security.Permission; import java.util.Date; import java.util.Enumeration; import java.util.Vector; import javax.naming.NamingException; import javax.naming.NamingEnumeration; import javax.naming.NameClassPair; import javax.naming.directory.DirContext; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import java.text.SimpleDateFormat; import java.text.DateFormat; import java.text.ParseException; import java.util.Locale; import org.apache.naming.core.JndiPermission; // import org.apache.naming.resources.Resource; // import org.apache.naming.resources.ResourceAttributes; /** * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> * @author Costin Manolache */ public class AttributeHelper { /** * Content length. */ public static final String CONTENT_LENGTH = "getcontentlength"; public static final String ALTERNATE_CONTENT_LENGTH = "content-length"; /** * MIME type of the content. */ public static final String CONTENT_TYPE = "getcontenttype"; public static final String ALTERNATE_TYPE = "content-type"; /** * Last modification date. XXX Use standard LDAP att name */ public static final String LAST_MODIFIED = "getlastmodified"; public static final String ALTERNATE_LAST_MODIFIED = "last-modified"; /** * Date formats using for Date parsing. */ protected static final SimpleDateFormat formats[] = { new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US), new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; /** * Get content length. * * @return content length value */ public static long getContentLength(Attributes attributes) { long contentLength=-1; if (contentLength != -1L) return contentLength; if (attributes != null) { Attribute attribute = attributes.get(CONTENT_LENGTH); if( attribute==null ) attribute=attributes.get(ALTERNATE_CONTENT_LENGTH ); if (attribute != null) { try { Object value = attribute.get(); if (value instanceof Long) { contentLength = ((Long) value).longValue(); } else { try { contentLength = Long.parseLong(value.toString()); } catch (NumberFormatException e) { ; // Ignore } } } catch (NamingException e) { ; // No value for the attribute } } } return contentLength; } /** * Return the content type value. */ public static String getContentType(Attributes attributes) { Attribute attribute = attributes.get(CONTENT_TYPE); if( attribute == null ) return null; try { String s= attribute.get().toString(); return s; } catch (Exception e) { // Shouldn't happen, unless the attribute has no value } return null; } /** Find the last modified of an entry. It's using various common * attribute names, and support Long, Date, String att values. */ public static long getLastModified( Attributes attributes ) { long lastModified=-1; Date lastModifiedDate; Attribute attribute = attributes.get(LAST_MODIFIED); if( attribute==null ) attribute=attributes.get(ALTERNATE_LAST_MODIFIED); if (attribute != null) { try { Object value = attribute.get(); if (value instanceof Long) { lastModified = ((Long) value).longValue(); } else if (value instanceof Date) { lastModified = ((Date) value).getTime(); lastModifiedDate = (Date) value; } else { String lastModifiedDateValue = value.toString(); Date result = null; // Parsing the HTTP Date for (int i = 0; (result == null) && (i < formats.length); i++) { try { result = formats[i].parse(lastModifiedDateValue); } catch (ParseException e) { ; } } if (result != null) { lastModified = result.getTime(); lastModifiedDate = result; } } } catch (NamingException e) { ; // No value for the attribute } } return lastModified; } } 1.1 jakarta-tomcat-connectors/naming/src/org/apache/naming/util/DomXml.java Index: DomXml.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.naming.util; import java.io.*; import java.net.*; import java.util.*; import java.security.*; import org.apache.tomcat.util.IntrospectionUtils; import javax.xml.parsers.*; /* Yes, it's using DOM */ import org.w3c.dom.*; import org.xml.sax.*; // moved from jk2 config package. /** * * @author Costin Manolache */ public class DomXml { String file; String name; // -------------------- Settings -------------------- /** */ public void setFile( String file ) { this.file=file; } /** */ public void setName( String name ) { this.name=name; } // -------------------- Implementation -------------------- Node domN; /** Return the top level node */ public Node getNode() { return domN; } // -------------------- ant wrapper -------------------- public void execute() { try { if( file== null) { log.error("No file attribute"); return; } File docF=new File(file); Document doc=readXml(docF); if( doc == null ) return; domN = doc.getDocumentElement(); if( domN==null ) { log.error("Can't find the root node"); return; } } catch( Exception ex ) { ex.printStackTrace(); } } private static org.apache.commons.logging.Log log= org.apache.commons.logging.LogFactory.getLog( DomXml.class ); // -------------------- DOM utils -------------------- /** Get the content of a node */ public static String getContent(Node n ) { if( n==null ) return null; Node n1=n.getFirstChild(); // XXX Check if it's a text node String s1=n1.getNodeValue(); return s1.trim(); } /** Get the first child */ public static Node getChild( Node parent, String name ) { if( parent==null ) return null; Node first=parent.getFirstChild(); if( first==null ) return null; for (Node node = first; node != null; node = node.getNextSibling()) { //System.out.println("getNode: " + name + " " + node.getNodeName()); if( name.equals( node.getNodeName() ) ) { return node; } } return null; } /** Get the first child's content ( i.e. it's included TEXT node ) */ public static String getChildContent( Node parent, String name ) { Node first=parent.getFirstChild(); if( first==null ) return null; for (Node node = first; node != null; node = node.getNextSibling()) { //System.out.println("getNode: " + name + " " + node.getNodeName()); if( name.equals( node.getNodeName() ) ) { return getContent( node ); } } return null; } /** Get the node in the list of siblings */ public static Node getNext( Node current ) { Node first=current.getNextSibling(); String name=current.getNodeName(); if( first==null ) return null; for (Node node = first; node != null; node = node.getNextSibling()) { //System.out.println("getNode: " + name + " " + node.getNodeName()); if( name.equals( node.getNodeName() ) ) { return node; } } return null; } public static class NullResolver implements EntityResolver { public InputSource resolveEntity (String publicId, String systemId) throws SAXException, IOException { if( log.isTraceEnabled()) log.trace("ResolveEntity: " + publicId + " " + systemId); return new InputSource(new StringReader("")); } } public void saveXml( Node n, File xmlF ) { } public static Document readXml(File xmlF) throws SAXException, IOException, ParserConfigurationException { if( ! xmlF.exists() ) { log.error("No xml file " + xmlF ); return null; } DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringComments(false); dbf.setIgnoringElementContentWhitespace(true); //dbf.setCoalescing(true); //dbf.setExpandEntityReferences(true); DocumentBuilder db = null; db = dbf.newDocumentBuilder(); db.setEntityResolver( new NullResolver() ); // db.setErrorHandler( new MyErrorHandler()); Document doc = db.parse(xmlF); return doc; } } 1.1 jakarta-tomcat-connectors/naming/src/org/apache/naming/util/RecyclableNamingEnumeration.java Index: RecyclableNamingEnumeration.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-connectors/naming/src/org/apache/naming/util/RecyclableNamingEnumeration.java,v 1.1 2002/10/01 18:49:49 costin Exp $ * $Revision: 1.1 $ * $Date: 2002/10/01 18:49:49 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.naming.util; import java.util.Hashtable; import java.util.Vector; import java.util.Enumeration; import javax.naming.NamingException; import javax.naming.NamingEnumeration; import javax.naming.NameClassPair; /** * Naming enumeration implementation. * * @author Remy Maucherat * @version $Revision: 1.1 $ $Date: 2002/10/01 18:49:49 $ */ public class RecyclableNamingEnumeration implements NamingEnumeration { // ----------------------------------------------------------- Constructors public RecyclableNamingEnumeration(Vector entries) { this.entries = entries; recycle(); } // -------------------------------------------------------------- Variables /** * Entries. */ protected Vector entries; /** * Underlying enumeration. */ protected Enumeration enum; // --------------------------------------------------------- Public Methods /** * Retrieves the next element in the enumeration. */ public Object next() throws NamingException { return nextElement(); } /** * Determines whether there are any more elements in the enumeration. */ public boolean hasMore() throws NamingException { return enum.hasMoreElements(); } /** * Closes this enumeration. */ public void close() throws NamingException { } public boolean hasMoreElements() { return enum.hasMoreElements(); } public Object nextElement() { return enum.nextElement(); } // -------------------------------------------------------- Package Methods /** * Recycle. */ void recycle() { enum = entries.elements(); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>