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

This commit is contained in:
Mohit Singh
2024-08-08 13:25:33 +05:30
parent cb9c051383
commit 8927470328
3 changed files with 9 additions and 10 deletions

View File

@@ -281,10 +281,9 @@ public class NodesEntityResource implements
*
* @param nodeId String id of folder - will also accept well-known alias, eg. -root- or -my- or -shared-
* Please refer to OpenAPI spec for more details !
* Returns the executionId which shows pending action, which can be used in a
* GET/calculateSize endpoint to check if the action's status has been completed, comprising the size of the node in bytes.
* Returns the response message i.e. Request has been acknowledged with 202
* GET/size endpoint to check if the action's status has been completed, comprising the size of the node in bytes.
* <p>
* If NodeId does not exist, EntityNotFoundException (status 404).
* If nodeId does not represent a folder, InvalidNodeTypeException (status 422).
*/
@Operation("calculate-folder-size")
@@ -309,8 +308,8 @@ public class NodesEntityResource implements
}
catch (Exception alfrescoRuntimeError)
{
LOG.error("Exception occurred in NodesEntityResource:createById {}", alfrescoRuntimeError.getMessage());
throw new AlfrescoRuntimeException("Exception occurred in NodesEntityResource:createById",alfrescoRuntimeError);
LOG.error("Exception occurred in NodesEntityResource:calculateFolderSize {}", alfrescoRuntimeError.getMessage());
throw new AlfrescoRuntimeException("Exception occurred in NodesEntityResource:calculateFolderSize",alfrescoRuntimeError);
}
}
@@ -323,7 +322,7 @@ public class NodesEntityResource implements
Map<String, Object> result = new HashMap<>();
try
{
LOG.debug("Retrieving OUTPUT from NodeSizeActionExecutor - NodesEntityResource:readById");
LOG.debug("Retrieving OUTPUT from NodeSizeActionExecutor - NodesEntityResource:getFolderSize");
NodeRef nodeRef = nodes.validateNode(nodeId);
validatePermissions(nodeRef, nodeId);
QName qName = nodeService.getType(nodeRef);
@@ -346,7 +345,7 @@ public class NodesEntityResource implements
}
catch (Exception ex)
{
LOG.error("Exception occurred in NodesEntityResource:readById {}", ex.getMessage());
LOG.error("Exception occurred in NodesEntityResource:getFolderSize {}", ex.getMessage());
throw ex; // Rethrow with original stack trace
}
}

View File

@@ -152,7 +152,7 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
String folder0Name = "f0-testParentFolder-"+RUNID;
String parentFolder = createFolder(tDocLibNodeId, folder0Name,null).getId();
for(int i=1;i<=300;i++)
for(int i=1;i<=500;i++)
{
String folderBName = "folder"+i+RUNID + "_B";
String folderB_Id = createFolder(parentFolder, folderBName, null).getId();
@@ -202,7 +202,7 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest
//current Time after executing GET/size API
LocalTime actualTime = LocalTime.now();
assertTrue("Calculating folder node is taking time greater than 15 seconds ",actualTime.isBefore(expectedTime));
assertTrue("Calculating folder node is taking time greater than 5 seconds ",actualTime.isBefore(expectedTime));
}
/**

View File

@@ -64,7 +64,7 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
public static final String NAME = "folder-size";
public static final String DEFAULT_SIZE = "default-size";
private static final String FIELD_FACET = "content.size";
private static final String FACET_QUERY = "content.size:[0 TO "+Integer.MAX_VALUE+"] \"label\": \"extra small\",\"group\":\"Size\"";
private static final String FACET_QUERY = "content.size:[0 TO "+Integer.MAX_VALUE+"] \"label\": \"large\",\"group\":\"Size\"";
private SearchService searchService;
private SimpleCache<Serializable,Object> simpleCache;