View Javadoc
1   /*
2    *   Licensed to the Apache Software Foundation (ASF) under one
3    *   or more contributor license agreements.  See the NOTICE file
4    *   distributed with this work for additional information
5    *   regarding copyright ownership.  The ASF licenses this file
6    *   to you under the Apache License, Version 2.0 (the
7    *   "License"); you may not use this file except in compliance
8    *   with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing,
13   *   software distributed under the License is distributed on an
14   *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *   KIND, either express or implied.  See the License for the
16   *   specific language governing permissions and limitations
17   *   under the License.
18   *
19   */
20  
21  package org.apache.directory.server.core.partition.ldif;
22  
23  
24  import java.net.URI;
25  
26  import org.apache.directory.api.ldap.model.csn.CsnFactory;
27  import org.apache.directory.api.ldap.model.schema.SchemaManager;
28  import org.apache.directory.server.core.api.DnFactory;
29  import org.apache.directory.server.core.api.partition.Partition;
30  import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
31  
32  
33  /**
34   * A common base class for LDIF file based Partition implementations.
35   *
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   */
38  public abstract class AbstractLdifPartition extends AvlPartition
39  {
40      /** The extension used for LDIF entry files */
41      protected static final String CONF_FILE_EXTN = ".ldif";
42  
43      /** A default CSN factory */
44      protected static CsnFactory defaultCSNFactory;
45  
46  
47      /**
48       * Creates a new instance of AbstractLdifPartition.
49       *
50       * @param schemaManager the schema manager
51       */
52      public AbstractLdifPartition( SchemaManager schemaManager )
53      {
54          super( schemaManager );
55          
56          initInstance();
57      }
58  
59  
60      /**
61       * Creates a new instance of AbstractLdifPartition.
62       *
63       * @param schemaManager the schema manager
64       * @param dnFactory the DN factory
65       */
66      public AbstractLdifPartition( SchemaManager schemaManager, DnFactory dnFactory )
67      {
68          super( schemaManager, dnFactory );
69          
70          initInstance();
71      }
72  
73  
74      /**
75       * Intializes the instance.
76       */
77      public void initInstance()
78      {
79          // Create the CsnFactory with a invalid ReplicaId
80          // @TODO : inject a correct ReplicaId
81          defaultCSNFactory = new CsnFactory( 0 );
82      }
83  
84  
85      /**
86       * {@inheritDoc}
87       */
88      @Override
89      public String getDefaultId()
90      {
91          return Partition.DEFAULT_ID;
92      }
93  
94  
95      /**
96       * {@inheritDoc}
97       */
98      @Override
99      public URI getPartitionPath()
100     {
101         return partitionPath;
102     }
103 }