-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNT-24127] Added Endpoint To Calculate Folder Size #2709
[MNT-24127] Added Endpoint To Calculate Folder Size #2709
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PMD found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
remote-api/src/main/java/org/alfresco/rest/api/nodes/NodeFolderSizeRelation.java
Fixed
Show fixed
Hide fixed
remote-api/src/main/java/org/alfresco/rest/api/nodes/NodeFolderSizeRelation.java
Fixed
Show fixed
Hide fixed
remote-api/src/main/java/org/alfresco/rest/api/nodes/NodeFolderSizeRelation.java
Fixed
Show fixed
Hide fixed
repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeActionExecuter.java
Fixed
Show fixed
Hide fixed
remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java
Fixed
Show fixed
Hide fixed
repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeActionExecuter.java
Fixed
Show fixed
Hide fixed
repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeActionExecuter.java
Fixed
Show fixed
Hide fixed
remote-api/src/main/java/org/alfresco/rest/api/nodes/NodeFolderSizeRelation.java
Fixed
Show fixed
Hide fixed
remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java
Fixed
Show fixed
Hide fixed
remote-api/src/test/java/org/alfresco/rest/api/tests/NodeFolderSizeApiTest.java
Fixed
Show fixed
Hide fixed
repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeActionExecuter.java
Fixed
Show fixed
Hide fixed
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]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the field private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* The class that wraps the ReST APIs from core. | ||
*/ | ||
|
||
public void setNodes(Nodes nodes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* Please refer to OpenAPI spec for more details ! | ||
* <p> | ||
* If NodeId does not exist, EntityNotFoundException (status 404). | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we mention the return type as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
if (properties == null || !properties.containsKey(FolderSizeModel.PROP_OUTPUT)) { | ||
result.put("status", "NOT INITIATED"); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/** | ||
* Node Size | ||
* | ||
* - get folder size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add functional description about the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
parentId = getSiteContainerNodeId(testSite.getId(), "documentLibrary"); | ||
return createNode(parentId, name, nodeType, null).getId(); | ||
} catch (Exception e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public class NodeFolderSizeRelation implements | ||
RelationshipResourceAction.CalculateSize<Map<String, Object>>, | ||
RelationshipResourceAction.ReadById<Map<String, Object>>, | ||
InitializingBean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} else { | ||
Map<String, Object> mapResult = (Map<String, Object>) properties.get(FolderSizeModel.PROP_OUTPUT); | ||
mapResult.put("status", status); | ||
result = mapResult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can return directly mapResult here right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we cannot return result map directly here, as we are keeping output in the same.
And instead of returning mapResult in every if-else we can return at the end.
* | ||
* @author Mohit Singh | ||
*/ | ||
public class NodeFolderSizeApiTest extends AbstractBaseApiTest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
parentId = getSiteContainerNodeId(testSite.getId(), "documentLibrary"); | ||
return createNode(parentId, name, nodeType, null).getId(); | ||
} catch (Exception e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
|
||
@Override | ||
public String getScope() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
import org.alfresco.service.namespace.QName; | ||
|
||
@AlfrescoPublicApi | ||
public class FolderSizeModel { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeActionExecuter.java
Outdated
Show resolved
Hide resolved
repository/src/main/java/org/alfresco/repo/action/executer/NodeSizeActionExecuter.java
Outdated
Show resolved
Hide resolved
* Action constants | ||
*/ | ||
public static final String NAME = "folder-size"; | ||
public static final String PAGE_SIZE = "page-size"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we are using in Primary Endpoint class.
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) | ||
{ | ||
Serializable serializable = ruleAction.getParameterValue(PAGE_SIZE); | ||
int maxItems = Integer.parseInt(serializable.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check the exception for the parseInt.
searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); | ||
searchParameters.setQuery(query); | ||
|
||
try{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue.
// executing Alfresco FTS query. | ||
results = searchService.query(searchParameters); | ||
|
||
while(true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting issue.
|
||
@RelationshipResource(name = "calculateSize", entityResource = NodesEntityResource.class, title = "Calculate size") | ||
public class NodeFolderSizeRelation implements RelationshipResourceAction.CalculateSize<Map<String, Object>>, | ||
RelationshipResourceAction.ReadById<Map<String, Object>>, InitializingBean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…into feature/MNT-24127-EndpointToCalculateFolderSize # Conflicts: # repository/src/main/resources/alfresco/caches.properties
…eSizeDetailsTests
…into feature/MNT-24127-EndpointToCalculateFolderSize
…eSizeDetailsTests
…eSizeDetailsTests
…eSizeDetailsTests
…ls feature for solr6 subsystem
…into feature/MNT-24127-EndpointToCalculateFolderSize
…ls feature for solr6 subsystem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
https://hyland.atlassian.net/browse/MNT-24127