mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
[feature/MNT-24127-EndpointToCalculateFolderSize] Added Endpoint to calculate folder size
This commit is contained in:
@@ -78,7 +78,7 @@ import org.springframework.extensions.webscripts.Status;
|
|||||||
@EntityResource(name="nodes", title = "Nodes")
|
@EntityResource(name="nodes", title = "Nodes")
|
||||||
public class NodesEntityResource implements
|
public class NodesEntityResource implements
|
||||||
EntityResourceAction.ReadById<Node>, EntityResourceAction.Delete, EntityResourceAction.Update<Node>,
|
EntityResourceAction.ReadById<Node>, EntityResourceAction.Delete, EntityResourceAction.Update<Node>,
|
||||||
BinaryResourceAction.Read, BinaryResourceAction.Update<Node>, InitializingBean
|
BinaryResourceAction.Read, BinaryResourceAction.Update<Node>, EntityResourceAction.RetrieveFolderSize<Map<String,Object>>, InitializingBean
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(NodesEntityResource.class);
|
private static final Logger LOG = LoggerFactory.getLogger(NodesEntityResource.class);
|
||||||
@@ -88,6 +88,7 @@ public class NodesEntityResource implements
|
|||||||
private static final String STATUS = "status";
|
private static final String STATUS = "status";
|
||||||
private static final String COMPLETED = "Completed";
|
private static final String COMPLETED = "Completed";
|
||||||
private static final String FOLDER = "folder";
|
private static final String FOLDER = "folder";
|
||||||
|
|
||||||
private Nodes nodes;
|
private Nodes nodes;
|
||||||
private DirectAccessUrlHelper directAccessUrlHelper;
|
private DirectAccessUrlHelper directAccessUrlHelper;
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
@@ -317,11 +318,13 @@ public class NodesEntityResource implements
|
|||||||
throw new AlfrescoRuntimeException("Exception occurred in NodesEntityResource:createById",alfrescoRuntimeError);
|
throw new AlfrescoRuntimeException("Exception occurred in NodesEntityResource:createById",alfrescoRuntimeError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Operation("get-folder-size")
|
@Override
|
||||||
|
@BinaryProperties({"get-folder-size"})
|
||||||
@WebApiDescription(title = "Returns Folder Node Size", description = "Returning a Folder Node Size")
|
@WebApiDescription(title = "Returns Folder Node Size", description = "Returning a Folder Node Size")
|
||||||
@WebApiParameters({@WebApiParam(name = "nodeId", title = "The unique id of Execution Job", description = "A single nodeId")})
|
@WebApiParameters({@WebApiParam(name = "nodeId", title = "The unique id of Execution Job", description = "A single nodeId")})
|
||||||
public Map<String, Object> getFolderSize(String nodeId, Void ignore, Parameters parameters, WithResponse withResponse)
|
public Map<String, Object> getFolderSize(String nodeId, Parameters parameters) throws EntityNotFoundException
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LOG.debug("Retrieving OUTPUT from NodeSizeActionExecutor - NodesEntityResource:readById");
|
LOG.debug("Retrieving OUTPUT from NodeSizeActionExecutor - NodesEntityResource:readById");
|
||||||
|
@@ -110,6 +110,8 @@ public class ResourceInspector
|
|||||||
|
|
||||||
ALL_ENTITY_RESOURCE_INTERFACES.add(MultiPartResourceAction.Create.class);
|
ALL_ENTITY_RESOURCE_INTERFACES.add(MultiPartResourceAction.Create.class);
|
||||||
|
|
||||||
|
ALL_ENTITY_RESOURCE_INTERFACES.add(EntityResourceAction.RetrieveFolderSize.class);
|
||||||
|
|
||||||
ALL_RELATIONSHIP_RESOURCE_INTERFACES.add(RelationshipResourceAction.Create.class);
|
ALL_RELATIONSHIP_RESOURCE_INTERFACES.add(RelationshipResourceAction.Create.class);
|
||||||
ALL_RELATIONSHIP_RESOURCE_INTERFACES.add(RelationshipResourceAction.Read.class);
|
ALL_RELATIONSHIP_RESOURCE_INTERFACES.add(RelationshipResourceAction.Read.class);
|
||||||
ALL_RELATIONSHIP_RESOURCE_INTERFACES.add(RelationshipResourceAction.ReadById.class);
|
ALL_RELATIONSHIP_RESOURCE_INTERFACES.add(RelationshipResourceAction.ReadById.class);
|
||||||
@@ -163,6 +165,7 @@ public class ResourceInspector
|
|||||||
findOperation(EntityResourceAction.UpdateWithResponse.class, PUT, helper);
|
findOperation(EntityResourceAction.UpdateWithResponse.class, PUT, helper);
|
||||||
findOperation(EntityResourceAction.DeleteWithResponse.class, DELETE, helper);
|
findOperation(EntityResourceAction.DeleteWithResponse.class, DELETE, helper);
|
||||||
findOperation(EntityResourceAction.DeleteSetWithResponse.class, DELETE, helper);
|
findOperation(EntityResourceAction.DeleteSetWithResponse.class, DELETE, helper);
|
||||||
|
findOperation(EntityResourceAction.RetrieveFolderSize.class, GET, helper);
|
||||||
|
|
||||||
findOperation(MultiPartResourceAction.Create.class, POST, helper);
|
findOperation(MultiPartResourceAction.Create.class, POST, helper);
|
||||||
|
|
||||||
@@ -725,15 +728,7 @@ public class ResourceInspector
|
|||||||
Map<String, Object> annotAttribs = AnnotationUtils.getAnnotationAttributes(annot);
|
Map<String, Object> annotAttribs = AnnotationUtils.getAnnotationAttributes(annot);
|
||||||
String actionName = String.valueOf(annotAttribs.get("value"));
|
String actionName = String.valueOf(annotAttribs.get("value"));
|
||||||
String actionPath = ResourceDictionary.propertyResourceKey(entityPath, actionName);
|
String actionPath = ResourceDictionary.propertyResourceKey(entityPath, actionName);
|
||||||
ResourceOperation ro;
|
ResourceOperation ro = inspectOperation(anyClass, annotatedMethod, POST);
|
||||||
if("/nodes/{id}/get-folder-size".equals(actionPath))
|
|
||||||
{
|
|
||||||
ro = inspectOperation(anyClass, annotatedMethod, GET);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ro = inspectOperation(anyClass, annotatedMethod, POST);
|
|
||||||
}
|
|
||||||
embeds.put(actionPath, new Pair<ResourceOperation, Method>(ro, annotatedMethod));
|
embeds.put(actionPath, new Pair<ResourceOperation, Method>(ro, annotatedMethod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,4 +161,14 @@ public interface EntityResourceAction
|
|||||||
*/
|
*/
|
||||||
public void deleteSet(Parameters params, WithResponse withResponse);
|
public void deleteSet(Parameters params, WithResponse withResponse);
|
||||||
}
|
}
|
||||||
|
public static interface RetrieveFolderSize<E> extends ResourceAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* get the size of Folder Node.
|
||||||
|
*
|
||||||
|
* @param nodeId Entity resource context for this relationship.
|
||||||
|
* @param params implementation may choose to restrict the set to be deleted based on params (ie. not necessarily "all")
|
||||||
|
*/
|
||||||
|
public E getFolderSize (String nodeId, Parameters parameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user