Search in sources :

Example 61 with AttrSet

use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.

the class TemplateManager method toCreationTemplate.

/**
     * Reads in a attribute set and converts name-value pairs to a
     * CreationTemplate object.
     * 
     * @param t
     *            attribute set contains template values
     * @return CreationTemplate object based on the name-value pairs
     */
private CreationTemplate toCreationTemplate(AttrSet t) {
    Attr nameAttr = t.getAttribute(TEMPLATE_NAME);
    String name = null;
    if (nameAttr != null) {
        name = nameAttr.getValue();
    }
    Attr namingAttr = t.getAttribute(TEMPLATE_NAMINGATTRIBUTE);
    String namingAttribute = null;
    if (namingAttr != null) {
        namingAttribute = namingAttr.getValue();
    }
    Attr classAttr = t.getAttribute(TEMPLATE_JAVACLASS);
    String[] classNames = null;
    if (classAttr != null) {
        classNames = classAttr.getStringValues();
    }
    AttrSet required = decodeAttr(t.getAttribute(TEMPLATE_REQUIRED), "=");
    AttrSet optional = decodeAttr(t.getAttribute(TEMPLATE_OPTIONAL), "=");
    AttrSet validated = decodeAttr(t.getAttribute(TEMPLATE_VALIDATED), "=");
    CreationTemplate template = new CreationTemplate();
    ArrayList classes = new ArrayList();
    try {
        if (classNames != null) {
            for (int i = 0; i < classNames.length; i++) {
                Class cls = Class.forName(classNames[i]);
                classes.add(cls);
            }
        }
        template = new CreationTemplate(name, required, optional, classes);
    } catch (ClassNotFoundException e) {
        template = new CreationTemplate(name, required, optional);
    }
    if (validated != null) {
        template.setValidation(validated);
    }
    if (namingAttribute != null) {
        template.setNamingAttribute(namingAttribute);
    }
    return template;
}
Also used : ArrayList(java.util.ArrayList) Attr(com.iplanet.services.ldap.Attr) AttrSet(com.iplanet.services.ldap.AttrSet)

Aggregations

AttrSet (com.iplanet.services.ldap.AttrSet)61 Attr (com.iplanet.services.ldap.Attr)33 Guid (com.iplanet.ums.Guid)19 Iterator (java.util.Iterator)16 Set (java.util.Set)14 UMSException (com.iplanet.ums.UMSException)13 AMException (com.iplanet.am.sdk.AMException)12 CreationTemplate (com.iplanet.ums.CreationTemplate)12 TemplateManager (com.iplanet.ums.TemplateManager)12 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 PersistentObject (com.iplanet.ums.PersistentObject)6 SSOException (com.iplanet.sso.SSOException)5 AMHashMap (com.iplanet.am.sdk.AMHashMap)4 AssignableDynamicGroup (com.iplanet.ums.AssignableDynamicGroup)4 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)3 AccessRightsException (com.iplanet.ums.AccessRightsException)3 EntryAlreadyExistsException (com.iplanet.ums.EntryAlreadyExistsException)3