Search in sources :

Example 1 with ServerSiteModel

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

the class ServerSiteViewBean method handleTblServerButtonDeleteRequest.

/**
     * Deletes server.
     *
     * @param event Request Invocation Event.
     * @throws ModelControlException if table model cannot be restored.
     */
public void handleTblServerButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_SERVERS);
    table.restoreStateData();
    Integer[] selected = tblServerModel.getSelectedRows();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    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.deleteServers(names);
        if (selected.length == 1) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.message.deleted");
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.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)

Example 2 with ServerSiteModel

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

the class ServerSiteViewBean method getSiteNames.

private void getSiteNames() {
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        Set sites = model.getSiteNames();
        Map map = new HashMap(sites.size() * 2);
        for (Iterator i = sites.iterator(); i.hasNext(); ) {
            String site = (String) i.next();
            String[] params = new String[2];
            params[0] = model.getSitePrimaryURL(site);
            Set assignedServers = model.getSiteServers(site);
            if ((assignedServers != null) && !assignedServers.isEmpty()) {
                Set set = new TreeSet();
                set.addAll(assignedServers);
                StringBuilder buff = new StringBuilder();
                for (Iterator j = set.iterator(); j.hasNext(); ) {
                    buff.append((String) j.next()).append("<br />");
                }
                params[1] = buff.toString();
            } else {
                params[1] = "";
            }
            map.put(site, params);
        }
        populateSiteTableModel(map);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) 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)

Example 3 with ServerSiteModel

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

the class ServerSiteViewBean method getServerNames.

private void getServerNames() {
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        Set servers = model.getServerNames();
        Map map = new HashMap(servers.size() * 2);
        for (Iterator i = servers.iterator(); i.hasNext(); ) {
            String server = (String) i.next();
            map.put(server, model.getServerSite(server));
        }
        populateServerTableModel(map);
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) 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 4 with ServerSiteModel

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

the class ServerSiteViewBean method populateServerTableModel.

private void populateServerTableModel(Map serverToSite) {
    tblServerModel.clearAll();
    SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
    SerializedField szCacheServer = (SerializedField) getChild(SZ_CACHE_SERVER);
    ServerSiteModel model = (ServerSiteModel) getModel();
    tblServerModel.setMaxRows(model.getPageSize());
    int counter = 0;
    HashMap cacheServer = new HashMap();
    ArrayList cache = new ArrayList();
    if ((serverToSite != null) && !serverToSite.isEmpty()) {
        for (Iterator iter = serverToSite.keySet().iterator(); iter.hasNext(); counter++) {
            if (counter > 0) {
                tblServerModel.appendRow();
            }
            String name = (String) iter.next();
            String siteName = (String) serverToSite.get(name);
            tblServerModel.setValue(TBL_DATA_SERVER_ACTION_HREF, name);
            tblServerModel.setValue(TBL_DATA_SERVER_NAME, name);
            tblServerModel.setValue(TBL_DATA_SITE, siteName);
            tblServerModel.setSelectionVisible(counter, true);
            cacheServer.put(name, siteName);
            cache.add(name);
        }
        szCache.setValue(cache);
        szCacheServer.setValue(cacheServer);
    } else {
        szCache.setValue(null);
    }
}
Also used : SerializedField(com.sun.identity.console.components.view.html.SerializedField) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel)

Example 5 with ServerSiteModel

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

the class SiteAddViewBean method handleButton1Request.

/**
     * Handles create site request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    ServerSiteModel model = (ServerSiteModel) getModel();
    AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
    String name = (String) getDisplayFieldValue(TF_NAME);
    name = name.trim();
    String url = (String) getDisplayFieldValue(TF_URL);
    url = url.trim();
    if ((name.length() > 0) && (url.length() > 0)) {
        try {
            model.createSite(name, url);
            backTrail();
            ServerSiteViewBean vb = (ServerSiteViewBean) getViewBean(ServerSiteViewBean.class);
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "serverconfig.create.site.missing.atributes");
        forwardTo();
    }
}
Also used : AMPropertySheet(com.sun.identity.console.base.AMPropertySheet) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

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