use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class UpgradeUtils method createServiceInstance.
/**
* Creates a service instance.
*
* @param serverInstance the server instance value
* @param serverId the server identifier
* @throws UpgradeException if there is an error.
*/
public static void createServiceInstance(String serverInstance, String serverId, Set values, String serverConfigXML) {
//throws UpgradeException {
String classMethod = "UpgradeUtils:createServiceInstance : ";
if (debug.messageEnabled()) {
debug.message(classMethod + "serverInstance :" + serverInstance);
debug.message(classMethod + "serverId :" + serverId);
}
try {
ServerConfiguration.createServerInstance(ssoToken, serverInstance, serverId, values, serverConfigXML);
} catch (UnknownPropertyNameException uce) {
//throw new UpgradeException("Unknwon property ");
} catch (ConfigurationException ce) {
//throw new UpgradeException("Unable to create Service instance");
} catch (SMSException sme) {
//throw new UpgradeException("Unable to create Service instance");
} catch (SSOException ssoe) {
//throw new UpgradeException("invalid ssotoken");
}
}
use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class CreateServer method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String serverName = getStringOptionValue(IArgument.SERVER_NAME);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
if ((datafile == null) && (attrValues == null)) {
throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
Map attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
String serverconfigxml = CLIUtil.getFileContent(getCommandManager(), getStringOptionValue(SERVER_CONFIG_XML_FILE));
String[] params = { serverName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_SERVER", params);
if (!ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
ServerConfiguration.createServerInstance(adminSSOToken, serverName, attributeValues, serverconfigxml);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("create-server-config-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("create-server-config-already-exists"), (Object[]) params));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_CREATE_SERVER", params);
} catch (UnknownPropertyNameException e) {
String[] args = { serverName, e.getMessage() };
debugError("CreateServer.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { serverName, e.getMessage() };
debugError("CreateServer.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
String[] args = { serverName, e.getMessage() };
debugError("CreateServer.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { serverName, e.getMessage() };
debugError("CreateServer.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serverName, e.getMessage() };
debugError("CreateServer.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class ServerEditGeneralViewBean method handleButton1Request.
/**
* Handles create site request.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
String serverName = (String) getPageSessionAttribute(PG_ATTR_SERVER_NAME);
String parentSite = (serverName.equals(ServerConfiguration.DEFAULT_SERVER_CONFIG)) ? null : (String) getDisplayFieldValue(PARENT_SITE);
ServerSiteModel model = (ServerSiteModel) getModel();
try {
model.modifyServer(serverName, parentSite, getAttributeValues());
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
} catch (UnknownPropertyNameException e) {
// ignore. this cannot happen because property in this page
// is customized.
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
forwardTo();
}
use of com.sun.identity.common.configuration.UnknownPropertyNameException 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.common.configuration.UnknownPropertyNameException 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();
}
Aggregations