use of com.sun.web.ui.view.addremove.CCAddRemove in project OpenAM by OpenRock.
the class AMPropertySheet method restoreStateData.
/**
* Automates the restoring of store data in some children. This is required
* for some special children such as <code>CCAddRemvoe</code>.
*
* @throws ModelControlException if cannot get model of property sheet.
*/
public void restoreStateData(Collection participatingChildren) throws ModelControlException {
ViewBean parent = getParentViewBean();
String[] names = parent == null ? null : parent.getChildNames();
if ((names != null) && (names.length > 0)) {
for (int i = 0; i < names.length; i++) {
String name = names[i];
if (participatingChildren.contains(name)) {
View child = parent.getChild(name);
if (CCAddRemove.class.isInstance(child)) {
((CCAddRemove) child).restoreStateData();
} else if (CCUnOrderedList.class.isInstance(child)) {
((CCUnOrderedList) child).restoreStateData();
} else if (CCMapList.class.isInstance(child)) {
((CCMapList) child).restoreStateData();
} else if (CCEditableList.class.isInstance(child)) {
((CCEditableList) child).restoreStateData();
} else if (CCOrderedList.class.isInstance(child)) {
((CCOrderedList) child).restoreStateData();
} else if (CCActionTable.class.isInstance(child)) {
((CCActionTable) child).restoreStateData();
}
}
}
}
}
use of com.sun.web.ui.view.addremove.CCAddRemove in project OpenAM by OpenRock.
the class EntityMembersViewBean method getMemberNames.
private void getMemberNames() {
if (!submitCycle) {
try {
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String type = (String) getPageSessionAttribute(PG_SESSION_MEMBER_TYPE);
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
if (cacheAssigned != null) {
assignedMembers = AMAdminUtils.toList(cacheAssigned);
} else {
EntitiesModel model = (EntitiesModel) getModel();
assignedMembers = new ArrayList();
assignedMembers.addAll(model.getMembers(curRealm, universalId, type));
}
if (canModify) {
CCAddRemoveModel addRemoveModel = (CCAddRemoveModel) propertySheetModel.getModel(ADD_REMOVE_MEMBERS);
addRemoveModel.clear();
if (cacheAssigned != null) {
addRemoveModel.setSelectedOptionList(cacheAssigned);
} else {
addRemoveModel.setSelectedOptionList(getOptionListForEntities(assignedMembers));
}
addRemoveModel.setAvailableOptionList(getAssignableMembers());
} else {
propertySheetModel.setValue(ADD_REMOVE_MEMBERS, AMAdminUtils.getString(getEntityDisplayNames(assignedMembers), ",", false));
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
if (canModify) {
CCAddRemove addRemove = (CCAddRemove) getChild(ADD_REMOVE_MEMBERS);
addRemove.resetStateData();
}
}
}
use of com.sun.web.ui.view.addremove.CCAddRemove in project OpenAM by OpenRock.
the class EntityMembersViewBean method handleButton1Request.
public void handleButton1Request(RequestInvocationEvent event) {
submitCycle = true;
CCAddRemove child = (CCAddRemove) getChild(ADD_REMOVE_MEMBERS);
child.restoreStateData();
CCAddRemoveModel addRemoveModel = (CCAddRemoveModel) propertySheetModel.getModel(ADD_REMOVE_MEMBERS);
OptionList os = addRemoveModel.getSelectedOptionList();
EntitiesModel model = (EntitiesModel) getModel();
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String type = (String) getPageSessionAttribute(PG_SESSION_MEMBER_TYPE);
try {
Set entities = getEntitiesID(model.getMembers(curRealm, universalId, type));
Set selected = getValues(os);
Set toAdd = new HashSet(selected);
toAdd.removeAll(entities);
entities.removeAll(selected);
if (!toAdd.isEmpty()) {
model.addMembers(universalId, toAdd);
}
if (!entities.isEmpty()) {
model.removeMembers(universalId, entities);
}
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
use of com.sun.web.ui.view.addremove.CCAddRemove in project OpenAM by OpenRock.
the class EntityMembershipViewBean method handleButton1Request.
public void handleButton1Request(RequestInvocationEvent event) {
submitCycle = true;
CCAddRemove child = (CCAddRemove) getChild(ADD_REMOVE_MEMBERS);
child.restoreStateData();
CCAddRemoveModel addRemoveModel = (CCAddRemoveModel) propertySheetModel.getModel(ADD_REMOVE_MEMBERS);
OptionList os = addRemoveModel.getSelectedOptionList();
EntitiesModel model = (EntitiesModel) getModel();
String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
String type = (String) getPageSessionAttribute(PG_SESSION_MEMBER_TYPE);
try {
Set entities = getEntitiesID(model.getMembership(curRealm, universalId, type));
Set selected = getValues(os);
Set toAdd = new HashSet(selected);
toAdd.removeAll(entities);
entities.removeAll(selected);
if (!toAdd.isEmpty()) {
model.addMemberships(universalId, toAdd);
}
if (!entities.isEmpty()) {
model.removeMemberships(universalId, entities);
}
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
Aggregations