Search in sources :

Example 6 with ReadOnlyCallback

use of org.olat.core.util.vfs.callbacks.ReadOnlyCallback 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)

Example 7 with ReadOnlyCallback

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

the class GroupfoldersWebDAVMergeSource method getGroupContainer.

private VFSContainer getGroupContainer(String name, BusinessGroup group, boolean isOwner) {
    String folderPath = collaborationManager.getFolderRelPath(group);
    // create container and set quota
    OlatRootFolderImpl localImpl = new OlatRootFolderImpl(folderPath, this);
    // already done in OlatRootFolderImpl localImpl.getBasefile().mkdirs(); // lazy initialize dirs
    String containerName = RequestUtil.normalizeFilename(name);
    NamedContainerImpl grpContainer = new GroupNamedContainer(containerName, localImpl);
    boolean writeAccess;
    if (!isOwner) {
        // check if participants have read/write access
        int folderAccess = CollaborationTools.FOLDER_ACCESS_ALL;
        Long lFolderAccess = collaborationManager.lookupFolderAccess(group);
        if (lFolderAccess != null) {
            folderAccess = lFolderAccess.intValue();
        }
        writeAccess = (folderAccess == CollaborationTools.FOLDER_ACCESS_ALL);
    } else {
        writeAccess = true;
    }
    VFSSecurityCallback secCallback;
    if (writeAccess) {
        SubscriptionContext sc = new SubscriptionContext(group, "toolfolder");
        secCallback = new FullAccessWithLazyQuotaCallback(folderPath, QuotaConstants.IDENTIFIER_DEFAULT_GROUPS, sc);
    } else {
        secCallback = new ReadOnlyCallback();
    }
    grpContainer.setLocalSecurityCallback(secCallback);
    return grpContainer;
}
Also used : FullAccessWithLazyQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithLazyQuotaCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl)

Example 8 with ReadOnlyCallback

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

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)

Example 9 with ReadOnlyCallback

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

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 10 with ReadOnlyCallback

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

the class SharedFolderWebService method getVFSWebservice.

/**
 * This retrieves the files in the shared folder and give full access to
 * the folder, read, write, delete.
 *
 * @response.representation.200.doc The list of files
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course or the file not found
 * @param repoEntryKey The course resourceable's id
 * @param httpRequest The HTTP request
 * @return
 */
@Path("{repoEntryKey}/files")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML, MediaType.APPLICATION_OCTET_STREAM })
public VFSWebservice getVFSWebservice(@PathParam("repoEntryKey") Long repoEntryKey, @Context HttpServletRequest httpRequest) {
    RepositoryEntry re = repositoryManager.lookupRepositoryEntry(repoEntryKey);
    if (re == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    VFSContainer container = SharedFolderManager.getInstance().getNamedSharedFolder(re, true);
    if (container == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    Roles roles = getRoles(httpRequest);
    if (roles.isOLATAdmin()) {
    // all ok
    } else {
        RepositoryEntrySecurity reSecurity = repositoryManager.isAllowed(RestSecurityHelper.getIdentity(httpRequest), RestSecurityHelper.getRoles(httpRequest), re);
        if (reSecurity.isEntryAdmin()) {
        // all ok
        } else if (reSecurity.isMember()) {
            container.setLocalSecurityCallback(new ReadOnlyCallback());
        } else {
            throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
        }
    }
    return new VFSWebservice(container);
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) VFSContainer(org.olat.core.util.vfs.VFSContainer) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) RepositoryEntry(org.olat.repository.RepositoryEntry) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces)

Aggregations

ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)30 VFSContainer (org.olat.core.util.vfs.VFSContainer)20 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)12 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 NamedContainerImpl (org.olat.core.util.vfs.NamedContainerImpl)8 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)6 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)6 MergeSource (org.olat.core.util.vfs.MergeSource)6 BCCourseNode (org.olat.course.nodes.BCCourseNode)6 CourseNode (org.olat.course.nodes.CourseNode)6 PFCourseNode (org.olat.course.nodes.PFCourseNode)6 Path (javax.ws.rs.Path)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)4 WindowControl (org.olat.core.gui.control.WindowControl)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 VirtualContainer (org.olat.core.util.vfs.VirtualContainer)4 VFSWebservice (org.olat.core.util.vfs.restapi.VFSWebservice)4 CourseConfig (org.olat.course.config.CourseConfig)4