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;
}
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());
}
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();
}
Aggregations