Package org.alfresco.rest.framework.core
Class ResourceInspector
java.lang.Object
org.alfresco.rest.framework.core.ResourceInspector
Looks at resources to see what they can do
- Author:
- Gethin James, janv
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindEmbeddedResources
(Class<?> anyClass) For a given class, looks for @EmbeddedEntityResource annotations, using the annotation produce a Map of the property name key and the entity keystatic String
Finds the name of the entity collection using the meta information.protected static String
findEntityName
(EntityResource entityAnnot) Finds the name of the entity using its annotation.protected static String
findEntityNameByAnnotationAttributes
(Map<String, Object> annotAttribs) Finds the name of the entity using its annotation.static Method
findMethod
(Class<? extends ResourceAction> resourceInterfaceWithOneMethod, Class<?> resource) Returns the method for the interfacestatic String
findUniqueId
(Object obj) Finds the unique id of an object using the @UniqueId annotation.static Method
findUniqueIdMethod
(Class<?> objClass) Finds a single method with the @UniqueId annotation.static String
findUniqueIdName
(Method uniqueIdMethod) Finds the property name that is used as the unique id.static List<ResourceMetadata>
Inspects the annotated resource to understand its capabilitiesstatic void
inspectAddressedProperties
(Api api, Class<?> resource, String entityPath, List<ResourceMetadata> metainfo) Inspects the entity resource and returns meta data about any addresssed/binary propertiesstatic Api
inspectApi
(Class<?> resource) Inspects the resource to determine what api it belongs to.static ResourceOperation
inspectOperation
(Class<?> resource, Method aMethod, org.springframework.http.HttpMethod httpMethod) Inspects the method and returns meta data about its operationsstatic void
inspectOperations
(Api api, Class<?> resource, String entityPath, List<ResourceMetadata> metainfo) Inspect a resource to find operations on it.static boolean
Returns true if the method has been marked as deleted.static boolean
Returns true if the method has been marked as no auth required.static int
validSuccessCode
(org.springframework.http.HttpMethod httpMethod, int success)
-
Constructor Details
-
ResourceInspector
public ResourceInspector()
-
-
Method Details
-
inspectAddressedProperties
public static void inspectAddressedProperties(Api api, Class<?> resource, String entityPath, List<ResourceMetadata> metainfo) Inspects the entity resource and returns meta data about any addresssed/binary properties- Parameters:
api
- ApientityPath
- String
-
inspectOperation
public static ResourceOperation inspectOperation(Class<?> resource, Method aMethod, org.springframework.http.HttpMethod httpMethod) Inspects the method and returns meta data about its operations- Parameters:
aMethod
- MethodhttpMethod
- HttpMethod- Returns:
- ResourceOperation
-
validSuccessCode
public static int validSuccessCode(org.springframework.http.HttpMethod httpMethod, int success) -
isDeleted
Returns true if the method has been marked as deleted.- Parameters:
method
- the method- Returns:
- true - if is is marked as deleted.
-
isNoAuth
Returns true if the method has been marked as no auth required.- Parameters:
method
- the method- Returns:
- true - if is is marked as no auth required.
-
findMethod
public static Method findMethod(Class<? extends ResourceAction> resourceInterfaceWithOneMethod, Class<?> resource) Returns the method for the interface- Returns:
- null or a Method
-
findEntityNameByAnnotationAttributes
Finds the name of the entity using its annotation.- Returns:
- the entity name/path
-
findEntityName
Finds the name of the entity using its annotation.- Parameters:
entityAnnot
- EntityResource- Returns:
- the entity name/path
-
findEntityCollectionNameName
Finds the name of the entity collection using the meta information.- Parameters:
meta
- ResourceMetadata- Returns:
- the entity name/path
-
findEmbeddedResources
For a given class, looks for @EmbeddedEntityResource annotations, using the annotation produce a Map of the property name key and the entity key- Returns:
- A map of property key name and a value of the entity path name
-
inspectOperations
public static void inspectOperations(Api api, Class<?> resource, String entityPath, List<ResourceMetadata> metainfo) Inspect a resource to find operations on it.- Parameters:
api
- ApientityPath
- Stringmetainfo
- resource metadata
-
inspectApi
Inspects the resource to determine what api it belongs to. It does this by looking for the WebApi package annotation.- Returns:
- Api
-
inspect
Inspects the annotated resource to understand its capabilities- Parameters:
resource
- Class
-
findUniqueId
Finds the unique id of an object using the @UniqueId annotation.- Parameters:
obj
- any object- Returns:
- a String object with the entity id set
-
findUniqueIdMethod
Finds a single method with the @UniqueId annotation.- Parameters:
objClass
- any object class- Returns:
- the Method
- Throws:
IllegalArgumentException
- if there is is more than 1 method annotated with @UniqueId
-
findUniqueIdName
Finds the property name that is used as the unique id.- Parameters:
uniqueIdMethod
- Method- Returns:
- String the property name that is used as the unique id.
-