Search in sources :

Example 46 with SerializedField

use of com.sun.identity.console.components.view.html.SerializedField in project OpenAM by OpenRock.

the class EntitiesViewBean method populateTableModelEx.

private void populateTableModelEx() {
    if (!tblModelPopulated) {
        tblModelPopulated = true;
        SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
        List cache = (List) szCache.getSerializedObj();
        if ((cache != null) && !cache.isEmpty()) {
            EntitiesModel model = (EntitiesModel) getModel();
            SSOToken ssoToken = model.getUserSSOToken();
            List list = new ArrayList(cache.size());
            for (Iterator iter = cache.iterator(); iter.hasNext(); ) {
                String id = (String) iter.next();
                try {
                    list.add(IdUtils.getIdentity(ssoToken, id));
                } catch (IdRepoException e) {
                //ignore since ID is not found.
                }
            }
            populateTableModel(list);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IdRepoException(com.sun.identity.idm.IdRepoException) ArrayList(java.util.ArrayList) List(java.util.List) EntitiesModel(com.sun.identity.console.idm.model.EntitiesModel)

Example 47 with SerializedField

use of com.sun.identity.console.components.view.html.SerializedField 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 48 with SerializedField

use of com.sun.identity.console.components.view.html.SerializedField in project OpenAM by OpenRock.

the class IDRepoViewBean method handleTblButtonDeleteRequest.

/**
     * Deletes ID Repo.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if table model cannot be restored.
     */
public void handleTblButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_SEARCH);
    table.restoreStateData();
    Integer[] selected = tblModel.getSelectedRows();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    List list = (List) szCache.getSerializedObj();
    Set names = new HashSet(selected.length * 2);
    for (int i = 0; i < selected.length; i++) {
        names.add(list.get(selected[i].intValue()));
    }
    try {
        IDRepoModel model = (IDRepoModel) getModel();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        model.deleteIDRepos(curRealm, names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "idRepo.message.deleted");
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "idRepo.message.deleted.pural");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    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) IDRepoModel(com.sun.identity.console.realm.model.IDRepoModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet)

Example 49 with SerializedField

use of com.sun.identity.console.components.view.html.SerializedField in project OpenAM by OpenRock.

the class IDRepoViewBean method populateTableModel.

private void populateTableModel(Collection idRepoNames) {
    tblModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    if ((idRepoNames != null) && !idRepoNames.isEmpty()) {
        List cache = new ArrayList(idRepoNames.size());
        IDRepoModel model = (IDRepoModel) getModel();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Map mapTypeToDisplayName = null;
        try {
            mapTypeToDisplayName = model.getIDRepoTypesMap();
        } catch (AMConsoleException e) {
            mapTypeToDisplayName = Collections.EMPTY_MAP;
        }
        boolean firstEntry = true;
        for (Iterator iter = idRepoNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblModel.appendRow();
            }
            String name = (String) iter.next();
            tblModel.setValue(TBL_DATA_NAME, name);
            try {
                String type = model.getIDRepoType(curRealm, name);
                String displayName = (String) mapTypeToDisplayName.get(type);
                if (displayName == null) {
                    displayName = type;
                }
                tblModel.setValue(TBL_DATA_TYPE, displayName);
            } catch (AMConsoleException e) {
                tblModel.setValue(TBL_DATA_TYPE, "");
            }
            tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(name));
            cache.add(name);
        }
        szCache.setValue((ArrayList) cache);
    } else {
        szCache.setValue(null);
    }
}
Also used : SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IDRepoModel(com.sun.identity.console.realm.model.IDRepoModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 50 with SerializedField

use of com.sun.identity.console.components.view.html.SerializedField in project OpenAM by OpenRock.

the class RMRealmViewBean method createChild.

protected View createChild(String name) {
    View view = null;
    if (name.equals(TBL_SEARCH)) {
        SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
        populateTableModel((List) szCache.getSerializedObj());
        view = new CCActionTable(this, tblModel, name);
    } else if (name.equals(PAGETITLE)) {
        view = new CCPageTitle(this, ptModel, name);
    } else if (tblModel.isChildSupported(name)) {
        view = tblModel.createChild(this, name);
    } else {
        view = super.createChild(name);
    }
    return view;
}
Also used : SerializedField(com.sun.identity.console.components.view.html.SerializedField) CCActionTable(com.sun.web.ui.view.table.CCActionTable) View(com.iplanet.jato.view.View) CCPageTitle(com.sun.web.ui.view.pagetitle.CCPageTitle)

Aggregations

SerializedField (com.sun.identity.console.components.view.html.SerializedField)57 ArrayList (java.util.ArrayList)33 List (java.util.List)31 CCActionTable (com.sun.web.ui.view.table.CCActionTable)28 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)19 Iterator (java.util.Iterator)19 HashSet (java.util.HashSet)17 Set (java.util.Set)17 Map (java.util.Map)15 HashMap (java.util.HashMap)14 View (com.iplanet.jato.view.View)10 SMSubConfig (com.sun.identity.console.base.model.SMSubConfig)9 CCPageTitle (com.sun.web.ui.view.pagetitle.CCPageTitle)9 CCActionTableModel (com.sun.web.ui.model.CCActionTableModel)8 AgentsModel (com.sun.identity.console.agentconfig.model.AgentsModel)6 ServerSiteModel (com.sun.identity.console.service.model.ServerSiteModel)6 EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)5 IdRepoException (com.sun.identity.idm.IdRepoException)4 SSOToken (com.iplanet.sso.SSOToken)3 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)3