/** * Convert all the Entry's attributes to LDIF. The DN is not written * @param entry the Entry to convert * @return the corresponding LDIF code as a String * @throws LdapException If a naming exception is encountered. */ public static String convertAttributesToLdif( Entry entry ) throws LdapException { return convertAttributesToLdif( entry, DEFAULT_LINE_LENGTH ); }
/** * Convert an Attributes as LDIF * @param attrs the Attributes to convert * @return the corresponding LDIF code as a String * @throws LdapException If a naming exception is encountered. */ public static String convertToLdif( Attributes attrs ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toClientEntry( attrs, null ), DEFAULT_LINE_LENGTH ); }
/** * Convert an Attributes as LDIF * @param attrs the Attributes to convert * @return the corresponding LDIF code as a String * @throws LdapException If a naming exception is encountered. */ public static String convertToLdif( Attributes attrs, int length ) throws LdapException { return convertAttributesToLdif( AttributeUtils.toClientEntry( attrs, null ), length ); }
/** * 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 NamingException If the conversion goes wrong */ protected String extensionsToLdif( String ID ) throws NamingException { StringBuilder sb = new StringBuilder(); Entry entry = new DefaultClientEntry(); EntryAttribute attribute = new DefaultClientAttribute( ID ); for ( String extension:extensions ) { attribute.add( extension ); } sb.append( LdifUtils.convertAttributesToLdif( entry ) ); return sb.toString(); }
/** * @return the Names as Ldif lines */ private String nameToLdif() throws NamingException { if ( names.size() == 0 ) { return ""; } else { Entry entry = new DefaultClientEntry(); EntryAttribute attribute = new DefaultClientAttribute( "m-name" ); for ( String name:names ) { attribute.add( name ); } entry.put( attribute ); return LdifUtils.convertAttributesToLdif( entry ); } }
/** * @return The description as a ldif line */ private String descToLdif() throws NamingException { if ( StringTools.isEmpty( description ) ) { return ""; } else { Entry entry = new DefaultClientEntry(); EntryAttribute attribute = new DefaultClientAttribute( "m-description", description ); entry.put( attribute ); return LdifUtils.convertAttributesToLdif( entry ); } }