use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class ModifySubConfiguration method modifySubConfigRoot.
private void modifySubConfigRoot(String serviceName, String subConfigName, Map attrValues, String operation) throws CLIException {
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String[] params = { subConfigName, serviceName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_SUB_CONFIGURATION", params);
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
ServiceConfig sc = scm.getGlobalConfig(null);
modifySubConfig(sc, subConfigName, attrValues, operation);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_SUB_CONFIGURATION", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("modify-sub-configuration-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { subConfigName, serviceName, e.getMessage() };
debugError("ModifySubConfiguration.addSubConfigToRoot", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_SUB_CONFIGURATION", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { subConfigName, serviceName, e.getMessage() };
debugError("ModifySubConfiguration.addSubConfigToRoot", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_SUB_CONFIGURATION", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class UpdateService method deleteService.
private void deleteService(RequestContext rc, ServiceManager ssm, String serviceName, SSOToken adminSSOToken) throws CLIException {
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
if (scm.getGlobalConfig(null) != null) {
scm.removeGlobalConfiguration(null);
}
ssm.deleteService(serviceName);
} catch (SSOException e) {
String[] args = { serviceName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_DELETE_SERVICE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serviceName, e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_DELETE_SERVICE", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SmsCollectionProvider method queryCollection.
/**
* Queries for child instances of config. The parent config referenced by the request path is found, and
* all child config for the type is returned.
* <p>
* Note that only query filter is supported, and only a filter of value {@code true} (i.e. all values).
* Sorting and paging are not supported.
* {@inheritDoc}
*/
@Override
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) {
if (!"true".equals(request.getQueryFilter().toString())) {
return new NotSupportedException("Query not supported: " + request.getQueryFilter()).asPromise();
}
if (request.getPagedResultsCookie() != null || request.getPagedResultsOffset() > 0 || request.getPageSize() > 0) {
return new NotSupportedException("Query paging not currently supported").asPromise();
}
try {
ServiceConfigManager scm = getServiceConfigManager(context);
String realm = realmFor(context);
if (subSchemaPath.isEmpty()) {
Set<String> instanceNames = new TreeSet<String>(scm.getInstanceNames());
for (String instanceName : instanceNames) {
ServiceConfig config = type == SchemaType.GLOBAL ? scm.getGlobalConfig(instanceName) : scm.getOrganizationConfig(realm, instanceName);
if (config != null) {
JsonValue value = getJsonValue(realm, config);
handler.handleResource(newResourceResponse(instanceName, String.valueOf(value.hashCode()), value));
}
}
} else {
ServiceConfig config = parentSubConfigFor(context, scm);
Set<String> names = config.getSubConfigNames("*", lastSchemaNodeName());
for (String configName : names) {
JsonValue value = getJsonValue(realm, config.getSubConfig(configName));
handler.handleResource(newResourceResponse(configName, String.valueOf(value.hashCode()), value));
}
}
return newResultPromise(newQueryResponse());
} catch (SMSException e) {
debug.warning("::SmsCollectionProvider:: SMSException on query", e);
return new InternalServerErrorException("Unable to query SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
debug.warning("::SmsCollectionProvider:: SSOException on query", e);
return new InternalServerErrorException("Unable to query SMS config: " + e.getMessage()).asPromise();
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SmsCollectionProvider method readInstance.
/**
* Reads a child instance of config. The parent config referenced by the request path is found, and
* the config is read using the resourceId.
* {@inheritDoc}
*/
@Override
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId, ReadRequest request) {
try {
ServiceConfigManager scm = getServiceConfigManager(context);
ServiceConfig config = parentSubConfigFor(context, scm);
ServiceConfig item = checkedInstanceSubConfig(context, resourceId, config);
JsonValue result = getJsonValue(realmFor(context), item);
return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
} catch (SMSException e) {
debug.warning("::SmsCollectionProvider:: SMSException on read", e);
return new InternalServerErrorException("Unable to read SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
debug.warning("::SmsCollectionProvider:: SSOException on read", e);
return new InternalServerErrorException("Unable to read SMS config: " + e.getMessage()).asPromise();
} catch (NotFoundException e) {
return e.asPromise();
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SmsCollectionProvider method deleteInstance.
/**
* Deletes a child instance of config. The parent config referenced by the request path is found, and
* the config is deleted using the resourceId.
* {@inheritDoc}
*/
@Override
public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, final String resourceId, DeleteRequest request) {
try {
ServiceConfigManager scm = getServiceConfigManager(context);
ServiceConfig config = parentSubConfigFor(context, scm);
checkedInstanceSubConfig(context, resourceId, config);
if (isDefaultCreatedAuthModule(context, resourceId)) {
scm.removeOrganizationConfiguration(realmFor(context), null);
} else {
config.removeSubConfig(resourceId);
}
return awaitDeletion(context, resourceId).then(new Function<Void, ResourceResponse, ResourceException>() {
@Override
public ResourceResponse apply(Void aVoid) {
return newResourceResponse(resourceId, "0", json(object(field("success", true))));
}
});
} catch (ServiceNotFoundException e) {
debug.warning("::SmsCollectionProvider:: ServiceNotFoundException on delete", e);
return new NotFoundException("Unable to delete SMS config: " + e.getMessage()).asPromise();
} catch (SMSException e) {
debug.warning("::SmsCollectionProvider:: SMSException on delete", e);
return new InternalServerErrorException("Unable to delete SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
debug.warning("::SmsCollectionProvider:: SSOException on delete", e);
return new InternalServerErrorException("Unable to delete SMS config: " + e.getMessage()).asPromise();
} catch (NotFoundException e) {
return e.asPromise();
}
}
Aggregations