001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 021package org.apache.directory.server.core.partition.ldif; 022 023 024import java.net.URI; 025 026import org.apache.directory.api.ldap.model.csn.CsnFactory; 027import org.apache.directory.api.ldap.model.schema.SchemaManager; 028import org.apache.directory.server.core.api.DnFactory; 029import org.apache.directory.server.core.api.partition.Partition; 030import org.apache.directory.server.core.partition.impl.avl.AvlPartition; 031 032 033/** 034 * A common base class for LDIF file based Partition implementations. 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 */ 038public abstract class AbstractLdifPartition extends AvlPartition 039{ 040 /** The extension used for LDIF entry files */ 041 protected static final String CONF_FILE_EXTN = ".ldif"; 042 043 /** A default CSN factory */ 044 protected static CsnFactory defaultCSNFactory; 045 046 047 /** 048 * Creates a new instance of AbstractLdifPartition. 049 * 050 * @param schemaManager the schema manager 051 */ 052 public AbstractLdifPartition( SchemaManager schemaManager ) 053 { 054 super( schemaManager ); 055 056 initInstance(); 057 } 058 059 060 /** 061 * Creates a new instance of AbstractLdifPartition. 062 * 063 * @param schemaManager the schema manager 064 * @param dnFactory the DN factory 065 */ 066 public AbstractLdifPartition( SchemaManager schemaManager, DnFactory dnFactory ) 067 { 068 super( schemaManager, dnFactory ); 069 070 initInstance(); 071 } 072 073 074 /** 075 * Intializes the instance. 076 */ 077 public void initInstance() 078 { 079 // Create the CsnFactory with a invalid ReplicaId 080 // @TODO : inject a correct ReplicaId 081 defaultCSNFactory = new CsnFactory( 0 ); 082 } 083 084 085 /** 086 * {@inheritDoc} 087 */ 088 @Override 089 public String getDefaultId() 090 { 091 return Partition.DEFAULT_ID; 092 } 093 094 095 /** 096 * {@inheritDoc} 097 */ 098 @Override 099 public URI getPartitionPath() 100 { 101 return partitionPath; 102 } 103}