/** * Inserts an entry into the DIT. If the entry exists, it is overwritten. Overwriting leaves is straight forward. * Overwriting inner nodes will first delete the node's entire subtree, then overwrite the node. Throws * {@link MissingParentException} if an ancestor of the entry is missing. */ public void storeOverwriteExisting(Entry entry) throws MissingParentException { try { deleteSubtreeIncludingRoot(entry.getDn()); } catch (NoSuchNodeException e) { LOGGER.debug("nothing to overwrite"); } finally { try { store(entry); } catch (EntryAlreadyExistsException e) { LOGGER.warn("should never reach here - entry should have been deleted"); } } }
/** * Create a new attributeValue * * @param type The attribute's name (called 'type' in the grammar) */ public void addAttributeType( String type ) throws LdapException { // do not create a new attribute if we have seen this attributeType before if ( getDecorated().getEntry().get( type ) != null ) { currentAttribute = getDecorated().getEntry().get( type ); return; } // fix this to use AttributeImpl(type.getString().toLowerCase()) currentAttribute = new DefaultEntryAttribute( type ); getDecorated().getEntry().put( currentAttribute ); }
String msg = I18n.err( I18n.ERR_10026, entry.getDn().getName(), schemaName ); LOG.warn( msg ); throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg ); String msg = I18n.err( I18n.ERR_10027, entry.getDn().getName(), schemaName ); LOG.info( msg ); schema = schemaManager.getLoadedSchema( schemaName ); Attribute mSyntax = entry.get( MetaSchemaConstants.M_SYNTAX_AT ); Attribute mSyntaxLength = entry.get( MetaSchemaConstants.M_LENGTH_AT ); Attribute mEquality = entry.get( MetaSchemaConstants.M_EQUALITY_AT ); Attribute mOrdering = entry.get( MetaSchemaConstants.M_ORDERING_AT ); Attribute mSubstr = entry.get( MetaSchemaConstants.M_SUBSTR_AT ); Attribute mSupAttributeType = entry.get( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT ); Attribute mCollective = entry.get( MetaSchemaConstants.M_COLLECTIVE_AT ); Attribute mSingleValued = entry.get( MetaSchemaConstants.M_SINGLE_VALUE_AT ); Attribute mNoUserModification = entry.get( MetaSchemaConstants.M_NO_USER_MODIFICATION_AT ); Attribute mUsage = entry.get( MetaSchemaConstants.M_USAGE_AT );
/** * Process the FQCN attribute * @throws LdapInvalidAttributeValueException */ private String getFqcn( Entry entry, String objectType ) throws LdapInvalidAttributeValueException { // The FQCN Attribute mFqcn = entry.get( MetaSchemaConstants.M_FQCN_AT ); if ( mFqcn == null ) { String msg = I18n.err( I18n.ERR_10028, objectType, MetaSchemaConstants.M_FQCN_AT ); LOG.warn( msg ); throw new IllegalArgumentException( msg ); } return mFqcn.getString(); }
/** * Create a new attribute * * @param type The attribute's type */ public void addAttribute( String type ) throws LdapException { currentAttribute = new DefaultEntryAttribute( type ); getDecorated().getEntry().put( currentAttribute ); }
if ( entry.size() != 0 )
String msg = I18n.err( I18n.ERR_10016, entry.getDn().getName(), schemaName ); LOG.warn( msg ); throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg ); String msg = I18n.err( I18n.ERR_10017, entry.getDn().getName(), schemaName ); LOG.info( msg ); schema = schemaManager.getLoadedSchema( schemaName ); Attribute byteCode = entry.get( MetaSchemaConstants.M_BYTECODE_AT );
if ( entry.get( SchemaConstants.CN_AT ) == null ) name = entry.get( SchemaConstants.CN_AT ).getString(); if ( entry.get( SchemaConstants.CREATORS_NAME_AT ) == null ) owner = entry.get( SchemaConstants.CREATORS_NAME_AT ).getString(); if ( entry.get( MetaSchemaConstants.M_DISABLED_AT ) != null ) String value = entry.get( MetaSchemaConstants.M_DISABLED_AT ).getString(); value = value.toUpperCase(); isDisabled = value.equals( "TRUE" ); if ( entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT ) != null ) Attribute depsAttr = entry.get( MetaSchemaConstants.M_DEPENDENCIES_AT );
/** * @return the Names as Ldif lines * @throws org.apache.directory.shared.ldap.model.exception.LdapException If the conversion goes wrong */ private String nameToLdif() throws LdapException { if ( names.size() == 0 ) { return ""; } else { Entry entry = new DefaultEntry(); Attribute attribute = new DefaultAttribute( "m-name" ); for ( String name : names ) { attribute.add( name ); } entry.put( attribute ); return LdifUtils.convertAttributesToLdif( entry ); } }
if ( ( entry != null ) && ( entry.size() != 0 ) )
String msg = I18n.err( I18n.ERR_10024, entry.getDn().getName(), schemaName ); LOG.warn( msg ); throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg ); String msg = I18n.err( I18n.ERR_10025, entry.getDn().getName(), schemaName ); LOG.info( msg ); schema = schemaManager.getLoadedSchema( schemaName ); Attribute mSuperiors = entry.get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ); Attribute mMay = entry.get( MetaSchemaConstants.M_MAY_AT ); Attribute mMust = entry.get( MetaSchemaConstants.M_MUST_AT ); Attribute mTypeObjectClass = entry.get( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT );
/** * Behaves like {@link #store(List)} except that duplicates do not throw an exception but are overwritten as * described in {@link #storeOverwriteExisting(Entry)}. Note that this action is not atomic. * */ public void storeOverwriteExisting(List<Entry> entries) throws NoSuchNodeException, MissingParentException { for (Entry entry : entries) { try { store(entry); } catch (EntryAlreadyExistsException e) { deleteSubtreeIncludingRoot(e.getEntry().getDn()); try { store(entry); } catch (EntryAlreadyExistsException e1) { LOGGER.debug("should never reach here"); throw new LdapDaoException(e1); } } } }
/** * Get an OID from an entry. Handles the bad cases (null OID, * not a valid OID, ...) */ private String getOid( Entry entry, String objectType ) throws LdapInvalidAttributeValueException { // The OID Attribute mOid = entry.get( MetaSchemaConstants.M_OID_AT ); if ( mOid == null ) { String msg = I18n.err( I18n.ERR_10005, objectType, MetaSchemaConstants.M_OID_AT ); LOG.warn( msg ); throw new IllegalArgumentException( msg ); } String oid = mOid.getString(); if ( !Oid.isOid( oid ) ) { String msg = I18n.err( I18n.ERR_10006, oid ); LOG.warn( msg ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); } return oid; }
/** * @return The description as a ldif line * @throws org.apache.directory.shared.ldap.model.exception.LdapException If the conversion goes wrong */ private String descToLdif() throws LdapException { if ( Strings.isEmpty( description ) ) { return ""; } else { Entry entry = new DefaultEntry(); Attribute attribute = new DefaultAttribute( "m-description", description ); entry.put( attribute ); return LdifUtils.convertAttributesToLdif( entry ); } }
if ( ( entry != null ) && ( entry.size() != 0 ) )
String msg = I18n.err( I18n.ERR_10022, entry.getDn().getName(), schemaName ); LOG.warn( msg ); throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg ); String msg = I18n.err( I18n.ERR_10023, entry.getDn().getName(), schemaName ); LOG.info( msg ); schema = schemaManager.getLoadedSchema( schemaName ); Attribute mSyntax = entry.get( MetaSchemaConstants.M_SYNTAX_AT );
private List<Node> extractNodesFromCursor(SearchCursor cursor) { LinkedList<Node> result = new LinkedList<Node>(); try { while (cursor.next()) { Node node = new Node(cursor.getEntry()); result.addFirst(node); node.setChildren(searchSubtree(node.getEntry().getDn())); for (Node n : node.getChildren()) { n.setParent(node); } } } catch (Exception e) { throw new LdapDaoException(e); } return result; }
Attribute mObsolete = entry.get( MetaSchemaConstants.M_OBSOLETE_AT ); Attribute mDescription = entry.get( MetaSchemaConstants.M_DESCRIPTION_AT ); Attribute names = entry.get( MetaSchemaConstants.M_NAME_AT ); Attribute mDisabled = entry.get( MetaSchemaConstants.M_DISABLED_AT ); Attribute xSchema = entry.get( MetaSchemaConstants.X_SCHEMA_AT ); Attribute xNotHumanReadable = entry.get( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT ); Attribute xReadOnly = entry.get( MetaSchemaConstants.X_READ_ONLY_AT ); Attribute xEnabled = entry.get( MetaSchemaConstants.X_ENABLED_AT );
String msg = I18n.err( I18n.ERR_10013, entry.getDn().getName(), schemaName ); LOG.warn( msg ); throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, msg ); String msg = I18n.err( I18n.ERR_10014, entry.getDn().getName(), schemaName ); LOG.info( msg ); schema = schemaManager.getLoadedSchema( schemaName ); Attribute byteCode = entry.get( MetaSchemaConstants.M_BYTECODE_AT );