use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class SetSiteFailoverURLs 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 siteName = getStringOptionValue(IArgument.SITE_NAME);
List secondaryURLs = (List) rc.getOption(IArgument.SECONDARY_URLS);
String[] params = { siteName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_SITE_FAILOVER_URLS", params);
if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
SiteConfiguration.setSiteSecondaryURLs(adminSSOToken, siteName, secondaryURLs);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-site-secondary-urls-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-site-secondary-urls-no-exists"), (Object[]) params));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_SITE_FAILOVER_URLS", params);
} catch (SSOException e) {
String[] args = { siteName, e.getMessage() };
debugError("SetSiteFailoverURLs.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_FAILOVER_URLS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { siteName, e.getMessage() };
debugError("SetSiteFailoverURLs.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_FAILOVER_URLS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, e.getMessage() };
debugError("SetSiteFailoverURLs.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_FAILOVER_URLS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.common.configuration.ConfigurationException 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.ConfigurationException in project OpenAM by OpenRock.
the class UpdateAgent 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 realm = getStringOptionValue(IArgument.REALM_NAME);
String agentName = getStringOptionValue(IArgument.AGENT_NAME);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
boolean bSet = isOptionSet(IArgument.AGENT_SET_ATTR_VALUE);
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[] params = { realm, agentName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_UPDATE_AGENT", params);
AMIdentity amid = new AMIdentity(adminSSOToken, agentName, IdType.AGENTONLY, realm, null);
if (!amid.isExists()) {
String[] args = { realm, agentName, "agent did not exist" };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT", args);
Object[] p = { agentName };
String msg = MessageFormat.format(getResourceString("update-agent-does-not-exist"), p);
throw new CLIException(msg, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
AgentConfiguration.updateAgent(adminSSOToken, realm, agentName, attributeValues, bSet);
outputWriter.printlnMessage(getResourceString("update-agent-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_UPDATE_AGENT", params);
} catch (IdRepoException e) {
String[] args = { realm, agentName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { realm, agentName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, agentName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { realm, agentName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class UpdateAgentGroup 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 realm = getStringOptionValue(IArgument.REALM_NAME);
String agentGroupName = getStringOptionValue(IArgument.AGENT_GROUP_NAME);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
boolean bSet = isOptionSet(IArgument.AGENT_SET_ATTR_VALUE);
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[] params = { realm, agentGroupName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_UPDATE_AGENT_GROUP", params);
AMIdentity amid = new AMIdentity(adminSSOToken, agentGroupName, IdType.AGENTGROUP, realm, null);
if (!amid.isExists()) {
String[] args = { realm, agentGroupName, "agent group did not exist" };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT_GROUP", args);
Object[] p = { agentGroupName };
String msg = MessageFormat.format(getResourceString("update-agent-group-does-not-exist"), p);
throw new CLIException(msg, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
AgentConfiguration.updateAgentGroup(adminSSOToken, realm, agentGroupName, attributeValues, bSet);
outputWriter.printlnMessage(getResourceString("update-agent-group-succeeded"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_UPDATE_AGENT_GROUP", params);
} catch (IdRepoException e) {
String[] args = { realm, agentGroupName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT_GROUP", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { realm, agentGroupName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT_GROUP", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { realm, agentGroupName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT_GROUP", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, agentGroupName, e.getMessage() };
debugError("UpdateAgent.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AGENT_GROUP", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method createSite.
/**
* Creates a site.
*
* @param name Name of Site.
* @param url Primary URL of Site.
* @throws AMConsoleException if error occurs when creating site.
*/
public void createSite(String name, String url) throws AMConsoleException {
String[] param = { name };
logEvent("ATTEMPT_CREATE_SITE", param);
try {
SiteConfiguration.createSite(getUserSSOToken(), name, url, Collections.EMPTY_SET);
logEvent("SUCCEED_CREATE_SITE", param);
} catch (ConfigurationException e) {
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { name, e.getMessage() };
logEvent("SMS_EXCEPTION_CREATE_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] params = { name, e.getMessage() };
logEvent("SSO_EXCEPTION_CREATE_SITE", params);
throw new AMConsoleException(getErrorString(e));
}
}
Aggregations