Search in sources :

Example 41 with EntitiesModel

use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.

the class EntityMembersViewBean method getAssignableMembers.

private OptionList getAssignableMembers() {
    OptionList avail = null;
    EntitiesModel model = (EntitiesModel) getModel();
    if ((filter == null) || (filter.trim().length() == 0)) {
        filter = "*";
        setDisplayFieldValue(TF_FILTER, "*");
    }
    setDisplayFieldValue(TF_FILTER, filter);
    try {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String searchType = (String) getPageSessionAttribute(EntityMembersViewBean.PG_SESSION_MEMBER_TYPE);
        IdSearchResults results = model.getEntityNames(curRealm, searchType, filter);
        int errorCode = results.getErrorCode();
        switch(errorCode) {
            case IdSearchResults.SIZE_LIMIT_EXCEEDED:
                setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.sizelimit.exceeded");
                break;
            case IdSearchResults.TIME_LIMIT_EXCEEDED:
                setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.timelimit.exceeded");
                break;
        }
        // assignable will contain users which shouldn't be displayed in
        // the console (dsameuser, etc...)
        Set assignable = results.getSearchResults();
        assignable.removeAll(model.getSpecialUsers(curRealm));
        String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
        removeAlreadyAssignedMembers(assignable);
        avail = getOptionListForEntities(assignable);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    return avail;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) OptionList(com.iplanet.jato.view.html.OptionList) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 42 with EntitiesModel

use of com.sun.identity.console.idm.model.EntitiesModel 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)

Example 43 with EntitiesModel

use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.

the class EntityMembershipViewBean method getAssignableMembership.

private OptionList getAssignableMembership() {
    OptionList avail = null;
    EntitiesModel model = (EntitiesModel) getModel();
    if ((filter == null) || (filter.trim().length() == 0)) {
        filter = "*";
        setDisplayFieldValue(TF_FILTER, "*");
    }
    setDisplayFieldValue(TF_FILTER, filter);
    try {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String searchType = (String) getPageSessionAttribute(EntityMembersViewBean.PG_SESSION_MEMBER_TYPE);
        IdSearchResults results = model.getEntityNames(curRealm, searchType, filter);
        int errorCode = results.getErrorCode();
        switch(errorCode) {
            case IdSearchResults.SIZE_LIMIT_EXCEEDED:
                setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.sizelimit.exceeded");
                break;
            case IdSearchResults.TIME_LIMIT_EXCEEDED:
                setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", "message.timelimit.exceeded");
                break;
        }
        Set members = results.getSearchResults();
        String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
        removeAlreadyAssignedMembers(members);
        avail = getOptionListForEntities(members);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    return avail;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) OptionList(com.iplanet.jato.view.html.OptionList) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 44 with EntitiesModel

use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.

the class ServicesSelectViewBean method setRadioButtons.

private void setRadioButtons(CCRadioButton rb) {
    try {
        EntitiesModel model = (EntitiesModel) getModel();
        String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
        Map assigned = model.getAssignedServiceNames(universalId);
        Map assignables = model.getAssignableServiceNames(universalId);
        for (Iterator i = assigned.keySet().iterator(); i.hasNext(); ) {
            assignables.remove(i.next());
        }
        if (!assignables.isEmpty()) {
            OptionList optList = AMFormatUtils.getSortedOptionList(assignables, model.getUserLocale());
            rb.setOptions(optList);
            if (!submitCycle) {
                rb.setValue(optList.getValue(0));
            }
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) OptionList(com.iplanet.jato.view.html.OptionList) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 45 with EntitiesModel

use of com.sun.identity.console.idm.model.EntitiesModel in project OpenAM by OpenRock.

the class EntityServicesViewBean method handleTblButtonDeleteRequest.

public void handleTblButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_SEARCH);
    table.restoreStateData();
    Integer[] selected = tblModel.getSelectedRows();
    Set names = new HashSet(selected.length * 2);
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    List cache = (List) szCache.getSerializedObj();
    if (selected.length > 0) {
        for (int i = 0; i < selected.length; i++) {
            names.add((String) cache.get(selected[i].intValue()));
        }
        try {
            EntitiesModel model = (EntitiesModel) getModel();
            String universalId = (String) getPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID);
            model.unassignServices(universalId, names);
            if (selected.length == 1) {
                setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "entities.message.service.unassigned");
            } else {
                setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "entities.message.service.unassigned.pural");
            }
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "entities.message.service.unassigned.non.selected");
    }
    forwardTo();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) List(java.util.List) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Aggregations

EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)55 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)23 Map (java.util.Map)15 Set (java.util.Set)13 HashSet (java.util.HashSet)10 Iterator (java.util.Iterator)10 List (java.util.List)9 OptionList (com.iplanet.jato.view.html.OptionList)7 AMIdentity (com.sun.identity.idm.AMIdentity)7 IdRepoException (com.sun.identity.idm.IdRepoException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)5 SerializedField (com.sun.identity.console.components.view.html.SerializedField)5 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)4 CCAddRemove (com.sun.web.ui.view.addremove.CCAddRemove)4 AMViewConfig (com.sun.identity.console.base.AMViewConfig)3 IdSearchResults (com.sun.identity.idm.IdSearchResults)3 IdType (com.sun.identity.idm.IdType)3 AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)2