use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class DeleteService 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();
boolean continueFlag = isOptionSet(IArgument.CONTINUE);
IOutput outputWriter = getOutputWriter();
List serviceNames = (List) rc.getOption(IArgument.SERVICE_NAME);
ServiceManager ssm = null;
boolean bError = false;
try {
ssm = new ServiceManager(adminSSOToken);
} catch (SMSException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
for (Iterator i = serviceNames.iterator(); i.hasNext(); ) {
String name = (String) i.next();
String[] param = { name };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_SERVICE", param);
deleteService(rc, ssm, name, adminSSOToken);
outputWriter.printlnMessage(getResourceString("service-deleted"));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCESS_DELETE_SERVICE", param);
} catch (CLIException e) {
bError = true;
if (continueFlag) {
outputWriter.printlnError(getResourceString("service-deletion-failed") + e.getMessage());
if (isVerbose()) {
outputWriter.printlnError(Debugger.getStackTrace(e));
}
} else {
throw e;
}
}
}
if (bError) {
throw new CLIException(getResourceString("one-or-more-services-not-deleted"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class DeleteSubConfiguration method deleteSubConfigFromRealm.
private void deleteSubConfigFromRealm(String realmName, String serviceName, String subConfigName) throws CLIException {
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String[] params = { realmName, subConfigName, serviceName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_SUB_CONFIGURATION_TO_REALM", params);
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
ServiceConfig sc = scm.getOrganizationConfig(realmName, null);
if (sc == null) {
sc = scm.createOrganizationConfig(realmName, null);
}
deleteSubConfig(sc, subConfigName);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_SUB_CONFIGURATION_TO_REALM", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("delete-sub-configuration-to-realm-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
debugError("DeleteSubConfiguration.deleteSubConfigFromRealm", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SUB_CONFIGURATIONT_TO_REALM", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
debugError("DeleteSubConfiguration.deleteSubConfigFromRealm", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SUB_CONFIGURATIONT_TO_REALM", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class ModifyAttributeSchemaAny 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();
String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
String any = getStringOptionValue(ARGUMENT_ANY);
ServiceSchema ss = getServiceSchema();
IOutput outputWriter = getOutputWriter();
try {
String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, any };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ATTRIBUTE_SCHEMA_ANY", params);
AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
if (attrSchema == null) {
String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, any, "attribute schema does not exist" };
attributeSchemaNoExist(attributeSchemaName, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_ANY", args);
}
attrSchema.setAny(any);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_ATTRIBUTE_SCHEMA_ANY", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-modify-any-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, any, e.getMessage() };
debugError("ModifyAttributeSchemaAny.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_ANY", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, any, e.getMessage() };
debugError("ModifyAttributeSchemaAny.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_ANY", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class ModifyAttributeSchemaType 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();
String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
String type = getStringOptionValue(ARGUMENT_TYPE);
ServiceSchema ss = getServiceSchema();
IOutput outputWriter = getOutputWriter();
try {
String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, type };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ATTRIBUTE_SCHEMA_TYPE", params);
AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
if (attrSchema == null) {
String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, type, "attribute schema does not exist" };
attributeSchemaNoExist(attributeSchemaName, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_TYPE", args);
}
attrSchema.setType(type);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_ATTRIBUTE_SCHEMA_TYPE", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-modify-type-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, type, e.getMessage() };
debugError("ModifyAttributeSchemaType.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_TYPE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, type, e.getMessage() };
debugError("ModifyAttributeSchemaType.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_TYPE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class GetServiceRevisionNumber method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
ServiceSchemaManager ssm = getServiceSchemaManager();
IOutput outputWriter = getOutputWriter();
String[] params = { serviceName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SERVICE_REVISION_NUMBER", params);
String revisionNumber = Integer.toString(ssm.getRevisionNumber());
String[] args = { serviceName, revisionNumber };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("service-schema-get-revision-number-succeed"), (Object[]) args));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SERVICE_REVISION_NUMBER", params);
}
Aggregations