ConditionTypesResource.java revision 41c1067de1a5fa74255d311e5362548ae41f9a04
/*
* 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 2014 ForgeRock AS.
*/
/**
* Allows for CREST-handling of stored {@link EntitlementCondition}s.
*
* These are unmodfiable - even by an administrator. As such this
* endpoint only supports the READ and QUERY operations.
*/
public class ConditionTypesResource implements CollectionResourceProvider {
private final static ObjectMapper mapper = new ObjectMapper().withModule(new JsonEntitlementConditionModule());
private final EntitlementRegistry entitlementRegistry;
/**
* Guiced constructor.
*
* @param debug Debug instance
* @param entitlementRegistry from which to locate condition types. Cannot be null.
*/
public ConditionTypesResource(@Named("frRest") Debug debug, EntitlementRegistry entitlementRegistry) {
}
/**
* Unsupported by this endpoint.
*/
public void actionCollection(ServerContext context, ActionRequest request, ResultHandler<JsonValue> handler) {
}
/**
* Unsupported by this endpoint.
*/
}
/**
* Unsupported by this endpoint.
*/
public void createInstance(ServerContext context, CreateRequest request, ResultHandler<Resource> handler) {
}
/**
* Unsupported by this endpoint.
*/
}
/**
* Unsupported by this endpoint.
*/
}
/**
* Unsupported by this endpoint.
*/
}
/**
* {@inheritDoc}
*
* Uses the {@link EntitlementRegistry} to locate the {@link EntitlementCondition}s to return.
*
* Looks up all the names of conditions registered in the system, and then returns each one to the
* result handler having determined its schema and jsonified it.
*/
public void queryCollection(ServerContext context, QueryRequest request, QueryResultHandler handler) {
if (conditionClass == null) {
if (debug.warningEnabled()) {
": Requested condition short name not found: " + conditionTypeName);
}
continue;
}
}
}
int remaining = 0;
remaining--;
if (debug.messageEnabled()) {
": Added resource to response: " + id);
}
if (!keepGoing) {
break;
}
}
}
}
/**
* {@inheritDoc}
*
* Uses the {@link EntitlementRegistry} to locate the {@link EntitlementCondition} to return.
*/
final Class<? extends EntitlementCondition> conditionClass = entitlementRegistry.getConditionType(resourceId);
if (conditionClass == null) {
if (debug.errorEnabled()) {
": Requested condition short name not found: " + resourceId);
}
return;
}
final Resource resource = new Resource(resourceId, String.valueOf(System.currentTimeMillis()), json);
}
/**
* Transforms a subclass of {@link EntitlementCondition} in to a JsonSchema representation.
* This schema is then combined with the Condition's name (taken as the resourceId) and all this is
* compiled together into a new {@link JsonValue} object until "title" and "config" fields respectively.
*
* @param conditionClass The class whose schema to produce.
* @param resourceId The ID of the resource to return
* @return A JsonValue containing the schema of the EntitlementCondition
*/
boolean logical) {
try {
//this will remove the 'name' attribute from those conditions which incorporate it unnecessarily
if (node instanceof ObjectNode) {
}
} catch (JsonMappingException e) {
if (debug.errorEnabled()) {
"jsonification to the Condition class representation.", e);
}
return null;
}
}
}