Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 32410 invoked from network); 14 Jan 2010 14:20:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jan 2010 14:20:26 -0000 Received: (qmail 99633 invoked by uid 500); 14 Jan 2010 14:20:26 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 99575 invoked by uid 500); 14 Jan 2010 14:20:25 -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 99566 invoked by uid 99); 14 Jan 2010 14:20:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 14:20:25 +0000 X-ASF-Spam-Status: No, hits=-1999.6 required=10.0 tests=ALL_TRUSTED,SUBJECT_FUZZY_TION X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 14:20:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 03242238890A; Thu, 14 Jan 2010 14:20:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r899209 - /directory/apacheds/branches/apacheds-cidit/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Date: Thu, 14 Jan 2010 14:20:01 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100114142002.03242238890A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kayyagari Date: Thu Jan 14 14:20:01 2010 New Revision: 899209 URL: http://svn.apache.org/viewvc?rev=899209&view=rev Log: o added support for instantiating journal and changelog o removed unused methods o added javadoc Modified: directory/apacheds/branches/apacheds-cidit/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Modified: directory/apacheds/branches/apacheds-cidit/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-cidit/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=899209&r1=899208&r2=899209&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-cidit/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original) +++ directory/apacheds/branches/apacheds-cidit/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Thu Jan 14 14:20:01 2010 @@ -34,9 +34,13 @@ import org.apache.directory.server.core.DefaultDirectoryService; import org.apache.directory.server.core.DirectoryService; +import org.apache.directory.server.core.changelog.ChangeLog; +import org.apache.directory.server.core.changelog.DefaultChangeLog; import org.apache.directory.server.core.entry.ClonedServerEntry; import org.apache.directory.server.core.entry.ServerEntry; import org.apache.directory.server.core.interceptor.Interceptor; +import org.apache.directory.server.core.journal.DefaultJournal; +import org.apache.directory.server.core.journal.Journal; import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; @@ -73,13 +77,15 @@ { /** the partition which holds the configuration data */ - private Partition configPartition; + private LdifPartition configPartition; /** the search engine of the partition */ private SearchEngine se; + /** the schema manager set in the config partition */ private SchemaManager schemaManager; + /** the parent directory of the config partition's working directory */ private File workDir; private static final Logger LOG = LoggerFactory.getLogger( ConfigPartitionReader.class ); @@ -158,7 +164,6 @@ * * @throws Exception */ - @SuppressWarnings("unchecked") public DirectoryService getDirectoryService() throws Exception { @@ -180,7 +185,7 @@ ClonedServerEntry dsEntry = configPartition.lookup( forwardEntry.getId() ); - LOG.debug( "dirServiceEntry {}", dsEntry ); + LOG.debug( "directory service entry {}", dsEntry ); DirectoryService dirService = new DefaultDirectoryService(); // MUST attributes @@ -197,9 +202,13 @@ Map partitions = getPartitions( partitionsDN ); - Partition system = partitions.remove( "system" ); - dirService.setSystemPartition( system ); - + Partition systemPartition = partitions.remove( "system" ); + if( systemPartition == null ) + { + throw new Exception( "system partition doesn't exist" ); + } + + dirService.setSystemPartition( systemPartition ); dirService.setPartitions( new HashSet( partitions.values() ) ); // MAY attributes @@ -218,7 +227,10 @@ EntryAttribute changeLogAttr = dsEntry.get( "ads-dsChangeLog" ); if ( changeLogAttr != null ) { - // configure CL + LdapDN clDN = new LdapDN( changeLogAttr.getString() ); + clDN.normalize( schemaManager.getNormalizerMapping() ); + ChangeLog cl = getChangeLog( clDN ); + dirService.setChangeLog( cl ); } EntryAttribute denormAttr = dsEntry.get( "ads-dsDenormalizeOpAttrsEnabled" ); @@ -230,7 +242,9 @@ EntryAttribute journalAttr = dsEntry.get( "ads-dsJournal" ); if ( journalAttr != null ) { - // dirService.setJournal( ); + LdapDN journalDN = new LdapDN( journalAttr.getString() ); + journalDN.normalize( schemaManager.getNormalizerMapping() ); + dirService.setJournal( getJournal( journalDN ) ); } EntryAttribute maxPduAttr = dsEntry.get( "ads-dsMaxPDUSize" ); @@ -519,6 +533,60 @@ return transport; } + + private ChangeLog getChangeLog( LdapDN changelogDN ) throws Exception + { + Long id = configPartition.getEntryId( changelogDN.getNormName() ); + Entry clEntry = configPartition.lookup( id ); + + ChangeLog cl = new DefaultChangeLog(); + EntryAttribute clEnabledAttr =clEntry.get( "ads-changeLogEnabled" ); + if( clEnabledAttr != null ) + { + cl.setEnabled( Boolean.parseBoolean( clEnabledAttr.getString() ) ); + } + + EntryAttribute clExpAttr = clEntry.get( "ads-changeLogExposed" ); + if( clExpAttr != null ) + { + cl.setExposed( Boolean.parseBoolean( clExpAttr.getString() ) ); + } + + return cl; + } + + + private Journal getJournal( LdapDN journalDN ) throws Exception + { + Long id = configPartition.getEntryId( journalDN.getNormName() ); + Entry jlEntry = configPartition.lookup( id ); + + Journal journal = new DefaultJournal(); + //FIXME the setFileName is part of the JournalStore API + // but there is currently no way to set the JournalStore in Journal + //jl.setFileName( getString( "ads-journalFileName", jlEntry ) ); + + EntryAttribute jlWorkDirAttr = jlEntry.get( "ads-journalWorkingDir" ); + if( jlWorkDirAttr != null ) + { + //jl.setWorkDir( jlWorkDirAttr.getString() ); + } + + EntryAttribute jlRotAttr = jlEntry.get( "ads-journalRotation" ); + if( jlRotAttr != null ) + { + journal.setRotation( Integer.parseInt( jlRotAttr.getString() ) ); + } + + EntryAttribute jlEnabledAttr = jlEntry.get( "ads-journalEnabled" ); + if( jlEnabledAttr != null ) + { + journal.setEnabled( Boolean.parseBoolean( jlEnabledAttr.getString() ) ); + } + + return journal; + } + /** * internal class used for holding the Interceptor classname and order configuration @@ -567,21 +635,6 @@ return fqcn; } - - /** - * @return the id - */ - public String getId() - { - return id; - } - - } - - - private boolean getBoolean( String attrName, Entry entry ) throws Exception - { - return Boolean.parseBoolean( entry.get( attrName ).getString() ); }