Search in sources :

Example 46 with UMSException

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

the class DCTreeServicesImpl method getDomainAttributes.

protected AttrSet getDomainAttributes(SSOToken token, String orgDN, String[] attrNames) throws AMException, SSOException {
    String domainName = null;
    try {
        AttrSet domAttrSet;
        domainName = getCanonicalDomain(token, orgDN);
        if (domainName == null) {
            debug.error("DCTree.getDomainAttributes-> " + "Domain not found for:  " + orgDN);
            return null;
        }
        DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
        DomainComponent dcNode = dcTree.getDomainComponent(domainName);
        if (attrNames != null) {
            domAttrSet = dcNode.getAttributes(attrNames);
        } else {
            domAttrSet = dcNode.getAttributes(dcNode.getAttributeNames());
        }
        AttrSet[] attrArray = splitAttrSet(null, domAttrSet);
        return attrArray[1];
    } catch (UMSException umse) {
        debug.error("DCTree.getDomainAttributes: " + " error getting attributes for domain " + domainName);
    }
    return null;
}
Also used : DomainComponent(com.iplanet.ums.dctree.DomainComponent) UMSException(com.iplanet.ums.UMSException) DomainComponentTree(com.iplanet.ums.dctree.DomainComponentTree) Guid(com.iplanet.ums.Guid) AttrSet(com.iplanet.services.ldap.AttrSet)

Example 47 with UMSException

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

the class NamingAttributeManager method getNamingAttributeFromTemplate.

/**
     * Gets the naming attribute after reading it from the corresponding
     * creation template. If not found, a default value will be used
     */
private static String getNamingAttributeFromTemplate(int objectType, String orgDN) {
    try {
        // Intitalize TemplateManager if not already initialized
        if (templateMgr == null) {
            templateMgr = TemplateManager.getTemplateManager();
        }
        String templateName = getCreationTemplateName(objectType);
        if (templateName == null) {
            debug.warning("AMNamingAttrMgr.getNamingAttr(objectType, " + "orgDN): (" + objectType + "," + orgDN + ") Could not determine creation template name. " + "Returning <empty> value");
            return "";
        }
        Guid orgGuid = ((orgDN == null) ? null : new Guid(orgDN));
        CreationTemplate creationTemp = templateMgr.getCreationTemplate(templateName, orgGuid, TemplateManager.SCOPE_ANCESTORS);
        // get search filter attribute
        String namingAttr = creationTemp.getNamingAttribute();
        if (namingAttr == null) {
            debug.error("AMNamingAttrManager.getNamingAttr()" + " Naming attribute for Object Type:" + objectType + " Org DN: " + orgDN + " is null");
        } else if (debug.messageEnabled()) {
            debug.message("AMNamingAttrManager.getNamingAttr(): Naming " + "attribute for Object type= " + objectType + ": " + namingAttr);
        }
        return namingAttr;
    } catch (UMSException ue) {
        // The right thing would be to propagate this exception back
        String defaultAttr = getDefaultNamingAttr(objectType);
        debug.warning("Unable to get the naming attribute for " + objectType + " Using default " + defaultAttr);
        return defaultAttr;
    }
}
Also used : CreationTemplate(com.iplanet.ums.CreationTemplate) UMSException(com.iplanet.ums.UMSException) Guid(com.iplanet.ums.Guid)

Example 48 with UMSException

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

the class SearchFilterManager method getSearchFilterFromTemplate.

static String getSearchFilterFromTemplate(int objectType, String orgDN, String searchTemplateName) {
    SearchTemplate searchTemp = null;
    String filter;
    try {
        String searchTempName = ((searchTemplateName == null) ? getSearchTemplateName(objectType) : searchTemplateName);
        if (searchTempName == null) {
            debug.warning("SearchFilterManager." + "getSearchFilterFromTemplate(): Search template name" + " is null. Unable to retrieve search filter. " + "Returning <empty> value.");
            return "";
        }
        TemplateManager mgr = TemplateManager.getTemplateManager();
        Guid orgGuid = ((orgDN == null) ? null : new Guid(orgDN));
        searchTemp = mgr.getSearchTemplate(searchTempName, orgGuid, TemplateManager.SCOPE_TOP);
    // Get the Original search filter
    // Check to see if the filter starts with "(" and ends with ")"
    // In which case there is no need to add opening and closing braces.
    // otherwise add the opening and closing braces.
    } catch (UMSException ue) {
        if (debug.messageEnabled()) {
            debug.message("SearchFilterManager." + "getSearchFilterFrom" + "Template() Got Exception", ue);
        }
    }
    if (searchTemp != null) {
        filter = searchTemp.getSearchFilter();
    } else {
        // FIXME: Why do we need to make it objectclass=*, can't we send the
        // default filter here?
        filter = "(objectclass=*)";
    }
    if (!filter.startsWith("(") || !filter.endsWith(")")) {
        filter = "(" + filter + ")";
    }
    if (debug.messageEnabled()) {
        if (searchTemp != null) {
            debug.message("SearchFilterManager." + "getSearchFilterFrom" + "Template() SearchTemplate Name = " + searchTemp.getName() + ", objectType = " + objectType + ", orgDN = " + orgDN + ", Obtained Filter = " + searchTemp.getSearchFilter() + ", Modified Filter = " + filter);
        } else {
            debug.message("SearchFilterManager." + "getSearchFilterFrom" + "Template() Filter = " + filter);
        }
    }
    return filter;
}
Also used : UMSException(com.iplanet.ums.UMSException) SearchTemplate(com.iplanet.ums.SearchTemplate) TemplateManager(com.iplanet.ums.TemplateManager) Guid(com.iplanet.ums.Guid)

Aggregations

UMSException (com.iplanet.ums.UMSException)48 Guid (com.iplanet.ums.Guid)40 AMException (com.iplanet.am.sdk.AMException)31 PersistentObject (com.iplanet.ums.PersistentObject)24 AttrSet (com.iplanet.services.ldap.AttrSet)16 Attr (com.iplanet.services.ldap.Attr)14 EntryNotFoundException (com.iplanet.ums.EntryNotFoundException)11 AccessRightsException (com.iplanet.ums.AccessRightsException)10 DomainComponentTree (com.iplanet.ums.dctree.DomainComponentTree)8 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)6 SearchResults (com.iplanet.ums.SearchResults)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 DN (org.forgerock.opendj.ldap.DN)6 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)5 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)5 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)5 TreeMap (java.util.TreeMap)5 LdapException (org.forgerock.opendj.ldap.LdapException)5