/** * Convert an Entry to LDIF * * @param entry the Entry to convert * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry ) { return convertToLdif( entry, DEFAULT_LINE_LENGTH ); }
/** * 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 */ public static String convertAttributesToLdif( Entry entry ) { return convertAttributesToLdif( 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 Value ) { return false; } else if ( value instanceof byte[] ) { return true; } else if ( value instanceof String ) { return !LdifUtils.isLDIFSafe( ( String ) value ); } return true; }
/** * Convert an Entry as LDIF * * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry, int length ) { StringBuilder sb = new StringBuilder(); if ( entry.getDn() != null ) { // First, dump the Dn if ( isLDIFSafe( entry.getDn().getName() ) ) { sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); } else { sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); } sb.append( '\n' ); } // Then all the attributes for ( Attribute attribute : entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
if ( !LdifUtils.isLDIFSafe( str ) ) lineBuffer.append( ":: " ).append( encodeBase64( str ) ); sb.append( stripLineToNChars( lineBuffer.toString(), length ) );
/** * Convert an Entry as LDIF * * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry, int length ) { StringBuilder sb = new StringBuilder(); if ( entry.getDn() != null ) { // First, dump the Dn if ( isLDIFSafe( entry.getDn().getName() ) ) { sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); } else { sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); } sb.append( '\n' ); } // Then all the attributes for ( Attribute attribute : entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
if ( !LdifUtils.isLDIFSafe( str ) ) lineBuffer.append( ":: " ).append( encodeBase64( str ) ); sb.append( stripLineToNChars( lineBuffer.toString(), length ) );
/** * 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 Entry as LDIF * * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry, int length ) { StringBuilder sb = new StringBuilder(); if ( entry.getDn() != null ) { // First, dump the Dn if ( isLDIFSafe( entry.getDn().getName() ) ) { sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); } else { sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); } sb.append( '\n' ); } // Then all the attributes for ( Attribute attribute : entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
if ( !LdifUtils.isLDIFSafe( str ) ) lineBuffer.append( ":: " ).append( encodeBase64( str ) ); sb.append( stripLineToNChars( lineBuffer.toString(), length ) );
/** * 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 */ public static String convertAttributesToLdif( Entry entry ) { return convertAttributesToLdif( entry, DEFAULT_LINE_LENGTH ); }
if ( LdifUtils.isLDIFSafe( dnStr ) )
/** * Convert an Entry to LDIF * * @param entry the Entry to convert * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry ) { return convertToLdif( entry, 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( controlStr.toString(), length ) ); sb.append( '\n' ); sb.append( stripLineToNChars( "changetype: " + changeType, length ) ); sb.append( '\n' ); if ( entry.hasControls() ) sb.append( stripLineToNChars( "changetype: " + ChangeType.Add, length ) ); sb.append( convertToLdif( attribute, length ) ); sb.append( convertToLdif( newRdn, length ) ); sb.append( convertToLdif( newSuperior, length ) ); sb.append( '\n' ); sb.append( convertToLdif( modification.getAttribute(), length ) );
/** * 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 */ public static String convertAttributesToLdif( Entry entry ) { return convertAttributesToLdif( entry, DEFAULT_LINE_LENGTH ); }
if ( LdifUtils.isLDIFSafe( dnStr ) )
/** * 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 ); }
if ( isLDIFSafe( entry.getDn().getName() ) ) sb.append( stripLineToNChars( "dn: " + entry.getDn(), length ) ); sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); sb.append( stripLineToNChars( controlStr.toString(), length ) ); sb.append( '\n' ); sb.append( stripLineToNChars( "changetype: " + changeType, length ) ); sb.append( '\n' ); if ( entry.hasControls() ) sb.append( stripLineToNChars( "changetype: " + ChangeType.Add, length ) ); sb.append( convertToLdif( attribute, length ) ); sb.append( convertToLdif( newRdn, length ) ); sb.append( convertToLdif( newSuperior, length ) ); sb.append( '\n' ); sb.append( convertToLdif( modification.getAttribute(), length ) );
/** * Convert an Attributes as LDIF * * @param attrs the Attributes to convert * @param length The ldif line length * @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.toEntry( attrs, null ), length ); }
if ( LdifUtils.isLDIFSafe( dnStr ) )