Search in sources :

Example 1 with OlatNamedContainerImpl

use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.

the class BriefcaseWebDAVMergeSource method init.

@Override
protected void init() {
    super.init();
    // mount /public
    String rootPath = PersonalFolderManager.getInstance().getRootPathFor(identity);
    OlatRootFolderImpl vfsPublic = new OlatRootFolderImpl(rootPath + "/public", this);
    // vfsPublic.getBasefile().mkdirs(); // lazy initialize folders
    // we do a little trick here and wrap it again in a NamedContainerImpl so
    // it doesn't show up as a OlatRootFolderImpl to prevent it from editing its MetaData
    OlatNamedContainerImpl vfsNamedPublic = new OlatNamedContainerImpl("public", vfsPublic);
    addContainer(vfsNamedPublic);
    // mount /private
    OlatRootFolderImpl vfsPrivate = new OlatRootFolderImpl(rootPath + "/private", this);
    // vfsPrivate.getBasefile().mkdirs(); // lazy initialize folders
    // we do a little trick here and wrap it again in a NamedContainerImpl so
    // it doesn't show up as a OlatRootFolderImpl to prevent it from editing its MetaData
    OlatNamedContainerImpl vfsNamedPrivate = new OlatNamedContainerImpl("private", vfsPrivate);
    addContainer(vfsNamedPrivate);
    init = true;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)

Example 2 with OlatNamedContainerImpl

use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.

the class TaskFolderCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == modulesForm) {
        boolean onoff = event.getCommand().endsWith("true");
        if (event.getCommand().startsWith("task")) {
            config.set(TACourseNode.CONF_TASK_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(taskTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("taskCondition", taskConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(taskConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("dropbox")) {
            config.set(TACourseNode.CONF_DROPBOX_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(dropboxTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("dropCondition", dropConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(dropConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("returnbox")) {
            config.set(TACourseNode.CONF_RETURNBOX_ENABLED, new Boolean(onoff));
            if (onoff) {
                accessabilityVC.put("returnboxCondition", returnboxConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(returnboxConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("scoring")) {
            config.set(TACourseNode.CONF_SCORING_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(scoringTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("scoringCondition", scoringConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(scoringConditionC.getInitialComponent());
            }
        } else if (event.getCommand().startsWith("solution")) {
            config.set(TACourseNode.CONF_SOLUTION_ENABLED, new Boolean(onoff));
            myTabbedPane.setEnabled(solutionTabPosition, onoff);
            if (onoff) {
                accessabilityVC.put("solutionCondition", solutionConditionC.getInitialComponent());
            } else {
                accessabilityVC.remove(solutionConditionC.getInitialComponent());
            }
        }
        fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        return;
    } else if (source == taskConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionTask(taskConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dropConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionDrop(dropConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == returnboxConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionReturnbox(returnboxConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == scoringConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionScoring(scoringConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == solutionConditionC) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionSolution(solutionConditionC.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dialogBoxController) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            // ok: open task folder
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
            frc = new FolderRunController(namedFolder, false, urequest, getWindowControl());
            listenTo(frc);
            CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            cmc.activate();
            fireEvent(urequest, Event.CHANGED_EVENT);
        }
    } else if (source == taskController) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            config.set(TACourseNode.CONF_TASK_TYPE, taskController.getTaskType());
            config.set(TACourseNode.CONF_TASK_TEXT, taskController.getOptionalText());
            config.set(TACourseNode.CONF_TASK_SAMPLING_WITH_REPLACEMENT, new Boolean(taskController.getIsSamplingWithReplacement()));
            config.setBooleanEntry(TACourseNode.CONF_TASK_PREVIEW, taskController.isTaskPreviewMode());
            config.setBooleanEntry(TACourseNode.CONF_TASK_DESELECT, taskController.isTaskDeselectMode());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            return;
        }
    } else if (source == scoringController) {
        if (event == Event.CANCELLED_EVENT) {
            if (hasLogEntries) {
                scoringController.setDisplayOnly(true);
            }
            editScoring.contextPut("isOverwriting", new Boolean(false));
            return;
        } else if (event == Event.DONE_EVENT) {
            scoringController.updateModuleConfiguration(config);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dropboxForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            config.set(TACourseNode.CONF_DROPBOX_ENABLEMAIL, new Boolean(dropboxForm.mailEnabled()));
            config.set(TACourseNode.CONF_DROPBOX_CONFIRMATION, dropboxForm.getConfirmation());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            return;
        }
    } else if (source == frc && (event instanceof FolderEvent) && event.getCommand().equals(FolderEvent.DELETE_EVENT)) {
        String deletedTaskFile = getFileListAsComaSeparated(((FolderEvent) event).getFilename());
        // cancel task assignment
        identitiesToBeNotified = removeAssignedTask(course, deletedTaskFile);
        if (identitiesToBeNotified.size() > 0) {
            // prepare mailTemplate if they are any identities to be notified
            removeAsListenerAndDispose(mailCtr);
            RepositoryEntry repositoryEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
            String courseURL = Settings.getServerContextPathURI() + "/url/RepositoryEntry/" + repositoryEntry.getKey();
            MailTemplate mailTemplate = this.createTaskDeletedMailTemplate(urequest, course.getCourseTitle(), courseURL, deletedTaskFile);
            mailCtr = new MailNotificationEditController(getWindowControl(), urequest, mailTemplate, true, false, true);
            listenTo(mailCtr);
            cmc = new CloseableModalController(getWindowControl(), translate("close"), mailCtr.getInitialComponent());
            listenTo(cmc);
            cmc.activate();
        }
    } else if (source == mailCtr) {
        if (event == Event.DONE_EVENT) {
            cmc.deactivate();
            if (identitiesToBeNotified != null && identitiesToBeNotified.size() > 0) {
                // sent email to all identities that used to have the deleted task assigned
                sendNotificationEmail(urequest, mailCtr.getMailTemplate(), identitiesToBeNotified);
            }
        } else if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
        }
    } else {
        log.warn("Can not handle event in TACourseNodeEditController source=" + source + " " + event.toString());
    }
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) MailTemplate(org.olat.core.util.mail.MailTemplate) FolderEvent(org.olat.core.commons.modules.bc.FolderEvent) RepositoryEntry(org.olat.repository.RepositoryEntry) MailNotificationEditController(org.olat.core.util.mail.MailNotificationEditController)

Example 3 with OlatNamedContainerImpl

use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.

the class FolderCallback method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == projectBrokerConditionController) {
        if (event == Event.CHANGED_EVENT) {
            node.setConditionProjectBroker(projectBrokerConditionController.getCondition());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == dialogBoxController) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            // ok: open task folder
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(CourseFactory.loadCourse(courseId), node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(new FolderCallback(relPath, false));
            removeAsListenerAndDispose(frc);
            frc = new FolderRunController(namedFolder, false, urequest, getWindowControl());
            listenTo(frc);
            removeAsListenerAndDispose(cmc);
            cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            listenTo(cmc);
            cmc.activate();
            fireEvent(urequest, Event.CHANGED_EVENT);
        }
    } else if (source == scoringController) {
        if (event == Event.CANCELLED_EVENT) {
            if (hasLogEntries) {
                scoringController.setDisplayOnly(true);
            }
            editScoring.contextPut("isOverwriting", new Boolean(false));
            return;
        } else if (event == Event.DONE_EVENT) {
            scoringController.updateModuleConfiguration(config);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == modulesForm) {
        boolean onoff = event.getCommand().endsWith("true");
        if (event.getCommand().startsWith("dropbox")) {
            config.set(ProjectBrokerCourseNode.CONF_DROPBOX_ENABLED, onoff);
        } else if (event.getCommand().startsWith("returnbox")) {
            config.set(ProjectBrokerCourseNode.CONF_RETURNBOX_ENABLED, onoff);
        }
        fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        return;
    } else if (source == accountManagerGroupController) {
        if (event instanceof IdentitiesAddEvent) {
            IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
            BusinessGroupAddResponse response = businessGroupService.addParticipants(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), accountManagerGroup, null);
            identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
            identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
            identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
            getLogger().info("Add users as account-managers");
            fireEvent(urequest, Event.CHANGED_EVENT);
        } else if (event instanceof IdentitiesRemoveEvent) {
            businessGroupService.removeParticipants(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), accountManagerGroup, null);
            getLogger().info("Remove users as account-managers");
            fireEvent(urequest, Event.CHANGED_EVENT);
        }
    } else if (source == optionsForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            projectBrokerModuleConfiguration.setNbrParticipantsPerTopic(optionsForm.getNnbrOfAttendees());
            if (projectBrokerModuleConfiguration.isAcceptSelectionManually() && !optionsForm.getSelectionAccept()) {
                // change 'Accept manually' to 'Accept automatically' => enroll all candidates
                projectGroupManager.acceptAllCandidates(projectBrokerId, urequest.getIdentity(), projectBrokerModuleConfiguration.isAutoSignOut(), optionsForm.getSelectionAccept());
            }
            projectBrokerModuleConfiguration.setAcceptSelectionManaually(optionsForm.getSelectionAccept());
            projectBrokerModuleConfiguration.setSelectionAutoSignOut(optionsForm.getSelectionAutoSignOut());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == customfieldsForm || source == projectEventForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
        getLogger().debug("NODECONFIG_CHANGED_node.shortTitle=" + node.getShortTitle());
        String groupName = translate("account.manager.groupname", node.getShortTitle());
        String groupDescription = translate("account.manager.groupdescription", node.getShortTitle());
        accountManagerGroup = projectGroupManager.updateAccountManagerGroupName(getIdentity(), groupName, groupDescription, accountManagerGroup);
    } else if (source == dropboxForm) {
        if (event == Event.CANCELLED_EVENT) {
            return;
        } else if (event == Event.DONE_EVENT) {
            config.set(ProjectBrokerCourseNode.CONF_DROPBOX_ENABLEMAIL, dropboxForm.mailEnabled());
            config.set(ProjectBrokerCourseNode.CONF_DROPBOX_CONFIRMATION, dropboxForm.getConfirmation());
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            return;
        }
    } else {
        getLogger().warn("Can not handle event in ProjectBrokerCourseEditorController source=" + source + " " + event.toString());
    }
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) BusinessGroupAddResponse(org.olat.group.BusinessGroupAddResponse)

Example 4 with OlatNamedContainerImpl

use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.

the class SharedFolderManager method getNamedSharedFolder.

/**
 * @param re The repository entry of the shared folder
 * @param urlCompliant Encode the name to be file save
 * @return The container
 */
public VFSContainer getNamedSharedFolder(RepositoryEntry re, boolean urlCompliant) {
    String name = re.getDisplayname();
    if (urlCompliant) {
        name = RequestUtil.normalizeFilename(name);
    }
    OlatRootFolderImpl folder = getSharedFolder(re.getOlatResource());
    return folder == null ? null : new OlatNamedContainerImpl(name, folder);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)

Example 5 with OlatNamedContainerImpl

use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl in project OpenOLAT by OpenOLAT.

the class UserInfoMainController method doOpenFolder.

private FolderRunController doOpenFolder(UserRequest ureq) {
    removeAsListenerAndDispose(folderRunController);
    String chosenUserFolderRelPath = FolderConfig.getUserHome(chosenIdentity.getName()) + "/public";
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(chosenUserFolderRelPath, null);
    OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(firstLastName, rootFolder);
    // decided in plenum to have read only view in the personal visiting card, even for admin
    VFSSecurityCallback secCallback = new ReadOnlyCallback();
    namedFolder.setLocalSecurityCallback(secCallback);
    OLATResourceable ores = OresHelper.createOLATResourceableType("userfolder");
    WindowControl bwControl = addToHistory(ureq, ores, null);
    folderRunController = new FolderRunController(namedFolder, false, true, false, ureq, bwControl);
    folderRunController.setResourceURL("[Identity:" + chosenIdentity.getKey() + "][userfolder:0]");
    listenTo(folderRunController);
    return folderRunController;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) OLATResourceable(org.olat.core.id.OLATResourceable) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) WindowControl(org.olat.core.gui.control.WindowControl) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Aggregations

OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)42 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)28 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)16 VFSItem (org.olat.core.util.vfs.VFSItem)12 Test (org.junit.Test)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)10 URI (java.net.URI)8 HttpResponse (org.apache.http.HttpResponse)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 HttpPut (org.apache.http.client.methods.HttpPut)6 Quota (org.olat.core.util.vfs.Quota)6 FullAccessWithQuotaCallback (org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback)6 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)6 File (java.io.File)4 IOException (java.io.IOException)4 URL (java.net.URL)4 Identity (org.olat.core.id.Identity)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4