use of org.olat.core.util.vfs.version.OrphanVersion in project openolat by klemens.
the class VersionMaintenanceForm method calculateOrphanSize.
public final void calculateOrphanSize() {
long size = 0l;
List<OrphanVersion> orphans = versionsManager.orphans();
for (OrphanVersion orphan : orphans) {
List<VFSRevision> revisions = orphan.getVersions().getRevisions();
if (revisions != null) {
for (VFSRevision revision : revisions) {
size += revision.getSize();
}
}
}
String unit = "KB";
double humanSize = size / 1024.0d;
if (humanSize > 1024) {
humanSize /= 1024;
unit = "MB";
}
DecimalFormat sizeFormat = new DecimalFormat("#0.#", new DecimalFormatSymbols(Locale.ENGLISH));
String readableSize = sizeFormat.format(humanSize) + " " + unit;
if (orphanSizeEl != null && !isDisposed()) {
orphanSizeEl.setValue(readableSize);
}
}
Aggregations