private VFSContainer doUnzip(VFSLeaf vfsItem, VFSContainer currentContainer, WindowControl wControl, UserRequest ureq) {
String name = vfsItem.getName();
// we make a new folder with the same name as the zip file
String sZipContainer = name.substring(0, name.length() - 4);
VFSContainer zipContainer = currentContainer.createChildContainer(sZipContainer);
if (zipContainer == null) {
// folder already exists... issue warning
wControl.setError(getTranslator().translate(NLS_UNZIP_ALREADYEXISTS, new String[] {sZipContainer}));
// selectionTree must be set here since it fires events which will get caught in event methods below
initFileSelectionController(ureq);
return null;
}
if (!ZipUtil.unzip(vfsItem, zipContainer)) {
// operation failed - rollback
zipContainer.delete();
return null;
} else {
// check quota
long quotaLeftKB = VFSManager.getQuotaLeftKB(currentContainer);
if (quotaLeftKB != Quota.UNLIMITED && quotaLeftKB < 0) {
// quota exceeded - rollback
zipContainer.delete();
wControl.setError(getTranslator().translate(NLS_QUOTAEXEEDED));
return null;
}
}
return zipContainer;