mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
[MNT-24127] Added Endpoint to Calculate Size of the folder with Integration Test Cases [ags][tas]
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* 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.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.nodes;
|
package org.alfresco.rest.api.nodes;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.model.FolderSizeModel;
|
import org.alfresco.model.FolderSizeModel;
|
||||||
import org.alfresco.repo.action.executer.NodeSizeActionExecuter;
|
import org.alfresco.repo.action.executer.NodeSizeActionExecuter;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
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.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.WebApiParam;
|
import org.alfresco.rest.framework.WebApiParam;
|
||||||
import org.alfresco.rest.framework.WebApiParameters;
|
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.RelationshipResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
@@ -74,6 +76,7 @@ public class NodeFolderSizeRelation implements
|
|||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private ActionService actionService;
|
private ActionService actionService;
|
||||||
|
static final String NOT_A_VALID_NODEID = "Node Id does not refer to a valid type [folder type]";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
@@ -127,6 +130,7 @@ public class NodeFolderSizeRelation implements
|
|||||||
Node nodeInfo = nodes.getNode(nodeId);
|
Node nodeInfo = nodes.getNode(nodeId);
|
||||||
NodePermissions nodePerms = nodeInfo.getPermissions();
|
NodePermissions nodePerms = nodeInfo.getPermissions();
|
||||||
int maxItems = params.getPaging().getMaxItems();
|
int maxItems = params.getPaging().getMaxItems();
|
||||||
|
QName qName = nodeService.getType(nodeRef);
|
||||||
|
|
||||||
if (nodePerms != null) {
|
if (nodePerms != null) {
|
||||||
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) {
|
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
|
try
|
||||||
{
|
{
|
||||||
Action folderSizeAction = actionService.createAction(NodeSizeActionExecuter.NAME);
|
Action folderSizeAction = actionService.createAction(NodeSizeActionExecuter.NAME);
|
||||||
@@ -161,6 +170,12 @@ public class NodeFolderSizeRelation implements
|
|||||||
NodeRef nodeRef = nodes.validateNode(nodeId);
|
NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||||
Node nodeInfo = nodes.getNode(nodeId);
|
Node nodeInfo = nodes.getNode(nodeId);
|
||||||
NodePermissions nodePerms = nodeInfo.getPermissions();
|
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 (nodePerms != null) {
|
||||||
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) {
|
if (permissionService.hasPermission(nodeRef, PermissionService.READ) == AccessStatus.DENIED) {
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* 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.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* 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.model.Site;
|
||||||
import org.alfresco.rest.api.tests.client.HttpResponse;
|
import org.alfresco.rest.api.tests.client.HttpResponse;
|
||||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
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.security.PermissionService;
|
||||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -136,8 +129,6 @@ public class NodeFolderSizeApiTest extends AbstractBaseApiTest{
|
|||||||
|
|
||||||
String siteTitle = "RandomSite" + System.currentTimeMillis();
|
String siteTitle = "RandomSite" + System.currentTimeMillis();
|
||||||
userOneN1Site = createSite("RN"+RUNID, siteTitle, siteTitle, SiteVisibility.PRIVATE, 201);
|
userOneN1Site = createSite("RN"+RUNID, siteTitle, siteTitle, SiteVisibility.PRIVATE, 201);
|
||||||
String rootNodeId = getRootNodeId();
|
|
||||||
String my2NodeId = getMyNodeId();
|
|
||||||
|
|
||||||
// Create a folder within the site document's library.
|
// Create a folder within the site document's library.
|
||||||
String folderName = "folder" + System.currentTimeMillis();
|
String folderName = "folder" + System.currentTimeMillis();
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* 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("id", nodeRef.getId());
|
||||||
response.put("size", totalSize);
|
response.put("size", totalSize);
|
||||||
response.put("calculatedAtTime", formattedTimestamp);
|
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_OUTPUT, (Serializable) response);
|
||||||
nodeService.setProperty(nodeRef, FolderSizeModel.PROP_STATUS,"COMPLETED");
|
nodeService.setProperty(nodeRef, FolderSizeModel.PROP_STATUS,"COMPLETED");
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2024 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
Reference in New Issue
Block a user