Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 34665 invoked from network); 10 Jun 2005 14:09:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Jun 2005 14:09:50 -0000 Received: (qmail 25596 invoked by uid 500); 10 Jun 2005 14:09:43 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 25456 invoked by uid 500); 10 Jun 2005 14:09:42 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 25225 invoked by uid 99); 10 Jun 2005 14:09:41 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 10 Jun 2005 07:09:33 -0700 Received: (qmail 28028 invoked by uid 65534); 10 Jun 2005 08:42:34 -0000 Message-ID: <20050610084234.28026.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r189923 - in /directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration: Configuration.java ConfigurationException.java ContextPartitionConfiguration.java MutableContextPartitionConfiguration.java Date: Fri, 10 Jun 2005 08:42:33 -0000 To: commits@directory.apache.org From: trustin@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: trustin Date: Fri Jun 10 01:42:32 2005 New Revision: 189923 URL: http://svn.apache.org/viewcvs?rev=3D189923&view=3Drev Log: * Added ConfigurationException and replaced IllegalArgumentExceptions with = it. * Modified ContextPartitionConfiguration more IoC framework friendly * Added MutableContextPartitionConfiguration Added: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/ConfigurationException.java (with props) directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/MutableContextPartitionConfiguration.java (with p= rops) Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/Configuration.java directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/ContextPartitionConfiguration.java Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apa= che/ldap/server/configuration/Configuration.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/c= ore/src/main/java/org/apache/ldap/server/configuration/Configuration.java?r= ev=3D189923&r1=3D189922&r2=3D189923&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/Configuration.java (original) +++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/Configuration.java Fri Jun 10 01:42:32 2005 @@ -39,15 +39,15 @@ * Gets {@link Configuration} instance from the specified JNDI environ= ment * {@link Hashtable}. *=20 - * @throws IllegalArgumentException if the specified environment doesn= 't - * contain the configuration instance. + * @throws ConfigurationException if the specified environment doesn't + * contain the configuration instance. */ public static Configuration toConfiguration( Hashtable jndiEnvironment= ) { Object value =3D jndiEnvironment.get( JNDI_KEY ); if( value =3D=3D null || !( value instanceof Configuration ) ) { - throw new IllegalArgumentException( "Not an ApacheDS configura= tion: " + value ); + throw new ConfigurationException( "Not an ApacheDS configurati= on: " + value ); } =20 return ( Configuration ) value; Added: directory/apacheds/branches/direve-158/core/src/main/java/org/apache= /ldap/server/configuration/ConfigurationException.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/c= ore/src/main/java/org/apache/ldap/server/configuration/ConfigurationExcepti= on.java?rev=3D189923&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/ConfigurationException.java (added) +++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/ConfigurationException.java Fri Jun 10 01:42:32 2005 @@ -0,0 +1,62 @@ +/* + * @(#) $Id$ + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ldap.server.configuration; + +/** + * A {@link RuntimeException} that is thrown when configuration is not val= id. + * + * @author Apache Directory Pr= oject + * @version $Rev$, $Date$ + */ +public class ConfigurationException extends RuntimeException +{ + private static final long serialVersionUID =3D -1439234202862091912L; + + /** + * Creates a new instance. + */ + public ConfigurationException() + { + super(); + } + + /** + * Creates a new instance. + */ + public ConfigurationException( String message ) + { + super( message ); + } + + /** + * Creates a new instance. + */ + public ConfigurationException( String message, Throwable cause ) + { + super( message, cause ); + } + + /** + * Creates a new instance. + */ + public ConfigurationException( Throwable cause ) + { + super( cause ); + } +} Propchange: directory/apacheds/branches/direve-158/core/src/main/java/org/a= pache/ldap/server/configuration/ConfigurationException.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apa= che/ldap/server/configuration/ContextPartitionConfiguration.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/c= ore/src/main/java/org/apache/ldap/server/configuration/ContextPartitionConf= iguration.java?rev=3D189923&r1=3D189922&r2=3D189923&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/ContextPartitionConfiguration.java (original) +++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/ContextPartitionConfiguration.java Fri Jun 10 01:42= :32 2005 @@ -19,11 +19,18 @@ package org.apache.ldap.server.configuration; =20 =20 +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttributes; + +import org.apache.ldap.server.ContextPartition; =20 =20 /** - * A configuration bean for ContextPartitions. + * A configuration for {@link ContextPartition}. * * @author Apache Directory Pr= oject * @version $Rev$, $Id$ @@ -31,77 +38,72 @@ public class ContextPartitionConfiguration { private String suffix; - private String id; - private String[] indices; - private Attributes attributes; - private String partitionClass; - private String properties; - - - public String getSuffix() + private Set indexedAttributes =3D new HashSet(); // Set + private Attributes rootEntry =3D new BasicAttributes(); + private ContextPartition partition; + =20 + /** + * Creates a new instance. + */ + protected ContextPartitionConfiguration() { - return suffix; } =20 - - public void setSuffix( String suffix ) - { - this.suffix =3D suffix; - } - - - public String getId() - { - return id; - } - - - public void setId( String id ) + public Set getIndexedAttributes() { - this.id =3D id; + Set result =3D new HashSet(); + result.addAll( indexedAttributes ); + return result; } - - - public String[] getIndices() + =20 + protected void setIndexedAttributes( Set indexedAttributes ) { - return indices; - } - + Set newIndexedAttributes =3D new HashSet(); =20 - public void setIndices( String[] indices ) - { - this.indices =3D indices; + Iterator i =3D indexedAttributes.iterator(); + while( i.hasNext() ) + { + Object e =3D i.next(); + if( !(e instanceof String) ) + { + throw new ConfigurationException( "All elements of indexed= Attributes must be strings." ); + } + =20 + // TODO Attribute name must be normalized and validated + String attr =3D ( ( String ) e ).trim(); + newIndexedAttributes.add( attr ); + } + this.indexedAttributes =3D newIndexedAttributes; } - - - public Attributes getAttributes() + =20 + public ContextPartition getPartition() { - return attributes; + return partition; } - - - public void setAttributes( Attributes attributes ) + =20 + protected void setPartition( ContextPartition partition ) { - this.attributes =3D attributes; + this.partition =3D partition; } - - public String getPartitionClass() + =20 + public Attributes getRootEntry() { - return partitionClass; + return ( Attributes ) rootEntry.clone(); } - - public void setPartitionClass( String partitionClass ) + =20 + protected void setRootEntry( Attributes rootEntry ) { - this.partitionClass =3D partitionClass; + this.rootEntry =3D ( Attributes ) rootEntry.clone(); } - - public String getProperties() + =20 + public String getSuffix() { - return properties; + return suffix; } - - public void setProperties( String properties ) + =20 + protected void setSuffix( String suffix ) { - this.properties =3D properties; + // TODO Suffix should be normalized before being set + this.suffix =3D suffix.trim(); } } Added: directory/apacheds/branches/direve-158/core/src/main/java/org/apache= /ldap/server/configuration/MutableContextPartitionConfiguration.java URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/c= ore/src/main/java/org/apache/ldap/server/configuration/MutableContextPartit= ionConfiguration.java?rev=3D189923&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/MutableContextPartitionConfiguration.java (added) +++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ld= ap/server/configuration/MutableContextPartitionConfiguration.java Fri Jun 1= 0 01:42:32 2005 @@ -0,0 +1,80 @@ +/* + * @(#) $Id$ + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ldap.server.configuration; + +import java.util.Set; + +import javax.naming.directory.Attributes; + +import org.apache.ldap.server.ContextPartition; + +/** + * A mutable version of {@link ContextPartitionConfiguration}. + * + * @author Apache Directory Pr= oject + * @version $Rev$, $Id$ + */ +public class MutableContextPartitionConfiguration extends + ContextPartitionConfiguration +{ + /** + * Creates a new instance. + */ + public MutableContextPartitionConfiguration() + { + } + + public void setIndexedAttributes( Set indexedAttributes ) + { + super.setIndexedAttributes( indexedAttributes ); + } + + public void setPartition( ContextPartition partition ) + { + super.setPartition( partition ); + } + + public void setRootEntry( Attributes rootEntry ) + { + super.setRootEntry( rootEntry ); + } + + public void setSuffix( String suffix ) + { + super.setSuffix( suffix ); + } + =20 + /** + * Validates this configuration. + *=20 + * @throws ConfigurationException if this configuration is not valid + */ + public void validate() + { + if( getSuffix() =3D=3D null ) + { + throw new ConfigurationException( "Suffix is not specified." ); + } + =20 + if( getPartition() =3D=3D null ) + { + throw new ConfigurationException( "Partition is not specified.= " ); + } + } +} Propchange: directory/apacheds/branches/direve-158/core/src/main/java/org/a= pache/ldap/server/configuration/MutableContextPartitionConfiguration.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision