Skip to content
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

Merged
merged 283 commits into from
Nov 8, 2024

Conversation

mohit-singh4
Copy link
Contributor

@mohit-singh4 mohit-singh4 commented Jun 24, 2024

Copy link

@github-advanced-security github-advanced-security bot left a 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.

@mohit-singh4 mohit-singh4 marked this pull request as ready for review June 25, 2024 07:00
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]";
Copy link
Contributor

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

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting issue

Copy link
Contributor Author

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).
*/
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format change.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue.

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue.

Copy link
Contributor Author

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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue.

Copy link
Contributor Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* Action constants
*/
public static final String NAME = "folder-size";
public static final String PAGE_SIZE = "page-size";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

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());
Copy link
Contributor

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{
Copy link
Contributor

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) {
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

mohit-singh4 added 27 commits October 20, 2024 11:46
…into feature/MNT-24127-EndpointToCalculateFolderSize

# Conflicts:
#	repository/src/main/resources/alfresco/caches.properties
…into feature/MNT-24127-EndpointToCalculateFolderSize
…into feature/MNT-24127-EndpointToCalculateFolderSize
Copy link
Contributor

@kavitshah-gl kavitshah-gl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@mohit-singh4 mohit-singh4 merged commit a35673d into master Nov 8, 2024
89 checks passed
@mohit-singh4 mohit-singh4 deleted the feature/MNT-24127-EndpointToCalculateFolderSize branch November 8, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants