Search in sources :

Example 26 with ServerSiteModel

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

the class ServerConfigXMLViewBean method handleTblServerConfigXMLUserButtonDeleteRequest.

/**
     * Handles remove server group entry request.
     *
     * @param event Request invocation event
     */
public void handleTblServerConfigXMLUserButtonDeleteRequest(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 defaultServerGroup = xmlObj.getDefaultServerGroup();
        CCActionTable table = (CCActionTable) getChild(TBL_USERS);
        table.restoreStateData();
        Integer[] selected = tblUserModel.getSelectedRows();
        if (selected.length >= defaultServerGroup.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) {
                defaultServerGroup.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)

Example 27 with ServerSiteModel

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

the class ServerEditViewBeanBase method createPropertyModel.

private void createPropertyModel(String serverName) {
    String xml = AMAdminUtils.getStringFromInputStream(getClass().getClassLoader().getResourceAsStream(getPropertyXML()));
    Set uiNames = getAllConfigUINames(xml);
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        Map attrValues = model.getServerConfiguration(serverName);
        Map defaultValues = model.getServerDefaults();
        Map textValues = new HashMap();
        for (Iterator i = uiNames.iterator(); i.hasNext(); ) {
            String uiName = (String) i.next();
            String propertyName = getActualPropertyName(uiName);
            if (!attrValues.containsKey(propertyName)) {
                textValues.put(uiName, defaultValues.get(propertyName));
            } else {
                activePropertyNames.add(uiName);
                i.remove();
            }
            allPropertyNames.add(uiName);
        }
        if (!textValues.isEmpty()) {
            xml = textifyXML(xml, uiNames, textValues);
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    // this is because default server configuration does not have
    // parent site.
    xml = removeParentSiteBlob(xml);
    propertySheetModel = new AMPropertySheetModel(xml);
    propertySheetModel.clear();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) 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)

Example 28 with ServerSiteModel

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

the class ServerSiteViewBean method handleTblSiteButtonDeleteRequest.

/**
     * Deletes site.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if table model cannot be restored.
     */
public void handleTblSiteButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_SITES);
    table.restoreStateData();
    Integer[] selected = tblSiteModel.getSelectedRows();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE_1);
    List list = (List) szCache.getSerializedObj();
    Set names = new HashSet(selected.length * 2);
    for (int i = 0; i < selected.length; i++) {
        String name = (String) list.get(selected[i].intValue());
        names.add(name);
    }
    try {
        ServerSiteModel model = (ServerSiteModel) getModel();
        model.deleteSites(names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "siteconfig.message.deleted");
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "siteconfig.message.deleted.pural");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) SerializedField(com.sun.identity.console.components.view.html.SerializedField) 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)

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