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 COMPLETED = "Completed";
|
||||
private static final String FOLDER = "folder";
|
||||
private static final String EXCEPTION = "Exception";
|
||||
private Nodes nodes;
|
||||
private DirectAccessUrlHelper directAccessUrlHelper;
|
||||
private PermissionService permissionService;
|
||||
@@ -356,6 +357,10 @@ public class NodesEntityResource implements
|
||||
{
|
||||
result.put(STATUS, outputResult);
|
||||
}
|
||||
else if(outputResult instanceof Exception)
|
||||
{
|
||||
result.put(EXCEPTION, ((Exception) outputResult).getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -292,7 +292,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
Object result = getter.getFolderSize(params.getEntityId());
|
||||
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))
|
||||
{
|
||||
@@ -302,7 +302,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params);
|
||||
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))
|
||||
{
|
||||
@@ -312,7 +312,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params, withResponse);
|
||||
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))
|
||||
{
|
||||
@@ -322,7 +322,7 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params);
|
||||
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))
|
||||
{
|
||||
@@ -332,6 +332,10 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
||||
BinaryResource prop = getter.readProperty(params.getEntityId(), params.getRelationshipId(), params, withResponse);
|
||||
return prop;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedResourceOperationException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
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.Site;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
@@ -41,8 +40,6 @@ import org.junit.runners.JUnit4;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -58,18 +55,11 @@ import static org.junit.Assert.assertTrue;
|
||||
@RunWith (JUnit4.class)
|
||||
public class NodeFolderSizeApiTest extends AbstractBaseApiTest
|
||||
{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NodeFolderSizeApiTest.class);
|
||||
|
||||
private Site userOneN1Site;
|
||||
|
||||
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)
|
||||
{
|
||||
String parentId;
|
||||
|
@@ -63,7 +63,6 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
|
||||
*/
|
||||
public static final String NAME = "folder-size";
|
||||
public static final String PAGE_SIZE = "page-size";
|
||||
public static final String ERROR = "exception";
|
||||
public static final String FIELD_FACET = "content.size";
|
||||
|
||||
private SearchService searchService;
|
||||
@@ -103,11 +102,11 @@ public class NodeSizeActionExecuter extends ActionExecuterAbstractBase
|
||||
{
|
||||
maxItems = Integer.parseInt(serializable.toString());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
catch (NumberFormatException numberFormatException)
|
||||
{
|
||||
LOG.error("Exception occurred while parsing String to INT: {}", e.getMessage());
|
||||
nodeAction.setParameterValue(ERROR, e.getMessage());
|
||||
throw e;
|
||||
LOG.error("Exception occurred while parsing String to INT: {}", numberFormatException.getMessage());
|
||||
simpleCache.put(actionedUponNodeRef.getId(),numberFormatException);
|
||||
throw numberFormatException;
|
||||
}
|
||||
|
||||
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());
|
||||
nodeAction.setParameterValue(ERROR, ex.getMessage());
|
||||
throw ex;
|
||||
LOG.error("Exception occurred in NodeSizeActionExecutor:results {}", runtimeException.getMessage());
|
||||
simpleCache.put(nodeRef.getId(),runtimeException);
|
||||
throw runtimeException;
|
||||
}
|
||||
|
||||
LOG.debug(" Calculating size of Folder Node - NodeSizeActionExecutor:executeImpl ");
|
||||
|
Reference in New Issue
Block a user