ScriptResource.java revision 16682c615640da7d54591f86528a5eb562e0ab97
/*
* 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 REST endpoint for managing scripts in OpenAM.
*
* @since 13.0.0
*/
public class ScriptResource extends RealmAwareResource {
private final ScriptingServiceFactory serviceFactory;
private final ScriptValidator scriptValidator;
/**
* Creates an instance of the {@code ScriptResource}.
*
* @param scriptConfigService An instance of the {@code ScriptConfigurationService}.
* @param exceptionMappingHandler An instance of the {@code ExceptionMappingHandler}.
*/
this.serviceFactory = scriptConfigService;
this.scriptValidator = scriptValidator;
}
public Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request) {
try {
throw new ScriptException(MISSING_SCRIPT);
}
if (scriptErrorList.isEmpty()) {
}
}
return newResultPromise(newActionResponse(json(object(field("success", false), field("errors", errors)))));
} catch (ScriptException se) {
}
} else {
return new NotSupportedException().asPromise();
}
}
public Promise<ActionResponse, ResourceException> actionInstance(Context context, String resourceId,
return new NotSupportedException().asPromise();
}
public Promise<ResourceResponse, ResourceException> patchInstance(Context context, String resourceId,
return new NotSupportedException().asPromise();
}
public Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request) {
try {
return newResultPromise(newResourceResponse(sc.getId(), String.valueOf(sc.hashCode()), asJson(sc)));
} catch (ScriptException se) {
}
}
public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, String resourceId,
try {
} catch (ScriptException se) {
}
}
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request,
try {
} else {
new QueryByStringFilterConverter(), null);
configs = serviceFactory.create(getContextSubject(context), getRealm(context)).get(stringQueryFilter);
}
}
return QueryResponsePresentation.perform(resultHandler, request, results, new JsonPointer(JSON_UUID));
} catch (ScriptException se) {
}
}
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId,
try {
} catch (ScriptException se) {
}
}
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId,
try {
} catch (ScriptException se) {
}
}
/**
* Convert the {@code ScriptConfiguration} into a {@code JsonValue} instance.
* @param scriptConfig The {@code ScriptConfiguration}.
* @return The {@code JsonValue}.
*/
}
/**
* Convert the {@code JsonValue} into a {@code ScriptConfiguration} instance.
* If the given UUID is {@code null} a new one will be generated.
* @param jsonValue The {@code JsonValue}.
* @param uuid The UUID for an existing script configuration.
* @return The {@code ScriptConfiguration}.
* @throws ScriptException When the given JSON value does not represent a script configuration.
*/
}
}
/**
* Convert the {@code JsonValue} into a {@code ScriptConfiguration} instance. The UUID for the script
* configuration will be generated.
* @param jsonValue The {@code JsonValue}.
* @return The {@code ScriptConfiguration}.
* @throws ScriptException When the given JSON does not represent a script configuration.
*/
}
if (encodedScript == null) {
return null;
}
if (decodedScript == null) {
}
}
}