[feature/MNT-24127-EndpointToCalculateFolderSize] Updated endpoints flow to calculate and retrieve folder size details

This commit is contained in:
mohit-singh4
2024-08-23 14:34:32 +05:30
parent d3b9ef1ef8
commit 00bfbff922
4 changed files with 14 additions and 14 deletions

View File

@@ -50,11 +50,11 @@ import org.alfresco.repo.action.executer.NodeSizeDetailsActionExecutor;
public class SizeDetailsImpl implements SizeDetails public class SizeDetailsImpl implements SizeDetails
{ {
private enum STATE
{
STATUS, NOT_INITIATED, IN_PROGRESS, COMPLETED;
};
private static final Logger LOG = LoggerFactory.getLogger(SizeDetailsImpl.class); private static final Logger LOG = LoggerFactory.getLogger(SizeDetailsImpl.class);
private static final String IN_PROGRESS = "IN-PROGRESS";
private static final String STATUS = "status";
private static final String COMPLETED = "COMPLETED";
private static final String NOT_INITIATED = "NOT-INITIATED";
private static final String INVALID_NODEID = "Invalid parameter: value of nodeId is invalid"; private static final String INVALID_NODEID = "Invalid parameter: value of nodeId is invalid";
private static final String FOLDER = "folder"; private static final String FOLDER = "folder";
private Nodes nodes; private Nodes nodes;
@@ -126,7 +126,7 @@ public class SizeDetailsImpl implements SizeDetails
private void executeAction(NodeRef nodeRef, int defaultItems, SimpleCache<Serializable, Map<String, Object>> simpleCache) private void executeAction(NodeRef nodeRef, int defaultItems, SimpleCache<Serializable, Map<String, Object>> simpleCache)
{ {
Map<String, Object > currentStatus = new HashMap<>(); Map<String, Object > currentStatus = new HashMap<>();
currentStatus.put(STATUS,IN_PROGRESS); currentStatus.put(STATE.STATUS.name(),STATE.IN_PROGRESS.name());
Action folderSizeAction = actionService.createAction(NodeSizeDetailsActionExecutor.NAME); Action folderSizeAction = actionService.createAction(NodeSizeDetailsActionExecutor.NAME);
folderSizeAction.setTrackStatus(true); folderSizeAction.setTrackStatus(true);
@@ -143,7 +143,7 @@ public class SizeDetailsImpl implements SizeDetails
{ {
if (result == null) if (result == null)
{ {
return new NodeSizeDetails(NOT_INITIATED); return new NodeSizeDetails(STATE.NOT_INITIATED.name());
} }
else if(result.containsKey(NodeSizeDetailsActionExecutor.EXCEPTION)) else if(result.containsKey(NodeSizeDetailsActionExecutor.EXCEPTION))
{ {
@@ -155,11 +155,11 @@ public class SizeDetailsImpl implements SizeDetails
if (hasSizeKey) if (hasSizeKey)
{ {
return new NodeSizeDetails((String) result.get("nodeId"), (Long) result.get("size"), (String) result.get("calculatedAt"), (Integer) result.get("numberOfFiles"), COMPLETED); return new NodeSizeDetails((String) result.get("nodeId"), (Long) result.get("size"), (String) result.get("calculatedAt"), (Integer) result.get("numberOfFiles"), STATE.COMPLETED.name());
} }
else else
{ {
return new NodeSizeDetails(IN_PROGRESS); return new NodeSizeDetails(STATE.IN_PROGRESS.name());
} }
} }

View File

@@ -77,7 +77,8 @@ import org.junit.runners.Suite;
org.alfresco.repo.web.scripts.node.NodeWebScripTest.class, org.alfresco.repo.web.scripts.node.NodeWebScripTest.class,
org.alfresco.rest.api.impl.CommentsImplUnitTest.class, org.alfresco.rest.api.impl.CommentsImplUnitTest.class,
org.alfresco.rest.api.impl.DownloadsImplCheckArchiveStatusUnitTest.class, org.alfresco.rest.api.impl.DownloadsImplCheckArchiveStatusUnitTest.class,
org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class,
org.alfresco.rest.api.impl.SizeDetailsImplTest.class
}) })
public class AppContext04TestSuite public class AppContext04TestSuite
{ {

View File

@@ -47,7 +47,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@@ -105,8 +105,8 @@ public class NodeSizeDetailsActionExecutor extends ActionExecuterAbstractBase
} }
catch (NumberFormatException numberFormatException) catch (NumberFormatException numberFormatException)
{ {
LOG.error("Exception occurred while parsing String to INT: {}", numberFormatException.getMessage()); LOG.error("Exception occurred while parsing String to INT: {} ", numberFormatException.getMessage());
response.put(EXCEPTION,numberFormatException.getMessage()); response.put(EXCEPTION,"Exception occurred while parsing String to INT: {} " + numberFormatException.getMessage());
simpleCache.put(actionedUponNodeRef.getId(),response); simpleCache.put(actionedUponNodeRef.getId(),response);
throw numberFormatException; throw numberFormatException;
} }
@@ -160,8 +160,8 @@ public class NodeSizeDetailsActionExecutor extends ActionExecuterAbstractBase
} }
catch (RuntimeException runtimeException) catch (RuntimeException runtimeException)
{ {
LOG.error("Exception occurred in NodeSizeDetailsActionExecutor:results {}", runtimeException.getMessage()); LOG.error("Exception occurred in NodeSizeDetailsActionExecutor:results {} ", runtimeException.getMessage());
response.put(EXCEPTION,runtimeException.getMessage()); response.put(EXCEPTION,"Exception occurred in NodeSizeDetailsActionExecutor:results {} "+runtimeException.getMessage());
simpleCache.put(nodeRef.getId(),response); simpleCache.put(nodeRef.getId(),response);
throw runtimeException; throw runtimeException;
} }