Search in sources :

Example 1 with ISearchIndex

use of com.sun.identity.entitlement.interfaces.ISearchIndex in project OpenAM by OpenRock.

the class ApplicationImpl method getSearchIndex.

private Class getSearchIndex(Map<String, Set<String>> attributeValues) throws CLIException {
    String searchIndex = getString(ATTR_SEARCH_INDEX, attributeValues);
    if ((searchIndex == null) || (searchIndex.trim().length() == 0)) {
        return null;
    }
    try {
        Class clazz = Class.forName(searchIndex);
        Object obj = clazz.newInstance();
        if (obj instanceof ISearchIndex) {
            return clazz;
        }
        Object[] params = { searchIndex };
        throw new CLIException(MessageFormat.format("search-index-does-not-extend-interface", params), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (InstantiationException ex) {
        throw new CLIException(ex, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IllegalAccessException ex) {
        throw new CLIException(ex, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ClassNotFoundException ex) {
        Object[] params = { searchIndex };
        throw new CLIException(MessageFormat.format("search-index-class-not-found", params), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ISearchIndex(com.sun.identity.entitlement.interfaces.ISearchIndex) CLIException(com.sun.identity.cli.CLIException)

Example 2 with ISearchIndex

use of com.sun.identity.entitlement.interfaces.ISearchIndex in project OpenAM by OpenRock.

the class EntitlementService method getApplicationData.

private Map<String, Set<String>> getApplicationData(Application appl) {
    Map<String, Set<String>> map = new HashMap<String, Set<String>>();
    Set<String> setServiceID = new HashSet<String>(2);
    map.put(SMSEntry.ATTR_SERVICE_ID, setServiceID);
    setServiceID.add("application");
    Set<String> setObjectClass = new HashSet<String>(4);
    map.put(SMSEntry.ATTR_OBJECTCLASS, setObjectClass);
    setObjectClass.add(SMSEntry.OC_TOP);
    setObjectClass.add(SMSEntry.OC_SERVICE_COMP);
    Set<String> data = new HashSet<String>();
    map.put(SMSEntry.ATTR_KEYVAL, data);
    data.add(EntitlementUtils.APPLICATION_TYPE + '=' + appl.getApplicationType().getName());
    if (appl.getDescription() != null) {
        data.add(EntitlementUtils.CONFIG_DESCRIPTION + "=" + appl.getDescription());
    } else {
        data.add(EntitlementUtils.CONFIG_DESCRIPTION + "=");
    }
    data.add(CONFIG_ENTITLEMENT_COMBINER + "=" + appl.getEntitlementCombiner().getClass().getName());
    Set<String> conditions = appl.getConditions();
    if ((conditions != null) && !conditions.isEmpty()) {
        for (String c : conditions) {
            data.add(CONFIG_CONDITIONS + "=" + c);
        }
    } else {
        data.add(CONFIG_CONDITIONS + "=");
    }
    Set<String> subjects = appl.getSubjects();
    if ((subjects != null) && !subjects.isEmpty()) {
        for (String s : subjects) {
            data.add(CONFIG_SUBJECTS + "=" + s);
        }
    } else {
        data.add(CONFIG_SUBJECTS + "=");
    }
    ISaveIndex sIndex = appl.getSaveIndex();
    if (sIndex != null) {
        String saveIndexClassName = sIndex.getClass().getName();
        data.add(CONFIG_SAVE_INDEX_IMPL + "=" + saveIndexClassName);
    }
    ISearchIndex searchIndex = appl.getSearchIndex();
    if (searchIndex != null) {
        String searchIndexClassName = searchIndex.getClass().getName();
        data.add(CONFIG_SEARCH_INDEX_IMPL + "=" + searchIndexClassName);
    }
    ResourceName recComp = appl.getResourceComparator(false);
    if (recComp != null) {
        String resCompClassName = recComp.getClass().getName();
        data.add(CONFIG_RESOURCE_COMP_IMPL + "=" + resCompClassName);
    }
    Set<String> sbjAttributes = appl.getAttributeNames();
    if ((sbjAttributes != null) && !sbjAttributes.isEmpty()) {
        for (String s : sbjAttributes) {
            data.add(ATTR_NAME_SUBJECT_ATTR_NAMES + "=" + s);
        }
    } else {
        data.add(ATTR_NAME_SUBJECT_ATTR_NAMES + "=");
    }
    for (String m : appl.getMetaData()) {
        data.add(ATTR_NAME_META + "=" + m);
    }
    if (!appl.getResourceTypeUuids().isEmpty()) {
        Set<String> searchableAttributes = new HashSet<String>();
        for (String resourceTypeUuid : appl.getResourceTypeUuids()) {
            searchableAttributes.add(EntitlementUtils.CONFIG_RESOURCE_TYPE_UUIDS + "=" + resourceTypeUuid);
        }
        map.put(SMSEntry.ATTR_XML_KEYVAL, searchableAttributes);
    }
    map.put("ou", getApplicationIndices(appl));
    return map;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ISearchIndex(com.sun.identity.entitlement.interfaces.ISearchIndex) ResourceName(com.sun.identity.entitlement.interfaces.ResourceName) ISaveIndex(com.sun.identity.entitlement.interfaces.ISaveIndex) HashSet(java.util.HashSet)

Example 3 with ISearchIndex

use of com.sun.identity.entitlement.interfaces.ISearchIndex in project OpenAM by OpenRock.

the class EntitlementService method getApplicationTypeData.

private Map<String, Set<String>> getApplicationTypeData(ApplicationType applType) {
    Map<String, Set<String>> data = new HashMap<String, Set<String>>();
    data.put(EntitlementUtils.CONFIG_ACTIONS, EntitlementUtils.getActionSet(applType.getActions()));
    ISaveIndex sIndex = applType.getSaveIndex();
    String saveIndexClassName = (sIndex != null) ? sIndex.getClass().getName() : null;
    data.put(CONFIG_SAVE_INDEX_IMPL, (saveIndexClassName == null) ? Collections.EMPTY_SET : getSet(saveIndexClassName));
    ISearchIndex searchIndex = applType.getSearchIndex();
    String searchIndexClassName = (searchIndex != null) ? searchIndex.getClass().getName() : null;
    data.put(CONFIG_SEARCH_INDEX_IMPL, (searchIndexClassName == null) ? Collections.EMPTY_SET : getSet(searchIndexClassName));
    ResourceName recComp = applType.getResourceComparator();
    String resCompClassName = (recComp != null) ? recComp.getClass().getName() : null;
    data.put(CONFIG_RESOURCE_COMP_IMPL, (resCompClassName == null) ? Collections.EMPTY_SET : getSet(resCompClassName));
    return data;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ISearchIndex(com.sun.identity.entitlement.interfaces.ISearchIndex) ResourceName(com.sun.identity.entitlement.interfaces.ResourceName) ISaveIndex(com.sun.identity.entitlement.interfaces.ISaveIndex)

Aggregations

ISearchIndex (com.sun.identity.entitlement.interfaces.ISearchIndex)3 ISaveIndex (com.sun.identity.entitlement.interfaces.ISaveIndex)2 ResourceName (com.sun.identity.entitlement.interfaces.ResourceName)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 CLIException (com.sun.identity.cli.CLIException)1