Search in sources :

Example 31 with EntitiesModel

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

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

the class EntitiesViewBean method populateTableModel.

private void populateTableModel(Collection entityNames) {
    tblModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    if ((entityNames != null) && !entityNames.isEmpty()) {
        // set the paging size
        EntitiesModel model = (EntitiesModel) getModel();
        tblModel.setMaxRows(model.getPageSize());
        // remove the special users from the set of enitities to display
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Set specialUsers = model.getSpecialUsers(curRealm);
        entityNames.removeAll(specialUsers);
        // get the current logged in user
        AMIdentity curUser = null;
        try {
            curUser = IdUtils.getIdentity(model.getUserSSOToken(), model.getUniversalID());
        } catch (IdRepoException idr) {
        // do nothing
        }
        int counter = 0;
        boolean firstEntry = true;
        List cache = new ArrayList(entityNames.size());
        for (Iterator iter = entityNames.iterator(); iter.hasNext(); ) {
            AMIdentity entity = (AMIdentity) iter.next();
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblModel.appendRow();
            }
            String name = AMFormatUtils.getIdentityDisplayName(model, entity);
            // hide the checkbox if this is the current user or amadmin
            boolean showCheckbox = ((curUser != null) && (!curUser.equals(entity))) && !model.isAmadminUser(entity);
            tblModel.setSelectionVisible(counter++, showCheckbox);
            String universalId = IdUtils.getUniversalId(entity);
            tblModel.setValue(TBL_DATA_NAME, name);
            tblModel.setValue(TBL_DATA_ID, LDAPUtils.rdnValueFromDn(universalId));
            tblModel.setValue(TBL_DATA_UNIVERSALNAME, universalId);
            tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(universalId));
            cache.add(universalId);
        }
        szCache.setValue((Serializable) cache);
    } else {
        szCache.setValue(null);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SerializedField(com.sun.identity.console.components.view.html.SerializedField) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 33 with EntitiesModel

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

the class EntitiesViewBean method handleTblDataActionHrefRequest.

/**
     * Forwards request to edit policy view bean.
     *
     * @param event Request Invocation Event.
     */
public void handleTblDataActionHrefRequest(RequestInvocationEvent event) {
    EntitiesModel model = (EntitiesModel) getModel();
    String universalId = hexToString((String) getDisplayFieldValue(TBL_DATA_ACTION_HREF));
    setPageSessionAttribute(EntityEditViewBean.UNIVERSAL_ID, universalId);
    try {
        AMIdentity amid = IdUtils.getIdentity(model.getUserSSOToken(), universalId);
        String idType = amid.getType().getName();
        AMViewBeanBase vb = (AMViewBeanBase) getViewBean(EntityEditViewBean.class);
        setPageSessionAttribute(EntityOpViewBeanBase.ENTITY_NAME, amid.getName());
        setPageSessionAttribute(EntityOpViewBeanBase.ENTITY_TYPE, idType);
        unlockPageTrail();
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (IdRepoException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    }
}
Also used : AMViewBeanBase(com.sun.identity.console.base.AMViewBeanBase) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 34 with EntitiesModel

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

the class EntitiesViewBean method getEntityNames.

private void getEntityNames() {
    EntitiesModel model = (EntitiesModel) getModel();
    String filter = ((String) getDisplayFieldValue(TF_FILTER));
    if ((filter == null) || (filter.length() == 0)) {
        filter = "*";
        setDisplayFieldValue(TF_FILTER, "*");
    } else {
        filter = filter.trim();
    }
    try {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        IdSearchResults results = model.getEntityNames(curRealm, getDisplayIDType(), 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;
        }
        populateTableModel(results.getSearchResults());
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        // disable the add button if there was an error 
        CCButton b = (CCButton) getChild(TBL_BUTTON_ADD);
        b.setDisabled(true);
    }
}
Also used : IdSearchResults(com.sun.identity.idm.IdSearchResults) CCButton(com.sun.web.ui.view.html.CCButton) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 35 with EntitiesModel

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

the class EntityEditViewBean method getIdType.

protected IdType getIdType(int hashCode) {
    IdType idType = null;
    EntitiesModel model = (EntitiesModel) getModel();
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    Map types = model.getSupportedEntityTypes(curRealm);
    for (Iterator iter = types.keySet().iterator(); iter.hasNext() && (idType == null); ) {
        try {
            IdType type = IdUtils.getType((String) iter.next());
            if (type.hashCode() == hashCode) {
                idType = type;
            }
        } catch (IdRepoException e) {
        // display message
        }
    }
    return idType;
}
Also used : Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) HashMap(java.util.HashMap) Map(java.util.Map) IdType(com.sun.identity.idm.IdType) 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