Search in sources :

Example 6 with AgentsModel

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

the class AgentConfigInheritViewBean method populatePropertyNameTableModel.

private void populatePropertyNameTableModel(Collection propertyNames) {
    if (!submitCycle && (propertyNames != null)) {
        tblPropertyNamesModel.clearAll();
        SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
        String universalId = (String) getPageSessionAttribute(AgentProfileViewBean.UNIVERSAL_ID);
        String agentType = getAgentType();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        AgentsModel model = (AgentsModel) getModel();
        Set inheritedPropertyNames = model.getInheritedPropertyNames(curRealm, universalId);
        Map nameToSchemas = model.getAttributeSchemas(agentType, propertyNames);
        removeNonInheritable(nameToSchemas, propertyNames);
        try {
            ResourceBundle rb = AgentConfiguration.getServiceResourceBundle(model.getUserLocale());
            String groupName = model.getAgentGroup(curRealm, universalId);
            Map groupValues = model.getGroupAttributeValues(curRealm, groupName);
            ArrayList cache = new ArrayList();
            int counter = 0;
            for (Iterator i = propertyNames.iterator(); i.hasNext(); counter++) {
                if (counter > 0) {
                    tblPropertyNamesModel.appendRow();
                }
                String name = (String) i.next();
                AttributeSchema as = (AttributeSchema) nameToSchemas.get(name);
                if (as != null) {
                    String displayName = rb.getString(as.getI18NKey());
                    tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_NAME, displayName);
                    try {
                        String help = rb.getString(as.getI18NKey() + ".help");
                        tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_HELP, help);
                    } catch (MissingResourceException e) {
                        // need to clear the help value
                        tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_HELP, "");
                    }
                    Object oValue = groupValues.get(name);
                    String value = "";
                    if (oValue != null) {
                        value = oValue.toString();
                        if (value.length() >= 2) {
                            value = value.substring(1, value.length() - 1);
                        }
                    }
                    tblPropertyNamesModel.setValue(TBL_DATA_VALUE, value);
                    tblPropertyNamesModel.setSelectionVisible(counter, true);
                    tblPropertyNamesModel.setRowSelected(inheritedPropertyNames.contains(name));
                    cache.add(name);
                }
            }
            szCache.setValue(cache);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        } catch (SMSException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        } catch (SSOException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) MissingResourceException(java.util.MissingResourceException) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) SerializedField(com.sun.identity.console.components.view.html.SerializedField) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ResourceBundle(java.util.ResourceBundle) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with AgentsModel

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

the class AgentAddViewBean method beginDisplay.

public void beginDisplay(DisplayEvent e) {
    String value = (String) getDisplayFieldValue(RADIO_CHOICE);
    if ((value == null) || value.equals("")) {
        setDisplayFieldValue(RADIO_CHOICE, AgentsViewBean.PROP_CENTRAL);
    }
    AgentsModel model = (AgentsModel) getModel();
    String agentType = getAgentType();
    Object[] param = { model.getLocalizedString("agenttype." + agentType) };
    ptModel.setPageTitleText(MessageFormat.format(model.getLocalizedString("page.title.agents.create"), param));
}
Also used : AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel)

Example 8 with AgentsModel

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

the class AgentsViewBean method handleTblDataActionGroupHrefRequest.

/**
     * Forwards request to edit agent group view bean.
     *
     * @param event Request Invocation Event.
     */
public void handleTblDataActionGroupHrefRequest(RequestInvocationEvent event) {
    AgentsModel model = (AgentsModel) getModel();
    String idType = getDisplayIDType();
    String universalId = hexToString((String) getDisplayFieldValue(TBL_DATA_ACTION_HREF_GROUP));
    setPageSessionAttribute(AgentProfileViewBean.UNIVERSAL_ID, universalId);
    SSOToken ssoToken = model.getUserSSOToken();
    String realm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    StringTokenizer st = new StringTokenizer(universalId, "=,");
    st.nextToken();
    String agentGrpName = st.nextToken();
    try {
        AMIdentity amid = new AMIdentity(ssoToken, agentGrpName, IdType.AGENTGROUP, realm, null);
        String vbName = (String) agentViewBeans.get(idType);
        if (vbName == null) {
            vbName = GENERIC_VIEW_BEAN;
        }
        Class clazz = Thread.currentThread().getContextClassLoader().loadClass(vbName);
        AMViewBeanBase vb = (AMViewBeanBase) getViewBean(clazz);
        removePageSessionAttribute(GenericAgentProfileViewBean.PS_TABNAME);
        setPageSessionAttribute(PG_SESSION_SUPERCEDE_AGENT_TYPE, model.getAgentType(amid));
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    } catch (ClassNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    }
}
Also used : AMViewBeanBase(com.sun.identity.console.base.AMViewBeanBase) StringTokenizer(java.util.StringTokenizer) SSOToken(com.iplanet.sso.SSOToken) AMIdentity(com.sun.identity.idm.AMIdentity) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 9 with AgentsModel

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

the class AgentProfileViewBean method setAgentTitle.

protected void setAgentTitle() {
    AgentsModel model = (AgentsModel) getModel();
    String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
    try {
        String title = model.getLocalizedString("edit.agentconfig.title");
        String displayName = model.getDisplayName(universalId);
        Object[] param = { displayName };
        ptModel.setPageTitleText(MessageFormat.format(title, param));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 10 with AgentsModel

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

the class AgentProfileViewBean method createPropertyModel.

protected boolean createPropertyModel() {
    boolean created = false;
    String type = getAgentType();
    if ((type != null) && (type.trim().length() > 0)) {
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        AgentsModel model = (AgentsModel) getModel();
        String universalId = (String) getPageSessionAttribute(UNIVERSAL_ID);
        String choice = (String) getPageSessionAttribute(AgentsViewBean.LOCAL_OR_NOT);
        if (checkAgentType(type)) {
            inheritedPropertyNames = (!isGroup && !is2dot2Agent() && !isAgentAuthenticator() && !choice.equals(AgentsViewBean.PROP_LOCAL)) ? model.getInheritedPropertyNames(curRealm, universalId) : Collections.EMPTY_SET;
        } else {
            inheritedPropertyNames = (!isGroup && !is2dot2Agent() && !isAgentAuthenticator()) ? model.getInheritedPropertyNames(curRealm, universalId) : Collections.EMPTY_SET;
        }
        AMPropertySheetModel psModel = createPropertySheetModel(type);
        if (psModel != null) {
            propertySheetModel = psModel;
            propertySheetModel.clear();
        }
        created = true;
    }
    return created;
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel)

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