/** * {@inheritDoc} */ @Override public boolean exists( Dn dn ) throws LdapException { HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( this, dn ); OperationManager operationManager = directoryService.getOperationManager(); return operationManager.hasEntry( hasEntryContext ); }
/** * @see Object#toString() */ public String toString() { return "HasEntryContext for Dn '" + getDn().getName() + "'"; } }
/** * Creates a new instance of HasEntryOperationContext. * * @param session The session to use */ public HasEntryOperationContext( CoreSession session ) { super( session ); if ( session != null ) { setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.HAS_ENTRY ) ); } }
HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( searchContext.getSession(), contextDn ); hasEntryContext.setPartition( partition ); hasEntryContext.setTransaction( partitionTxn ); searchContext.setPartition( partition ); searchContext.setTransaction( partitionTxn ); HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( searchContext.getSession(), contextDn ); hasEntryContext.setPartition( partition ); hasEntryContext.setTransaction( partitionTxn ); searchContext.setPartition( partition ); searchContext.setTransaction( partitionTxn );
public ServerContext( DirectoryService service, CoreSession session, Name name ) throws Exception { this.service = service; this.dn = JndiUtils.fromName( name ); this.env = new Hashtable<String, Object>(); this.env.put( PROVIDER_URL, dn.toString() ); this.env.put( DirectoryService.JNDI_KEY, service ); this.session = session; OperationManager operationManager = service.getOperationManager(); HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( session, dn ); if ( !operationManager.hasEntry( hasEntryContext ) ) { throw new NameNotFoundException( I18n.err( I18n.ERR_490, dn ) ); } schemaManager = service.getSchemaManager(); // setup attribute type value objectClassAT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT ); }
/** * {@inheritDoc} */ @Override public boolean hasEntry( HasEntryOperationContext hasEntryContext ) throws LdapException { Dn dn = hasEntryContext.getDn(); if ( IS_DEBUG ) { LOG.debug( "Check if Dn '" + dn + "' exists." ); } if ( dn.isRootDse() ) { return true; } Partition partition = getPartition( dn ); return partition.hasEntry( hasEntryContext ); }
/** * Creates a new instance of HasEntryOperationContext. * * @param session The session to use * @param entryDn The Entry Dn we want to know if it exists */ public HasEntryOperationContext( CoreSession session, Dn entryDn ) { super( session, entryDn ); if ( session != null ) { setInterceptors( session.getDirectoryService().getInterceptors( OperationEnum.HAS_ENTRY ) ); } }
/** * Must be called by all subclasses to initialize the nexus proxy and the * environment settings to be used by this Context implementation. This * constructor is used to propagate new contexts from existing contexts. * * @param service the directory service core * @param principal the directory user principal that is propagated * @param name the distinguished name of this context * @throws NamingException if there is a problem creating the new context */ public ServerContext( DirectoryService service, LdapPrincipal principal, Name name ) throws Exception { this.service = service; this.dn = JndiUtils.fromName( name ); this.env = new Hashtable<String, Object>(); this.env.put( PROVIDER_URL, dn.toString() ); this.env.put( DirectoryService.JNDI_KEY, service ); session = new DefaultCoreSession( principal, service ); OperationManager operationManager = service.getOperationManager(); HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( session, dn ); if ( !operationManager.hasEntry( hasEntryContext ) ) { throw new NameNotFoundException( I18n.err( I18n.ERR_490, dn ) ); } schemaManager = service.getSchemaManager(); // setup attribute type value objectClassAT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT ); }
/** * @see javax.naming.Context#rebind(javax.naming.Name, java.lang.Object) */ public void rebind( Name name, Object obj ) throws NamingException { Dn target = buildTarget( JndiUtils.fromName( name ) ); OperationManager operationManager = service.getOperationManager(); try { HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( session, target ); if ( operationManager.hasEntry( hasEntryContext ) ) { doDeleteOperation( target ); } } catch ( Exception e ) { JndiUtils.wrap( e ); } bind( name, obj ); }
/** * @see javax.naming.directory.DirContext#rebind(javax.naming.Name, * java.lang.Object, javax.naming.directory.Attributes) */ public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException { Dn target = buildTarget( JndiUtils.fromName( name ) ); try { HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( getSession(), target ); if ( getDirectoryService().getOperationManager().hasEntry( hasEntryContext ) ) { doDeleteOperation( target ); } } catch ( Exception e ) { JndiUtils.wrap( e ); } bind( name, obj, AttributeUtils.toCaseInsensitive( attrs ) ); }
private void initializeSystemPartition() throws Exception { Partition system = getSystemPartition(); // Add root context entry for system partition Dn systemSuffixDn = getDnFactory().create( ServerDNConstants.SYSTEM_DN ); CoreSession adminSession = getAdminSession(); if ( !system.hasEntry( new HasEntryOperationContext( adminSession, systemSuffixDn ) ) ) { Entry systemEntry = new DefaultEntry( schemaManager, systemSuffixDn ); // Add the ObjectClasses systemEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC ); // Add some operational attributes systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN ); systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); systemEntry.add( SchemaConstants.ENTRY_CSN_AT, getCSN().toString() ); systemEntry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() ); systemEntry.put( DnUtils.getRdnAttributeType( ServerDNConstants.SYSTEM_DN ), DnUtils .getRdnValue( ServerDNConstants.SYSTEM_DN ) ); AddOperationContext addOperationContext = new AddOperationContext( adminSession, systemEntry ); system.add( addOperationContext ); } }
if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, adminDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, userDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, groupDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, name ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, configurationDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, partitionsDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, servicesDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, interceptorsDn ) ) ) if ( !partitionNexus.hasEntry( new HasEntryOperationContext( adminSession, sysPrefRootDn ) ) )
OperationManager operationManager = service.getOperationManager(); HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( session, dn );