Search in sources :

Example 11 with ServerSiteModel

use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.

the class ServerConfigXMLAddServerViewBean method handleButton1Request.

/**
     * Handles create server to server configuration XML request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    ServerSiteModel model = (ServerSiteModel) getModel();
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    String serverGroupType = (String) getPageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
    String name = (String) getDisplayFieldValue(TF_NAME);
    name = name.trim();
    String host = (String) getDisplayFieldValue(TF_HOST);
    host = host.trim();
    String port = (String) getDisplayFieldValue(TF_PORT);
    port = port.trim();
    String type = (String) getDisplayFieldValue(CHOICE_TYPE);
    if ((name.length() > 0) && (port.length() > 0) && (host.length() > 0)) {
        try {
            ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
            ServerConfigXML.ServerGroup serverGroup = (serverGroupType.equals(DSConfigMgr.DEFAULT)) ? xmlObj.getDefaultServerGroup() : xmlObj.getSMSServerGroup();
            serverGroup.addHost(name, host, port, type);
            model.setServerConfigXML(serverName, xmlObj.toXML());
            backTrail();
            ServerConfigXMLViewBean vb = (ServerConfigXMLViewBean) getViewBean(ServerConfigXMLViewBean.class);
            removePageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        } catch (ConfigurationException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "serverconfig.create.server.missing.atributes");
        forwardTo();
    }
}
Also used : ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 12 with ServerSiteModel

use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.

the class ServerConfigXMLViewBean method handleButton1Request.

/**
     * Handles save request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) {
    submitCycle = true;
    String svrMinPool = (String) getDisplayFieldValue(TF_SERVER_MIN_POOL);
    String svrMaxPool = (String) getDisplayFieldValue(TF_SERVER_MAX_POOL);
    String bindDN = (String) getDisplayFieldValue(TF_SERVER_BIND_DN);
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
        ServerConfigXML.ServerGroup smsServerGroup = xmlObj.getSMSServerGroup();
        if (bAMSDKEnabled) {
            String userMinPool = (String) getDisplayFieldValue(TF_USER_MIN_POOL);
            String userMaxPool = (String) getDisplayFieldValue(TF_USER_MAX_POOL);
            ServerConfigXML.ServerGroup defaultServerGroup = xmlObj.getDefaultServerGroup();
            defaultServerGroup.minPool = Integer.parseInt(userMinPool);
            defaultServerGroup.maxPool = Integer.parseInt(userMaxPool);
            defaultServerGroup.dsBaseDN = ((String) getDisplayFieldValue(TF_USER_ROOTSUFFIX)).trim();
            for (Iterator i = defaultServerGroup.dsUsers.iterator(); i.hasNext(); ) {
                DirUserObject o = (DirUserObject) i.next();
                if (o.type.equals("proxy")) {
                    o.dn = "cn=puser,ou=DSAME Users," + defaultServerGroup.dsBaseDN;
                    String pwd = (String) getDisplayFieldValue(TF_USER_PROXY_PWD);
                    if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
                        o.password = Crypt.encode(pwd);
                    }
                } else if (o.type.equals("admin")) {
                    o.dn = "cn=dsameuser,ou=DSAME Users," + defaultServerGroup.dsBaseDN;
                    String pwd = (String) getDisplayFieldValue(TF_USER_ADMIN_PWD);
                    if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
                        o.password = Crypt.encode(pwd);
                    }
                }
            }
        }
        smsServerGroup.minPool = Integer.parseInt(svrMinPool);
        smsServerGroup.maxPool = Integer.parseInt(svrMaxPool);
        List userGroup = smsServerGroup.dsUsers;
        ServerConfigXML.DirUserObject bind = (ServerConfigXML.DirUserObject) userGroup.iterator().next();
        bind.dn = bindDN;
        String bindPwd = (String) getDisplayFieldValue(TF_SERVER_BIND_PWD);
        if (!bindPwd.equals(AMPropertySheetModel.passwordRandom)) {
            bind.password = Crypt.encode(bindPwd);
        }
        model.setServerConfigXML(serverName, xmlObj.toXML());
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("serverconfig.updated"));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } catch (NumberFormatException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("exception.thread.pool.no.integer"));
    }
    forwardTo();
}
Also used : DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) Iterator(java.util.Iterator) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) List(java.util.List) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 13 with ServerSiteModel

use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.

the class ServerConfigXMLViewBean method beginDisplay.

/**
     * Displays the profile of a site.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    ServerSiteModel model = (ServerSiteModel) getModel();
    ptModel.setPageTitleText(model.getEditServerPageTitle(serverName));
    try {
        setConfigProperties(serverName, model);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 14 with ServerSiteModel

use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.

the class ServerEditViewBeanBase method modifyProperties.

protected void modifyProperties() {
    String serverName = (String) getPageSessionAttribute(PG_ATTR_SERVER_NAME);
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        model.modifyServer(serverName, null, getAttributeValues());
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
    } catch (UnknownPropertyNameException e) {
    // ignore, this cannot happen because properties on this page
    // are pre checked.
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 15 with ServerSiteModel

use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.

the class ServerEditAdvancedViewBean method getProperties.

private void getProperties() {
    if (!submitCycle) {
        try {
            ServerSiteModel model = (ServerSiteModel) getModel();
            String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
            properties = new TreeSet();
            Map map = model.getServerConfiguration(serverName);
            discardDealtWithProperties(map);
            discardHiddenProperties(map);
            for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
                Map.Entry entry = (Map.Entry) i.next();
                properties.add((String) entry.getKey() + "=" + (String) entry.getValue());
            }
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
    populateTableModel(properties);
}
Also used : TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ServerSiteModel (com.sun.identity.console.service.model.ServerSiteModel)28 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)23 Iterator (java.util.Iterator)11 HashSet (java.util.HashSet)8 HashMap (java.util.HashMap)7 Set (java.util.Set)7 SerializedField (com.sun.identity.console.components.view.html.SerializedField)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 TreeSet (java.util.TreeSet)6 CCActionTable (com.sun.web.ui.view.table.CCActionTable)5 ServerConfigXML (com.sun.identity.common.configuration.ServerConfigXML)4 List (java.util.List)4 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)3 AMPropertySheet (com.sun.identity.console.base.AMPropertySheet)3 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)1 DirUserObject (com.sun.identity.common.configuration.ServerConfigXML.DirUserObject)1 AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)1 FQDNUrl (com.sun.identity.shared.FQDNUrl)1 CCEditableList (com.sun.web.ui.view.editablelist.CCEditableList)1