Skip to content
Snippets Groups Projects
Commit 707d82ea authored by srosse's avatar srosse
Browse files

OO-108: fix red screen if the the user must delete some versions and click on...

OO-108: fix red screen if the the user must delete some versions and click on the [x] button of the panel with the list of versions
parent fa8d15fe
No related branches found
No related tags found
No related merge requests found
...@@ -74,13 +74,11 @@ import org.olat.core.util.vfs.VFSConstants; ...@@ -74,13 +74,11 @@ import org.olat.core.util.vfs.VFSConstants;
import org.olat.core.util.vfs.VFSContainer; import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSItem; import org.olat.core.util.vfs.VFSItem;
import org.olat.core.util.vfs.VFSLeaf; import org.olat.core.util.vfs.VFSLeaf;
import org.olat.core.util.vfs.VFSManager;
import org.olat.core.util.vfs.version.Versionable; import org.olat.core.util.vfs.version.Versionable;
import org.olat.core.util.vfs.version.Versions; import org.olat.core.util.vfs.version.Versions;
import org.olat.core.util.vfs.version.VersionsManager; import org.olat.core.util.vfs.version.VersionsManager;
import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;
import com.oreilly.servlet.multipart.FileRenamePolicy;
/** /**
* <h3>Description</h3> * <h3>Description</h3>
* <p> * <p>
...@@ -343,16 +341,14 @@ public class FileUploadController extends FormBasicController { ...@@ -343,16 +341,14 @@ public class FileUploadController extends FormBasicController {
// file already exists... upload anyway with new filename and // file already exists... upload anyway with new filename and
// in the folder manager status. // in the folder manager status.
// rename file and ask user what to do // rename file and ask user what to do
FileRenamePolicy frp = new DefaultFileRenamePolicy();
if ( ! (existingVFSItem instanceof LocalImpl)) { if ( ! (existingVFSItem instanceof LocalImpl)) {
throw new AssertException("Can only LocalImpl VFS items, don't know what to do with file of type::" + existingVFSItem.getClass().getCanonicalName()); throw new AssertException("Can only LocalImpl VFS items, don't know what to do with file of type::" + existingVFSItem.getClass().getCanonicalName());
} }
File existingFile = ((LocalImpl)existingVFSItem).getBasefile();
File tmpOrigFilename = new File(existingFile.getAbsolutePath()); String renamedFilename = VFSManager.rename(uploadVFSContainer, existingVFSItem.getName());
String renamedFilename = frp.rename(tmpOrigFilename).getName(); newFile = uploadVFSContainer.createChildLeaf(renamedFilename);
newFile = (VFSLeaf) uploadVFSContainer.resolve(renamedFilename);
// Copy content to tmp file // Copy content to tmp file
InputStream in = null; InputStream in = null;
BufferedOutputStream out = null; BufferedOutputStream out = null;
boolean success = false; boolean success = false;
...@@ -608,20 +604,38 @@ public class FileUploadController extends FormBasicController { ...@@ -608,20 +604,38 @@ public class FileUploadController extends FormBasicController {
// ... and notify listeners. // ... and notify listeners.
finishUpload(ureq); finishUpload(ureq);
} else if (source == revisionListDialogBox) {
removeAsListenerAndDispose(revisionListCtr);
revisionListCtr = null;
removeAsListenerAndDispose(revisionListDialogBox);
revisionListDialogBox = null;
//remove the file
newFile.delete();
VersionsManager.getInstance().delete(newFile, true);
} else if (source == revisionListCtr) { } else if (source == revisionListCtr) {
if(FolderCommandStatus.STATUS_CANCELED == revisionListCtr.getStatus()) { if(FolderCommandStatus.STATUS_CANCELED == revisionListCtr.getStatus()) {
revisionListDialogBox.deactivate(); revisionListDialogBox.deactivate();
removeAsListenerAndDispose(revisionListDialogBox);
revisionListDialogBox = null;
//don't want to delete revisions, clean the temporary file //don't want to delete revisions, clean the temporary file
newFile.delete(); if(newFile != null) {
VersionsManager.getInstance().delete(newFile, true); newFile.delete();
fireEvent(ureq, Event.CANCELLED_EVENT); VersionsManager.getInstance().delete(newFile, true);
}
} else { } else {
if (existingVFSItem instanceof Versionable && ((Versionable)existingVFSItem).getVersions().isVersioned()) { if (existingVFSItem instanceof Versionable && ((Versionable)existingVFSItem).getVersions().isVersioned()) {
revisionListDialogBox.deactivate(); revisionListDialogBox.deactivate();
removeAsListenerAndDispose(revisionListDialogBox);
revisionListDialogBox = null;
if(existingVFSItem.getParentContainer() != null) {
existingVFSItem = existingVFSItem.getParentContainer().resolve(existingVFSItem.getName());
}
Versionable versionable = (Versionable)existingVFSItem; Versionable versionable = (Versionable)existingVFSItem;
Versions versions = versionable.getVersions(); Versions versions = versionable.getVersions();
int maxNumOfRevisions = FolderConfig.versionsAllowed(null); int maxNumOfRevisions = FolderConfig.versionsAllowed(null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment