You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/01/17 13:17:46 UTC
svn commit: r900116 - in /directory/apacheds/trunk/default-config/src:
main/java/org/apache/directory/server/config/
test/java/org/apache/directory/server/config/
Author: elecharny
Date: Sun Jan 17 12:17:46 2010
New Revision: 900116
URL: http://svn.apache.org/viewvc?rev=900116&view=rev
Log:
Minor refactoring (removing warnings, adding nls)
Modified:
directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/LdifConfigExtractor.java
directory/apacheds/trunk/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
Modified: directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=900116&r1=900115&r2=900116&view=diff
==============================================================================
--- directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original)
+++ directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Sun Jan 17 12:17:46 2010
@@ -92,6 +92,7 @@
*/
public class ConfigPartitionReader
{
+ private static final Logger LOG = LoggerFactory.getLogger( ConfigPartitionReader.class );
/** the partition which holds the configuration data */
private LdifPartition configPartition;
@@ -110,7 +111,7 @@
{
public boolean accept( File file, String name )
{
- if( file.isDirectory() )
+ if ( file.isDirectory() )
{
return true;
}
@@ -119,8 +120,6 @@
}
};
- private static final Logger LOG = LoggerFactory.getLogger( ConfigPartitionReader.class );
-
/**
*
@@ -155,11 +154,11 @@
*/
public LdapServer getLdapServer() throws Exception
{
- EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-ldapServer" ) );
+ EqualityNode<String> filter = new EqualityNode<String>( "objectClass", new ClientStringValue( "ads-ldapServer" ) );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -168,12 +167,13 @@
return null;
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry ldapServerEntry = configPartition.lookup( forwardEntry.getId() );
LOG.debug( "LDAP Server Entry {}", ldapServerEntry );
- if( !isEnabled( ldapServerEntry ) )
+
+ if ( !isEnabled( ldapServerEntry ) )
{
return null;
}
@@ -192,11 +192,11 @@
public KdcServer getKdcServer() throws Exception
{
- EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-kerberosServer" ) );
+ EqualityNode<String> filter = new EqualityNode<String>( "objectClass", new ClientStringValue( "ads-kerberosServer" ) );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -205,12 +205,13 @@
return null;
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry kdcEntry = configPartition.lookup( forwardEntry.getId() );
LOG.debug( "kerberos server entry {}", kdcEntry );
- if( !isEnabled( kdcEntry ) )
+
+ if ( !isEnabled( kdcEntry ) )
{
return null;
}
@@ -226,17 +227,20 @@
// MAY attributes
EntryAttribute clockSkewAttr = kdcEntry.get( "ads-krbAllowableClockSkew" );
- if( clockSkewAttr != null )
+
+ if ( clockSkewAttr != null )
{
kdcServer.setAllowableClockSkew( Long.parseLong( clockSkewAttr.getString() ) );
}
EntryAttribute encryptionTypeAttr = kdcEntry.get( "ads-krbEncryptionTypes" );
- if( encryptionTypeAttr != null )
+
+ if ( encryptionTypeAttr != null )
{
EncryptionType[] encryptionTypes = new EncryptionType[ encryptionTypeAttr.size() ];
Iterator<Value<?>> itr = encryptionTypeAttr.getAll();
int count = 0;
+
while( itr.hasNext() )
{
Value<?> val = itr.next();
@@ -247,67 +251,78 @@
}
EntryAttribute emptyAddrAttr = kdcEntry.get( "ads-krbEmptyAddressesAllowed" );
- if( emptyAddrAttr != null )
+
+ if ( emptyAddrAttr != null )
{
kdcServer.setEmptyAddressesAllowed( Boolean.parseBoolean( emptyAddrAttr.getString() ) );
}
EntryAttribute fwdAllowedAttr = kdcEntry.get( "ads-krbForwardableAllowed" );
- if( fwdAllowedAttr != null )
+
+ if ( fwdAllowedAttr != null )
{
kdcServer.setForwardableAllowed( Boolean.parseBoolean( fwdAllowedAttr.getString() ) );
}
EntryAttribute paEncTmstpAttr = kdcEntry.get( "ads-krbPaEncTimestampRequired" );
- if( paEncTmstpAttr != null )
+
+ if ( paEncTmstpAttr != null )
{
kdcServer.setPaEncTimestampRequired( Boolean.parseBoolean( paEncTmstpAttr.getString() ) );
}
EntryAttribute posdtAllowedAttr = kdcEntry.get( "ads-krbPostdatedAllowed" );
- if( posdtAllowedAttr != null )
+
+ if ( posdtAllowedAttr != null )
{
kdcServer.setPostdatedAllowed( Boolean.parseBoolean( posdtAllowedAttr.getString() ) );
}
EntryAttribute prxyAllowedAttr = kdcEntry.get( "ads-krbProxiableAllowed" );
- if( prxyAllowedAttr != null )
+
+ if ( prxyAllowedAttr != null )
{
kdcServer.setProxiableAllowed( Boolean.parseBoolean( prxyAllowedAttr.getString() ) );
}
EntryAttribute rnwAllowedAttr = kdcEntry.get( "ads-krbRenewableAllowed" );
- if( rnwAllowedAttr != null )
+
+ if ( rnwAllowedAttr != null )
{
kdcServer.setRenewableAllowed( Boolean.parseBoolean( rnwAllowedAttr.getString() ) );
}
EntryAttribute kdcPrncplAttr = kdcEntry.get( "ads-krbKdcPrincipal" );
- if( kdcPrncplAttr != null )
+
+ if ( kdcPrncplAttr != null )
{
kdcServer.setKdcPrincipal( kdcPrncplAttr.getString() );
}
EntryAttribute maxRnwLfTimeAttr = kdcEntry.get( "ads-krbMaximumRenewableLifetime" );
- if( maxRnwLfTimeAttr != null )
+
+ if ( maxRnwLfTimeAttr != null )
{
kdcServer.setMaximumRenewableLifetime( Long.parseLong( maxRnwLfTimeAttr.getString() ) );
}
EntryAttribute maxTcktLfTimeAttr = kdcEntry.get( "ads-krbMaximumTicketLifetime" );
- if( maxTcktLfTimeAttr != null )
+
+ if ( maxTcktLfTimeAttr != null )
{
kdcServer.setMaximumTicketLifetime( Long.parseLong( maxTcktLfTimeAttr.getString() ) );
}
EntryAttribute prmRealmAttr = kdcEntry.get( "ads-krbPrimaryRealm" );
- if( prmRealmAttr != null )
+
+ if ( prmRealmAttr != null )
{
kdcServer.setPrimaryRealm( prmRealmAttr.getString() );
}
EntryAttribute bdyCkhsmVerifyAttr = kdcEntry.get( "ads-krbBodyChecksumVerified" );
- if( bdyCkhsmVerifyAttr != null )
+
+ if ( bdyCkhsmVerifyAttr != null )
{
kdcServer.setBodyChecksumVerified( Boolean.parseBoolean( bdyCkhsmVerifyAttr.getString() ) );
}
@@ -318,11 +333,11 @@
public DnsServer getDnsServer() throws Exception
{
- EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-dnsServer" ) );
+ EqualityNode<String> filter = new EqualityNode<String>( "objectClass", new ClientStringValue( "ads-dnsServer" ) );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -331,12 +346,13 @@
return null;
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry dnsEntry = configPartition.lookup( forwardEntry.getId() );
LOG.debug( "DNS server entry {}", dnsEntry );
- if( !isEnabled( dnsEntry ) )
+
+ if ( !isEnabled( dnsEntry ) )
{
return null;
}
@@ -357,11 +373,11 @@
//TODO making this method invisible cause there is no DhcpServer exists as of now
private DhcpService getDhcpServer() throws Exception
{
- EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-dhcpServer" ) );
+ EqualityNode<String> filter = new EqualityNode<String>( "objectClass", new ClientStringValue( "ads-dhcpServer" ) );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -370,12 +386,13 @@
return null;
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry dhcpEntry = configPartition.lookup( forwardEntry.getId() );
LOG.debug( "DHCP server entry {}", dhcpEntry );
- if( !isEnabled( dhcpEntry ) )
+
+ if ( !isEnabled( dhcpEntry ) )
{
return null;
}
@@ -389,11 +406,11 @@
public NtpServer getNtpServer() throws Exception
{
- EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-ntpServer" ) );
+ EqualityNode<String> filter = new EqualityNode<String>( "objectClass", new ClientStringValue( "ads-ntpServer" ) );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -402,12 +419,13 @@
return null;
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry ntpEntry = configPartition.lookup( forwardEntry.getId() );
LOG.debug( "NTP server entry {}", ntpEntry );
- if( !isEnabled( ntpEntry ) )
+
+ if ( !isEnabled( ntpEntry ) )
{
return null;
}
@@ -427,11 +445,11 @@
public HttpServer getHttpServer() throws Exception
{
- EqualityNode filter = new EqualityNode( "objectClass", new ClientStringValue( "ads-httpServer" ) );
+ EqualityNode<String> filter = new EqualityNode<String>( "objectClass", new ClientStringValue( "ads-httpServer" ) );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -440,12 +458,13 @@
return null;
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry httpEntry = configPartition.lookup( forwardEntry.getId() );
LOG.debug( "HTTP server entry {}", httpEntry );
- if( !isEnabled( httpEntry ) )
+
+ if ( !isEnabled( httpEntry ) )
{
return null;
}
@@ -453,19 +472,22 @@
HttpServer httpServer = new HttpServer();
EntryAttribute portAttr = httpEntry.get( "ads-systemPort" );
- if( portAttr != null )
+
+ if ( portAttr != null )
{
httpServer.setPort( Integer.parseInt( portAttr.getString() ) );
}
EntryAttribute confFileAttr = httpEntry.get( "ads-httpConfFile" );
- if( confFileAttr != null )
+
+ if ( confFileAttr != null )
{
httpServer.setConfFile( confFileAttr.getString() );
}
EntryAttribute webAppsAttr = httpEntry.get( "ads-httpWebApps" );
- if( webAppsAttr != null )
+
+ if ( webAppsAttr != null )
{
LdapDN webAppsDN = new LdapDN( webAppsAttr.getString() );
webAppsDN.normalize( schemaManager.getNormalizerMapping() );
@@ -491,7 +513,7 @@
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
- IndexCursor cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( configPartition.getSuffixDn(), AliasDerefMode.NEVER_DEREF_ALIASES, filter,
controls );
if ( !cursor.next() )
@@ -501,7 +523,7 @@
+ configPartition.getSuffixDn() );
}
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
cursor.close();
ClonedServerEntry dsEntry = configPartition.lookup( forwardEntry.getId() );
@@ -524,28 +546,32 @@
Map<String, Partition> partitions = getPartitions( partitionsDN );
Partition systemPartition = partitions.remove( "system" );
- if( systemPartition == null )
+
+ if ( systemPartition == null )
{
throw new Exception( "system partition doesn't exist" );
}
dirService.setSystemPartition( systemPartition );
- dirService.setPartitions( new HashSet( partitions.values() ) );
+ dirService.setPartitions( new HashSet<Partition>( partitions.values() ) );
// MAY attributes
EntryAttribute acEnabledAttr = dsEntry.get( "ads-dsAccessControlEnabled" );
+
if ( acEnabledAttr != null )
{
dirService.setAccessControlEnabled( Boolean.parseBoolean( acEnabledAttr.getString() ) );
}
EntryAttribute anonAccessAttr = dsEntry.get( "ads-dsAllowAnonymousAccess" );
+
if ( anonAccessAttr != null )
{
dirService.setAllowAnonymousAccess( Boolean.parseBoolean( anonAccessAttr.getString() ) );
}
EntryAttribute changeLogAttr = dsEntry.get( "ads-dsChangeLog" );
+
if ( changeLogAttr != null )
{
LdapDN clDN = new LdapDN( changeLogAttr.getString() );
@@ -555,12 +581,14 @@
}
EntryAttribute denormAttr = dsEntry.get( "ads-dsDenormalizeOpAttrsEnabled" );
+
if ( denormAttr != null )
{
dirService.setDenormalizeOpAttrsEnabled( Boolean.parseBoolean( denormAttr.getString() ) );
}
EntryAttribute journalAttr = dsEntry.get( "ads-dsJournal" );
+
if ( journalAttr != null )
{
LdapDN journalDN = new LdapDN( journalAttr.getString() );
@@ -569,24 +597,28 @@
}
EntryAttribute maxPduAttr = dsEntry.get( "ads-dsMaxPDUSize" );
+
if ( maxPduAttr != null )
{
dirService.setMaxPDUSize( Integer.parseInt( maxPduAttr.getString() ) );
}
EntryAttribute passwordHidAttr = dsEntry.get( "ads-dsPasswordHidden" );
+
if ( passwordHidAttr != null )
{
dirService.setPasswordHidden( Boolean.parseBoolean( passwordHidAttr.getString() ) );
}
EntryAttribute replAttr = dsEntry.get( "ads-dsReplication" );
+
if ( replAttr != null )
{
// configure replication
}
EntryAttribute syncPeriodAttr = dsEntry.get( "ads-dsSyncPeriodMillis" );
+
if ( syncPeriodAttr != null )
{
// FIXME the DirectoryService interface doesn't have this setter
@@ -594,6 +626,7 @@
}
EntryAttribute testEntryAttr = dsEntry.get( "ads-dsTestEntries" );
+
if ( testEntryAttr != null )
{
String entryFilePath = testEntryAttr.getString();
@@ -623,13 +656,13 @@
PresenceNode filter = new PresenceNode( "ads-interceptorId" );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- IndexCursor cursor = se.cursor( interceptorsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( interceptorsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
Set<InterceptorConfig> set = new TreeSet<InterceptorConfig>();
while ( cursor.next() )
{
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
ServerEntry interceptorEntry = configPartition.lookup( forwardEntry.getId() );
String id = getString( "ads-interceptorId", interceptorEntry );
@@ -667,21 +700,22 @@
PresenceNode filter = new PresenceNode( "ads-partitionId" );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- IndexCursor cursor = se.cursor( partitionsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( partitionsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
Map<String,Partition> partitions = new HashMap<String,Partition>();
while( cursor.next() )
{
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
ServerEntry partitionEntry = configPartition.lookup( forwardEntry.getId() );
- if( !isEnabled( partitionEntry ) )
+ if ( !isEnabled( partitionEntry ) )
{
continue;
}
EntryAttribute ocAttr = partitionEntry.get( "objectClass" );
- if( ocAttr.contains( "ads-jdbmPartition" ) )
+
+ if ( ocAttr.contains( "ads-jdbmPartition" ) )
{
JdbmPartition partition = getJdbmPartition( partitionEntry );
partitions.put( partition.getId(), partition );
@@ -709,19 +743,22 @@
partition.setSuffix( getString( "ads-partitionSuffix", partitionEntry ) );
EntryAttribute cacheAttr = partitionEntry.get( "ads-partitionCacheSize" );
- if( cacheAttr != null )
+
+ if ( cacheAttr != null )
{
partition.setCacheSize( Integer.parseInt( cacheAttr.getString() ) );
}
EntryAttribute optimizerAttr = partitionEntry.get( "ads-jdbmPartitionOptimizerEnabled" );
- if( optimizerAttr != null )
+
+ if ( optimizerAttr != null )
{
partition.setOptimizerEnabled( Boolean.parseBoolean( optimizerAttr.getString() ) );
}
EntryAttribute syncAttr = partitionEntry.get( "ads-partitionSyncOnWrite" );
- if( syncAttr != null )
+
+ if ( syncAttr != null )
{
partition.setSyncOnWrite( Boolean.parseBoolean( syncAttr.getString() ) );
}
@@ -740,21 +777,23 @@
PresenceNode filter = new PresenceNode( "ads-indexAttributeId" );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- IndexCursor cursor = se.cursor( indexesDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( indexesDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
Set<Index<?,ServerEntry>> indexes = new HashSet<Index<?,ServerEntry>>();
while( cursor.next() )
{
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
ServerEntry indexEntry = configPartition.lookup( forwardEntry.getId() );
- if( !isEnabled( indexEntry ) )
+
+ if ( !isEnabled( indexEntry ) )
{
continue;
}
EntryAttribute ocAttr = indexEntry.get( "objectClass" );
- if( ocAttr.contains( "ads-jdbmIndex" ) )
+
+ if ( ocAttr.contains( "ads-jdbmIndex" ) )
{
indexes.add( getJdbmIndex( indexEntry ) );
}
@@ -770,10 +809,11 @@
private JdbmIndex<?, ServerEntry> getJdbmIndex( ServerEntry indexEntry ) throws Exception
{
- JdbmIndex<?, ServerEntry> index = new JdbmIndex();
+ JdbmIndex<String, ServerEntry> index = new JdbmIndex<String, ServerEntry>();
index.setAttributeId( getString( "ads-indexAttributeId", indexEntry ) );
EntryAttribute cacheAttr = indexEntry.get( "ads-indexCacheSize" );
- if( cacheAttr != null )
+
+ if ( cacheAttr != null )
{
index.setCacheSize( Integer.parseInt( cacheAttr.getString() ) );
}
@@ -787,15 +827,16 @@
PresenceNode filter = new PresenceNode( "ads-transportId" );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- IndexCursor cursor = se.cursor( transportsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( transportsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
List<Transport> transports = new ArrayList<Transport>();
while( cursor.next() )
{
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
ServerEntry transportEntry = configPartition.lookup( forwardEntry.getId() );
- if( !isEnabled( transportEntry ) )
+
+ if ( !isEnabled( transportEntry ) )
{
continue;
}
@@ -807,24 +848,25 @@
}
-
private Transport getTransport( Entry transportEntry ) throws Exception
{
Transport transport = null;
EntryAttribute ocAttr = transportEntry.get( "objectClass" );
- if( ocAttr.contains( "ads-tcpTransport" ) )
+
+ if ( ocAttr.contains( "ads-tcpTransport" ) )
{
transport = new TcpTransport();
}
- else if( ocAttr.contains( "ads-udpTransport" ) )
+ else if ( ocAttr.contains( "ads-udpTransport" ) )
{
transport = new UdpTransport();
}
transport.setPort( getInt( "ads-systemPort", transportEntry ) );
EntryAttribute addressAttr = transportEntry.get( "ads-transportAddress" );
- if( addressAttr != null )
+
+ if ( addressAttr != null )
{
transport.setAddress( addressAttr.getString() );
}
@@ -834,19 +876,22 @@
}
EntryAttribute backlogAttr = transportEntry.get( "ads-transportBacklog" );
- if( backlogAttr != null )
+
+ if ( backlogAttr != null )
{
transport.setBackLog( Integer.parseInt( backlogAttr.getString() ) );
}
EntryAttribute sslAttr = transportEntry.get( "ads-transportEnableSSL" );
- if( sslAttr != null )
+
+ if ( sslAttr != null )
{
transport.setEnableSSL( Boolean.parseBoolean( sslAttr.getString() ) );
}
EntryAttribute nbThreadsAttr = transportEntry.get( "ads-transportNbThreads" );
- if( nbThreadsAttr != null )
+
+ if ( nbThreadsAttr != null )
{
transport.setNbThreads( Integer.parseInt( nbThreadsAttr.getString() ) );
}
@@ -857,18 +902,20 @@
private ChangeLog getChangeLog( LdapDN changelogDN ) throws Exception
{
- Long id = configPartition.getEntryId( changelogDN.getNormName() );
+ long id = configPartition.getEntryId( changelogDN.getNormName() );
Entry clEntry = configPartition.lookup( id );
ChangeLog cl = new DefaultChangeLog();
EntryAttribute clEnabledAttr =clEntry.get( "ads-changeLogEnabled" );
- if( clEnabledAttr != null )
+
+ if ( clEnabledAttr != null )
{
cl.setEnabled( Boolean.parseBoolean( clEnabledAttr.getString() ) );
}
EntryAttribute clExpAttr = clEntry.get( "ads-changeLogExposed" );
- if( clExpAttr != null )
+
+ if ( clExpAttr != null )
{
cl.setExposed( Boolean.parseBoolean( clExpAttr.getString() ) );
}
@@ -879,7 +926,7 @@
private Journal getJournal( LdapDN journalDN ) throws Exception
{
- Long id = configPartition.getEntryId( journalDN.getNormName() );
+ long id = configPartition.getEntryId( journalDN.getNormName() );
Entry jlEntry = configPartition.lookup( id );
Journal journal = new DefaultJournal();
@@ -888,19 +935,22 @@
store.setFileName( getString( "ads-journalFileName", jlEntry ) );
EntryAttribute jlWorkDirAttr = jlEntry.get( "ads-journalWorkingDir" );
- if( jlWorkDirAttr != null )
+
+ if ( jlWorkDirAttr != null )
{
store.setWorkingDirectory( jlWorkDirAttr.getString() );
}
EntryAttribute jlRotAttr = jlEntry.get( "ads-journalRotation" );
- if( jlRotAttr != null )
+
+ if ( jlRotAttr != null )
{
journal.setRotation( Integer.parseInt( jlRotAttr.getString() ) );
}
EntryAttribute jlEnabledAttr = jlEntry.get( "ads-journalEnabled" );
- if( jlEnabledAttr != null )
+
+ if ( jlEnabledAttr != null )
{
journal.setEnabled( Boolean.parseBoolean( jlEnabledAttr.getString() ) );
}
@@ -915,7 +965,8 @@
List<LdifEntry> entries = new ArrayList<LdifEntry>();
File file = new File( entryFilePath );
- if( !file.exists() )
+
+ if ( !file.exists() )
{
LOG.warn( "LDIF test entry file path doesn't exist {}", entryFilePath );
}
@@ -931,9 +982,10 @@
private void loadEntries( File ldifFile, List<LdifEntry> entries ) throws Exception
{
- if( ldifFile.isDirectory() )
+ if ( ldifFile.isDirectory() )
{
File[] files = ldifFile.listFiles( ldifFilter );
+
for( File f : files )
{
loadEntries( f, entries );
@@ -953,20 +1005,21 @@
PresenceNode filter = new PresenceNode( "ads-httpWarFile" );
SearchControls controls = new SearchControls();
controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- IndexCursor cursor = se.cursor( webAppsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+ IndexCursor<Long, ServerEntry> cursor = se.cursor( webAppsDN, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
Set<WebApp> webApps = new HashSet<WebApp>();
while( cursor.next() )
{
- ForwardIndexEntry<Long, Long> forwardEntry = ( ForwardIndexEntry<Long, Long> ) cursor.get();
+ ForwardIndexEntry<Long, ServerEntry> forwardEntry = ( ForwardIndexEntry<Long, ServerEntry> ) cursor.get();
ServerEntry webAppEntry = configPartition.lookup( forwardEntry.getId() );
WebApp app = new WebApp();
app.setWarFile( getString( "ads-httpWarFile", webAppEntry ) );
EntryAttribute ctxPathAttr = webAppEntry.get( "ads-httpAppCtxPath" );
- if( ctxPathAttr != null )
+
+ if ( ctxPathAttr != null )
{
app.setContextPath( ctxPathAttr.getString() );
}
@@ -983,7 +1036,6 @@
*/
private class InterceptorConfig implements Comparable<InterceptorConfig>
{
-
private String id;
private String fqcn;
private int order;
@@ -991,7 +1043,7 @@
public InterceptorConfig( String id, String fqcn, int order )
{
- if( order < 1 )
+ if ( order < 1 )
{
throw new IllegalArgumentException( "Invalid interceptor order" );
}
@@ -1043,7 +1095,7 @@
private boolean isEnabled( Entry entry ) throws Exception
{
EntryAttribute enabledAttr = entry.get( "ads-enabled" );
- if( enabledAttr != null )
+ if ( enabledAttr != null )
{
return Boolean.parseBoolean( enabledAttr.getString() );
}
@@ -1051,6 +1103,5 @@
{
return true;
}
-
}
}
Modified: directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/LdifConfigExtractor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/LdifConfigExtractor.java?rev=900116&r1=900115&r2=900116&view=diff
==============================================================================
--- directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/LdifConfigExtractor.java (original)
+++ directory/apacheds/trunk/default-config/src/main/java/org/apache/directory/server/config/LdifConfigExtractor.java Sun Jan 17 12:17:46 2010
@@ -90,6 +90,7 @@
Map<String, Boolean> list = ResourceMap.getResources( pattern );
System.out.println( list );
+
for ( Entry<String, Boolean> entry : list.entrySet() )
{
if ( entry.getValue() )
@@ -179,7 +180,8 @@
out.write( buf, 0, readCount );
}
out.flush();
- } finally
+ }
+ finally
{
out.close();
}
Modified: directory/apacheds/trunk/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java?rev=900116&r1=900115&r2=900116&view=diff
==============================================================================
--- directory/apacheds/trunk/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java (original)
+++ directory/apacheds/trunk/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java Sun Jan 17 12:17:46 2010
@@ -21,7 +21,8 @@
package org.apache.directory.server.config;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.List;
@@ -68,6 +69,7 @@
String workingDirectory = workDir.getPath();
// Extract the schema on disk (a brand new one) and load the registries
File schemaRepository = new File( workingDirectory, "schema" );
+
if ( schemaRepository.exists() )
{
FileUtils.deleteDirectory( schemaRepository );