use of org.olat.core.util.vfs.version.Versions in project OpenOLAT by OpenOLAT.
the class FileCopyController method fileAlreadyExists.
private void fileAlreadyExists(UserRequest ureq) {
renamedFilename = proposedRenamedFilename(existingVFSItem);
boolean locked = vfsLockManager.isLockedForMe(existingVFSItem, getIdentity(), ureq.getUserSession().getRoles());
if (locked) {
// the file is locked and cannot be overwritten
removeAsListenerAndDispose(lockedFileDialog);
lockedFileDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.lockedFile.title"), translate("ul.lockedFile.text", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(lockedFileDialog);
lockedFileDialog.activate();
} else if (existingVFSItem instanceof Versionable && ((Versionable) existingVFSItem).getVersions().isVersioned()) {
Versionable versionable = (Versionable) existingVFSItem;
Versions versions = versionable.getVersions();
String relPath = null;
if (existingVFSItem instanceof OlatRootFileImpl) {
relPath = ((OlatRootFileImpl) existingVFSItem).getRelPath();
}
int maxNumOfRevisions = FolderConfig.versionsAllowed(relPath);
if (maxNumOfRevisions == 0) {
// it's possible if someone change the configuration
// let calling method decide what to do.
removeAsListenerAndDispose(overwriteDialog);
overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.overwrite.threeoptions.text", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.overwrite"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(overwriteDialog);
overwriteDialog.activate();
} else if (versions.getRevisions().isEmpty() || maxNumOfRevisions < 0 || maxNumOfRevisions > versions.getRevisions().size()) {
// let calling method decide what to do.
removeAsListenerAndDispose(overwriteDialog);
overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.versionoroverwrite", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.newVersion"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(overwriteDialog);
overwriteDialog.activate();
} else {
String title = translate("ul.tooManyRevisions.title", new String[] { Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size()) });
String description = translate("ul.tooManyRevisions.description", new String[] { Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size()) });
removeAsListenerAndDispose(revisionListCtr);
revisionListCtr = new RevisionListController(ureq, getWindowControl(), versionable, null, description, false);
listenTo(revisionListCtr);
removeAsListenerAndDispose(revisionListDialogBox);
revisionListDialogBox = new CloseableModalController(getWindowControl(), translate("delete"), revisionListCtr.getInitialComponent(), true, title);
listenTo(revisionListDialogBox);
revisionListDialogBox.activate();
}
} else {
// let calling method decide what to do.
// for this, we put a list with "existing name" and "new name"
overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.overwrite.threeoptions.text", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.overwrite"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(overwriteDialog);
overwriteDialog.activate();
}
}
use of org.olat.core.util.vfs.version.Versions in project openolat by klemens.
the class FileCopyController method fileAlreadyExists.
private void fileAlreadyExists(UserRequest ureq) {
renamedFilename = proposedRenamedFilename(existingVFSItem);
boolean locked = vfsLockManager.isLockedForMe(existingVFSItem, getIdentity(), ureq.getUserSession().getRoles());
if (locked) {
// the file is locked and cannot be overwritten
removeAsListenerAndDispose(lockedFileDialog);
lockedFileDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.lockedFile.title"), translate("ul.lockedFile.text", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(lockedFileDialog);
lockedFileDialog.activate();
} else if (existingVFSItem instanceof Versionable && ((Versionable) existingVFSItem).getVersions().isVersioned()) {
Versionable versionable = (Versionable) existingVFSItem;
Versions versions = versionable.getVersions();
String relPath = null;
if (existingVFSItem instanceof OlatRootFileImpl) {
relPath = ((OlatRootFileImpl) existingVFSItem).getRelPath();
}
int maxNumOfRevisions = FolderConfig.versionsAllowed(relPath);
if (maxNumOfRevisions == 0) {
// it's possible if someone change the configuration
// let calling method decide what to do.
removeAsListenerAndDispose(overwriteDialog);
overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.overwrite.threeoptions.text", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.overwrite"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(overwriteDialog);
overwriteDialog.activate();
} else if (versions.getRevisions().isEmpty() || maxNumOfRevisions < 0 || maxNumOfRevisions > versions.getRevisions().size()) {
// let calling method decide what to do.
removeAsListenerAndDispose(overwriteDialog);
overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.versionoroverwrite", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.newVersion"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(overwriteDialog);
overwriteDialog.activate();
} else {
String title = translate("ul.tooManyRevisions.title", new String[] { Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size()) });
String description = translate("ul.tooManyRevisions.description", new String[] { Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size()) });
removeAsListenerAndDispose(revisionListCtr);
revisionListCtr = new RevisionListController(ureq, getWindowControl(), versionable, null, description, false);
listenTo(revisionListCtr);
removeAsListenerAndDispose(revisionListDialogBox);
revisionListDialogBox = new CloseableModalController(getWindowControl(), translate("delete"), revisionListCtr.getInitialComponent(), true, title);
listenTo(revisionListDialogBox);
revisionListDialogBox.activate();
}
} else {
// let calling method decide what to do.
// for this, we put a list with "existing name" and "new name"
overwriteDialog = DialogBoxUIFactory.createGenericDialog(ureq, getWindowControl(), translate("ul.overwrite.threeoptions.title"), translate("ul.overwrite.threeoptions.text", new String[] { existingVFSItem.getName(), renamedFilename }), asList(translate("ul.overwrite.threeoptions.overwrite"), translate("ul.overwrite.threeoptions.rename", renamedFilename), translate("ul.overwrite.threeoptions.cancel")));
listenTo(overwriteDialog);
overwriteDialog.activate();
}
}
use of org.olat.core.util.vfs.version.Versions in project openolat by klemens.
the class FileUploadController method doFinishRevisionList.
private void doFinishRevisionList(UserRequest ureq) {
if (existingVFSItem.getParentContainer() != null) {
existingVFSItem = existingVFSItem.getParentContainer().resolve(existingVFSItem.getName());
}
Versionable versionable = (Versionable) existingVFSItem;
Versions versions = versionable.getVersions();
int maxNumOfRevisions = getMaxNumOfRevisionsOfExistingVFSItem();
if (maxNumOfRevisions < 0 || maxNumOfRevisions > versions.getRevisions().size()) {
askForComment(ureq);
} else {
askToReduceRevisionList(ureq, versionable);
}
}
use of org.olat.core.util.vfs.version.Versions in project openolat by klemens.
the class FileUploadController method uploadVersionedFile.
private void uploadVersionedFile(UserRequest ureq, String renamedFilename) {
Versionable versionable = (Versionable) existingVFSItem;
Versions versions = versionable.getVersions();
int maxNumOfRevisions = getMaxNumOfRevisionsOfExistingVFSItem();
if (maxNumOfRevisions == 0) {
// it's possible if someone change the configuration
// let calling method decide what to do.
askOverwriteOrRename(ureq, renamedFilename);
} else if (versions.getRevisions().isEmpty() || maxNumOfRevisions < 0 || maxNumOfRevisions > versions.getRevisions().size()) {
// let calling method decide what to do.
askNewVersionOrRename(ureq, renamedFilename);
} else {
// too many revisions
askToReduceRevisionList(ureq, versionable);
}
}
use of org.olat.core.util.vfs.version.Versions in project openolat by klemens.
the class FileUploadController method askToReduceRevisionList.
private void askToReduceRevisionList(UserRequest ureq, Versionable versionable) {
removeAsListenerAndDispose(revisionListCtr);
removeAsListenerAndDispose(revisionListDialogBox);
Versions versions = versionable.getVersions();
int maxNumOfRevisions = getMaxNumOfRevisionsOfExistingVFSItem();
String[] params = new String[] { Integer.toString(maxNumOfRevisions), Integer.toString(versions.getRevisions().size()) };
String title = translate("ul.tooManyRevisions.title", params);
String description = translate("ul.tooManyRevisions.description", params);
revisionListCtr = new RevisionListController(ureq, getWindowControl(), versionable, null, description, false);
listenTo(revisionListCtr);
revisionListDialogBox = new CloseableModalController(getWindowControl(), translate("delete"), revisionListCtr.getInitialComponent(), true, title);
listenTo(revisionListDialogBox);
revisionListDialogBox.activate();
}
Aggregations