[MNT-24127] Added Endpoint to Calculate Size of the folder with Integration Test Cases [ags][tas]

This commit is contained in:
mohit-singh4
2024-06-24 11:24:10 +05:30
parent 08616cb33d
commit 25a95383be
4 changed files with 21 additions and 14 deletions

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -25,7 +25,7 @@
*/
package org.alfresco.rest.api.nodes;
import org.alfresco.model.ContentModel;
import org.alfresco.model.FolderSizeModel;
import org.alfresco.repo.action.executer.NodeSizeActionExecuter;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -35,6 +35,8 @@ import org.alfresco.rest.api.model.NodePermissions;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.WebApiParameters;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidNodeTypeException;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.Parameters;
@@ -74,6 +76,7 @@ public class NodeFolderSizeRelation implements
private PermissionService permissionService;
private NodeService nodeService;
private ActionService actionService;
static final String NOT_A_VALID_NODEID = "Node Id does not refer to a valid type [folder type]";
/**
* The logger
@@ -127,6 +130,7 @@ public class NodeFolderSizeRelation implements
Node nodeInfo = nodes.getNode(nodeId);
NodePermissions nodePerms = nodeInfo.getPermissions();
int maxItems = params.getPaging().getMaxItems();
QName qName = nodeService.getType(nodeRef);
if (nodePerms != null) {
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) {
@@ -134,6 +138,11 @@ public class NodeFolderSizeRelation implements
}
}
if(!"folder".equals(qName.getLocalName()))
{
throw new InvalidNodeTypeException(NOT_A_VALID_NODEID);
}
try
{
Action folderSizeAction = actionService.createAction(NodeSizeActionExecuter.NAME);
@@ -161,6 +170,12 @@ public class NodeFolderSizeRelation implements
NodeRef nodeRef = nodes.validateNode(nodeId);
Node nodeInfo = nodes.getNode(nodeId);
NodePermissions nodePerms = nodeInfo.getPermissions();
QName qName = nodeService.getType(nodeRef);
if(!"folder".equals(qName.getLocalName()))
{
throw new InvalidNodeTypeException(NOT_A_VALID_NODEID);
}
if (nodePerms != null) {
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) {

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -30,15 +30,8 @@ import org.alfresco.rest.api.model.NodeTarget;
import org.alfresco.rest.api.model.Site;
import org.alfresco.rest.api.tests.client.HttpResponse;
import org.alfresco.rest.api.tests.util.RestApiUtil;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.namespace.NamespaceService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -136,8 +129,6 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest{
String siteTitle = "RandomSite" + System.currentTimeMillis();
userOneN1Site = createSite("RN"+RUNID, siteTitle, siteTitle, SiteVisibility.PRIVATE, 201);
String rootNodeId = getRootNodeId();
String my2NodeId = getMyNodeId();
// Create a folder within the site document's library.
String folderName = "folder" + System.currentTimeMillis();

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -149,6 +149,7 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
response.put("id", nodeRef.getId());
response.put("size", totalSize);
response.put("calculatedAtTime", formattedTimestamp);
response.put("numberOfFiles", results!=null?results.getNodeRefs().size():0);
nodeService.setProperty(nodeRef, FolderSizeModel.PROP_OUTPUT, (Serializable) response);
nodeService.setProperty(nodeRef, FolderSizeModel.PROP_STATUS,"COMPLETED");
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of