Search in sources :

Example 21 with CCAddRemove

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();
                }
            }
        }
    }
}
Also used : CCEditableList(com.sun.web.ui.view.editablelist.CCEditableList) CCMapList(com.sun.identity.console.ui.view.CCMapList) ViewBean(com.iplanet.jato.view.ViewBean) CCOrderedList(com.sun.identity.console.ui.view.CCOrderedList) CCActionTable(com.sun.web.ui.view.table.CCActionTable) View(com.iplanet.jato.view.View) ContainerView(com.iplanet.jato.view.ContainerView) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) CCUnOrderedList(com.sun.identity.console.ui.view.CCUnOrderedList)

Example 22 with CCAddRemove

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();
        }
    }
}
Also used : CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) ArrayList(java.util.ArrayList) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 23 with CCAddRemove

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();
}
Also used : CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) Set(java.util.Set) HashSet(java.util.HashSet) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) OptionList(com.iplanet.jato.view.html.OptionList) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel) HashSet(java.util.HashSet)

Example 24 with CCAddRemove

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();
}
Also used : CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) Set(java.util.Set) HashSet(java.util.HashSet) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) CCAddRemove(com.sun.web.ui.view.addremove.CCAddRemove) OptionList(com.iplanet.jato.view.html.OptionList) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel) HashSet(java.util.HashSet)

Aggregations

CCAddRemove (com.sun.web.ui.view.addremove.CCAddRemove)24 Set (java.util.Set)13 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)11 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 HashSet (java.util.HashSet)10 Map (java.util.Map)8 OptionList (com.iplanet.jato.view.html.OptionList)7 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)4 EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)4 IdentitySubjectModel (com.sun.identity.console.policy.model.IdentitySubjectModel)4 CCDropDownMenu (com.sun.web.ui.view.html.CCDropDownMenu)4 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 FSAuthDomainsModel (com.sun.identity.console.federation.model.FSAuthDomainsModel)2 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)2 ContainerView (com.iplanet.jato.view.ContainerView)1 View (com.iplanet.jato.view.View)1 ViewBean (com.iplanet.jato.view.ViewBean)1 SerializedField (com.sun.identity.console.components.view.html.SerializedField)1