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();
}
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());
}
}
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());
}
}
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);
}
}
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();
}
}
Aggregations