Search in sources :

Example 1 with VFSWebservice

use of org.olat.core.util.vfs.restapi.VFSWebservice 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 2 with VFSWebservice

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

Example 3 with VFSWebservice

use of org.olat.core.util.vfs.restapi.VFSWebservice in project openolat by klemens.

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 4 with VFSWebservice

use of org.olat.core.util.vfs.restapi.VFSWebservice in project openolat by klemens.

the class BCWebService method getVFSWebService.

/**
 * Return the FX implementation to manage a folder.
 * @param courseId
 * @param nodeId
 * @param request
 * @return
 */
@Path("{nodeId}/files")
public VFSWebservice getVFSWebService(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest request) {
    boolean author = isAuthor(request);
    ICourse course = CoursesWebService.loadCourse(courseId);
    if (course == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    } else if (!author && !CourseWebService.isCourseAccessible(course, false, request)) {
        throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
    }
    CourseNode node;
    if (author) {
        node = course.getEditorTreeModel().getCourseNode(nodeId);
    } else {
        node = course.getRunStructure().getNode(nodeId);
    }
    if (node == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    } else if (!(node instanceof BCCourseNode)) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_ACCEPTABLE).build());
    }
    BCCourseNode bcNode = (BCCourseNode) node;
    UserRequest ureq = getUserRequest(request);
    VFSContainer container = BCCourseNode.getSecurisedNodeFolderContainer(bcNode, course.getCourseEnvironment(), ureq.getUserSession().getIdentityEnvironment());
    return new VFSWebservice(container);
}
Also used : BCCourseNode(org.olat.course.nodes.BCCourseNode) WebApplicationException(javax.ws.rs.WebApplicationException) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) VFSWebservice(org.olat.core.util.vfs.restapi.VFSWebservice) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path)

Example 5 with VFSWebservice

use of org.olat.core.util.vfs.restapi.VFSWebservice in project OpenOLAT by OpenOLAT.

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

Path (javax.ws.rs.Path)10 VFSWebservice (org.olat.core.util.vfs.restapi.VFSWebservice)10 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 Identity (org.olat.core.id.Identity)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 WebApplicationException (javax.ws.rs.WebApplicationException)4 CollaborationTools (org.olat.collaboration.CollaborationTools)4 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 Quota (org.olat.core.util.vfs.Quota)4 QuotaManager (org.olat.core.util.vfs.QuotaManager)4 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)4 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)4 VFSWebServiceSecurityCallback (org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback)4 BusinessGroup (org.olat.group.BusinessGroup)4 BusinessGroupService (org.olat.group.BusinessGroupService)4 Produces (javax.ws.rs.Produces)2 BriefcaseWebDAVProvider (org.olat.core.commons.modules.bc.BriefcaseWebDAVProvider)2 UserRequest (org.olat.core.gui.UserRequest)2 Roles (org.olat.core.id.Roles)2 ICourse (org.olat.course.ICourse)2