Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 56283 invoked from network); 27 Nov 2010 13:25:47 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 Nov 2010 13:25:47 -0000 Received: (qmail 11645 invoked by uid 500); 27 Nov 2010 13:25:47 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 11592 invoked by uid 500); 27 Nov 2010 13:25:47 -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 11585 invoked by uid 99); 27 Nov 2010 13:25:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Nov 2010 13:25:46 +0000 X-ASF-Spam-Status: No, hits=-1996.4 required=10.0 tests=ALL_TRUSTED,FS_REPLICA 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; Sat, 27 Nov 2010 13:25:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C6F5F23889B9; Sat, 27 Nov 2010 13:24:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1039676 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec: LdapMessageGrammar.java controls/ControlEnum.java controls/ControlFactory.java controls/replication/syncInfoValue/SyncInfoValueControl.java Date: Sat, 27 Nov 2010 13:24:08 -0000 To: commits@directory.apache.org From: seelmann@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101127132408.C6F5F23889B9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: seelmann Date: Sat Nov 27 13:24:08 2010 New Revision: 1039676 URL: http://svn.apache.org/viewvc?rev=1039676&view=rev Log: Fix for DIRSERVER-1585: - removed ControlEnum - added ControlFactory which always creates a new Control instance - added default constructor to SyncInfoValueControl to be able to create an instance from ControlFactory - simplyfied LdapMessageGrammar as ControlFactory never returns null Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlFactory.java Removed: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlEnum.java Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1039676&r1=1039675&r2=1039676&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Sat Nov 27 13:24:08 2010 @@ -70,8 +70,7 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.codec.actions.StoreReferenceAction; import org.apache.directory.shared.ldap.codec.actions.StoreTypeMatchingRuleAction; import org.apache.directory.shared.ldap.codec.actions.ValueAction; -import org.apache.directory.shared.ldap.codec.controls.ControlEnum; -import org.apache.directory.shared.ldap.codec.controls.ControlImpl; +import org.apache.directory.shared.ldap.codec.controls.ControlFactory; import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter; import org.apache.directory.shared.ldap.codec.search.SubstringFilter; import org.apache.directory.shared.ldap.exception.LdapException; @@ -3450,13 +3449,7 @@ public final class LdapMessageGrammar ex Message message = ldapMessageContainer.getMessage(); - Control control = ControlEnum.getControl( oidValue ); - - if ( control == null ) - { - // This control is unknown, we will create a neutral control - control = new ControlImpl( oidValue ); - } + Control control = ControlFactory.createControl( oidValue ); message.addControl( control ); Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlFactory.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlFactory.java?rev=1039676&view=auto ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlFactory.java (added) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlFactory.java Sat Nov 27 13:24:08 2010 @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.directory.shared.ldap.codec.controls; + + +import org.apache.directory.shared.ldap.codec.controls.replication.syncDoneValue.SyncDoneValueControl; +import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl; +import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueControl; +import org.apache.directory.shared.ldap.codec.controls.replication.syncStateValue.SyncStateValueControl; +import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedResultsControl; +import org.apache.directory.shared.ldap.codec.search.controls.persistentSearch.PersistentSearchControl; +import org.apache.directory.shared.ldap.codec.search.controls.subentries.SubentriesControl; +import org.apache.directory.shared.ldap.message.control.Control; + + +/** + * A factory for Controls. + * + * @author Apache Directory Project + */ +public class ControlFactory +{ + + /** + * Creates a new Control instance. If the OID of a known control is provided + * a concrete Control instance is returned, otherwise an instance of + * ControlImpl is returned. The following Controls are known: + *
    + *
  • ManageDsaITControl
  • + *
  • PagedResultsControl
  • + *
  • PersistentSearchControl
  • + *
  • SubentriesControl
  • + *
  • SyncDoneValueControl
  • + *
  • SyncInfoValueControl
  • + *
  • SyncRequestValueControl
  • + *
  • SyncStateValueControl
  • + *
+ * + * Note that the created Control is empty, criticality and value are not set. + * Some Controls also need additional initialization. + * + * @param oid the control OID + * @return the control instance + */ + public static Control createControl( String oid ) + { + if ( ManageDsaITControl.CONTROL_OID.equals( oid ) ) + { + return new ManageDsaITControl(); + } + + if ( PagedResultsControl.CONTROL_OID.equals( oid ) ) + { + return new PagedResultsControl(); + } + + if ( PersistentSearchControl.CONTROL_OID.equals( oid ) ) + { + return new PersistentSearchControl(); + } + + if ( SubentriesControl.CONTROL_OID.equals( oid ) ) + { + return new SubentriesControl(); + } + + if ( SyncDoneValueControl.CONTROL_OID.equals( oid ) ) + { + return new SyncDoneValueControl(); + } + + if ( SyncInfoValueControl.CONTROL_OID.equals( oid ) ) + { + return new SyncInfoValueControl(); + } + + if ( SyncRequestValueControl.CONTROL_OID.equals( oid ) ) + { + return new SyncRequestValueControl(); + } + + if ( SyncStateValueControl.CONTROL_OID.equals( oid ) ) + { + return new SyncStateValueControl(); + } + + // This control is unknown, we will create a neutral control + return new ControlImpl( oid ); + } +} Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java?rev=1039676&r1=1039675&r2=1039676&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/replication/syncInfoValue/SyncInfoValueControl.java Sat Nov 27 13:24:08 2010 @@ -63,22 +63,26 @@ public class SyncInfoValueControl extend /** + * The constructor for this codec. Dont't forget to set the type. + */ + public SyncInfoValueControl() + { + super( CONTROL_OID ); + + decoder = new SyncInfoValueControlDecoder(); + } + + + /** * The constructor for this codec. * @param type The kind of syncInfo we will store. Can be newCookie, * refreshPresent, refreshDelete or syncIdSet */ public SyncInfoValueControl( SynchronizationInfoEnum type ) { - super( CONTROL_OID ); + this(); - decoder = new SyncInfoValueControlDecoder(); - this.type = type; - - // Initialize the arrayList if needed - if ( type == SynchronizationInfoEnum.SYNC_ID_SET ) - { - syncUUIDs = new ArrayList(); - } + setType( type); } @@ -102,6 +106,12 @@ public class SyncInfoValueControl extend public void setType( SynchronizationInfoEnum type ) { this.type = type; + + // Initialize the arrayList if needed + if ( type == SynchronizationInfoEnum.SYNC_ID_SET && syncUUIDs == null ) + { + syncUUIDs = new ArrayList(); + } }