public synchronized void removeContextPartition( LdapDN suffix ) throws NamingException { String key = suffix.toString(); Partition partition = ( Partition ) partitions.get( key ); if ( partition == null ) { throw new NameNotFoundException( "No partition with suffix: " + key ); } Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); namingContexts.remove( partition.getUpSuffix().toString() ); partitions.remove( key ); partition.sync(); partition.destroy(); }
public synchronized void addContextPartition( PartitionConfiguration config ) throws NamingException { Partition partition = config.getContextPartition(); // Turn on default indices String key = config.getSuffix(); if ( partitions.containsKey( key ) ) { throw new ConfigurationException( "Duplicate partition suffix: " + key ); } partition.init( factoryCfg, config ); partitions.put( partition.getSuffix().toString(), partition ); Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); namingContexts.add( partition.getUpSuffix().toString() ); }
/** * Looks up the backend corresponding to the entry first, then checks to * see if the entry already exists. If so an exception is thrown. If not * the add operation against the backend proceeds. This check is performed * here so backend implementors do not have to worry about performing these * kinds of checks. * * @see Partition#add(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.Attributes) */ public void add( LdapDN dn, Attributes entry ) throws NamingException { Partition backend = getBackend( dn ); backend.add( dn, entry ); }
@Override public void removeAllPartitions() throws DirectoryServerException { Set<? extends Partition> partitions = this.directoryService.getPartitions(); for (Partition partition : partitions) { if (!"schema".equalsIgnoreCase(partition.getId())) { try { if (logger.isDebugEnabled()) { logger.debug("Removing partition with id - " + partition.getId() + " suffix - " + partition.getSuffix()); } this.directoryService.removePartition(partition); } catch (Exception e) { String msg = "Unable to remove partition with id " + partition.getId() + " with suffix " + partition.getSuffix(); logger.error(msg, e); throw new DirectoryServerException(msg, e); } } } }
/** * @see PartitionNexus#getSuffix(org.apache.directory.shared.ldap.name.LdapDN) */ public LdapDN getSuffix ( LdapDN dn ) throws NamingException { Partition backend = getBackend( dn ); return backend.getSuffix(); }
/** * @see Partition#delete(org.apache.directory.shared.ldap.name.LdapDN) */ public void delete( LdapDN dn ) throws NamingException { Partition backend = getBackend( dn ); backend.delete( dn ); }
public void bind( LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId ) throws NamingException { Partition partition = getBackend( bindDn ); partition.bind( bindDn, credentials, mechanisms, saslAuthId ); }
/** * @inheritDoc */ @Override public boolean partitionInitialized(String partitionId) { Set<? extends Partition> partitions = this.directoryService.getPartitions(); for (Partition partition : partitions) { if (partition.getId().equals(partitionId)) { return true; } } return false; }
/** * @see Partition#hasEntry(org.apache.directory.shared.ldap.name.LdapDN) */ public boolean hasEntry( LdapDN dn ) throws NamingException { if ( IS_DEBUG ) { log.debug( "Check if DN '" + dn + "' exists." ); } if ( dn.size() == 0 ) { return true; } Partition backend = getBackend( dn ); return backend.hasEntry( dn ); }
/** * Create the root DN. * * @param partition The partition in which to create the root DN. * @throws Exception If there was an error creating the root DN. */ private void createRoot(final Partition partition) throws Exception { try { service.getAdminSession().lookup(partition.getSuffixDn()); } catch (final LdapNameNotFoundException e) { final LdapDN dn = new LdapDN(getRoot()); final String dc = getRoot().substring(3, getRoot().indexOf(',')); final ServerEntry entry = service.newEntry(dn); entry.add("objectClass", "top", "domain", "extensibleObject"); entry.add("dc", dc); service.getAdminSession().add(entry); } }
private Partition getPartition(String partitionSuffix) { Set availablePartitions = this.directoryService.getPartitions(); Partition partition; for (Object object : availablePartitions) { partition = (Partition) object; if (partition.getSuffix().equals(partitionSuffix)) { return partition; } } return null; }
try partition.destroy();
system.init( factoryCfg, systemCfg ); systemCfg.setContextPartition( system ); String key = system.getSuffix().toString(); if ( partitions.containsKey( key ) ) namingContexts.add( system.getUpSuffix().toString() );
/** * Unregisters an ContextPartition with this BackendManager. Called for each * registered Backend right befor it is to be stopped. This prevents * protocol server requests from reaching the Backend and effectively puts * the ContextPartition's naming context offline. * * Operations against the naming context should result in an LDAP BUSY * result code in the returnValue if the naming context is not online. * * @param partition ContextPartition component to unregister with this * BackendNexus. */ private void unregister( Partition partition ) throws NamingException { Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); namingContexts.remove( partition.getSuffix().toString() ); partitions.remove( partition.getSuffix().toString() ); }
public void addContextPartition( NextInterceptor next, PartitionConfiguration cfg ) throws NamingException { next.addContextPartition( cfg ); // add referrals immediately after adding the new partition Partition partition = cfg.getContextPartition(); LdapDN suffix = partition.getSuffix(); Invocation invocation = InvocationStack.getInstance().peek(); NamingEnumeration list = invocation.getProxy().search( suffix, env, getReferralFilter(), getControls(), SEARCH_BYPASS ); addReferrals( list, suffix ); }