Search in sources :

Example 11 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class AMPropertySheet method getAttributeValues.

/**
     * Returns a map of attribute name to values which have different values 
     * from the original values.
     *
     * @param orig Map of attribute to original values.
     * @param modified true to return map of attribute name to values that
     *        have values that is different from values in <code>orig</code>.
     * @param matchPwd true to match password with confirm password value.
     * @param amModel <code>AMModel</code> object.
     * @return a map of attribute name to values.
     * @throws ModelControlException if cannot get model of property sheet.
     * @throws AMConsoleException if password and confirm password values do
     *         not match.
     */
public Map getAttributeValues(Map orig, boolean modified, boolean matchPwd, AMModel amModel) throws ModelControlException, AMConsoleException {
    restoreStateData(orig.keySet());
    AMPropertySheetModel model = (AMPropertySheetModel) getModel();
    Map attrValues = new HashMap(orig.size() * 2);
    Map multipleChoiceValues = getMultipleChoiceValues(model);
    for (Iterator iter = orig.keySet().iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        if (model.isChildSupported(name)) {
            Object tmpValue = orig.get(name);
            Set origValue = null;
            // the element type used in the display
            if (Set.class.isInstance(tmpValue)) {
                origValue = (Set) tmpValue;
            } else {
                // assuming this child is a list
                Map tmp = (Map) tmpValue;
                origValue = (Set) tmp.get("values");
            }
            Object childModel = model.getModel(name);
            Set values = null;
            if (CCAddRemoveModel.class.isInstance(childModel)) {
                values = getValues(((CCAddRemoveModel) childModel).getSelectedOptionList());
            } else if (CCEditableListModel.class.isInstance(childModel)) {
                values = getValues(((CCEditableListModel) childModel).getOptionList());
            } else if (CCOrderedListModel.class.isInstance(childModel)) {
                values = getListValues(((CCOrderedListModel) childModel).getSelectedOptionList());
                if (values == null || values.isEmpty()) {
                    values = new HashSet(1);
                    values.add("[0]=");
                }
            } else if (model.isChildSupported(name + PropertyTemplate.PWD_CONFIRM_SUFFIX)) {
                String pwd = (String) model.getValue(name);
                String confirmPwd = (String) model.getValue(name + PropertyTemplate.PWD_CONFIRM_SUFFIX);
                if (!matchPwd || pwd.equals(confirmPwd)) {
                    if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
                        values = new HashSet(2);
                        values.add(pwd);
                    } else {
                        values = (Set) orig.get(name);
                    }
                } else {
                    throw new AMConsoleException("password-mismatched");
                }
            } else if (model.isChildSupported(PropertyTemplate.DATE_MARKER_NAME + name)) {
                String date = (String) model.getValue(name);
                values = getDateInUserLocale(date, amModel);
            } else {
                values = (Set) multipleChoiceValues.get(name);
                if (values == null) {
                    // Convert to a set of values, excluding any empty strings
                    values = AMAdminUtils.toSetIgnoreEmpty(model.getValues(name));
                }
            }
            if (!modified || !equalsSet(values, origValue)) {
                attrValues.put(name, values);
            }
        }
    }
    return attrValues;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) HashMap(java.util.HashMap) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) Iterator(java.util.Iterator) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) CCOrderedListModel(com.sun.identity.console.ui.model.CCOrderedListModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 12 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class CreateSAML2MetaDataViewBean method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    setPageSessionAttribute("protocol", protocol);
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTIES);
    ps.init();
    populateRealmData();
    psModel.setModel(AFFI_MEMBERS, new CCEditableListModel());
}
Also used : AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel)

Example 13 with CCEditableListModel

use of com.sun.web.ui.model.CCEditableListModel in project OpenAM by OpenRock.

the class CreateSAML2MetaDataViewBean method createPropertyModel.

private void createPropertyModel() {
    if (protocol == null) {
        protocol = (String) getPageSessionAttribute("protocol");
    }
    String xml;
    if (protocol.equals(PROTO_SAMLv2)) {
        xml = "com/sun/identity/console/propertyCreateSAML2Entity.xml";
    } else if (protocol.equals(PROTO_IDFF)) {
        xml = "com/sun/identity/console/propertyCreateIDFFEntity.xml";
    } else {
        xml = "com/sun/identity/console/propertyCreateWSFedEntity.xml";
    }
    psModel = new AMPropertySheetModel(getClass().getClassLoader().getResourceAsStream(xml));
    psModel.setModel(AFFI_MEMBERS, new CCEditableListModel());
    psModel.clear();
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel)

Aggregations

CCEditableListModel (com.sun.web.ui.model.CCEditableListModel)13 CCEditableList (com.sun.web.ui.view.editablelist.CCEditableList)7 Set (java.util.Set)6 CCOrderedListModel (com.sun.identity.console.ui.model.CCOrderedListModel)4 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 TreeSet (java.util.TreeSet)4 View (com.iplanet.jato.view.View)3 OptionList (com.iplanet.jato.view.html.OptionList)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)3 AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)3 CCMapListModel (com.sun.identity.console.ui.model.CCMapListModel)3 CCUnOrderedListModel (com.sun.identity.console.ui.model.CCUnOrderedListModel)3 CCUnOrderedList (com.sun.identity.console.ui.view.CCUnOrderedList)3 OrderedSet (com.sun.identity.shared.datastruct.OrderedSet)3 HashMap (java.util.HashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)3 ContainerView (com.iplanet.jato.view.ContainerView)2