Search in sources :

Example 16 with AgentsModel

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

the class AgentProfileViewBean method handleButton1Request.

/**
     * Handles Save button click.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if cannot access to framework model.
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    boolean bRefresh = false;
    AgentsModel model = (AgentsModel) getModel();
    String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
    String type = getAgentType();
    String choice = (String) getPageSessionAttribute(AgentsViewBean.LOCAL_OR_NOT);
    try {
        Map values = getFormValues();
        if (checkAgentType(type)) {
            if (!isGroup && !is2dot2Agent() && !isAgentAuthenticator() && (choice != null) && !choice.equals(AgentsViewBean.PROP_LOCAL)) {
                for (Iterator i = inheritedPropertyNames.iterator(); i.hasNext(); ) {
                    values.remove(i.next());
                }
                if (type.equals(AgentsViewBean.DEFAULT_ID_TYPE)) {
                    Iterator itr = values.keySet().iterator();
                    while (itr.hasNext()) {
                        String name = (String) itr.next();
                        Set v = (Set) values.get(name);
                        if ((v != null) && !v.isEmpty() && (v.size() == 1)) {
                            Iterator itr2 = v.iterator();
                            while (itr2.hasNext()) {
                                String subv = (String) itr2.next();
                                subv.trim();
                                if (subv.length() == 0) {
                                    values.put(name, null);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if (!isGroup && !is2dot2Agent() && !isAgentAuthenticator()) {
                for (Iterator i = inheritedPropertyNames.iterator(); i.hasNext(); ) {
                    values.remove(i.next());
                }
            }
        }
        model.setAttributeValues(universalId, values);
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        if (checkAgentType(type)) {
            if (!isGroup && !is2dot2Agent() && isFirstTab() && !isAgentAuthenticator() && (choice != null) && !choice.equals(AgentsViewBean.PROP_LOCAL)) {
                String agentGroup = getDisplayFieldStringValue(CHILD_AGENT_GROUP);
                bRefresh = model.setGroup(curRealm, universalId, agentGroup);
                String status = getDisplayFieldStringValue(AgentsViewBean.ATTR_CONFIG_REPO);
                if (status.equals("local")) {
                    setPageSessionAttribute(AgentsViewBean.LOCAL_OR_NOT, AgentsViewBean.PROP_LOCAL);
                    bRefresh = true;
                }
            }
        } else {
            if (!isGroup && !is2dot2Agent() && !isAgentAuthenticator() && isFirstTab()) {
                String agentGroup = getDisplayFieldStringValue(CHILD_AGENT_GROUP);
                bRefresh = model.setGroup(curRealm, universalId, agentGroup);
            }
        }
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        bRefresh = false;
    }
    if (bRefresh) {
        setPageSessionAttribute(UPDATED_PROFILE, "true");
        AMPostViewBean vb = (AMPostViewBean) getViewBean(AMPostViewBean.class);
        passPgSessionMap(vb);
        String url = this.getDefaultDisplayURL();
        int idx = url.indexOf("/", 1);
        url = ".." + url.substring(idx);
        vb.setTargetViewBeanURL(url);
        vb.forwardTo(getRequestContext());
    } else {
        forwardTo();
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) AMPostViewBean(com.sun.identity.console.base.AMPostViewBean)

Example 17 with AgentsModel

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

the class AgentProfileViewBean method beginBtnInheritDisplay.

/**
     * Disables inheritance setting button if the agent does not belong
     * a group.
     *
     * @param event Child Display Event.
     * @return <code>true</code> if the agent belongs to a group.
     */
public boolean beginBtnInheritDisplay(ChildDisplayEvent event) {
    AgentsModel model = (AgentsModel) getModel();
    String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
    disableButton(BTN_INHERIT, false);
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    try {
        String groupId = model.getAgentGroup(curRealm, universalId);
        if ((groupId == null) || (groupId.trim().length() == 0)) {
            disableButton(BTN_INHERIT, true);
        }
    } catch (AMConsoleException ex) {
        disableButton(BTN_INHERIT, true);
    }
    return !isGroup;
}
Also used : AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 18 with AgentsModel

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

the class AgentsViewBean method handleTblButtonGroupDeleteRequest.

/**
     * Deletes agent groups.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if table model cannot be restored.
     */
public void handleTblButtonGroupDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_SEARCH_GROUP);
    table.restoreStateData();
    Integer[] selected = tblGroupModel.getSelectedRows();
    Set names = new HashSet(selected.length * 2);
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    Map mapCache = (Map) szCache.getSerializedObj();
    List cache = (List) mapCache.get(CACHE_AGENT_GROUPS);
    for (int i = 0; i < selected.length; i++) {
        names.add((String) cache.get(selected[i].intValue()));
    }
    try {
        AgentsModel model = (AgentsModel) getModel();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        model.deleteAgentGroups(curRealm, names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agent.groups.message.deleted"));
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agent.groups.message.deleted.pural"));
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) SerializedField(com.sun.identity.console.components.view.html.SerializedField) List(java.util.List) ArrayList(java.util.ArrayList) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 19 with AgentsModel

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

the class AgentsViewBean method addAgentsTab.

private CCNavNode addAgentsTab(int idx) {
    AgentsModel model = (AgentsModel) getModel();
    AMViewConfig config = AMViewConfig.getInstance();
    return config.addAgentTabs(tabModel, model, idx);
}
Also used : AMViewConfig(com.sun.identity.console.base.AMViewConfig) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel)

Example 20 with AgentsModel

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

the class AgentsViewBean method handleTblButtonDeleteRequest.

/**
     * Deletes agents.
     *
     * @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();
    Set names = new HashSet(selected.length * 2);
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    Map mapCache = (Map) szCache.getSerializedObj();
    List cache = (List) mapCache.get(CACHE_AGENTS);
    for (int i = 0; i < selected.length; i++) {
        names.add((String) cache.get(selected[i].intValue()));
    }
    try {
        AgentsModel model = (AgentsModel) getModel();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        model.deleteAgents(curRealm, names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agents.message.deleted"));
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("agents.message.deleted.pural"));
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) SerializedField(com.sun.identity.console.components.view.html.SerializedField) List(java.util.List) ArrayList(java.util.ArrayList) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

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