public void add(Class<?> resourceType, Class<?> collectionType, Class<? extends BaseResource> parentType) { put(parentType, new Collection(resourceType, collectionType, parentType)); } }
protected void removeSubResource(String id) { synchronized (resources) { resources.remove(id); } }
/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param clz the individual return type expected from the query * @param typePrefix true if return type prefix is to be included * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, Class<?> clz, boolean typePrefix) { return getConstraint(uriInfo, null, clz, typePrefix); }
/** * Create a #UriBuilder which encapsulates the path to an object * * i.e. for a VM tag, return a UriBuilder which encapsulates * '/rhevm-api/vms/{vm_id}/tags/{tag_id}' * * @param uriInfo the URI info * @param model the object * @return the #UriBuilder encapsulating the object's path */ public static <R extends BaseResource> UriBuilder getUriBuilder(UriInfo uriInfo, R model) { return getUriBuilder(uriInfo, model, null); }
/** * Set the href attribute on the object (and its inline objects) * and construct its set of action links * * @param uriInfo the URI info * @param model the object * @param suggestedParentType the suggested parent type * @return the object, with href attributes and action links */ public static <R extends BaseResource> R addLinks(UriInfo uriInfo, R model) { return addLinks(uriInfo, model, null); }
public AbstractActionableResource(String id, Executor executor) { super(id); this.executor = executor; actions = new ReapedMap<String, ActionResource>(REAP_AFTER); }
/** * Validate presence of required parameters. * Note the model type is java.lang.Object as opposed to a generic * <T extends BaseResource> in order to accommodate parameters types * such as Action. * * @param model the incoming representation * @param required the required field names * @throws WebApplicationException wrapping an appropriate response * iff a required parameter is missing */ public static void validateParameters(Object model, String... required) { validateParameters(INCOMPLETE_PARAMS_REASON, INCOMPLETE_PARAMS_DETAIL, model, 2, required); }
/** * Create a new instance of the resource * * @return a newly constructed instance */ protected R newModel() { return ReflectionHelper.newModel(this); }
/** * Impose immutability constraints. * * @param <T> representation type * @param strict array of strictly immutable field names * @param incoming incoming representation * @param existing existing representation * @return error Response if appropriate */ public static <T extends BaseResource> Response imposeConstraints(String[] strict, T incoming, T existing) { return imposeConstraints(strict, incoming, existing, BROKEN_CONSTRAINT_REASON, BROKEN_CONSTRAINT_DETAIL); }
/** * Lookup the #Collection instance which represents this object * * i.e. for a VM tag (i.e. a Tag object which its VM property set) * return the #Collection instance which encapsulates AssignedTagResource, * AssignedTagsResource and VM. * * @param model the object to query for * @return the #Collection instance representing the object's collection */ private static Collection getCollection(BaseResource model) { return getCollection(model, null); }
public ParentToCollectionMap(Class<?> resourceType, Class<?> collectionType, Class<? extends BaseResource> parentType) { super(); add(resourceType, collectionType, parentType); }
/** * Set the href attribute on the supplied object * * e.g. set href = '/rhevm-api/vms/{vm_id}/tags/{tag_id}' on a VM tag * * @param uriInfo the URI info * @param model the object * @return the model, with the href attribute set */ private static <R extends BaseResource> void setHref(UriInfo uriInfo, R model) { setHref(uriInfo, model, null); }
private static boolean assertFields(Object model, String fields) { return assertFields(model, null, fields); }
/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param clz the individual return type expected from the query * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, Class<?> clz) { return getConstraint(uriInfo, null, clz); }
public AbstractActionableResource(String id, Executor executor, UriInfoProvider uriProvider) { super(id); this.executor = executor; this.uriProvider = uriProvider; actions = new ReapedMap<String, ActionResource>(REAP_AFTER); }
/** * Extract constraint from query parameters. * * @param uriInfo contains query parameters if set * @param defaultQuery raw query to use if not present in URI parameters * @param clz the individual return type expected from the query * @return constraint in correct format */ public static String getConstraint(UriInfo uriInfo, String defaultQuery, Class<?> clz) { return getConstraint(uriInfo, defaultQuery, clz, true); }