/** * 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 ); }
/** * 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 ); }
/** * Gets the next LDIF on the channel. * * @return the next LDIF as a String. * @exception NoSuchElementException If we can't read the next entry */ public LdifEntry next() { return nextInternal(); }
/** * Compute a reverse LDIF of a DeleteRequest. We have to get the previous * entry in order to restore it. * * @param dn The deleted entry DN * @param deletedEntry The entry which has been deleted * @return A reverse LDIF */ public static LdifEntry reverseDel( DN dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( EntryAttribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; }
/** * 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 ); }
/** * Compute a reverse LDIF of an AddRequest. It's simply a delete request * of the added entry * * @param dn the dn of the added entry * @return a reverse LDIF */ public static LdifEntry reverseAdd( DN dn ) { LdifEntry entry = new LdifEntry(); entry.setChangeType( ChangeType.Delete ); entry.setDn( dn ); return entry; }
private void init( BufferedReader reader ) throws LdapLdifException, LdapException { this.reader = reader; lines = new ArrayList<String>(); position = new Position(); version = DEFAULT_VERSION; containsChanges = false; containsEntries = false; // First get the version - if any - version = parseVersion(); prefetched = parseEntry(); }
public String toString() { return "LdifControl : {" + getOid() + ", " + isCritical() + ", " + StringTools.dumpBytes( getValue() ) + "}"; } }
/** * Convert a LDIF String to an attributes. * * @param ldif The LDIF string containing an attribute value * @return An Attributes instance * @exception LdapException If the LDIF String cannot be converted to an Attributes */ public static Attributes convertAttributesFromLdif( String ldif ) throws LdapLdifException { LdifAttributesReader reader = new LdifAttributesReader(); return AttributeUtils.toAttributes( reader.parseEntry( ldif ) ); }
/** * Always throws UnsupportedOperationException! * * @see java.util.Iterator#remove() */ public void remove() { removeInternal(); }
/** * Revert a DN to it's previous version by removing the first RDN and adding the given RDN. * It's a rename operation. The biggest issue is that we have many corner cases, depending * on the RDNs we are manipulating, and on the content of the initial entry. * * @param entry The initial Entry * @param newRdn The new RDN * @param deleteOldRdn A flag which tells to delete the old RDN AVAs * @return A list of LDIF reverted entries * @throws NamingException If the name reverting failed */ public static List<LdifEntry> reverseRename( Entry entry, RDN newRdn, boolean deleteOldRdn ) throws LdapInvalidDnException { return reverseMoveAndRename( entry, null, newRdn, deleteOldRdn ); }
/** * Get the entry's entry * * @return the stored Entry */ public Entry getEntry() { if ( isEntry() ) { return entry; } else { return null; } }
/** * Constructors */ public LdifReader() { lines = new ArrayList<String>(); position = new Position(); version = DEFAULT_VERSION; }
private static void parseFill( char[] document, Position position ) { while ( StringTools.isCharASCII( document, position.pos, ' ' ) ) { position.inc(); } }
/** * 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 ); }
/** * 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 ) 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 ); }
/** * @return a String representing the Entry, as a LDIF */ public String toString() { try { return LdifUtils.convertToLdif( this ); } catch ( LdapException ne ) { return null; } }