Skip to content

Commit

Permalink
[feature/MNT-24127] Endpoint Added To Calculate Folder Size
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-singh4 committed Jul 23, 2024
1 parent 4edc87c commit 2f35962
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FolderSizeImpl {
private ActionService actionService;
private static final Logger LOG = LoggerFactory.getLogger(FolderSizeImpl.class);

public Map<String, Object> executingAsynchronousFolderAction(final int maxItems, final NodeRef nodeRef, final Map<String, Object> result, final SimpleCache<Serializable, Object> simpleCache) throws Exception
public Map<String, Object> executingAsynchronousFolderAction(final int maxItems, final NodeRef nodeRef, final Map<String, Object> result, final SimpleCache<Serializable, Object> simpleCache)
{
Action folderSizeAction = actionService.createAction(NodeSizeActionExecuter.NAME);
folderSizeAction.setTrackStatus(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ public class NodeFolderSizeRelation implements CalculateSize<Map<String, Object>
private NodeService nodeService;
private ActionService actionService;
private ActionTrackingService actionTrackingService;
private FolderSizeImpl folderSizeImpl;
private NodeRef nodeRef;
private String invalidMessage = "Invalid parameter: value of nodeId is invalid";

private String notFoundMessage = "Searched ExecutionId does not exist";

/** the simple cache that will hold action data */
Expand Down Expand Up @@ -150,7 +147,7 @@ public void setSimpleCache(SimpleCache<Serializable, Object> simpleCache)
@WebApiDescription(title = "Calculating Folder Size", description = "Calculating size of a folder", successStatus = Status.STATUS_ACCEPTED)
public Map<String, Object> createById(String nodeId, Parameters params)
{
nodeRef = nodes.validateNode(nodeId);
NodeRef nodeRef = nodes.validateNode(nodeId);
int maxItems = Math.min(params.getPaging().getMaxItems(), 1000);
QName qName = nodeService.getType(nodeRef);
Map<String, Object> result = new HashMap<>();
Expand All @@ -164,13 +161,13 @@ public Map<String, Object> createById(String nodeId, Parameters params)

try
{
this.folderSizeImpl = new FolderSizeImpl(actionService);
return this.folderSizeImpl.executingAsynchronousFolderAction(maxItems, nodeRef, result, simpleCache);
FolderSizeImpl folderSizeImpl = new FolderSizeImpl(actionService);
return folderSizeImpl.executingAsynchronousFolderAction(maxItems, nodeRef, result, simpleCache);
}
catch (Exception ex)
{
LOG.error("Exception occurred in NodeFolderSizeRelation:createById {}", ex.getMessage());
throw new AlfrescoRuntimeException("Exception occurred in NodeFolderSizeRelation:createById");
throw new AlfrescoRuntimeException("Exception occurred in NodeFolderSizeRelation:createById",ex);
}
}

Expand All @@ -179,7 +176,7 @@ public Map<String, Object> createById(String nodeId, Parameters params)
@WebApiParameters({@WebApiParam(name = "executionId", title = "The unique id of Execution Job", description = "A single execution id")})
public Map<String, Object> readById(String executionId, String id, Parameters parameters)
{
Map<String, Object> result = new HashMap<>();
Map<String, Object> result;

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void testBGetCalculateFolderSize() throws Exception
AuthenticationUtil.setFullyAuthenticatedUser(user1);

// Check if response and JSON parsing were successful
executionId = executionId.substring(executionId.indexOf("=") + 1,executionId.indexOf("}"));
executionId = executionId.substring(executionId.indexOf('=') + 1,executionId.indexOf('}'));
HttpResponse response = getSingle(getFolderSizeUrl(executionId), null, 200);
assertNotNull(response);

Expand Down

0 comments on commit 2f35962

Please sign in to comment.