/** * Add a new value to the current attribute * * @param value The value to add */ public void addAttributeValue( String value ) { currentAttribute.add( value ); }
/** * Store the current operation * * @param currentOperation The currentOperation to set. */ public void setCurrentOperation( int currentOperation ) { this.currentOperation = ModificationOperation.getOperation( currentOperation ); }
/** * Return the current attribute's type */ public String getCurrentAttributeType() { return currentAttribute.getId(); }
/** * @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 ); } }
/** * Return a String value, from teh given Valu, even if it's a binary value */ private String getStringValue( Attribute attribute ) { Value<?> value = attribute.get(); if ( value instanceof BinaryValue ) { // We have to transform the value to a String return Strings.utf8ToString( value.getBytes() ); } else { return value.getString(); } }
/** * @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 ); } }
/** * Return the extensions formated as Ldif lines * * @param id The attributeId : can be m-objectClassExtension or * m-attributeTypeExtension * @return The extensions formated as ldif lines * @throws org.apache.directory.shared.ldap.model.exception.LdapException If the conversion goes wrong */ protected String extensionsToLdif( String id ) throws LdapException { StringBuilder sb = new StringBuilder(); Entry entry = new DefaultEntry(); Attribute attribute = new DefaultAttribute( id ); for ( String extension : extensions.keySet() ) { attribute.add( extension ); } sb.append( LdifUtils.convertAttributesToLdif( entry ) ); return sb.toString(); }
/** * {@inheritDoc} */ public Class<?> findClass( String name ) throws ClassNotFoundException { byte[] classBytes = null; Value<?> value = attribute.get(); if ( value.isHumanReadable() ) { throw new ClassNotFoundException( I18n.err( I18n.ERR_10002 ) ); } classBytes = value.getBytes(); return defineClass( name, classBytes, 0, classBytes.length ); } }
/** * 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 ); }
/** * Create a list of string from a multivalued attribute's values */ private List<String> getStrings( Attribute attr ) { if ( attr == null ) { return EMPTY_LIST; } List<String> strings = new ArrayList<String>( attr.size() ); for ( Value<?> value : attr ) { strings.add( value.getString() ); } return strings; }
/** * 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 ); }
/** * 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(); }
/** * Add a new attributeTypeAndValue * * @param type The attribute's name */ public void addAttributeTypeAndValues( String type ) { currentAttribute = new DefaultEntryAttribute( type ); Modification modification = new DefaultModification( currentOperation, currentAttribute ); getDecorated().addModification( modification ); }
/** * Sets the attribute. * * @param attribute the new attribute * @throws LdapException if the attribute is not binary. */ public void setAttribute( Attribute attribute ) throws LdapException { if ( attribute.isHumanReadable() ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.CONSTRAINT_VIOLATION, I18n.err( I18n.ERR_10001 ) ); } this.attribute = attribute; }
/** * Add a new value to the current attribute * * @param value The value to add */ public void addAttributeValue( byte[] value ) { currentAttribute.add( value ); }
/** * @return Returns the currentAttribute type. */ public String getCurrentAttributeType() { return currentAttribute.getId(); }
/** * Add a new value to the current attribute * * @param value The value to add */ public void addAttributeValue( byte[] value ) { currentAttribute.add( value ); }
/** * Add a new value to the current attribute * * @param value The value to add */ public void addAttributeValue( Value<?> value ) { currentAttribute.add( value ); }
/** * Add a new value to the current attribute * * @param value The value to add */ public void addAttributeValue( String value ) { currentAttribute.add( value ); }