[feature/MNT-24127-EndpointToCalculateFolderSize] Added Endpoint to calculate folder size

This commit is contained in:
Mohit Singh
2024-08-02 15:21:45 +05:30
parent 873dfe2224
commit 0c5cc98de9
7 changed files with 54 additions and 106 deletions

View File

@@ -45,6 +45,18 @@ public class FolderSizeImpl {
private static final String IN_PROGRESS = "IN-PROGRESS";
public Map<String, Object> executingAsynchronousFolderAction(final NodeRef nodeRef, final int maxItems, final Map<String, Object> result, final SimpleCache<Serializable, Object> simpleCache)
{
if(simpleCache.get(nodeRef.getId()) == null)
{
executeAction(nodeRef, maxItems, simpleCache);
}
LOG.debug("Executing NodeSizeActionExecuter from executingAsynchronousFolderAction method");
result.putIfAbsent("nodeId",nodeRef.getId());
return result;
}
protected void executeAction(NodeRef nodeRef, int maxItems, SimpleCache<Serializable, Object> simpleCache)
{
Action folderSizeAction = actionService.createAction(NodeSizeActionExecuter.NAME);
folderSizeAction.setTrackStatus(true);
@@ -52,10 +64,5 @@ public class FolderSizeImpl {
folderSizeAction.setParameterValue(NodeSizeActionExecuter.PAGE_SIZE, maxItems);
simpleCache.put(nodeRef.getId(),IN_PROGRESS);
actionService.executeAction(folderSizeAction, nodeRef, false, true);
LOG.debug("Executing NodeSizeActionExecuter from executingAsynchronousFolderAction method");
result.putIfAbsent("executionId",folderSizeAction.getId());
return result;
}
}

View File

@@ -282,7 +282,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
if (StringUtils.isNotBlank(params.getEntityId()))
{
if (EntityResourceAction.RetrieveFolderSize.class.isAssignableFrom(resource.getResource().getClass())
&& (GET_FOLDERSIZE.equals(resource.getMetaData().getUniqueId()) || params.getBinaryProperty().equals("get-folder-size")))
&& (GET_FOLDERSIZE.equals(resource.getMetaData().getUniqueId())))
{
if (resource.getMetaData().isDeleted(EntityResourceAction.RetrieveFolderSize.class))
{

View File

@@ -100,9 +100,9 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
}
/**
* Test case for POST/calculateSize, which calculates Folder Size.
* Test case for POST/calculate-folder-size, which calculates Folder Size.
* <p>POST:</p>
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/calculateSize}
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/calculate-folder-size}
*/
@Test
public void testAPostCalculateFolderSize() throws Exception {
@@ -129,9 +129,9 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
}
/**
* Test case for GET/calculateSize, to retrieve FolderSize.
* Test case for GET/get-folder-size, to retrieve FolderSize.
* <p>GET:</p>
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/calculateSize}
* {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>/get-folder-size}
*/
@Test
public void testBGetCalculateFolderSize() throws Exception

View File

@@ -305,6 +305,7 @@ public class PublicApiHttpClient
{
RestApiEndpoint endpoint = new RestApiEndpoint(c, rq.getNetworkId(), entityId, relationshipEntityId, params);
String url = endpoint.getUrl();
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&& "+url+" :: "+entityId);
GetMethod req = new GetMethod(url);
return submitRequest(req, rq);
@@ -762,6 +763,7 @@ public class PublicApiHttpClient
}
addParams(sb, params);
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&& 2 "+sb.toString());
this.url = sb.toString();
}