diff --git a/remote-api/src/main/java/org/alfresco/rest/api/impl/SizeDetailsImpl.java b/remote-api/src/main/java/org/alfresco/rest/api/impl/SizeDetailsImpl.java index baae67b003..7eaeda6649 100644 --- a/remote-api/src/main/java/org/alfresco/rest/api/impl/SizeDetailsImpl.java +++ b/remote-api/src/main/java/org/alfresco/rest/api/impl/SizeDetailsImpl.java @@ -50,11 +50,11 @@ import org.alfresco.repo.action.executer.NodeSizeDetailsActionExecutor; public class SizeDetailsImpl implements SizeDetails { + private enum STATE + { + STATUS, NOT_INITIATED, IN_PROGRESS, COMPLETED; + }; private static final Logger LOG = LoggerFactory.getLogger(SizeDetailsImpl.class); - private static final String IN_PROGRESS = "IN-PROGRESS"; - private static final String STATUS = "status"; - private static final String COMPLETED = "COMPLETED"; - private static final String NOT_INITIATED = "NOT-INITIATED"; private static final String INVALID_NODEID = "Invalid parameter: value of nodeId is invalid"; private static final String FOLDER = "folder"; private Nodes nodes; @@ -126,7 +126,7 @@ public class SizeDetailsImpl implements SizeDetails private void executeAction(NodeRef nodeRef, int defaultItems, SimpleCache> simpleCache) { Map currentStatus = new HashMap<>(); - currentStatus.put(STATUS,IN_PROGRESS); + currentStatus.put(STATE.STATUS.name(),STATE.IN_PROGRESS.name()); Action folderSizeAction = actionService.createAction(NodeSizeDetailsActionExecutor.NAME); folderSizeAction.setTrackStatus(true); @@ -143,7 +143,7 @@ public class SizeDetailsImpl implements SizeDetails { if (result == null) { - return new NodeSizeDetails(NOT_INITIATED); + return new NodeSizeDetails(STATE.NOT_INITIATED.name()); } else if(result.containsKey(NodeSizeDetailsActionExecutor.EXCEPTION)) { @@ -155,11 +155,11 @@ public class SizeDetailsImpl implements SizeDetails if (hasSizeKey) { - return new NodeSizeDetails((String) result.get("nodeId"), (Long) result.get("size"), (String) result.get("calculatedAt"), (Integer) result.get("numberOfFiles"), COMPLETED); + return new NodeSizeDetails((String) result.get("nodeId"), (Long) result.get("size"), (String) result.get("calculatedAt"), (Integer) result.get("numberOfFiles"), STATE.COMPLETED.name()); } else { - return new NodeSizeDetails(IN_PROGRESS); + return new NodeSizeDetails(STATE.IN_PROGRESS.name()); } } diff --git a/remote-api/src/test/java/org/alfresco/AppContext04TestSuite.java b/remote-api/src/test/java/org/alfresco/AppContext04TestSuite.java index 8f41edd452..c56273db18 100644 --- a/remote-api/src/test/java/org/alfresco/AppContext04TestSuite.java +++ b/remote-api/src/test/java/org/alfresco/AppContext04TestSuite.java @@ -77,7 +77,8 @@ import org.junit.runners.Suite; org.alfresco.repo.web.scripts.node.NodeWebScripTest.class, org.alfresco.rest.api.impl.CommentsImplUnitTest.class, org.alfresco.rest.api.impl.DownloadsImplCheckArchiveStatusUnitTest.class, - org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class + org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class, + org.alfresco.rest.api.impl.SizeDetailsImplTest.class }) public class AppContext04TestSuite { diff --git a/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeSizeDetailsTest.java b/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeSizeDetailsTest.java index 946b2e18a8..2ae3a28c40 100644 --- a/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeSizeDetailsTest.java +++ b/remote-api/src/test/java/org/alfresco/rest/api/tests/NodeSizeDetailsTest.java @@ -47,7 +47,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.time.LocalTime; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeDetailsActionExecutor.java b/repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeDetailsActionExecutor.java index fb85545e1f..1cecf89df5 100644 --- a/repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeDetailsActionExecutor.java +++ b/repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeDetailsActionExecutor.java @@ -105,8 +105,8 @@ public class NodeSizeDetailsActionExecutor extends ActionExecuterAbstractBase } catch (NumberFormatException numberFormatException) { - LOG.error("Exception occurred while parsing String to INT: {}", numberFormatException.getMessage()); - response.put(EXCEPTION,numberFormatException.getMessage()); + LOG.error("Exception occurred while parsing String to INT: {} ", numberFormatException.getMessage()); + response.put(EXCEPTION,"Exception occurred while parsing String to INT: {} " + numberFormatException.getMessage()); simpleCache.put(actionedUponNodeRef.getId(),response); throw numberFormatException; } @@ -160,8 +160,8 @@ public class NodeSizeDetailsActionExecutor extends ActionExecuterAbstractBase } catch (RuntimeException runtimeException) { - LOG.error("Exception occurred in NodeSizeDetailsActionExecutor:results {}", runtimeException.getMessage()); - response.put(EXCEPTION,runtimeException.getMessage()); + LOG.error("Exception occurred in NodeSizeDetailsActionExecutor:results {} ", runtimeException.getMessage()); + response.put(EXCEPTION,"Exception occurred in NodeSizeDetailsActionExecutor:results {} "+runtimeException.getMessage()); simpleCache.put(nodeRef.getId(),response); throw runtimeException; }