use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class BulkFederation method handleIDFFRequest.
private void handleIDFFRequest(BufferedWriter out) throws CLIException {
Map userIdMapping = getUserIdMapping(userIdMappingFileName);
for (Iterator i = userIdMapping.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
String localUserId = (String) e.getKey();
String remoteUserId = (String) e.getValue();
idffFederateUser(localUserId, remoteUserId, out);
}
IOutput outputWriter = getOutputWriter();
outputWriter.printlnMessage(getResourceString("bulk-federation-succeeded"));
}
use of com.sun.identity.cli.IOutput 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);
}
}
use of com.sun.identity.cli.IOutput 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.cli.IOutput in project OpenAM by OpenRock.
the class ListSites 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();
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_SITES", null);
Set sites = SiteConfiguration.getSites(adminSSOToken);
if ((sites != null) && !sites.isEmpty()) {
for (Iterator i = sites.iterator(); i.hasNext(); ) {
outputWriter.printlnMessage((String) i.next());
}
} else {
outputWriter.printlnMessage(getResourceString("list-sites-no-instances"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_LIST_SITES", null);
} catch (SSOException e) {
String[] args = { e.getMessage() };
debugError("ListSites.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_SITES", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { e.getMessage() };
debugError("ListSites.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_SITES", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class RemoveServerConfig 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);
List propertyNames = rc.getOption(IArgument.PROPERTY_NAMES);
try {
String[] params = { serverName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_REMOVE_SERVER_CONFIG", params);
if (serverName.equals(DEFAULT_SVR_CONFIG)) {
ServerConfiguration.removeServerConfiguration(adminSSOToken, ServerConfiguration.DEFAULT_SERVER_CONFIG, propertyNames);
} else {
if (ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
ServerConfiguration.removeServerConfiguration(adminSSOToken, serverName, propertyNames);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("remove-server-config-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("remove-server-config-does-not-exists"), (Object[]) params));
}
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_REMOVE_SERVER_CONFIG", params);
} catch (IOException e) {
String[] args = { serverName, e.getMessage() };
debugError("RemoveServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { serverName, e.getMessage() };
debugError("RemoveServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serverName, e.getMessage() };
debugError("RemoveServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations