Commit a6397209 authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 2.0.0~M20

parent 04b0497f
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M19</version>
<version>2.0.0-M20</version>
</parent>
<artifactId>apacheds-all</artifactId>
......@@ -163,7 +163,7 @@
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<filters>
<filter>
<artifact>bouncycastle:bcprov-jdk15</artifact>
<artifact>org.bouncycastle:bcprov-jdk15on</artifact>
<excludes>
<exclude>META-INF/BCKEY.SF</exclude>
<exclude>META-INF/BCKEY.DSA</exclude>
......
......@@ -28,8 +28,8 @@ import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.registries.Schema;
import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader;
import org.apache.directory.api.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager;
import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
import org.apache.directory.mavibot.btree.memory.BulkDataSorter;
import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
import org.apache.directory.mavibot.btree.serializer.StringSerializer;
......
......@@ -65,8 +65,8 @@ import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.name.Rdn;
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.schemaloader.JarLdifSchemaLoader;
import org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager;
import org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader;
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
import org.apache.directory.api.util.DateUtils;
import org.apache.directory.mavibot.btree.serializer.LongSerializer;
import org.apache.directory.mavibot.btree.serializer.StringSerializer;
......
......@@ -65,9 +65,10 @@ public class MavibotPartitionBuilderTest
//File file = new File( outDir, "builder-test.ldif" );
File file = new File( outDir, "30k.ldif" );
//InputStream in = MavibotPartitionBuilder.class.getClassLoader().getResourceAsStream( "builder-test.ldif" );
InputStream in = MavibotPartitionBuilder.class.getClassLoader().getResourceAsStream( "30k.ldif" );
FileUtils.copyInputStreamToFile( in, file );
in.close();
try ( InputStream in = MavibotPartitionBuilder.class.getClassLoader().getResourceAsStream( "30k.ldif" ) )
{
FileUtils.copyInputStreamToFile( in, file );
}
MavibotPartitionBuilder builder = new MavibotPartitionBuilder( configFile, file.getAbsolutePath(), outDir.getAbsolutePath() );
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M19</version>
<version>2.0.0-M20</version>
</parent>
<artifactId>apacheds-core-annotations</artifactId>
......
......@@ -42,4 +42,8 @@ import java.lang.annotation.Target;
public @interface ApplyLdifFiles
{
String[] value();
/** Class which class loader is used to read LDIF files. Required in OSGi environment. */
Class<?> clazz() default ApplyLdifFiles.class;
}
......@@ -57,8 +57,8 @@ public @interface CreateAuthenticator
int delegatePort() default -1;
/** The base DN from which we will delegate authentication */
String delegateBaseDn() default "";
/** The base DN from which we will do authentication */
String baseDn() default "";
/** Tells if we use SSL to connect */
......
......@@ -52,6 +52,7 @@ import org.apache.directory.server.core.authn.Authenticator;
import org.apache.directory.server.core.authn.DelegatingAuthenticator;
import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.partition.impl.btree.mavibot.MavibotIndex;
import org.apache.directory.server.i18n.I18n;
import org.junit.runner.Description;
import org.slf4j.Logger;
......@@ -127,7 +128,7 @@ public class DSAnnotationProcessor
dauth.setDelegatePort( createAuthenticator.delegatePort() );
dauth.setDelegateSsl( createAuthenticator.delegateSsl() );
dauth.setDelegateTls( createAuthenticator.delegateTls() );
dauth.setDelegateBaseDn( createAuthenticator.delegateBaseDn() );
dauth.setBaseDn( service.getDnFactory().create( createAuthenticator.baseDn() ) );
dauth.setDelegateSslTrustManagerFQCN( createAuthenticator.delegateSslTrustManagerFQCN() );
dauth.setDelegateTlsTrustManagerFQCN( createAuthenticator.delegateTlsTrustManagerFQCN() );
}
......@@ -211,7 +212,7 @@ public class DSAnnotationProcessor
createPartition.suffix(),
createPartition.cacheSize(),
new File( service.getInstanceLayout().getPartitionsDirectory(), createPartition.name() ) );
partition.setCacheService( service.getCacheService() );
CreateIndex[] indexes = createPartition.indexes();
......@@ -250,12 +251,29 @@ public class DSAnnotationProcessor
for ( CreateIndex createIndex : indexes )
{
// The annotation does not specify a specific index
// type.
// We use the generic index implementation.
JdbmIndex index = new JdbmIndex( createIndex.attribute(), false );
if ( createIndex.type() == JdbmIndex.class )
{
// JDBM index
JdbmIndex index = new JdbmIndex( createIndex.attribute(), false );
btreePartition.addIndexedAttributes( index );
}
else if ( createIndex.type() == MavibotIndex.class )
{
// Mavibot index
MavibotIndex index = new MavibotIndex( createIndex.attribute(), false );
btreePartition.addIndexedAttributes( index );
btreePartition.addIndexedAttributes( index );
}
else
{
// The annotation does not specify a specific index
// type.
// We use the generic index implementation.
JdbmIndex index = new JdbmIndex( createIndex.attribute(), false );
btreePartition.addIndexedAttributes( index );
}
}
}
}
......@@ -465,7 +483,7 @@ public class DSAnnotationProcessor
{
LOG.debug( "Applying {} to {}", applyLdifFiles.value(),
desc.getDisplayName() );
injectLdifFiles( desc.getClass(), service, applyLdifFiles.value() );
injectLdifFiles( applyLdifFiles.clazz(), service, applyLdifFiles.value() );
}
ApplyLdifs applyLdifs = desc.getAnnotation( ApplyLdifs.class );
......
......@@ -30,10 +30,10 @@ import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.api.ldap.model.schema.comparators.NormalizingComparator;
import org.apache.directory.api.ldap.model.schema.registries.ComparatorRegistry;
import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader;
import org.apache.directory.api.ldap.schemaextractor.SchemaLdifExtractor;
import org.apache.directory.api.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.api.ldap.schemaloader.LdifSchemaLoader;
import org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager;
import org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor;
import org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor;
import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
import org.apache.directory.api.util.exception.Exceptions;
import org.apache.directory.server.constants.ServerDNConstants;
import org.apache.directory.server.core.DefaultDirectoryService;
......@@ -110,8 +110,8 @@ public class DefaultDirectoryServiceFactory implements DirectoryServiceFactory
this.directoryService = directoryService;
this.partitionFactory = partitionFactory;
}
/**
* {@inheritDoc}
*/
......@@ -248,7 +248,7 @@ public class DefaultDirectoryServiceFactory implements DirectoryServiceFactory
buildInstanceDirectory( name );
CacheService cacheService = new CacheService();
cacheService.initialize( directoryService.getInstanceLayout() );
cacheService.initialize( directoryService.getInstanceLayout(), name );
directoryService.setCacheService( cacheService );
......
......@@ -223,7 +223,7 @@ public class DirectoryServiceAnnotationTest
{
protected DummyAuthenticator()
{
super( AuthenticationLevel.SIMPLE );
super( AuthenticationLevel.SIMPLE, Dn.ROOT_DSE );
}
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M19</version>
<version>2.0.0-M20</version>
</parent>
<artifactId>apacheds-core-api</artifactId>
......@@ -114,7 +114,7 @@
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<artifactId>ehcache</artifactId>
</dependency>
</dependencies>
......
......@@ -45,15 +45,14 @@ public abstract class AbstractLayout
/** The required files */
private File[] requiredFiles = new File[0];
/** The directory */
/** The base directory */
private File directory;
/**
* Creates a new instance of AbstractLayout.
*
* @param directory
* the directory
* @param directory the base directory
*/
protected AbstractLayout( File directory )
{
......@@ -64,8 +63,7 @@ public abstract class AbstractLayout
/**
* Creates a new instance of AbstractLayout.
*
* @param directoryPath
* the path to the directory
* @param directoryPath the path to the base directory
*/
protected AbstractLayout( String directoryPath )
{
......@@ -74,10 +72,9 @@ public abstract class AbstractLayout
/**
* Gets the installation directory.
* Gets the base directory.
*
* @return
* the installation directory
* @return the base directory
*/
protected File getDirectory()
{
......@@ -88,8 +85,7 @@ public abstract class AbstractLayout
/**
* Gets the required directories.
*
* @return
* the required directories
* @return the required directories
*/
public File[] getRequiredDirectories()
{
......@@ -100,8 +96,7 @@ public abstract class AbstractLayout
/**
* Gets the required files.
*
* @return
* the required files
* @return the required files
*/
public File[] getRequiredFiles()
{
......@@ -130,8 +125,7 @@ public abstract class AbstractLayout
/**
* Sets the required directories.
*
* @param requiredDirectories
* an array of required directories
* @param requiredDirectories an array of required directories
*/
protected void setRequiredDirectories( File[] requiredDirectories )
{
......@@ -142,8 +136,7 @@ public abstract class AbstractLayout
/**
* Sets the required files.
*
* @param requiredFiles
* an array of required files
* @param requiredFiles an array of required files
*/
protected void setRequiredFiles( File[] requiredFiles )
{
......
......@@ -22,6 +22,7 @@ package org.apache.directory.server.core.api;
import java.io.File;
import java.util.UUID;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
......@@ -46,17 +47,22 @@ import org.slf4j.LoggerFactory;
*/
public class CacheService
{
/** The cache configuration file */
private static final String DIRECTORY_CACHESERVICE_XML = "directory-cacheservice.xml";
/** The associated logger */
private static final Logger LOG = LoggerFactory.getLogger( CacheService.class );
/** the ehcache cache manager */
private CacheManager cacheManager;
/** A flag telling if the cache Service has been intialized */
private boolean initialized;
/**
* Creates a new instance of CacheService.
*/
public CacheService()
{
}
......@@ -65,11 +71,12 @@ public class CacheService
/**
* Creates a new instance of CacheService with the given cache manager.
*
* @param cachemanager
* @param cachemanager The provided CaxcheManager instance
*/
public CacheService( CacheManager cachemanager )
{
this.cacheManager = cachemanager;
if ( cachemanager != null )
{
initialized = true;
......@@ -77,7 +84,24 @@ public class CacheService
}
/**
* Initialize the CacheService
*
* @param layout The place on disk where the cache configuration will be stored
*/
public void initialize( InstanceLayout layout )
{
initialize( layout, null );
}
/**
* Initialize the CacheService
*
* @param layout The place on disk where the cache configuration will be stored
* @param instanceId The Instance identifier
*/
public void initialize( InstanceLayout layout, String instanceId )
{
if ( initialized )
{
......@@ -85,10 +109,13 @@ public class CacheService
return;
}
LOG.debug( "CacheService initialization, for instance {}", instanceId );
if ( ( cacheManager != null ) && ( cacheManager.getStatus() == Status.STATUS_ALIVE ) )
{
LOG.warn( "cache service was already initialized and is alive" );
initialized = true;
return;
}
......@@ -123,13 +150,26 @@ public class CacheService
cachePath = FileUtils.getTempDirectoryPath();
}
String confName = UUID.randomUUID().toString();
cc.setName( confName );
if ( cachePath == null )
{
cachePath = FileUtils.getTempDirectoryPath();
}
cachePath += File.separator + confName;
cc.getDiskStoreConfiguration().setPath( cachePath );
cacheManager = new CacheManager( cc );
initialized = true;
}
/**
* Clear the cache and shutdown it
*/
public void destroy()
{
if ( !initialized )
......@@ -146,10 +186,17 @@ public class CacheService
}
/**
* Get a specific cache from its name, or create a new one
*
* @param name The Cache name we want to retreive
* @return The found cache. If we don't find it, we create a new one.
*/
public Cache getCache( String name )
{
if ( !initialized )
{
LOG.error( "Cannot fetch the cache named {}, the CacheServcie is not initialized", name );
throw new IllegalStateException( "CacheService was not initialized" );
}
......@@ -159,6 +206,7 @@ public class CacheService
if ( cache == null )
{
LOG.info( "No cache with name {} exists, creating one", name );
cacheManager.addCache( name );
cache = cacheManager.getCache( name );
}
......@@ -167,15 +215,22 @@ public class CacheService
}
/**
* Remove a cache if it exists.
*
* @param name The Cache's name we want to remove
*/
public void remove( String name )
{
cacheManager.removeCache( name );
}
if ( cacheManager.cacheExists( name ) )
{
LOG.info( "Removing the cache named {}", name );
public void attach( Cache cache )
{
cacheManager.addCache( cache );
cacheManager.removeCache( name );
}
else
{
LOG.info( "Cannot removing the cache named {}, it does not exist", name );
}
}
}
......@@ -22,6 +22,7 @@ package org.apache.directory.server.core.api;
import java.util.Iterator;
import java.util.Map;
import org.apache.directory.api.ldap.model.constants.Loggers;
import org.apache.directory.api.ldap.model.cursor.AbstractCursor;
......@@ -31,10 +32,14 @@ import org.apache.directory.api.ldap.model.cursor.CursorException;
import org.apache.directory.api.ldap.model.cursor.SearchCursor;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.message.IntermediateResponse;
import org.apache.directory.api.ldap.model.message.LdapResult;
import org.apache.directory.api.ldap.model.message.Referral;
import org.apache.directory.api.ldap.model.message.Response;
import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
import org.apache.directory.api.ldap.model.message.ResultResponse;
import org.apache.directory.api.ldap.model.message.SearchRequest;
import org.apache.directory.api.ldap.model.message.SearchResultDone;
import org.apache.directory.api.ldap.model.message.SearchResultDoneImpl;
import org.apache.directory.api.ldap.model.message.SearchResultEntry;
......@@ -69,14 +74,17 @@ public class EntryToResponseCursor extends AbstractCursor<Response> implements S
/** The messsage ID */
private int messageId;
/** The search request */
private SearchRequest searchRequest;
public EntryToResponseCursor( int messageId, Cursor<Entry> wrapped )
public EntryToResponseCursor( SearchRequest searchRequest, int messageId, Cursor<Entry> wrapped )
{
if ( IS_DEBUG )
{
LOG_CURSOR.debug( "Creating EntryToResponseCursor {}", this );
}
this.searchRequest = searchRequest;
this.wrapped = wrapped;
this.messageId = messageId;
}
......@@ -222,7 +230,30 @@ public class EntryToResponseCursor extends AbstractCursor<Response> implements S
if ( !next )
{
searchDoneResp = new SearchResultDoneImpl( messageId );
searchDoneResp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
ResultCodeEnum re = ResultCodeEnum.SUCCESS;
ResultResponse processedResp = searchRequest.getResultResponse();
LdapResult filledResult = processedResp.getLdapResult();
if ( filledResult.getResultCode() != re )
{
re = filledResult.getResultCode();
}
searchDoneResp.getLdapResult().setResultCode( re );
Map<String,Control> ctrls = processedResp.getControls();
if ( ctrls != null )
{
Iterator<Control> itr = ctrls.values().iterator();
while ( itr.hasNext() )
{
searchDoneResp.addControl( itr.next() );
}
}
done = true;
}
......
......@@ -81,13 +81,13 @@ public class InstanceLayout extends AbstractLayout
private static final String RUN_DIR = "apacheds.run.dir";
/** Static directory names */
private static final String LOG_NAME = "log";
private static final String RUN_NAME = "run";
private static final String CONF_NAME = "conf";
private static final String PARTITIONS_NAME = "partitions";
public static final String LOG_NAME = "log";
public static final String RUN_NAME = "run";
public static final String CONF_NAME = "conf";
public static final String PARTITIONS_NAME = "partitions";
private static final String REPL_NAME = "syncrepl-data";
private static final String CACHE_NAME = "cache";
/** Static file names */
private static final String LOG4J_PROPERTIES = "log4j.properties";
private static final String WRAPPER_CONF = "wrapper.conf";
......@