Search in sources :

Example 1 with DeleteOperation

use of org.opends.server.core.DeleteOperation in project OpenAM by OpenRock.

the class SMSEmbeddedLdapObject method delete.

/**
     * Delete the entry in the directory. This will delete sub-entries also!
     */
public void delete(SSOToken token, String dn) throws SMSException, SSOException {
    SMSAuditor auditor = newAuditor(token, dn, readCurrentState(dn));
    // Check if there are sub-entries, delete if present
    Iterator se = subEntries(token, dn, "*", 0, false, false).iterator();
    while (se.hasNext()) {
        String entry = (String) se.next();
        if (debug.messageEnabled()) {
            debug.message("SMSEmbeddedLdapObject: deleting sub-entry: " + entry);
        }
        delete(token, getNamingAttribute() + "=" + entry + "," + dn);
    }
    // Check if there are suborganizations, delete if present
    // The recursive 'false' here has the scope SCOPE_ONE
    // while searching for the suborgs.
    // Loop through the suborg at the first level and if there
    // is no next suborg, delete that.
    Set subOrgNames = searchSubOrgNames(token, dn, "*", 0, false, false, false);
    for (Iterator so = subOrgNames.iterator(); so.hasNext(); ) {
        String subOrg = (String) so.next();
        if (debug.messageEnabled()) {
            debug.message("SMSEmbeddedLdapObject: deleting " + "suborganization: " + subOrg);
        }
        delete(token, subOrg);
    }
    DeleteOperation dop = icConn.processDelete(dn);
    ResultCode resultCode = dop.getResultCode();
    if (resultCode != ResultCode.SUCCESS) {
        if (debug.warningEnabled()) {
            debug.warning("SMSEmbeddedLdapObject.delete: " + "Unable to delete entry:" + dn);
        }
        throw (new SMSException("", "sms-entry-cannot-delete"));
    }
    objectChanged(dn, DELETE);
    if (auditor != null) {
        auditor.auditDelete();
    }
}
Also used : SMSAuditor(org.forgerock.openam.auditors.SMSAuditor) DeleteOperation(org.opends.server.core.DeleteOperation) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) ResultCode(org.forgerock.opendj.ldap.ResultCode)

Aggregations

SMSException (com.sun.identity.sm.SMSException)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 SMSAuditor (org.forgerock.openam.auditors.SMSAuditor)1 ResultCode (org.forgerock.opendj.ldap.ResultCode)1 DeleteOperation (org.opends.server.core.DeleteOperation)1