/** * Convert an Entry to LDIF * @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 convertEntryToLdif( Entry entry ) throws LdapException { return convertEntryToLdif( entry, DEFAULT_LINE_LENGTH ); }
/** * Indicates if the value needs to be encoded as Base64 * * @param value * the value to check * @return * true if the value needs to be encoded as Base64 */ public static boolean needsBase64Encoding( Object value ) { if ( value instanceof byte[] ) { return true; } else if ( value instanceof String ) { return !LdifUtils.isLDIFSafe( ( String ) value ); } return true; }
/** * 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 ); }
if ( isLDIFSafe( entry.getDn().getName() ) ) sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); sb.append( convertToLdif( attribute, length ) );
if ( !LdifUtils.isLDIFSafe( str ) ) lineBuffer.append( ":: " + encodeBase64( str ) ); sb.append( stripLineToNChars( lineBuffer.toString(), length ) );
/** * Converts an EntryAttribute to LDIF * @param attr the >EntryAttribute to convert * @return the corresponding LDIF code as a String * @throws LdapException If a naming exception is encountered. */ public static String convertToLdif( EntryAttribute attr ) throws LdapException { return convertToLdif( attr, DEFAULT_LINE_LENGTH ); }
if ( isLDIFSafe( entry.getDn().getName() ) ) sb.append( stripLineToNChars( "dn: " + entry.getDn(), length ) ); sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); sb.append( stripLineToNChars( "changetype: " + changeType, length ) ); sb.append( '\n' ); sb.append( convertToLdif( attribute, length ) ); sb.append( convertToLdif( newRdn, length ) ); sb.append( convertToLdif( newSuperior, length ) ); sb.append( '\n' ); sb.append( convertToLdif( modification.getAttribute() ) ); sb.append( "-\n" );
/** * Convert an LdifEntry to LDIF * @param entry the LdifEntry to convert * @return the corresponding LDIF as a String * @throws LdapException If a naming exception is encountered. */ public static String convertToLdif( LdifEntry entry ) throws LdapException { return convertToLdif( entry, DEFAULT_LINE_LENGTH ); }
/** * Convert an Attributes as LDIF. The DN is written. * @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, DN dn, int length ) throws LdapException { return convertEntryToLdif( AttributeUtils.toClientEntry( attrs, dn ), 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 ); }
/** * Indicates if the value needs to be encoded as Base64 * * @param value * the value to check * @return * true if the value needs to be encoded as Base64 */ public static boolean needsBase64Encoding( Object value ) { if ( value instanceof byte[] ) { return true; } else if ( value instanceof String ) { return !LdifUtils.isLDIFSafe( ( String ) value ); } return true; }
/** * @return a String representing the Entry, as a LDIF */ public String toString() { try { return LdifUtils.convertToLdif( this ); } catch ( LdapException ne ) { return null; } }
/** * Convert an Attributes as LDIF. The DN is written. * @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, DN dn ) throws LdapException { return convertEntryToLdif( AttributeUtils.toClientEntry( attrs, dn ), 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 ); }
/** * Convert the Entry's attributes to LDIF. The DN is not written. * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String * @throws LdapException If a naming exception is encountered. */ public static String convertAttributesToLdif( Entry entry, int length ) throws LdapException { StringBuilder sb = new StringBuilder(); // Then all the attributes for ( EntryAttribute attribute:entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
public String dnToLdif( String schemaName ) throws NamingException { StringBuilder sb = new StringBuilder(); String dn = "m-oid=" + oid + ", ou=attributeTypes" + ", cn=" + Rdn.escapeValue( schemaName ) + ", ou=schema"; // First dump the DN only Entry entry = new DefaultClientEntry( new LdapDN( dn ) ); sb.append( LdifUtils.convertEntryToLdif( entry ) ); return sb.toString(); } }
/** * 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(); }
public String dnToLdif( String schemaName ) throws NamingException { StringBuilder sb = new StringBuilder(); String dn = "m-oid=" + oid + ", ou=objectClasses" + ", cn=" + Rdn.escapeValue( schemaName ) + ", ou=schema"; // First dump the DN only Entry entry = new DefaultClientEntry( new LdapDN( dn ) ); sb.append( LdifUtils.convertEntryToLdif( 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 ); } }
out.write( LdifUtils.convertEntryToLdif( entry ) ); out.flush(); out.close(); out.write( LdifUtils.convertEntryToLdif( entry ) ); out.flush(); out.close();