Search in sources :

Example 6 with Versions

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();
    }
}
Also used : Versionable(org.olat.core.util.vfs.version.Versionable) Versions(org.olat.core.util.vfs.version.Versions) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) OlatRootFileImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl) RevisionListController(org.olat.core.commons.modules.bc.version.RevisionListController)

Example 7 with Versions

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();
    }
}
Also used : Versionable(org.olat.core.util.vfs.version.Versionable) Versions(org.olat.core.util.vfs.version.Versions) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) OlatRootFileImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl) RevisionListController(org.olat.core.commons.modules.bc.version.RevisionListController)

Example 8 with Versions

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);
    }
}
Also used : Versionable(org.olat.core.util.vfs.version.Versionable) Versions(org.olat.core.util.vfs.version.Versions)

Example 9 with Versions

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);
    }
}
Also used : Versionable(org.olat.core.util.vfs.version.Versionable) Versions(org.olat.core.util.vfs.version.Versions)

Example 10 with Versions

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();
}
Also used : Versions(org.olat.core.util.vfs.version.Versions) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) RevisionListController(org.olat.core.commons.modules.bc.version.RevisionListController)

Aggregations

Versions (org.olat.core.util.vfs.version.Versions)20 Versionable (org.olat.core.util.vfs.version.Versionable)10 VFSRevision (org.olat.core.util.vfs.version.VFSRevision)8 RevisionListController (org.olat.core.commons.modules.bc.version.RevisionListController)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 OlatRootFileImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 FileLinkChooserController (org.olat.core.commons.controllers.linkchooser.FileLinkChooserController)2 URLChoosenEvent (org.olat.core.commons.controllers.linkchooser.URLChoosenEvent)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaInfoFactory (org.olat.core.commons.modules.bc.meta.MetaInfoFactory)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 VersionCommentController (org.olat.core.commons.modules.bc.version.VersionCommentController)2 License (org.olat.core.commons.services.license.License)2