Search in sources :

Example 6 with Modification

use of org.forgerock.opendj.ldap.Modification in project OpenAM by OpenRock.

the class ModSet method remove.

/**
     * Removes the first attribute with the specified name in the set of modifications.
     * @param name name of the attribute to remove
     */
public synchronized void remove(String name) {
    for (int i = 0; i < modifications.size(); i++) {
        Modification mod = modifications.get(i);
        Attribute attr = mod.getAttribute();
        if (name.equalsIgnoreCase(attr.getAttributeDescriptionAsString())) {
            modifications.remove(i);
            return;
        }
    }
}
Also used : Modification(org.forgerock.opendj.ldap.Modification) Attribute(org.forgerock.opendj.ldap.Attribute)

Example 7 with Modification

use of org.forgerock.opendj.ldap.Modification in project OpenAM by OpenRock.

the class Validation method validateAttributes.

/**
     * Determines whether each attribute in the ModSet is valid.
     * 
     * @param modSet
     *            modSet to test
     * @param cls
     *            Class associated with these attributes
     * @param guid
     *            the guid of the Organization where the config data is stored
     * @exception UMSException
     *                failure
     * @exception DataConstraintException
     *                data validation failure
     */
public static void validateAttributes(ModSet modSet, Class cls, Guid guid) throws UMSException, DataConstraintException {
    if (modSet == null) {
        return;
    }
    for (int i = 0; i < modSet.size(); i++) {
        Modification ldapMod = modSet.elementAt(i);
        if (!ModificationType.DELETE.equals(ldapMod.getModificationType())) {
            Attr attr = new Attr(ldapMod.getAttribute());
            validateAttribute(attr, cls, guid);
        }
    }
}
Also used : Modification(org.forgerock.opendj.ldap.Modification) Attr(com.iplanet.services.ldap.Attr)

Example 8 with Modification

use of org.forgerock.opendj.ldap.Modification in project OpenAM by OpenRock.

the class COSManager method toModifications.

private Collection<Modification> toModifications(ModificationType type, AttrSet attrSet) {
    Collection<Modification> modifications = new HashSet<>();
    Enumeration<Attr> attributes = attrSet.getAttributes();
    while (attributes.hasMoreElements()) {
        modifications.add(new Modification(type, attributes.nextElement().toLDAPAttribute()));
    }
    return modifications;
}
Also used : Modification(org.forgerock.opendj.ldap.Modification) Attr(com.iplanet.services.ldap.Attr) HashSet(java.util.HashSet)

Example 9 with Modification

use of org.forgerock.opendj.ldap.Modification in project OpenAM by OpenRock.

the class ModSet method add.

/**
     * Specifies another modification to be added to the set of modifications.
     * @param op the type of modification to make. This can be one of the following:
     *   <P>
     *   <UL>
     *   <LI><CODE>LDAPModification.ADD</CODE> (the value should be added to the attribute)
     *   <LI><CODE>LDAPModification.DELETE</CODE> (the value should be removed from the attribute)
     *   <LI><CODE>LDAPModification.REPLACE</CODE> (the value should replace the existing value of the attribute)
     *   </UL><P>
     * If you are working with a binary value (not a string value), you need to bitwise OR (|) the
     * modification type with <CODE>LDAPModification.BVALUES</CODE>.
     * <P>
     *
     * @param attr the attribute (possibly with values) to modify
     */
public synchronized void add(int op, Attribute attr) {
    Modification mod = new Modification(ModificationType.valueOf(op), attr);
    modifications.add(mod);
}
Also used : Modification(org.forgerock.opendj.ldap.Modification)

Example 10 with Modification

use of org.forgerock.opendj.ldap.Modification in project OpenAM by OpenRock.

the class PersistentObject method modify.

/**
     * Modifies the values of a single attribute for the entity.
     * <P>
     * IMPORTANT: To make the changes persistent, you need to call the save
     * method to save the changes.
     * <P>
     * 
     * @param attr
     *            Attribute value to be modified
     * @param modificationType
     *            Operation type in the modification. Input values include
     * 
     * <pre>
     *               ModificationType.ADD,
     *               ModificationType.DELETE,
     *               ModificationType.REPLACE,
     *               ModificationType.INCREMENT
     * </pre>
     * 
     * @see ModSet
     *
     * @supported.api
     */
public void modify(Attr attr, ModificationType modificationType) {
    Modification modification = new Modification(modificationType, attr.toLDAPAttribute());
    modify(Collections.singleton(modification));
}
Also used : Modification(org.forgerock.opendj.ldap.Modification)

Aggregations

Modification (org.forgerock.opendj.ldap.Modification)13 LdapException (org.forgerock.opendj.ldap.LdapException)7 ModifyRequest (org.forgerock.opendj.ldap.requests.ModifyRequest)7 Attribute (org.forgerock.opendj.ldap.Attribute)6 ByteString (org.forgerock.opendj.ldap.ByteString)6 Connection (org.forgerock.opendj.ldap.Connection)5 LinkedAttribute (org.forgerock.opendj.ldap.LinkedAttribute)4 Attr (com.iplanet.services.ldap.Attr)2 HashSet (java.util.HashSet)2 ResultCode (org.forgerock.opendj.ldap.ResultCode)2 DSConfigMgr (com.iplanet.services.ldap.DSConfigMgr)1 LDAPServiceException (com.iplanet.services.ldap.LDAPServiceException)1 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 Debug (com.sun.identity.shared.debug.Debug)1 SMSException (com.sun.identity.sm.SMSException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashMap (java.util.HashMap)1