use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class ListEntities method handleIDFFRequest.
private void handleIDFFRequest(RequestContext rc) throws CLIException {
IOutput outputWriter = getOutputWriter();
Object[] objs = { realm };
try {
IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
Set entities = metaManager.getAllEntities(realm);
if ((entities == null) || entities.isEmpty()) {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-entities-no-entities"), objs));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-entities-entity-listing"), objs));
for (Iterator i = entities.iterator(); i.hasNext(); ) {
String name = (String) i.next();
outputWriter.printlnMessage(" " + name);
}
}
} catch (IDFFMetaException e) {
debugWarning("ListEntities.handleIDFFRequest", e);
String[] args = { realm, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_ENTITIES", args);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class AddPluginSchema 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();
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String interfaceName = getStringOptionValue(ARGUMENT_INTERFACE_NAME);
String pluginName = getStringOptionValue(ARGUMENT_PLUGIN_NAME);
String i18nKey = getStringOptionValue(ARGUMENT_I18N_KEY);
String i18nName = getStringOptionValue(ARGUMENT_I18N_NAME);
String className = getStringOptionValue(ARGUMENT_CLASS_NAME);
ServiceManager sm = null;
try {
sm = new ServiceManager(adminSSOToken);
} catch (SMSException smse) {
throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException ssoe) {
throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
IOutput outputWriter = getOutputWriter();
try {
String[] params = { serviceName, interfaceName, pluginName, i18nKey, i18nName, className };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_PLUGIN_SCHEMA", params);
Document pluginDoc = createPluginSchemaXML(serviceName, interfaceName, pluginName, i18nKey, i18nName, className);
if (pluginDoc != null) {
sm.addPluginSchema(pluginDoc);
String[] params2 = { serviceName, pluginName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_PLUGIN_SCHEMA", params2);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-succeed"), (Object[]) params));
} else {
String[] args = { serviceName, pluginName, "Null XML Document" };
debugError("AddPluginSchema.handleRequest:: Null XML Document");
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
throw new CLIException("Null XML Document", ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
} catch (SSOException ssoe) {
String[] args = { serviceName, pluginName, ssoe.getMessage() };
debugError("AddPluginSchema.handleRequest", ssoe);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-failed"), (Object[]) args));
throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException smse) {
String[] args = { serviceName, pluginName, smse.getMessage() };
debugError("AddPluginSchema.handleRequest", smse);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-failed"), (Object[]) args));
throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class GetAttributeSchemaChoiceValues method handleRequest.
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
String attributeName = getStringOptionValue(IArgument.ATTRIBUTE_NAME);
ServiceSchema ss = getServiceSchema();
IOutput outputWriter = getOutputWriter();
String[] params = { serviceName, schemaType, subSchemaName, attributeName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
if (attrSchema == null) {
String[] args = { serviceName, schemaType, subSchemaName, attributeName, "attribute schema does not exist" };
attributeSchemaNoExist(attributeName, "FAILED_GET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", args);
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
getOutputWriter().printlnMessage(FormatUtils.formatMap(getResourceString("attribute-schema-i18nkey"), getResourceString("attribute-schema-choice-value"), getChoiceValues(attrSchema)));
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class GetSubConfiguration method printGlobalSubConfig.
private void printGlobalSubConfig(String serviceName, String subConfigName) throws CLIException {
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String[] params = { subConfigName, serviceName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SUB_CONFIGURATION", params);
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
ServiceConfig sc = scm.getGlobalConfig(null);
printSubConfig(sc, subConfigName);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SUB_CONFIGURATION", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("get-sub-configuration-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { subConfigName, serviceName, e.getMessage() };
debugError("GetSubConfiguration.printGlobalSubConfig", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUB_CONFIGURATION", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { subConfigName, serviceName, e.getMessage() };
debugError("GetSubConfiguration.printGlobalSubConfig", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUB_CONFIGURATION", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class ShowApplicationType method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
String appTypeName = getStringOptionValue(PARAM_APPL_TYPE_NAME);
String[] params = { appTypeName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_APPLICATION_TYPE", params);
ApplicationType applType = ApplicationTypeManager.getAppplicationType(getAdminSubject(), appTypeName);
IOutput writer = getOutputWriter();
if (applType == null) {
Object[] param = { appTypeName };
writer.printlnMessage(MessageFormat.format(getResourceString("show-application-type-not-found"), param));
} else {
displayAttrs(writer, applType);
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SHOW_APPLICATION_TYPE", params);
}
Aggregations