Skip to content

Commit

Permalink
[MNT-24127] Added endpoint implementation to calculating folder size.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-singh4 committed Mar 5, 2024
1 parent 2732e40 commit 412af05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3567,7 +3567,7 @@ public Map<String, Object> getFolderSize(String folderNodeId){
int k = 1024;
String[] sizes = {"Bytes", "KB", "MB", "GB", "TB", "PB"};
int i = (int) Math.floor(Math.log(size) / Math.log(k));
float finalSize = Float.parseFloat(String.valueOf((size / Math.pow(k, i))));
float finalSize = Float.parseFloat(String.valueOf(size / Math.pow(k, i)));
Map<String, Object> response = new HashMap<>();
response.put("id", folderNodeId);
response.put("size", String.valueOf(finalSize + " " + sizes[i]));
Expand All @@ -3579,11 +3579,7 @@ protected long getNodeSize(NodeRef nodeRef){
long size=0;
// Collecting current node size.
ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
try {
size = contentData.getSize();
} catch (Exception e) {
size = 0;
}
size = contentData.getSize();
List<ChildAssociationRef> chilAssocsList = nodeService.getChildAssocs(nodeRef);
for (ChildAssociationRef childAssociationRef : chilAssocsList) {
NodeRef childNodeRef = childAssociationRef.getChildRef();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ public static interface DeleteSetWithResponse extends ResourceAction
*/
public void deleteSet(String entityResourceId, Parameters params, WithResponse withResponse);
}
public static interface FolderSize<E> extends ResourceAction
interface FolderSize<E> extends ResourceAction
{
/**
* Return the size of Folder.
*
* @param nodeId Entity resource context for this relationship.
*/
public E readAll(String nodeId);
E readAll(String nodeId);
}
}

0 comments on commit 412af05

Please sign in to comment.