Search in sources :

Example 21 with VFSSecurityCallback

use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project openolat by klemens.

the class ReturnboxFullAccessCallback method init.

protected void init(UserRequest ureq) {
    myContent = createVelocityContainer("dropboxscoring");
    taskLaunchButton = LinkFactory.createButton("task.launch", myContent, this);
    cancelTaskButton = LinkFactory.createButton("task.cancel", myContent, this);
    cancelTaskButton.setVisible(!userCourseEnv.isCourseReadOnly());
    putInitialPanel(myContent);
    ModuleConfiguration modConfig = node.getModuleConfiguration();
    Boolean bValue = (Boolean) modConfig.get(TACourseNode.CONF_TASK_ENABLED);
    myContent.contextPut("hasTask", (bValue != null) ? bValue : new Boolean(false));
    // configured value
    Boolean hasDropbox = (Boolean) modConfig.get(TACourseNode.CONF_DROPBOX_ENABLED);
    Boolean hasDropboxValue = (hasDropbox != null) ? hasDropbox : new Boolean(true);
    myContent.contextPut("hasDropbox", hasDropboxValue);
    Boolean hasReturnbox = (Boolean) modConfig.get(TACourseNode.CONF_RETURNBOX_ENABLED);
    myContent.contextPut("hasReturnbox", (hasReturnbox != null) ? hasReturnbox : hasDropboxValue);
    // dropbox display
    Identity assessee = userCourseEnv.getIdentityEnvironment().getIdentity();
    String assesseeName = assessee.getName();
    UserManager userManager = CoreSpringFactory.getImpl(UserManager.class);
    String assesseeFullName = StringHelper.escapeHtml(userManager.getUserDisplayName(assessee));
    // notification
    if (hasNotification) {
        subsContext = DropboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node);
        if (subsContext != null) {
            String path = DropboxController.getDropboxPathRelToFolderRoot(userCourseEnv.getCourseEnvironment(), node);
            contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, this.getWindowControl(), path, subsContext, DropboxController.class);
            myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
            myContent.contextPut("hasNotification", Boolean.TRUE);
        }
    } else {
        myContent.contextPut("hasNotification", Boolean.FALSE);
    }
    OlatRootFolderImpl rootDropbox = new OlatRootFolderImpl(getDropboxFilePath(assesseeName), null);
    rootDropbox.setLocalSecurityCallback(getDropboxVfsSecurityCallback());
    OlatNamedContainerImpl namedDropbox = new OlatNamedContainerImpl(assesseeFullName, rootDropbox);
    namedDropbox.setLocalSecurityCallback(getDropboxVfsSecurityCallback());
    dropboxFolderRunController = new FolderRunController(namedDropbox, false, ureq, getWindowControl());
    listenTo(dropboxFolderRunController);
    myContent.put("dropbox", dropboxFolderRunController.getInitialComponent());
    Identity assessedIdentity = userCourseEnv.getIdentityEnvironment().getIdentity();
    // returnbox display
    OlatRootFolderImpl rootReturnbox = new OlatRootFolderImpl(getReturnboxFilePath(assesseeName), null);
    VFSSecurityCallback secCallback = getReturnboxVfsSecurityCallback(rootReturnbox.getRelPath(), assessedIdentity);
    rootReturnbox.setLocalSecurityCallback(secCallback);
    OlatNamedContainerImpl namedReturnbox = new OlatNamedContainerImpl(assesseeFullName, rootReturnbox);
    namedReturnbox.setLocalSecurityCallback(secCallback);
    returnboxFolderRunController = new FolderRunController(namedReturnbox, false, ureq, getWindowControl());
    returnboxFolderRunController.disableSubscriptionController();
    listenTo(returnboxFolderRunController);
    myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
    // insert Status Pull-Down Menu depending on user role == author
    boolean isAuthor = ureq.getUserSession().getRoles().isAuthor();
    boolean isTutor = userCourseEnv.getCourseEnvironment().getCourseGroupManager().isIdentityCourseCoach(ureq.getIdentity());
    if (((AssessableCourseNode) node).hasStatusConfigured() && (isAuthor || isTutor)) {
        myContent.contextPut("hasStatusPullDown", Boolean.TRUE);
        statusForm = new StatusForm(ureq, getWindowControl(), userCourseEnv.isCourseReadOnly());
        listenTo(statusForm);
        // get identity not from request (this would be an author)
        StatusManager.getInstance().loadStatusFormData(statusForm, node, userCourseEnv);
        myContent.put("statusForm", statusForm.getInitialComponent());
    }
    assignedTask = TaskController.getAssignedTask(assessedIdentity, userCourseEnv.getCourseEnvironment(), node);
    if (assignedTask != null) {
        myContent.contextPut("assignedtask", assignedTask);
        myContent.contextPut("taskIcon", CSSHelper.createFiletypeIconCssClassFor(assignedTask));
        if (!(assignedTask.toLowerCase().endsWith(".html") || assignedTask.toLowerCase().endsWith(".htm") || assignedTask.toLowerCase().endsWith(".txt"))) {
            taskLaunchButton.setTarget("_blank");
        }
    }
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) UserManager(org.olat.user.UserManager) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) Identity(org.olat.core.id.Identity) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 22 with VFSSecurityCallback

use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project OpenOLAT by OpenOLAT.

the class ImsCPHandler method createEditorController.

@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbar) {
    // only unzips, if not already unzipped
    OlatRootFolderImpl cpRoot = FileResourceManager.getInstance().unzipContainerResource(re.getOlatResource());
    Quota quota = QuotaManager.getInstance().getCustomQuota(cpRoot.getRelPath());
    if (quota == null) {
        Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_REPO);
        quota = QuotaManager.getInstance().createQuota(cpRoot.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    VFSSecurityCallback secCallback = new FullAccessWithQuotaCallback(quota);
    cpRoot.setLocalSecurityCallback(secCallback);
    return new CPEditMainController(ureq, wControl, toolbar, cpRoot, re.getOlatResource());
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) CPEditMainController(org.olat.ims.cp.ui.CPEditMainController)

Example 23 with VFSSecurityCallback

use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project OpenOLAT by OpenOLAT.

the class LearningGroupWebService method getFolder.

@Path("{groupKey}/folder")
public VFSWebservice getFolder(@PathParam("groupKey") Long groupKey, @Context HttpServletRequest request) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    BusinessGroup bg = bgs.loadBusinessGroup(groupKey);
    if (bg == null) {
        return null;
    }
    if (!isGroupManager(request)) {
        Identity identity = RestSecurityHelper.getIdentity(request);
        if (!bgs.isIdentityInBusinessGroup(identity, bg)) {
            return null;
        }
    }
    CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(bg);
    if (!collabTools.isToolEnabled(CollaborationTools.TOOL_FOLDER)) {
        return null;
    }
    String relPath = collabTools.getFolderRelPath();
    QuotaManager qm = QuotaManager.getInstance();
    Quota folderQuota = qm.getCustomQuota(relPath);
    if (folderQuota == null) {
        Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_GROUPS);
        folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
    }
    SubscriptionContext subsContext = null;
    VFSSecurityCallback secCallback = new VFSWebServiceSecurityCallback(true, true, true, folderQuota, subsContext);
    OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(relPath, null);
    rootContainer.setLocalSecurityCallback(secCallback);
    return new VFSWebservice(rootContainer);
}
Also used : VFSWebServiceSecurityCallback(org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Quota(org.olat.core.util.vfs.Quota) BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) QuotaManager(org.olat.core.util.vfs.QuotaManager) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) Path(javax.ws.rs.Path)

Example 24 with VFSSecurityCallback

use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project OpenOLAT by OpenOLAT.

the class UserFoldersWebService method getFolder.

@Path("personal")
public VFSWebservice getFolder(@Context HttpServletRequest request) {
    Identity ureqIdentity = getIdentity(request);
    if (identity.getKey().equals(ureqIdentity.getKey())) {
        // private and public folder
        VFSContainer myFodlers = new BriefcaseWebDAVProvider().getContainer(ureqIdentity);
        return new VFSWebservice(myFodlers);
    } else {
        // only public
        String chosenUserFolderRelPath = FolderConfig.getUserHome(identity.getName()) + "/" + "public";
        OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(chosenUserFolderRelPath, null);
        VFSSecurityCallback secCallback = new ReadOnlyCallback();
        rootFolder.setLocalSecurityCallback(secCallback);
        return new VFSWebservice(rootFolder);
    }
}
Also used : BriefcaseWebDAVProvider(org.olat.core.commons.modules.bc.BriefcaseWebDAVProvider) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) Identity(org.olat.core.id.Identity) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) Path(javax.ws.rs.Path)

Example 25 with VFSSecurityCallback

use of org.olat.core.util.vfs.callbacks.VFSSecurityCallback in project OpenOLAT by OpenOLAT.

the class PFManager method provideCoachContainer.

/**
 * Provide coach view in webdav.
 *
 * @param pfNode
 * @param courseEnv
 * @param identity
 * @return the VFSContainer
 */
private VFSContainer provideCoachContainer(PFCourseNode pfNode, CourseEnvironment courseEnv, Identity identity, boolean admin) {
    Locale locale = I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage());
    Translator translator = Util.createPackageTranslator(PFRunController.class, locale);
    SubscriptionContext nodefolderSubContext = CourseModule.createSubscriptionContext(courseEnv, pfNode);
    List<Identity> participants = getParticipants(identity, courseEnv, admin);
    String path = courseEnv.getCourseBaseContainer().getRelPath() + "/" + FILENAME_PARTICIPANTFOLDER;
    VFSContainer courseElementBaseContainer = new OlatRootFolderImpl(path, null);
    VirtualContainer namedCourseFolder = new VirtualContainer(translator.translate("participant.folder"));
    for (Identity participant : participants) {
        Path relPath = Paths.get(pfNode.getIdent(), getIdFolderName(participant));
        VFSContainer userBaseContainer = VFSManager.resolveOrCreateContainerFromPath(courseElementBaseContainer, relPath.toString());
        String participantfoldername = userManager.getUserDisplayName(participant);
        VirtualContainer participantFolder = new VirtualContainer(participantfoldername);
        namedCourseFolder.addItem(participantFolder);
        if (pfNode.hasParticipantBoxConfigured()) {
            VFSContainer dropContainer = new NamedContainerImpl(translator.translate("drop.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_DROPBOX));
            // if coach is also participant, can user his/her webdav folder with participant rights
            if (identity.equals(participant)) {
                VFSContainer dropbox = resolveOrCreateDropFolder(courseEnv, pfNode, identity);
                VFSSecurityCallback callback = calculateCallback(courseEnv, pfNode, dropbox, true);
                dropContainer.setLocalSecurityCallback(callback);
            } else {
                dropContainer.setLocalSecurityCallback(new ReadOnlyCallback(nodefolderSubContext));
            }
            participantFolder.addItem(dropContainer);
        }
        if (pfNode.hasCoachBoxConfigured()) {
            VFSContainer returnContainer = new NamedContainerImpl(translator.translate("return.box"), VFSManager.resolveOrCreateContainerFromPath(userBaseContainer, FILENAME_RETURNBOX));
            returnContainer.setLocalSecurityCallback(new ReadWriteDeleteCallback(nodefolderSubContext));
            participantFolder.addItem(returnContainer);
        }
    }
    return namedCourseFolder;
}
Also used : Locale(java.util.Locale) Path(java.nio.file.Path) VFSContainer(org.olat.core.util.vfs.VFSContainer) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Translator(org.olat.core.gui.translator.Translator) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Aggregations

VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)50 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)28 VFSContainer (org.olat.core.util.vfs.VFSContainer)26 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)24 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)10 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)8 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)8 Identity (org.olat.core.id.Identity)8 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)8 VFSItem (org.olat.core.util.vfs.VFSItem)8 Path (java.nio.file.Path)6 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)6 VirtualContainer (org.olat.core.util.vfs.VirtualContainer)6 Quota (org.olat.core.util.vfs.Quota)5 Locale (java.util.Locale)4 Path (javax.ws.rs.Path)4 WindowControl (org.olat.core.gui.control.WindowControl)4 MediaResource (org.olat.core.gui.media.MediaResource)4