use of org.forgerock.json.resource.NotFoundException in project OpenAM by OpenRock.
the class SitesResourceProvider method queryCollection.
@Override
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) {
if (!"true".equals(request.getQueryFilter().toString())) {
return new BadRequestException("Query only supports 'true' filter").asPromise();
}
try {
SSOToken token = getSsoToken(context);
Set<String> siteNames = SiteConfiguration.getSites(token);
for (String siteName : siteNames) {
handler.handleResource(getSite(token, siteName));
}
return newResultPromise(newQueryResponse());
} catch (SSOException | SMSException | ConfigurationException e) {
debug.error("Could not read sites", e);
return new InternalServerErrorException("Could not read sites").asPromise();
} catch (NotFoundException e) {
debug.error("Could not read site", e);
return new InternalServerErrorException("Could not read site we've just got name for").asPromise();
}
}
use of org.forgerock.json.resource.NotFoundException in project OpenAM by OpenRock.
the class SmsCollectionProvider method updateInstance.
/**
* Updates a child instance of config. The parent config referenced by the request path is found, and
* the config is updated using the resourceId.
* {@inheritDoc}
*/
@Override
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request) {
JsonValue content = request.getContent();
String realm = realmFor(context);
try {
Map<String, Set<String>> attrs = converter.fromJson(realm, content);
ServiceConfigManager scm = getServiceConfigManager(context);
ServiceConfig config = parentSubConfigFor(context, scm);
ServiceConfig node = checkedInstanceSubConfig(context, resourceId, config);
node.setAttributes(attrs);
JsonValue result = getJsonValue(realm, node);
return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
} catch (ServiceNotFoundException e) {
debug.warning("::SmsCollectionProvider:: ServiceNotFoundException on update", e);
return new NotFoundException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SMSException e) {
debug.warning("::SmsCollectionProvider:: SMSException on update", e);
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
debug.warning("::SmsCollectionProvider:: SSOException on update", e);
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (ResourceException e) {
return e.asPromise();
}
}
use of org.forgerock.json.resource.NotFoundException in project OpenAM by OpenRock.
the class SitesResourceProvider method readInstance.
@Override
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String id, ReadRequest request) {
try {
SSOToken token = getSsoToken(context);
ResourceResponse site = getSite(token, id);
return newResultPromise(site);
} catch (SMSException | SSOException | ConfigurationException e) {
debug.error("Could not read site {}", id, e);
return new InternalServerErrorException("Could not read site").asPromise();
} catch (NotFoundException e) {
return e.asPromise();
}
}
use of org.forgerock.json.resource.NotFoundException 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 org.forgerock.json.resource.NotFoundException 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