Search in sources :

Example 11 with EntryNotFoundException

use of com.iplanet.ums.EntryNotFoundException in project OpenAM by OpenRock.

the class DomainComponentTree method addDomain.

/**
     * Add a virtual domain into the domain component
     * tree.
     * 
     * @param domain
     *            Fully qualified domain name
     * @return Domain Componet entry just added to the dctree
     * @throws InvalidDCRootException
     *             if dcroot is not defined
     * @throws UMSException
     *             for write problem in adding domain to dctree
     * @supported.api
     */
public DomainComponent addDomain(String domain) throws UMSException {
    if (domain == null || domain.length() == 0) {
        throw new IllegalArgumentException();
    }
    if (m_dcRoot == null) {
        throw new InvalidDCRootException();
    }
    StringTokenizer st = new StringTokenizer(domain, ".");
    int nDoms = st.countTokens();
    String[] doms = new String[nDoms];
    int i = 0;
    while (st.hasMoreElements()) {
        doms[i++] = st.nextToken();
    }
    PersistentObject parent = UMSObject.getObject(getSSOToken(), m_dcRoot.getGuid());
    // Going from right to left on the virtual domain name
    // to go through all the domain components (dc). Make sure that
    // all dc entries are created in the dctree
    // e.g. adding a domain for eng.sun.com with dcRoot being o=internet
    // will yield
    // <pre>
    // o=internet (assmumed to exist)
    // dc=com,o=internet (created)
    // dc=sun,dc=com,o=ineternet (created)
    // dc=eng,dc=sun,dc=com,o=internet (created)
    // </pre>
    // in the domain component tree
    //
    DomainComponent dc = null;
    for (i = 0; i < nDoms; i++) {
        SearchResults results = parent.getChildren("dc=" + doms[nDoms - i - 1], null);
        try {
            dc = (DomainComponent) results.assertOneEntry();
        } catch (EntryNotFoundException e) {
            dc = new DomainComponent(getSSOToken(), doms[nDoms - i - 1]);
            parent.addChild(dc);
        }
        parent = UMSObject.getObject(getSSOToken(), dc.getGuid());
    }
    return dc;
}
Also used : StringTokenizer(java.util.StringTokenizer) EntryNotFoundException(com.iplanet.ums.EntryNotFoundException) PersistentObject(com.iplanet.ums.PersistentObject) SearchResults(com.iplanet.ums.SearchResults)

Aggregations

EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)11 AMException (com.iplanet.am.sdk.AMException)10 UMSException (com.iplanet.ums.UMSException)10 Guid (com.iplanet.ums.Guid)9 DN (org.forgerock.opendj.ldap.DN)5 AccessRightsException (com.iplanet.ums.AccessRightsException)4 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)4 AttrSet (com.iplanet.services.ldap.AttrSet)3 ManagedRole (com.iplanet.ums.ManagedRole)3 PersistentObject (com.iplanet.ums.PersistentObject)3 SearchResults (com.iplanet.ums.SearchResults)3 AMHashMap (com.iplanet.am.sdk.AMHashMap)2 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)2 AMUserEntryProcessed (com.iplanet.am.sdk.AMUserEntryProcessed)2 Attr (com.iplanet.services.ldap.Attr)2 DynamicGroup (com.iplanet.ums.DynamicGroup)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2