From 754269a75136af5cb1073a9811531a230c7a2aba Mon Sep 17 00:00:00 2001 From: Ancuta Morarasu Date: Wed, 11 May 2016 11:46:04 +0000 Subject: [PATCH] Merged HEAD (5.2) to 5.2.N (5.2.1) 126503 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122758 gjames: RA-211: Added new interface for WithResponse. Revert>Java7 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126847 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../interfaces/BinaryResourceAction.java | 52 +++++++++++++++- .../interfaces/EntityResourceAction.java | 59 +++++++++++++++++-- .../RelationshipResourceAction.java | 56 ++++++++++++++++-- .../RelationshipResourceBinaryAction.java | 55 ++++++++++++++++- 4 files changed, 208 insertions(+), 14 deletions(-) diff --git a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/BinaryResourceAction.java b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/BinaryResourceAction.java index 99b57c0670..4b73d78f4e 100755 --- a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/BinaryResourceAction.java +++ b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/BinaryResourceAction.java @@ -33,6 +33,7 @@ import org.alfresco.rest.framework.resource.content.BinaryResource; import org.alfresco.rest.framework.resource.content.FileBinaryResource; import org.alfresco.rest.framework.resource.content.NodeBinaryResource; import org.alfresco.rest.framework.resource.parameters.Parameters; +import org.alfresco.rest.framework.webscripts.WithResponse; /** * Permissible actions for binary resources of an Entity Resource @@ -60,8 +61,24 @@ public interface BinaryResourceAction */ public BinaryResource readProperty (String entityId, Parameters parameters) throws EntityNotFoundException; } - + /** + * HTTP GET - Retrieve a binary resource + */ + public static interface ReadWithResponse extends ResourceAction + { + /** + * Retrieves a binary property by returning a BinaryResource object. The specific property is specified in the {@link Parameters} object. + * See {@link Parameters#hasBinaryProperty(String)} or {@link Parameters#getBinaryProperty()} + * @param entityId unique id + * @param parameters {@link Parameters} + * @return BinaryResource - Either {@link FileBinaryResource} or {@link NodeBinaryResource} + * @throws EntityNotFoundException + */ + public BinaryResource readProperty (String entityId, Parameters parameters, WithResponse withResponse) throws EntityNotFoundException; + } + + /** * HTTP DELETE - Deletes a binary resource */ public static interface Delete extends ResourceAction @@ -75,8 +92,23 @@ public interface BinaryResourceAction */ public void deleteProperty (String entityId, Parameters parameters); } - + /** + * HTTP DELETE - Deletes a binary resource + */ + public static interface DeleteWithResponse extends ResourceAction + { + + /** + * Deletes a binary property. The specific property is specified in the {@link Parameters} object. + * See {@link Parameters#hasBinaryProperty(String)} or {@link Parameters#getBinaryProperty()} + * @param entityId unique id + * @param parameters {@link Parameters} + */ + public void deleteProperty (String entityId, Parameters parameters, WithResponse withResponse); + } + + /** * HTTP PUT - Updates a binary resource if it exists, error if not */ public static interface Update extends ResourceAction @@ -93,4 +125,20 @@ public interface BinaryResourceAction public E updateProperty (String entityId, BasicContentInfo contentInfo, InputStream stream, Parameters params); } + /** + * HTTP PUT - Updates a binary resource if it exists, error if not + */ + public static interface UpdateWithResponse extends ResourceAction + { + + /** + * Updates a binary property. The specific property is specified in the {@link Parameters} object. + * See {@link Parameters#hasBinaryProperty(String)} or {@link Parameters#getBinaryProperty()} + * @param entityId unique id + * @param stream An inputstream + * @param contentInfo Basic information about the content stream + * @param params {@link Parameters} + */ + public E updateProperty (String entityId, BasicContentInfo contentInfo, InputStream stream, Parameters params, WithResponse withResponse); + } } diff --git a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/EntityResourceAction.java b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/EntityResourceAction.java index 4c9ef8c023..07f0445dcc 100644 --- a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/EntityResourceAction.java +++ b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/EntityResourceAction.java @@ -30,6 +30,7 @@ import java.util.List; import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException; import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; import org.alfresco.rest.framework.resource.parameters.Parameters; +import org.alfresco.rest.framework.webscripts.WithResponse; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; @@ -50,7 +51,15 @@ public interface EntityResourceAction { public List create (List entity, Parameters parameters); } - + + /** + * HTTP POST - Create a new entity + */ + public static interface CreateWithResponse extends ResourceAction + { + public List create (List entity, Parameters parameters, WithResponse withResponse); + } + /** * HTTP GET - Retrieve list of entities */ @@ -66,17 +75,39 @@ public interface EntityResourceAction */ public CollectionWithPagingInfo readAll (Parameters params); } - + + /** + * HTTP GET - Retrieve list of entities + */ + public static interface ReadWithResponse extends ResourceAction + { + + /** + * Reads all the entries from the collection. + * + * Paging information is provided. + * @param params - will never be null and will have the PAGING default values + * @return CollectionWithPagingInfo + */ + public CollectionWithPagingInfo readAll (Parameters params, WithResponse withResponse); + } + /** * HTTP GET - Retrieve an entity by its unique id */ public static interface ReadById extends ResourceAction { public E readById (String id, Parameters parameters) throws EntityNotFoundException; - // public E readById (String id, Parameters parameters, Status status, Cache cache) throws EntityNotFoundException; - } - + + /** + * HTTP GET - Retrieve an entity by its unique id + */ + public static interface ReadByIdWithResponse extends ResourceAction + { + public E readById (String id, Parameters parameters, WithResponse withResponse) throws EntityNotFoundException; + } + /** * HTTP PUT - Update entity if it exists, error if not */ @@ -84,7 +115,15 @@ public interface EntityResourceAction { public E update (String id, E entity, Parameters parameters); } - + + /** + * HTTP PUT - Update entity if it exists, error if not + */ + public static interface UpdateWithResponse extends ResourceAction + { + public E update (String id, E entity, Parameters parameters, WithResponse withResponse); + } + /** * HTTP DELETE - Deletes an entity */ @@ -92,4 +131,12 @@ public interface EntityResourceAction { public void delete (String id, Parameters parameters); } + + /** + * HTTP DELETE - Deletes an entity + */ + public static interface DeleteWithResponse extends ResourceAction + { + public void delete (String id, Parameters parameters, WithResponse withResponse); + } } diff --git a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceAction.java b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceAction.java index afa9bfd5a6..8e8cb49320 100644 --- a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceAction.java +++ b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceAction.java @@ -30,6 +30,7 @@ import java.util.List; import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; import org.alfresco.rest.framework.resource.parameters.Parameters; +import org.alfresco.rest.framework.webscripts.WithResponse; /** * Permissible actions for an Relationship Resources @@ -55,7 +56,23 @@ public interface RelationshipResourceAction */ public CollectionWithPagingInfo readAll (String entityResourceId, Parameters params); } - + + /** + * HTTP GET - Retrieve list of related entities by its related entityResource Id + */ + public static interface ReadWithResponse extends ResourceAction + { + /** + * Reads all the relationship entities from the collection using the related entityResourceId. + * + * Paging information is provided. + * @param entityResourceId Entity resource context for this relationship + * @param params - will never be null and will have the PAGING default values + * @return CollectionWithPagingInfo + */ + public CollectionWithPagingInfo readAll (String entityResourceId, Parameters params, WithResponse withResponse); + } + /** * HTTP GET - Retrieve a relation by its unique id & entity context */ @@ -63,7 +80,15 @@ public interface RelationshipResourceAction { public E readById (String entityResourceId, String id, Parameters parameters) throws RelationshipResourceNotFoundException; } - + + /** + * HTTP GET - Retrieve a relation by its unique id & entity context + */ + public static interface ReadByIdWithResponse extends ResourceAction + { + public E readById (String entityResourceId, String id, Parameters parameters, WithResponse withResponse) throws RelationshipResourceNotFoundException; + } + /** * HTTP PUT - Update entity (by its related entityResource Id) if it exists, error if not */ @@ -71,7 +96,15 @@ public interface RelationshipResourceAction { public E update (String entityResourceId, E entity, Parameters parameters); } - + + /** + * HTTP PUT - Update entity (by its related entityResource Id) if it exists, error if not + */ + public static interface UpdateWithResponse extends ResourceAction + { + public E update (String entityResourceId, E entity, Parameters parameters, WithResponse withResponse); + } + /** * HTTP POST - Create one or more new entity */ @@ -79,7 +112,15 @@ public interface RelationshipResourceAction { public List create (String entityResourceId, List entity, Parameters parameters); } - + + /** + * HTTP POST - Create one or more new entity + */ + public static interface CreateWithResponse extends ResourceAction + { + public List create (String entityResourceId, List entity, Parameters parameters, WithResponse withResponse); + } + /** * HTTP DELETE - Deletes a relation by its unique id & entity context */ @@ -88,4 +129,11 @@ public interface RelationshipResourceAction public void delete (String entityResourceId, String id, Parameters parameters); } + /** + * HTTP DELETE - Deletes a relation by its unique id & entity context + */ + public static interface DeleteWithResponse extends ResourceAction + { + public void delete (String entityResourceId, String id, Parameters parameters, WithResponse withResponse); + } } diff --git a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceBinaryAction.java b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceBinaryAction.java index 5766c93f1a..34d0f79998 100755 --- a/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceBinaryAction.java +++ b/source/java/org/alfresco/rest/framework/resource/actions/interfaces/RelationshipResourceBinaryAction.java @@ -6,6 +6,7 @@ import org.alfresco.rest.framework.resource.content.BinaryResource; import org.alfresco.rest.framework.resource.content.FileBinaryResource; import org.alfresco.rest.framework.resource.content.NodeBinaryResource; import org.alfresco.rest.framework.resource.parameters.Parameters; +import org.alfresco.rest.framework.webscripts.WithResponse; import java.io.InputStream; @@ -36,7 +37,24 @@ public interface RelationshipResourceBinaryAction */ public BinaryResource readProperty(String entityId, String entityResourceId, Parameters parameters) throws EntityNotFoundException; } - + + /** + * HTTP GET - Retrieve a binary resource + */ + public static interface ReadWithResponse extends ResourceAction + { + /** + * Retrieves a binary property by returning a BinaryResource object. The specific property is specified in the {@link Parameters} object. + * See {@link Parameters#hasBinaryProperty(String)} or {@link Parameters#getBinaryProperty()} + * @param entityId unique id + * @param entityResourceId Entity resource context for this relationship + * @param parameters {@link Parameters} + * @return BinaryResource - Either {@link FileBinaryResource} or {@link NodeBinaryResource} + * @throws EntityNotFoundException + */ + public BinaryResource readProperty(String entityId, String entityResourceId, Parameters parameters, WithResponse withResponse) throws EntityNotFoundException; + } + /** * HTTP DELETE - Deletes a binary resource */ @@ -52,7 +70,22 @@ public interface RelationshipResourceBinaryAction */ public void deleteProperty(String entityId, String entityResourceId, Parameters parameters); } - + + /** + * HTTP DELETE - Deletes a binary resource + */ + public static interface DeleteWithResponse extends ResourceAction + { + + /** + * Deletes a binary property. The specific property is specified in the {@link Parameters} object. + * See {@link Parameters#hasBinaryProperty(String)} or {@link Parameters#getBinaryProperty()} + * @param entityId unique id + * @param entityResourceId Entity resource context for this relationship + * @param parameters {@link Parameters} + */ + public void deleteProperty(String entityId, String entityResourceId, Parameters parameters, WithResponse withResponse); + } /** * HTTP PUT - Updates a binary resource if it exists, error if not */ @@ -71,4 +104,22 @@ public interface RelationshipResourceBinaryAction public E updateProperty(String entityId, String entityResourceId, BasicContentInfo contentInfo, InputStream stream, Parameters params); } + /** + * HTTP PUT - Updates a binary resource if it exists, error if not + */ + public static interface UpdateWithResponse extends ResourceAction + { + + /** + * Updates a binary property. The specific property is specified in the {@link Parameters} object. + * See {@link Parameters#hasBinaryProperty(String)} or {@link Parameters#getBinaryProperty()} + * @param entityId unique id + * @param entityResourceId Entity resource context for this relationship + * @param stream An inputstream + * @param contentInfo Basic information about the content stream + * @param params {@link Parameters} + */ + public E updateProperty(String entityId, String entityResourceId, BasicContentInfo contentInfo, + InputStream stream, Parameters params, WithResponse withResponse); + } }