Search in sources :

Example 1 with AgentsModel

use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.

the class AgentsViewBean method getAgentNames.

private void getAgentNames() {
    AgentsModel model = (AgentsModel) getModel();
    String filter = ((String) getDisplayFieldValue(TF_FILTER));
    String gfilter = ((String) getDisplayFieldValue(TF_GROUP_FILTER));
    if ((filter == null) || (filter.length() == 0)) {
        filter = "*";
        setDisplayFieldValue(TF_FILTER, "*");
    } else {
        filter = filter.trim();
    }
    if ((gfilter == null) || (gfilter.length() == 0)) {
        gfilter = "*";
        setDisplayFieldValue(TF_GROUP_FILTER, "*");
    } else {
        gfilter = gfilter.trim();
    }
    // this is to faciliate combined types.
    String agentType = getDisplayIDType();
    AMViewConfig cfg = AMViewConfig.getInstance();
    Set agentTypes = cfg.getCombineAgentTypes(agentType);
    if (agentTypes == null) {
        agentTypes = new HashSet(2);
        agentTypes.add(agentType);
    } else {
        supportedTypes.addAll(agentTypes);
    }
    try {
        Set agents = new HashSet();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        int errorCode = model.getAgentNames(curRealm, agentTypes, filter, agents);
        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 agentGroups = new HashSet();
        errorCode = model.getAgentGroupNames(curRealm, agentTypes, gfilter, agentGroups);
        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;
        }
        Map results = new HashMap(4);
        results.put(CACHE_AGENTS, agents);
        results.put(CACHE_AGENT_GROUPS, agentGroups);
        populateTableModel(results);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        CCButton b = (CCButton) getChild(TBL_BUTTON_ADD);
        b.setDisabled(true);
        b = (CCButton) getChild(TBL_BUTTON_ADD_GROUP);
        b.setDisabled(true);
    }
}
Also used : AMViewConfig(com.sun.identity.console.base.AMViewConfig) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) CCButton(com.sun.web.ui.view.html.CCButton) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 2 with AgentsModel

use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.

the class AgentsViewBean method populateTableModel.

private void populateTableModel(Map map) {
    tblModel.clearAll();
    tblGroupModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    if ((map != null) && !map.isEmpty()) {
        // set the paging size
        AgentsModel model = (AgentsModel) getModel();
        tblModel.setMaxRows(model.getPageSize());
        tblGroupModel.setMaxRows(model.getPageSize());
        Map mapCache = new HashMap(4);
        Collection agents = (Collection) map.get(CACHE_AGENTS);
        if ((agents != null) && !agents.isEmpty()) {
            int counter = 0;
            boolean firstEntry = true;
            List cacheAgents = new ArrayList(agents.size());
            for (Iterator iter = agents.iterator(); iter.hasNext(); ) {
                AMIdentity entity = (AMIdentity) iter.next();
                if (firstEntry) {
                    firstEntry = false;
                } else {
                    tblModel.appendRow();
                }
                String name = AMFormatUtils.getIdentityDisplayName(model, entity);
                tblModel.setSelectionVisible(counter++, true);
                String universalId = IdUtils.getUniversalId(entity);
                tblModel.setValue(TBL_DATA_NAME, name);
                tblModel.setValue(TBL_DATA_UNIVERSALNAME, universalId);
                tblModel.setValue(TBL_DATA_ACTION_HREF, stringToHex(universalId));
                if (centralizable) {
                    if (model.isCentralized(universalId)) {
                        tblModel.setValue(TBL_DATA_LOCAL, "table.agents.data.repo.centralized");
                    } else {
                        tblModel.setValue(TBL_DATA_LOCAL, "table.agents.data.repo.localized");
                    }
                } else if (combinedType) {
                    try {
                        tblModel.setValue(TBL_DATA_TYPE, model.getLocalizedString("agenttype." + model.getAgentType(entity)));
                    } catch (AMConsoleException e) {
                        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
                    }
                }
                cacheAgents.add(universalId);
            }
            mapCache.put(CACHE_AGENTS, cacheAgents);
        }
        Collection agentgroups = (Collection) map.get(CACHE_AGENT_GROUPS);
        if ((agentgroups != null) && !agentgroups.isEmpty()) {
            int counter = 0;
            boolean firstEntry = true;
            List cacheAgentGroups = new ArrayList(agentgroups.size());
            for (Iterator iter = agentgroups.iterator(); iter.hasNext(); ) {
                AMIdentity entity = (AMIdentity) iter.next();
                if (firstEntry) {
                    firstEntry = false;
                } else {
                    tblGroupModel.appendRow();
                }
                String name = AMFormatUtils.getIdentityDisplayName(model, entity);
                tblGroupModel.setSelectionVisible(counter++, true);
                String universalId = IdUtils.getUniversalId(entity);
                tblGroupModel.setValue(TBL_DATA_NAME_GROUP, name);
                tblGroupModel.setValue(TBL_DATA_UNIVERSALNAME_GROUP, universalId);
                tblGroupModel.setValue(TBL_DATA_ACTION_HREF_GROUP, stringToHex(universalId));
                if (combinedType) {
                    try {
                        tblGroupModel.setValue(TBL_DATA_TYPE_GROUP, model.getLocalizedString("agenttype." + model.getAgentType(entity)));
                    } catch (AMConsoleException e) {
                        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
                    }
                }
                cacheAgentGroups.add(universalId);
            }
            mapCache.put(CACHE_AGENT_GROUPS, cacheAgentGroups);
        }
        szCache.setValue((Serializable) mapCache);
    } else {
        szCache.setValue(null);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SerializedField(com.sun.identity.console.components.view.html.SerializedField) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with AgentsModel

use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.

the class AgentsViewBean method beginDisplay.

/**
     * Sets the agent title and populates the agent and agent group
     * action table.
     *
     * @param event Display Event.
     * @throws ModelControlException if cannot access to framework model.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event, false);
    resetButtonState(TBL_BUTTON_DELETE);
    AgentsModel model = (AgentsModel) getModel();
    String agentType = getDisplayIDType();
    Object[] param = { agentType };
    ptModel.setPageTitleText(model.getLocalizedString("agenttype." + agentType));
    ptModel.setPageTitleHelpMessage(model.getLocalizedString("agenttype." + agentType + ".help"));
    tblModel.setTitle(MessageFormat.format(model.getLocalizedString("table.agents.title.name"), param));
    tblModel.setTitleLabel(MessageFormat.format(model.getLocalizedString("table.agents.summary"), param));
    tblModel.setSummary(MessageFormat.format(model.getLocalizedString("table.agents.summary"), param));
    tblGroupModel.setTitle(MessageFormat.format(model.getLocalizedString("table.agent.groups.title.name"), param));
    tblGroupModel.setTitleLabel(MessageFormat.format(model.getLocalizedString("table.agent.groups.summary"), param));
    tblGroupModel.setSummary(MessageFormat.format(model.getLocalizedString("table.agent.groups.summary"), param));
    getAgentNames();
    CCButton b = (CCButton) getChild(TBL_BUTTON_DELETE);
    b.setDisabled(true);
    b = (CCButton) getChild(TBL_BUTTON_DELETE_GROUP);
    b.setDisabled(true);
}
Also used : CCButton(com.sun.web.ui.view.html.CCButton) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel)

Example 4 with AgentsModel

use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.

the class GenericAgentProfileViewBean method createTabModel.

protected void createTabModel() {
    String agentType = getAgentType();
    if (isLocalConfig(agentType)) {
        agentType = AgentsViewBean.AGENT_2_2;
    }
    if (agentType != null) {
        super.createTabModel();
        AgentsModel model = (AgentsModel) getModel();
        AgentTabManager mgr = AgentTabManager.getInstance();
        List tabs = mgr.getTabs(agentType);
        if ((tabs != null) && !tabs.isEmpty()) {
            for (int i = 0; i < tabs.size(); i++) {
                String tabName = (String) tabs.get(i);
                tabModel.addNode(new CCNavNode(Integer.parseInt(TAB_PREFIX + i), model.getLocalizedString("tab.label." + agentType + "." + tabName), "", ""));
            }
        } else {
            tabModel.addNode(new CCNavNode(TAB_GENERAL_ID, "tab.general", "", ""));
        }
        String group = (String) getPageSessionAttribute(IS_GROUP);
        if ((group != null) && group.equals("true")) {
            tabModel.addNode(new CCNavNode(TAB_GROUP_ID, "tab.group", "", ""));
        }
    }
}
Also used : CCNavNode(com.sun.web.ui.model.CCNavNode) List(java.util.List) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel)

Example 5 with AgentsModel

use of com.sun.identity.console.agentconfig.model.AgentsModel in project OpenAM by OpenRock.

the class AgentGroupMembersViewBean method beginDisplay.

/**
     * Displays servers and sites information.
     *
     * @param event Display Event.
     * @throws ModelControlException if unable to initialize model.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    AgentsModel model = (AgentsModel) getModel();
    String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
    try {
        Set agents = model.getAgentGroupMembers(universalId);
        if ((agents == null) || agents.isEmpty()) {
            setDisplayFieldValue(CHILD_MEMBERS, model.getLocalizedString("agentconfig.group.members.nomembers"));
        } else {
            Set ordered = new TreeSet();
            Map nameToId = new HashMap(agents.size() * 2);
            for (Iterator i = agents.iterator(); i.hasNext(); ) {
                AMIdentity amid = (AMIdentity) i.next();
                String name = amid.getName();
                ordered.add(name);
                nameToId.put(name, amid.getUniversalId());
            }
            StringBuilder buff = new StringBuilder();
            for (Iterator i = ordered.iterator(); i.hasNext(); ) {
                String name = (String) i.next();
                buff.append(name).append(" (").append((String) nameToId.get(name)).append(")<br />");
            }
            setDisplayFieldValue(CHILD_MEMBERS, buff.toString());
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AgentsModel (com.sun.identity.console.agentconfig.model.AgentsModel)25 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)18 Map (java.util.Map)10 HashMap (java.util.HashMap)8 SerializedField (com.sun.identity.console.components.view.html.SerializedField)6 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 List (java.util.List)6 Set (java.util.Set)6 HashSet (java.util.HashSet)5 TreeSet (java.util.TreeSet)5 AMIdentity (com.sun.identity.idm.AMIdentity)4 SSOException (com.iplanet.sso.SSOException)3 SSOToken (com.iplanet.sso.SSOToken)3 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)3 CCActionTable (com.sun.web.ui.view.table.CCActionTable)3 AMViewBeanBase (com.sun.identity.console.base.AMViewBeanBase)2 AMViewConfig (com.sun.identity.console.base.AMViewConfig)2 AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)2 IdRepoException (com.sun.identity.idm.IdRepoException)2