mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
[feature/MNT-24127-EndpointToCalculateFolderSize] Added endpoint to calculate folder size
This commit is contained in:
@@ -86,6 +86,7 @@ public class NodesEntityResource implements
|
|||||||
private static final String STATUS = "status";
|
private static final String STATUS = "status";
|
||||||
private static final String COMPLETED = "Completed";
|
private static final String COMPLETED = "Completed";
|
||||||
private static final String FOLDER = "folder";
|
private static final String FOLDER = "folder";
|
||||||
|
private static final String EXCEPTION = "Exception";
|
||||||
private Nodes nodes;
|
private Nodes nodes;
|
||||||
private DirectAccessUrlHelper directAccessUrlHelper;
|
private DirectAccessUrlHelper directAccessUrlHelper;
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
@@ -356,6 +357,10 @@ public class NodesEntityResource implements
|
|||||||
{
|
{
|
||||||
result.put(STATUS, outputResult);
|
result.put(STATUS, outputResult);
|
||||||
}
|
}
|
||||||
|
else if(outputResult instanceof Exception)
|
||||||
|
{
|
||||||
|
result.put(EXCEPTION, ((Exception) outputResult).getMessage());
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -292,7 +292,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
|||||||
Object result = getter.getFolderSize(params.getEntityId());
|
Object result = getter.getFolderSize(params.getEntityId());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (BinaryResourceAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
|
else if (BinaryResourceAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
|
||||||
{
|
{
|
||||||
if (resource.getMetaData().isDeleted(BinaryResourceAction.Read.class))
|
if (resource.getMetaData().isDeleted(BinaryResourceAction.Read.class))
|
||||||
{
|
{
|
||||||
@@ -302,7 +302,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
|||||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params);
|
BinaryResource prop = getter.readProperty(params.getEntityId(), params);
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
if (BinaryResourceAction.ReadWithResponse.class.isAssignableFrom(resource.getResource().getClass()))
|
else if (BinaryResourceAction.ReadWithResponse.class.isAssignableFrom(resource.getResource().getClass()))
|
||||||
{
|
{
|
||||||
if (resource.getMetaData().isDeleted(BinaryResourceAction.ReadWithResponse.class))
|
if (resource.getMetaData().isDeleted(BinaryResourceAction.ReadWithResponse.class))
|
||||||
{
|
{
|
||||||
@@ -312,7 +312,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
|||||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params, withResponse);
|
BinaryResource prop = getter.readProperty(params.getEntityId(), params, withResponse);
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
if (RelationshipResourceBinaryAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
|
else if (RelationshipResourceBinaryAction.Read.class.isAssignableFrom(resource.getResource().getClass()))
|
||||||
{
|
{
|
||||||
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.Read.class))
|
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.Read.class))
|
||||||
{
|
{
|
||||||
@@ -322,7 +322,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
|||||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params);
|
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params);
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
if (RelationshipResourceBinaryAction.ReadWithResponse.class.isAssignableFrom(resource.getResource().getClass()))
|
else if (RelationshipResourceBinaryAction.ReadWithResponse.class.isAssignableFrom(resource.getResource().getClass()))
|
||||||
{
|
{
|
||||||
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.ReadWithResponse.class))
|
if (resource.getMetaData().isDeleted(RelationshipResourceBinaryAction.ReadWithResponse.class))
|
||||||
{
|
{
|
||||||
@@ -332,6 +332,10 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
|||||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params, withResponse);
|
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params, withResponse);
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new UnsupportedResourceOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.tests;
|
package org.alfresco.rest.api.tests;
|
||||||
|
|
||||||
import org.alfresco.repo.cache.SimpleCache;
|
|
||||||
import org.alfresco.rest.api.model.NodeTarget;
|
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.nodes.NodesEntityResource;
|
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||||
@@ -41,8 +40,6 @@ import org.junit.runners.JUnit4;
|
|||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -58,18 +55,11 @@ import static org.junit.Assert.assertTrue;
|
|||||||
@RunWith (JUnit4.class)
|
@RunWith (JUnit4.class)
|
||||||
public class NodeFolderSizeApiTest extends AbstractBaseApiTest
|
public class NodeFolderSizeApiTest extends AbstractBaseApiTest
|
||||||
{
|
{
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(NodeFolderSizeApiTest.class);
|
||||||
|
|
||||||
private Site userOneN1Site;
|
private Site userOneN1Site;
|
||||||
|
|
||||||
private String folderId;
|
private String folderId;
|
||||||
|
|
||||||
private SimpleCache<Serializable,Object> simpleCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The logger
|
|
||||||
*/
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(NodeFolderSizeApiTest.class);
|
|
||||||
|
|
||||||
private String addToDocumentLibrary(Site testSite, String name, String nodeType)
|
private String addToDocumentLibrary(Site testSite, String name, String nodeType)
|
||||||
{
|
{
|
||||||
String parentId;
|
String parentId;
|
||||||
|
@@ -63,7 +63,6 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
|
|||||||
*/
|
*/
|
||||||
public static final String NAME = "folder-size";
|
public static final String NAME = "folder-size";
|
||||||
public static final String PAGE_SIZE = "page-size";
|
public static final String PAGE_SIZE = "page-size";
|
||||||
public static final String ERROR = "exception";
|
|
||||||
public static final String FIELD_FACET = "content.size";
|
public static final String FIELD_FACET = "content.size";
|
||||||
|
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
@@ -103,11 +102,11 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
maxItems = Integer.parseInt(serializable.toString());
|
maxItems = Integer.parseInt(serializable.toString());
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException numberFormatException)
|
||||||
{
|
{
|
||||||
LOG.error("Exception occurred while parsing String to INT: {}", e.getMessage());
|
LOG.error("Exception occurred while parsing String to INT: {}", numberFormatException.getMessage());
|
||||||
nodeAction.setParameterValue(ERROR, e.getMessage());
|
simpleCache.put(actionedUponNodeRef.getId(),numberFormatException);
|
||||||
throw e;
|
throw numberFormatException;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef nodeRef = actionedUponNodeRef;
|
NodeRef nodeRef = actionedUponNodeRef;
|
||||||
@@ -155,11 +154,11 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RuntimeException ex)
|
catch (RuntimeException runtimeException)
|
||||||
{
|
{
|
||||||
LOG.error("Exception occurred in NodeSizeActionExecutor:results {}", ex.getMessage());
|
LOG.error("Exception occurred in NodeSizeActionExecutor:results {}", runtimeException.getMessage());
|
||||||
nodeAction.setParameterValue(ERROR, ex.getMessage());
|
simpleCache.put(nodeRef.getId(),runtimeException);
|
||||||
throw ex;
|
throw runtimeException;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug(" Calculating size of Folder Node - NodeSizeActionExecutor:executeImpl ");
|
LOG.debug(" Calculating size of Folder Node - NodeSizeActionExecutor:executeImpl ");
|
||||||
|
Reference in New Issue
Block a user