Skip to content

Commit

Permalink
SAK-50375 Content calculate collection sizes by collection type (saka…
Browse files Browse the repository at this point in the history
  • Loading branch information
ern authored Aug 14, 2024
1 parent 0691788 commit 324ffae
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10880,20 +10880,33 @@ public List getMembers()
*
* @return The size of all the resource body bytes within this collection in Kbytes.
*/
public long getBodySizeK()
{
long size = 0;

String context = getContext();
if(context != null || m_id.startsWith(COLLECTION_DROPBOX))
{
size = getSizeForContext(context!=null?context:m_id)/1000L;
}

log.debug("getBodySizeK(): collection: {} size: {}",getId(),size);
return size;
public long getBodySizeK() {
long size = 0;
String context = getContext();
if (context != null) {
Map<String, Long> sizes = getSizeForContext(context);
if (m_id.startsWith(COLLECTION_DROPBOX)) {
size = sizes.keySet().stream()
.filter(k -> k.startsWith(COLLECTION_DROPBOX))
.mapToLong(k -> Long.valueOf(sizes.get(k)))
.sum();
} else if (m_id.startsWith(COLLECTION_USER)) {
size = sizes.keySet().stream()
.filter(k -> k.startsWith(COLLECTION_USER))
.mapToLong(k -> Long.valueOf(sizes.get(k)))
.sum();
} else {
size = sizes.keySet().stream()
.filter(k -> k.startsWith(COLLECTION_SITE))
.mapToLong(k -> Long.valueOf(sizes.get(k)))
.sum();
}

} // getBodySizeK
if (size > 0) size /= 1024L;
}
log.debug("getBodySizeK(): collection: {} size: {}", getId(), size);
return size;
}

/**
* Access a List of the collections' internal members as full ContentResource or ContentCollection objects.
Expand Down Expand Up @@ -12982,9 +12995,9 @@ public void registerSiteContentAdvisorProvidor(SiteContentAdvisorProvider adviso
siteContentAdvisorsProviders.put(type, advisor);
}

protected long getSizeForContext(String context)
public Map<String, Long> getSizeForContext(String context)
{
return 0;
return Collections.emptyMap();
}

public Map<String, String> transferCopyEntities(String fromContext, String toContext, List<String> ids, List<String> options, boolean cleanup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ public interface ContentServiceSql
* returns the sql statement which retrieves the total number of bytes within a site-level collection (context) in the CONTENT_RESOURCE table.
*/
String getQuotaQuerySql();

/**
* returns the sql statement which retrieves the total number of bytes for each collection within a site.
*/
String getContextSizesSql();

/**
* returns the sql statement which retrieves the total number of bytes for this collection
*/
String getCollectionSizeSql();

String getDropBoxQuotaQuerySql();
/**
* returns the sql statement which retrieves the total number of bytes within a site-level collection skiping user folders.
Expand Down
Loading

0 comments on commit 324ffae

Please sign in to comment.