use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.
the class AddSiteFailoverURLs 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_ADD_SITE_FAILOVER_URLS", params);
if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
SiteConfiguration.addSiteSecondaryURLs(adminSSOToken, siteName, secondaryURLs);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-site-secondary-urls-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-site-secondary-urls-no-exists"), (Object[]) params));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SITE_FAILOVER_URLS", params);
} catch (SSOException e) {
String[] args = { siteName, e.getMessage() };
debugError("AddSiteFailoverURLs.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { siteName, e.getMessage() };
debugError("AddSiteFailoverURLs.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, e.getMessage() };
debugError("AddSiteFailoverURLs.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_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 AddSiteMembers method handleRequest.
/**
* Adds members to a site.
*
* @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();
String siteName = getStringOptionValue(IArgument.SITE_NAME);
List serverNames = (List) rc.getOption(IArgument.SERVER_NAMES);
IOutput outputWriter = getOutputWriter();
try {
String[] params = { siteName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SITE_MEMBERS", params);
if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
SiteConfiguration.addServersToSite(adminSSOToken, siteName, serverNames);
outputWriter.printlnMessage(getResourceString("add-site-members-succeeded"));
} else {
outputWriter.printlnMessage(getResourceString("add-site-members-site-not-exist"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SITE_MEMBERS", params);
} catch (ConfigurationException e) {
String[] args = { siteName, e.getMessage() };
debugError("AddSiteMembers.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { siteName, e.getMessage() };
debugError("AddSiteMembers.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, e.getMessage() };
debugError("AddSiteMembers.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", 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 AddAgentsToGroup 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);
List agentNames = rc.getOption(IArgument.AGENT_NAMES);
String[] params = { realm, agentGroupName, "" };
String agentName = "";
try {
AMIdentity amidGroup = new AMIdentity(adminSSOToken, agentGroupName, IdType.AGENTGROUP, realm, null);
for (Iterator i = agentNames.iterator(); i.hasNext(); ) {
agentName = (String) i.next();
params[2] = agentName;
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_AGENT_TO_GROUP", params);
AMIdentity amid = new AMIdentity(adminSSOToken, agentName, IdType.AGENTONLY, realm, null);
AgentConfiguration.AddAgentToGroup(amidGroup, amid);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_AGENT_TO_GROUP", params);
}
if (agentNames.size() > 1) {
outputWriter.printlnMessage(getResourceString("add-agent-to-group-succeeded-pural"));
} else {
outputWriter.printlnMessage(getResourceString("add-agent-to-group-succeeded"));
}
} catch (IdRepoException e) {
String[] args = { realm, agentGroupName, agentName, e.getMessage() };
debugError("AddAgentsToGroup.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AGENT_TO_GROUP", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { realm, agentGroupName, agentName, e.getMessage() };
debugError("AddAgentsToGroup.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AGENT_TO_GROUP", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { realm, agentGroupName, agentName, e.getMessage() };
debugError("AddAgentsToGroup.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AGENT_TO_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 ShowSiteMembers method handleRequest.
/**
* Display members of a site.
*
* @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();
String siteName = getStringOptionValue(IArgument.SITE_NAME);
String[] params = { siteName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_SITE_MEMBERS", params);
IOutput outputWriter = getOutputWriter();
try {
Set members = SiteConfiguration.listServers(adminSSOToken, siteName);
if ((members != null) && !members.isEmpty()) {
for (Iterator i = members.iterator(); i.hasNext(); ) {
outputWriter.printlnMessage((String) i.next());
}
} else {
outputWriter.printlnMessage(getResourceString("show-site-members-no-members"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SHOW_SITE_MEMBERS", params);
} catch (ConfigurationException e) {
String[] args = { siteName, e.getMessage() };
debugError("ShowSiteMembers.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SHOW_SITE_MEMBERS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { siteName, e.getMessage() };
debugError("ShowSiteMembers.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SHOW_SITE_MEMBERS", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { siteName, e.getMessage() };
debugError("ShowSiteMembers.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SHOW_SITE_MEMBERS", 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 SetServerConfigXML method handleRequest.
/**
* Set Server Configuration XML.
*
* @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();
String serverName = getStringOptionValue(IArgument.SERVER_NAME);
String xmlFile = getStringOptionValue(IArgument.XML_FILE);
IOutput outputWriter = getOutputWriter();
try {
String[] params = { serverName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_SERVER_CONFIG_XML", params);
String xml = xmlFile;
boolean isWebEnabled = getCommandManager().webEnabled();
if (!isWebEnabled) {
xml = CLIUtil.getFileContent(getCommandManager(), xmlFile);
}
ServerConfiguration.setServerConfigXML(adminSSOToken, serverName, xml);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("set-serverconfig-xml-succeeded"), (Object[]) params));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_SERVER_CONFIG_XML", params);
} catch (SSOException e) {
String[] args = { serverName, e.getMessage() };
debugError("SetServerConfigXML.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVER_CONFIG_XML", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (ConfigurationException e) {
String[] args = { serverName, e.getMessage() };
debugError("SetServerConfigXML.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVER_CONFIG_XML", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serverName, e.getMessage() };
debugError("SetServerConfigXML.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVER_CONFIG_XML", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations