mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
122241 gjames: RA-833: Added a RelationshipResourceBinaryAction git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126462 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -9,6 +9,7 @@ import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationE
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
@@ -61,9 +62,18 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
}
|
||||
case PROPERTY:
|
||||
final String resourceName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_RESOURCE);
|
||||
final String propertyName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.PROPERTY);
|
||||
|
||||
if (StringUtils.isNotBlank(entityId) && StringUtils.isNotBlank(resourceName))
|
||||
{
|
||||
return Params.valueOf(entityId, null, null, null, resourceName, null, null);
|
||||
if (StringUtils.isNotBlank(propertyName))
|
||||
{
|
||||
return Params.valueOf(entityId, relationshipId, null, null, propertyName, null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Params.valueOf(entityId, null, null, null, resourceName, null, null);
|
||||
}
|
||||
}
|
||||
//Fall through to unsupported.
|
||||
default:
|
||||
@@ -100,14 +110,28 @@ public class ResourceWebScriptDelete extends AbstractResourceWebScript implement
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
case PROPERTY:
|
||||
if (resource.getMetaData().isDeleted(BinaryResourceAction.Delete.class))
|
||||
if (BinaryResourceAction.Delete.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
throw new DeletedResourceException("(DELETE) "+resource.getMetaData().getUniqueId());
|
||||
if (resource.getMetaData().isDeleted(BinaryResourceAction.Delete.class))
|
||||
{
|
||||
throw new DeletedResourceException("(DELETE) "+resource.getMetaData().getUniqueId());
|
||||
}
|
||||
BinaryResourceAction.Delete binDeleter = (BinaryResourceAction.Delete) resource.getResource();
|
||||
binDeleter.deleteProperty(params.getEntityId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
}
|
||||
if (RelationshipResourceBinaryAction.Delete.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.Delete.class))
|
||||
{
|
||||
throw new DeletedResourceException("(DELETE) "+resource.getMetaData().getUniqueId());
|
||||
}
|
||||
RelationshipResourceBinaryAction.Delete binDeleter = (RelationshipResourceBinaryAction.Delete) resource.getResource();
|
||||
binDeleter.deleteProperty(params.getEntityId(), params.getRelationshipId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
}
|
||||
BinaryResourceAction.Delete binDeleter = (BinaryResourceAction.Delete) resource.getResource();
|
||||
binDeleter.deleteProperty(params.getEntityId(), params);
|
||||
//Don't pass anything to the callback - its just successful
|
||||
return null;
|
||||
default:
|
||||
throw new UnsupportedResourceOperationException("DELETE not supported for Actions");
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAct
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction.Read;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction.ReadById;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.content.ContentInfo;
|
||||
import org.alfresco.rest.framework.resource.content.NodeBinaryResource;
|
||||
@@ -87,9 +88,18 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
}
|
||||
case PROPERTY:
|
||||
final String resourceName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_RESOURCE);
|
||||
final String propertyName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.PROPERTY);
|
||||
|
||||
if (StringUtils.isNotBlank(entityId) && StringUtils.isNotBlank(resourceName))
|
||||
{
|
||||
return Params.valueOf(entityId, null, null, null, resourceName, params, null);
|
||||
if (StringUtils.isNotBlank(propertyName))
|
||||
{
|
||||
return Params.valueOf(entityId, relationshipId, null, null, propertyName, params, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Params.valueOf(entityId, null, null, null, resourceName, params, null);
|
||||
}
|
||||
}
|
||||
//Fall through to unsupported.
|
||||
default:
|
||||
@@ -187,11 +197,16 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params);
|
||||
return prop;
|
||||
}
|
||||
else
|
||||
if (RelationshipResourceBinaryAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
throw new UnsupportedResourceOperationException();
|
||||
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.Read.class))
|
||||
{
|
||||
throw new DeletedResourceException("(GET) "+resource.getMetaData().getUniqueId());
|
||||
}
|
||||
RelationshipResourceBinaryAction.Read getter = (RelationshipResourceBinaryAction.Read) resource.getResource();
|
||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params);
|
||||
return prop;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -68,6 +68,7 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
{
|
||||
final RecognizedParams params = ResourceWebScriptHelper.getRecognizedParams(req);
|
||||
final String entityId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.ENTITY_ID);
|
||||
final String relationshipId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_ID);
|
||||
|
||||
switch (resourceMeta.getType())
|
||||
{
|
||||
@@ -83,7 +84,6 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
return Params.valueOf(null, params, postedObj);
|
||||
}
|
||||
case RELATIONSHIP:
|
||||
String relationshipId = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_ID);
|
||||
if (StringUtils.isNotBlank(relationshipId))
|
||||
{
|
||||
throw new UnsupportedResourceOperationException("POST is executed against the collection URL");
|
||||
@@ -95,6 +95,8 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
}
|
||||
case OPERATION:
|
||||
final String operationName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_RESOURCE);
|
||||
final String propertyName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.PROPERTY);
|
||||
|
||||
if (StringUtils.isNotBlank(entityId) && StringUtils.isNotBlank(operationName))
|
||||
{
|
||||
Class objectType = resourceMeta.getObjectType(HttpMethod.POST);
|
||||
@@ -104,7 +106,15 @@ public class ResourceWebScriptPost extends AbstractResourceWebScript implements
|
||||
//Operations don't support a List as json body
|
||||
postedObj = ResourceWebScriptHelper.extractJsonContent(req, jsonHelper, objectType);
|
||||
}
|
||||
return Params.valueOf(entityId, params, postedObj);
|
||||
|
||||
if (StringUtils.isNotBlank(propertyName))
|
||||
{
|
||||
return Params.valueOf(entityId, relationshipId, params, postedObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Params.valueOf(entityId, params, postedObj);
|
||||
}
|
||||
}
|
||||
//Fall through to unsupported.
|
||||
default:
|
||||
|
@@ -34,7 +34,9 @@ import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationE
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
|
||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
||||
import org.alfresco.rest.framework.resource.content.ContentInfoImpl;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
|
||||
@@ -95,9 +97,19 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
|
||||
}
|
||||
case PROPERTY:
|
||||
final String resourceName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.RELATIONSHIP_RESOURCE);
|
||||
final String propertyName = req.getServiceMatch().getTemplateVars().get(ResourceLocator.PROPERTY);
|
||||
|
||||
if (StringUtils.isNotBlank(entityId) && StringUtils.isNotBlank(resourceName))
|
||||
{
|
||||
return Params.valueOf(entityId, null, null, getStream(req), resourceName, params, getContentInfo(req));
|
||||
if (StringUtils.isNotBlank(propertyName))
|
||||
{
|
||||
return Params.valueOf(entityId, relationshipId, null, getStream(req), propertyName, params, getContentInfo(req));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Params.valueOf(entityId, null, null, getStream(req), resourceName, params, getContentInfo(req));
|
||||
}
|
||||
|
||||
}
|
||||
//Fall through to unsupported.
|
||||
default:
|
||||
@@ -185,12 +197,24 @@ public class ResourceWebScriptPut extends AbstractResourceWebScript implements P
|
||||
Object relResult = relationUpdater.update(params.getEntityId(), params.getPassedIn(), params);
|
||||
return relResult;
|
||||
case PROPERTY:
|
||||
if (resource.getMetaData().isDeleted(BinaryResourceAction.Update.class))
|
||||
if (BinaryResourceAction.Update.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
throw new DeletedResourceException("(UPDATE) "+resource.getMetaData().getUniqueId());
|
||||
if (resource.getMetaData().isDeleted(BinaryResourceAction.Update.class))
|
||||
{
|
||||
throw new DeletedResourceException("(UPDATE) "+resource.getMetaData().getUniqueId());
|
||||
}
|
||||
BinaryResourceAction.Update<Object> binUpdater = (BinaryResourceAction.Update<Object>) resource.getResource();
|
||||
return binUpdater.updateProperty(params.getEntityId(), params.getContentInfo(), params.getStream(), params);
|
||||
}
|
||||
if (RelationshipResourceBinaryAction.Update.class.isAssignableFrom(resource.getResource().getClass()))
|
||||
{
|
||||
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.Update.class))
|
||||
{
|
||||
throw new DeletedResourceException("(UPDATE) "+resource.getMetaData().getUniqueId());
|
||||
}
|
||||
RelationshipResourceBinaryAction.Update<Object> binUpdater = (RelationshipResourceBinaryAction.Update<Object>) resource.getResource();
|
||||
return binUpdater.updateProperty(params.getEntityId(), params.getRelationshipId(), params.getContentInfo(), params.getStream(), params);
|
||||
}
|
||||
BinaryResourceAction.Update<Object> binUpdater = (BinaryResourceAction.Update<Object>) resource.getResource();
|
||||
return binUpdater.updateProperty(params.getEntityId(), params.getContentInfo(), params.getStream(), params);
|
||||
default:
|
||||
throw new UnsupportedResourceOperationException("PUT not supported for Actions");
|
||||
}
|
||||
|
Reference in New Issue
Block a user