Search in sources :

Example 16 with ServerSiteModel

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

the class ServerEditAdvancedViewBean method beginDisplay.

/**
     * Displays the advanced profile of a serer.
     *
     * @param event Display Event.
     */
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));
    getProperties();
}
Also used : ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel)

Example 17 with ServerSiteModel

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

the class ServerEditAdvancedViewBean method handleButton1Request.

/**
     * Handles save properties  request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    String valProperties = (String) getDisplayFieldValue(PROPERTIES);
    properties = new HashSet();
    Map map = new HashMap();
    StringTokenizer st = new StringTokenizer(valProperties, "\n");
    while (st.hasMoreElements()) {
        String t = st.nextToken();
        t = t.replaceAll("\r", "");
        int idx = t.indexOf('=');
        String name = t.substring(0, idx).trim();
        String value = t.substring(idx + 1).trim();
        properties.add(t);
        map.put(name, value);
    }
    ServerSiteModel model = (ServerSiteModel) getModel();
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    /*
         * only global default has values for hidden properties. should not
         * try to set hidden property values for server instance
         */
    if (serverName.equals(ServerConfiguration.DEFAULT_SERVER_CONFIG)) {
        for (Iterator i = hiddenProperties.entrySet().iterator(); i.hasNext(); ) {
            Map.Entry entry = (Map.Entry) i.next();
            map.put(entry.getKey(), entry.getValue());
        }
    }
    try {
        Map origValues = model.getServerConfiguration(serverName);
        discardDealtWithProperties(origValues);
        String unkownPropertyMessage = null;
        try {
            model.modifyServer(serverName, null, map);
        } catch (UnknownPropertyNameException ex) {
            unkownPropertyMessage = ex.getL10NMessage(model.getUserLocale());
        }
        for (Iterator i = origValues.keySet().iterator(); i.hasNext(); ) {
            String key = (String) i.next();
            if (map.containsKey(key)) {
                i.remove();
            }
        }
        if (!origValues.isEmpty()) {
            model.updateServerConfigInheritance(serverName, origValues.keySet(), null);
        }
        if (unkownPropertyMessage != null) {
            Object[] args = { unkownPropertyMessage };
            setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", MessageFormat.format(model.getLocalizedString("serverconfig.updated.with.invalid.properties"), args));
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) HashMap(java.util.HashMap) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) StringTokenizer(java.util.StringTokenizer) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 18 with ServerSiteModel

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

the class ServerConfigInheritViewBean method populatePropertyNameTableModel.

private void populatePropertyNameTableModel(Collection propertyNames) {
    if (!submitCycle && (propertyNames != null)) {
        tblPropertyNamesModel.clearAll();
        SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
        String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
        ServerSiteModel model = (ServerSiteModel) getModel();
        Map defaultValues = model.getServerDefaults();
        ArrayList cache = new ArrayList();
        try {
            Map serverProperties = model.getServerConfiguration(serverName);
            int counter = 0;
            boolean first = false;
            for (Iterator iter = propertyNames.iterator(); iter.hasNext(); counter++) {
                if (counter > 0) {
                    tblPropertyNamesModel.appendRow();
                }
                String name = (String) iter.next();
                String displayName = name.substring(3);
                displayName = "amconfig." + displayName.replaceAll("-", ".");
                String actualPropertyName = ServerEditViewBeanBase.getActualPropertyName(name);
                tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_NAME, displayName);
                tblPropertyNamesModel.setValue(TBL_DATA_VALUE, (String) defaultValues.get(actualPropertyName));
                tblPropertyNamesModel.setSelectionVisible(counter, true);
                tblPropertyNamesModel.setRowSelected(!serverProperties.containsKey(actualPropertyName));
                cache.add(name);
            }
            szCache.setValue(cache);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
}
Also used : SerializedField(com.sun.identity.console.components.view.html.SerializedField) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 19 with ServerSiteModel

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

the class ServerConfigInheritViewBean method handleButton1Request.

/**
     * Handles save profile request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    CCActionTable table = (CCActionTable) getChild(TBL_PROPERTY_NAMES);
    table.restoreStateData();
    Integer[] selected = tblPropertyNamesModel.getSelectedRows();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    List list = (List) szCache.getSerializedObj();
    Set toInherit = new HashSet(selected.length * 2);
    for (int i = 0; i < selected.length; i++) {
        String name = (String) list.get(selected[i].intValue());
        toInherit.add(ServerEditViewBeanBase.getActualPropertyName(name));
    }
    Set notToInherit = new HashSet(list.size() * 2);
    for (Iterator i = list.iterator(); i.hasNext(); ) {
        String name = (String) i.next();
        notToInherit.add(ServerEditViewBeanBase.getActualPropertyName(name));
    }
    notToInherit.removeAll(toInherit);
    try {
        ServerSiteModel model = (ServerSiteModel) getModel();
        String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
        model.updateServerConfigInheritance(serverName, toInherit, notToInherit);
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "servercfg.inheritance.updated");
    } 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) Iterator(java.util.Iterator) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) ArrayList(java.util.ArrayList) List(java.util.List) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet)

Example 20 with ServerSiteModel

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

the class ServerConfigXMLViewBean method handleTblServerConfigXMLServerButtonDeleteRequest.

/**
     * Handles remove server group entry request.
     *
     * @param event Request invocation event
     */
public void handleTblServerConfigXMLServerButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
        ServerConfigXML.ServerGroup smsServerGroup = xmlObj.getSMSServerGroup();
        CCActionTable table = (CCActionTable) getChild(TBL_SERVERS);
        table.restoreStateData();
        Integer[] selected = tblServerModel.getSelectedRows();
        if (selected.length >= smsServerGroup.hosts.size()) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("exception.cannot,delete.all.servers"));
        } else {
            for (int i = selected.length - 1; i >= 0; --i) {
                smsServerGroup.hosts.remove(selected[i].intValue());
            }
            model.setServerConfigXML(serverName, xmlObj.toXML());
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

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