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