/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
/**
* A CREST singleton provider for SMS schema config.
* @since 13.0.0
*/
SmsSingletonProvider(@Assisted SmsJsonConverter converter, @Assisted("schema") ServiceSchema schema,
Reject.ifTrue(type != SchemaType.GLOBAL && type != SchemaType.ORGANIZATION, "Unsupported type: " + type);
this.dynamicSchema = dynamicSchema;
if (dynamicSchema != null) {
} else {
this.dynamicConverter = null;
}
}
/**
* Reads config for the singleton instance referenced, and returns the JsonValue representation.
* {@inheritDoc}
*/
try {
return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
} catch (SMSException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (NotFoundException e) {
return e.asPromise();
}
}
}
/**
* Augments the provided {@code JsonValue} to include any dynamic attributes, if present.
*
* @param value The {@code JsonValue} to augment.
* @return The same {@code JsonValue} after is has been augmented.
*/
if (dynamicConverter != null) {
}
return value;
}
private void updateDynamicAttributes(Context context, JsonValue value) throws SMSException, SSOException,
} else {
}
}
/**
* Updates config for the singleton instance referenced, and returns the JsonValue representation.
* {@inheritDoc}
*/
if (dynamicSchema != null) {
try {
} catch (SMSException e) {
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (IdRepoException e) {
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (ResourceException e) {
return e.asPromise();
}
}
try {
return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
} catch (SMSException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (ResourceException e) {
return e.asPromise();
}
}
/**
* Deletes config for the singleton instance referenced.
* {@inheritDoc}
*/
try {
if (subSchemaPath.isEmpty()) {
} else {
}
} else {
}
return newResultPromise(newResourceResponse(resourceId(), "0", json(object(field("success", true)))));
} catch (SMSException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
}
}
/**
* Creates config for the singleton instance referenced, and returns the JsonValue representation.
* {@inheritDoc}
*/
try {
if (subSchemaPath.isEmpty()) {
} else {
}
} else {
}
return newResultPromise(newResourceResponse(resourceId(), String.valueOf(result.hashCode()), result));
} catch (SMSException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
} catch (ResourceException e) {
return e.asPromise();
}
}
public Promise<ActionResponse, ResourceException> handleAction(Context context, ActionRequest request) {
}
if (dynamicSchema != null) {
}
}
return result;
}
/**
* Gets the referenced {@link ServiceConfig} for the current request.
* @param serverContext The request context.
* @param resourceId The name of the config. If this is root Schema config, this will be null. Otherwise, it will
* be the name of the schema type.
* @return The instance retrieved from the service manager layer.
* @throws SMSException From downstream service manager layer.
* @throws SSOException From downstream service manager layer.
* @throws NotFoundException If the config being addressed doesn't exist.
*/
protected ServiceConfig getServiceConfigNode(Context serverContext, String resourceId) throws SSOException,
if (subSchemaPath.isEmpty()) {
} else {
throw new NotFoundException();
}
}
} else {
throw new NotFoundException();
}
}
return result;
}
/**
* Gets the referenced global {@link ServiceConfig} for the current request.
*
* @param scm The {@code ServerConfigManager} instance.
* @param resourceId The name of the config. If this is root Schema config, this will be null. Otherwise, it will
* be the name of the schema type.
* @return The global instance retrieved from the service manager layer.
* @throws SMSException From downstream service manager layer.
* @throws SSOException From downstream service manager layer.
* @throws NotFoundException If the config being addressed doesn't exist.
*/
protected ServiceConfig getGlobalConfigNode(ServiceConfigManager scm, String resourceId) throws SSOException,
throw new NotFoundException();
}
return result;
}
} else {
}
}
return value;
}
private Map<String, Set<String>> convertFromJson(JsonValue value, String realm) throws ResourceException {
}
protected void saveConfigAttributes(ServiceConfig config, Map<String, Set<String>> attributes) throws SSOException,
}
}
/**
* Gets the resource ID. For root Schema config, this will be null. Otherwise, it will be the name of the schema
* type this provider addresses.
*/
}
public Promise<QueryResponse, ResourceException> handleQuery(Context serverContext, QueryRequest queryRequest,
}
}
}