use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class CreateSite 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);
String siteURL = getStringOptionValue(IArgument.SITE_URL);
List secondaryURLs = (List) rc.getOption(IArgument.SECONDARY_URLS);
String[] params = { siteName, siteURL };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_SITE", params);
if (!SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
SiteConfiguration.createSite(adminSSOToken, siteName, siteURL, secondaryURLs);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("create-site-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("create-site-already-exists"), (Object[]) params));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_CREATE_SITE", params);
} catch (SSOException e) {
String[] args = { siteName, siteURL, e.getMessage() };
debugError("CreateSite.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SITE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { siteName, siteURL, e.getMessage() };
debugError("CreateSite.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SITE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, siteURL, e.getMessage() };
debugError("CreateSite.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SITE", 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 DeleteSite 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);
String[] params = { siteName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_SITE", params);
if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
SiteConfiguration.deleteSite(adminSSOToken, siteName);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("delete-site-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(getResourceString("delete-site-no-exists"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_SITE", params);
} catch (SSOException e) {
String[] args = { siteName, e.getMessage() };
debugError("DeleteSite.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SITE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { siteName, e.getMessage() };
debugError("DeleteSite.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SITE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, e.getMessage() };
debugError("DeleteSite.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SITE", 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 SetSitePrimaryURL 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);
String siteURL = getStringOptionValue(IArgument.SITE_URL);
String[] params = { siteName, siteURL };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_SITE_PRIMARY_URL", params);
if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
SiteConfiguration.setSitePrimaryURL(adminSSOToken, siteName, siteURL);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-site-primary-url-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-site-primary-url-no-exists"), (Object[]) params));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_SITE_PRIMARY_URL", params);
} catch (SSOException e) {
String[] args = { siteName, siteURL, e.getMessage() };
debugError("SetSitePrimaryURL.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_PRIMARY_URL", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { siteName, siteURL, e.getMessage() };
debugError("SetSitePrimaryURL.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_PRIMARY_URL", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, siteURL, e.getMessage() };
debugError("SetSitePrimaryURL.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SITE_PRIMARY_URL", 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 CloneServer 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 cloneServerName = getStringOptionValue(CLONE_NAME);
String[] params = { serverName, cloneServerName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CLONE_SERVER", params);
if (ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
if (ServerConfiguration.isServerInstanceExist(adminSSOToken, cloneServerName)) {
outputWriter.printlnMessage(getResourceString("clone-server-exists"));
} else {
ServerConfiguration.cloneServerInstance(adminSSOToken, serverName, cloneServerName);
outputWriter.printlnMessage(getResourceString("clone-server-succeeded"));
}
} else {
outputWriter.printlnMessage(getResourceString("clone-server-no-exists"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_CLONE_SERVER", params);
} catch (ConfigurationException e) {
String[] args = { serverName, e.getMessage() };
debugError("CreateServer.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CLONE_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_CLONE_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_CLONE_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 SitesResourceProvider method deleteInstance.
@Override
public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, String id, DeleteRequest request) {
ResourceResponse site;
SSOToken token;
try {
token = getSsoToken(context);
site = getSite(token, id);
} catch (SMSException | SSOException | ConfigurationException e) {
debug.error("Could not read site {}", id, e);
return new InternalServerErrorException("Could not read site").asPromise();
} catch (NotFoundException e) {
return e.asPromise();
}
try {
if (!site.getRevision().equals(request.getRevision())) {
return new PreconditionFailedException("Revision did not match").asPromise();
} else if (!SiteConfiguration.listServers(token, id).isEmpty()) {
return new PreconditionFailedException("Site still has servers attached to it").asPromise();
} else if (!SiteConfiguration.deleteSite(token, id)) {
return new InternalServerErrorException("Could not delete site: " + id).asPromise();
} else {
return newResultPromise(site);
}
} catch (SSOException | SMSException | ConfigurationException e) {
debug.error("Could not delete site {}", id, e);
return new InternalServerErrorException("Could not delete site").asPromise();
}
}
Aggregations