use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.
the class ServerConfigXMLAddServerViewBean method handleButton1Request.
/**
* Handles create server to server configuration XML request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
ServerSiteModel model = (ServerSiteModel) getModel();
String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
String serverGroupType = (String) getPageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
String name = (String) getDisplayFieldValue(TF_NAME);
name = name.trim();
String host = (String) getDisplayFieldValue(TF_HOST);
host = host.trim();
String port = (String) getDisplayFieldValue(TF_PORT);
port = port.trim();
String type = (String) getDisplayFieldValue(CHOICE_TYPE);
if ((name.length() > 0) && (port.length() > 0) && (host.length() > 0)) {
try {
ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
ServerConfigXML.ServerGroup serverGroup = (serverGroupType.equals(DSConfigMgr.DEFAULT)) ? xmlObj.getDefaultServerGroup() : xmlObj.getSMSServerGroup();
serverGroup.addHost(name, host, port, type);
model.setServerConfigXML(serverName, xmlObj.toXML());
backTrail();
ServerConfigXMLViewBean vb = (ServerConfigXMLViewBean) getViewBean(ServerConfigXMLViewBean.class);
removePageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
} catch (ConfigurationException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
} else {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "serverconfig.create.server.missing.atributes");
forwardTo();
}
}
use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.
the class ServerConfigXMLViewBean method handleButton1Request.
/**
* Handles save request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) {
submitCycle = true;
String svrMinPool = (String) getDisplayFieldValue(TF_SERVER_MIN_POOL);
String svrMaxPool = (String) getDisplayFieldValue(TF_SERVER_MAX_POOL);
String bindDN = (String) getDisplayFieldValue(TF_SERVER_BIND_DN);
String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
ServerSiteModel model = (ServerSiteModel) getModel();
try {
ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
ServerConfigXML.ServerGroup smsServerGroup = xmlObj.getSMSServerGroup();
if (bAMSDKEnabled) {
String userMinPool = (String) getDisplayFieldValue(TF_USER_MIN_POOL);
String userMaxPool = (String) getDisplayFieldValue(TF_USER_MAX_POOL);
ServerConfigXML.ServerGroup defaultServerGroup = xmlObj.getDefaultServerGroup();
defaultServerGroup.minPool = Integer.parseInt(userMinPool);
defaultServerGroup.maxPool = Integer.parseInt(userMaxPool);
defaultServerGroup.dsBaseDN = ((String) getDisplayFieldValue(TF_USER_ROOTSUFFIX)).trim();
for (Iterator i = defaultServerGroup.dsUsers.iterator(); i.hasNext(); ) {
DirUserObject o = (DirUserObject) i.next();
if (o.type.equals("proxy")) {
o.dn = "cn=puser,ou=DSAME Users," + defaultServerGroup.dsBaseDN;
String pwd = (String) getDisplayFieldValue(TF_USER_PROXY_PWD);
if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
o.password = Crypt.encode(pwd);
}
} else if (o.type.equals("admin")) {
o.dn = "cn=dsameuser,ou=DSAME Users," + defaultServerGroup.dsBaseDN;
String pwd = (String) getDisplayFieldValue(TF_USER_ADMIN_PWD);
if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
o.password = Crypt.encode(pwd);
}
}
}
}
smsServerGroup.minPool = Integer.parseInt(svrMinPool);
smsServerGroup.maxPool = Integer.parseInt(svrMaxPool);
List userGroup = smsServerGroup.dsUsers;
ServerConfigXML.DirUserObject bind = (ServerConfigXML.DirUserObject) userGroup.iterator().next();
bind.dn = bindDN;
String bindPwd = (String) getDisplayFieldValue(TF_SERVER_BIND_PWD);
if (!bindPwd.equals(AMPropertySheetModel.passwordRandom)) {
bind.password = Crypt.encode(bindPwd);
}
model.setServerConfigXML(serverName, xmlObj.toXML());
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", model.getLocalizedString("serverconfig.updated"));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
} catch (NumberFormatException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("exception.thread.pool.no.integer"));
}
forwardTo();
}
use of com.sun.identity.console.service.model.ServerSiteModel in project OpenAM by OpenRock.
the class ServerConfigXMLViewBean method beginDisplay.
/**
* Displays the profile of a site.
*/
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));
try {
setConfigProperties(serverName, model);
} 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 ServerEditViewBeanBase method modifyProperties.
protected void modifyProperties() {
String serverName = (String) getPageSessionAttribute(PG_ATTR_SERVER_NAME);
ServerSiteModel model = (ServerSiteModel) getModel();
try {
model.modifyServer(serverName, null, getAttributeValues());
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
} catch (UnknownPropertyNameException e) {
// ignore, this cannot happen because properties on this page
// are pre checked.
} 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 ServerEditAdvancedViewBean method getProperties.
private void getProperties() {
if (!submitCycle) {
try {
ServerSiteModel model = (ServerSiteModel) getModel();
String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
properties = new TreeSet();
Map map = model.getServerConfiguration(serverName);
discardDealtWithProperties(map);
discardHiddenProperties(map);
for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) {
Map.Entry entry = (Map.Entry) i.next();
properties.add((String) entry.getKey() + "=" + (String) entry.getValue());
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
populateTableModel(properties);
}
Aggregations