Search in sources :

Example 36 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AMAttrSchemaComparator method compare.

/**
     * Performs string comparison on attribute schema's i18n keys
     *
     * @param o1  <code>AttributeSchema</code> object
     * @param o2  <code>AttributeSchema</code> object
     * @return 0 if i18n key of o1 is equal to i18n key of o2; less than 0 if
     * i18n key of o1 is lexicographically less than i18n key of o2; greater
     * than 0 if i18n key of o1 is greater than i18n key of o2.
     */
public int compare(Object o1, Object o2) {
    AttributeSchema attr1 = (AttributeSchema) o1;
    AttributeSchema attr2 = (AttributeSchema) o2;
    if (collator != null) {
        return collator.compare(attr1.getI18NKey(), attr2.getI18NKey());
    } else {
        return attr1.getI18NKey().compareTo(attr2.getI18NKey());
    }
}
Also used : AttributeSchema(com.sun.identity.sm.AttributeSchema)

Example 37 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AMAdminUtils method getAttributeSchema.

/**
     * Returns attribute schema object.
     *
     * @param serviceName Name of service.
     * @param schemaType Type of Schema.
     * @param subSchemaName Name of sub schema.
     * @param attributeName Name of attribute schema.
     * @return attribute schema object.
     */
public static AttributeSchema getAttributeSchema(String serviceName, SchemaType schemaType, String subSchemaName, String attributeName) {
    Set attributeSchemas = getAttributeSchemas(serviceName, schemaType, subSchemaName);
    AttributeSchema attrSchema = null;
    for (Iterator i = attributeSchemas.iterator(); i.hasNext() && (attrSchema == null); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        if (as.getName().equals(attributeName)) {
            attrSchema = as;
        }
    }
    return attrSchema;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) AttributeSchema(com.sun.identity.sm.AttributeSchema) Iterator(java.util.Iterator)

Example 38 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AgentPropertyXMLBuilder method getAttributeSchemas.

private void getAttributeSchemas(String serviceName, boolean localized) throws SMSException, SSOException {
    mapTypeToAttributeSchema = new HashMap();
    Set localProperty = null;
    if (localized && !bGroup) {
        localProperty = AgentConfiguration.getLocalPropertyNames(agentType);
    }
    Set attrSchemas = AgentConfiguration.getAgentAttributeSchemas(agentType);
    for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        String i18nKey = as.getI18NKey();
        if ((i18nKey == null) || (i18nKey.trim().length() == 0)) {
            i.remove();
        } else if (bGroup) {
            if (as.getName().equals(ATTR_NAME_PWD) || as.getName().equals(ATTR_LOC_CONFIG)) {
                i.remove();
            }
        } else if ((localProperty != null) && !localProperty.contains(as.getName())) {
            i.remove();
        }
    }
    AgentTabManager mgr = AgentTabManager.getInstance();
    Map secToAttrNames = null;
    if (!localized) {
        secToAttrNames = (tabName == null) ? mgr.getAttributeNames(agentType, -1) : mgr.getAttributeNames(agentType, mgr.getTabId(agentType, tabName));
    }
    if ((secToAttrNames == null) || secToAttrNames.isEmpty()) {
        mapTypeToAttributeSchema.put(DUMMY_SECTION, attrSchemas);
    } else {
        for (Iterator i = secToAttrNames.keySet().iterator(); i.hasNext(); ) {
            String sectionName = (String) i.next();
            Set attrNames = (Set) secToAttrNames.get(sectionName);
            Set set = getAttributeSchemas(attrSchemas, attrNames);
            if ((set != null) && !set.isEmpty()) {
                mapTypeToAttributeSchema.put(sectionName, set);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) AgentTabManager(com.sun.identity.console.agentconfig.AgentTabManager) HashMap(java.util.HashMap) Map(java.util.Map)

Example 39 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class AgentPropertyXMLBuilder method getAttributeSchemas.

private Set getAttributeSchemas(Set attrSchemas, Set selectable) {
    Set results = new HashSet(selectable.size() * 2);
    if ((attrSchemas != null) && !attrSchemas.isEmpty()) {
        for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) i.next();
            String name = as.getName();
            if (selectable.contains(name)) {
                String i18nKey = as.getI18NKey();
                if ((i18nKey != null) && (i18nKey.trim().length() > 0)) {
                    results.add(as);
                }
            }
        }
    }
    return results;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashSet(java.util.HashSet)

Example 40 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema in project OpenAM by OpenRock.

the class PropertyXMLBuilderBase method buildSchemaTypeXML.

protected void buildSchemaTypeXML(String schemaTypeName, Set attributeSchemas, StringBuffer xml, AMModel model, ResourceBundle serviceBundle, Set readonly, boolean section, boolean addSubSection) {
    if (section) {
        String label = "lbl" + schemaTypeName.replace('.', '_');
        Object[] params = { label, schemaTypeName };
        xml.append(MessageFormat.format(SECTION_START_TAG, params));
    }
    List sorted = new ArrayList(attributeSchemas);
    if (!(attributeSchemas instanceof LinkedHashSet)) {
        // Sort attribute schemas by property key if they are not sorted by section properties.
        Collections.sort(sorted, new AttributeSchemaComparator(null));
    }
    for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) iter.next();
        if (allAttributesReadonly || readonly.contains(as.getName())) {
            buildReadonlyXML(as, xml, model, serviceBundle);
        } else if (SCRIPTSELECT.equals(as.getUIType())) {
            buildScriptSelectXML(as, xml, model, serviceBundle, false);
        } else if (GLOBALSCRIPTSELECT.equals(as.getUIType())) {
            buildScriptSelectXML(as, xml, model, serviceBundle, true);
        } else {
            buildAttributeSchemaTypeXML(as, xml, model, serviceBundle, addSubSection);
            String tagClassName = getTagClassName(as);
            if (tagClassName.equals(TAGNAME_PASSWORD)) {
                buildConfirmPasswordXML(as, xml, model, serviceBundle);
            }
            if (AttributeSchema.Syntax.SCRIPT.equals(as.getSyntax())) {
                buildFileUploadXML(as, xml, model);
            }
        }
    }
    xml.append((section ? SECTION_END_TAG : ""));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AttributeSchema (com.sun.identity.sm.AttributeSchema)149 Iterator (java.util.Iterator)80 ServiceSchema (com.sun.identity.sm.ServiceSchema)76 Set (java.util.Set)75 SMSException (com.sun.identity.sm.SMSException)67 HashSet (java.util.HashSet)59 SSOException (com.iplanet.sso.SSOException)58 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)46 HashMap (java.util.HashMap)36 Map (java.util.Map)34 CLIException (com.sun.identity.cli.CLIException)28 CLIRequest (com.sun.identity.cli.CLIRequest)18 AfterTest (org.testng.annotations.AfterTest)18 BeforeTest (org.testng.annotations.BeforeTest)18 Parameters (org.testng.annotations.Parameters)18 Test (org.testng.annotations.Test)18 IOutput (com.sun.identity.cli.IOutput)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)9 SSOToken (com.iplanet.sso.SSOToken)8