/** * 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(); }
/** * 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(); }
if ( ( mSyntax != null ) && ( mSyntax.get() != null ) ) attributeType.setSyntaxOid( mSyntax.getString() ); attributeType.setSyntaxLength( Integer.parseInt( mSyntaxLength.getString() ) ); attributeType.setEqualityOid( mEquality.getString() ); attributeType.setOrderingOid( mOrdering.getString() ); attributeType.setSubstringOid( mSubstr.getString() ); attributeType.setSuperiorOid( mSupAttributeType.getString() ); String val = mCollective.getString(); attributeType.setCollective( val.equalsIgnoreCase( "TRUE" ) ); String val = mSingleValued.getString(); attributeType.setSingleValued( val.equalsIgnoreCase( "TRUE" ) ); String val = mNoUserModification.getString(); attributeType.setUserModifiable( !val.equalsIgnoreCase( "TRUE" ) ); attributeType.setUsage( UsageEnum.getUsage( mUsage.getString() ) );
/** * {@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 ); } }
byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) );
/** * 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; }
/** * 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; }
/** * 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(); } }
byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) );
/** * 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; }
byteCodeStr = new String( Base64.encode( byteCode.getBytes() ) );
/** * @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 ); } }
String val = mObsolete.getString(); schemaObject.setObsolete( val.equalsIgnoreCase( "TRUE" ) ); String val = mDisabled.getString(); schemaObject.setEnabled( !val.equalsIgnoreCase( "TRUE" ) ); String schemaName = xSchema.getString(); String value = xNotHumanReadable.getString(); String value = xReadOnly.getString(); String value = xEnabled.getString();
matchingRule.setSyntaxOid( mSyntax.getString() );
String type = mTypeObjectClass.getString(); oc.setType( ObjectClassTypeEnum.getClassType( type ) );