Search in sources :

Example 11 with OlatNamedContainerImpl

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

the class CoursesFoldersTest method testCreateFolder.

@Test
public void testCreateFolder() throws IOException, URISyntaxException {
    assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getNodeURI()).path("files").path("RootFolder").build();
    HttpPut method = conn.createPut(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    OlatNamedContainerImpl folder = BCCourseNode.getNodeFolderContainer((BCCourseNode) bcNode, course1.getCourseEnvironment());
    VFSItem item = folder.resolve("RootFolder");
    assertNotNull(item);
    assertTrue(item instanceof VFSContainer);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) HttpResponse(org.apache.http.HttpResponse) VFSItem(org.olat.core.util.vfs.VFSItem) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 12 with OlatNamedContainerImpl

use of org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl 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 13 with OlatNamedContainerImpl

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

the class BCWebService method createFolderVO.

public static FolderVO createFolderVO(IdentityEnvironment ienv, ICourse course, BCCourseNode bcNode, Collection<String> subscribed) {
    OlatNamedContainerImpl container = BCCourseNode.getSecurisedNodeFolderContainer(bcNode, course.getCourseEnvironment(), ienv);
    VFSSecurityCallback secCallback = container.getLocalSecurityCallback();
    FolderVO folderVo = new FolderVO();
    folderVo.setName(course.getCourseTitle());
    folderVo.setDetailsName(bcNode.getShortTitle());
    if (subscribed != null && subscribed.contains(bcNode.getIdent())) {
        folderVo.setSubscribed(true);
    } else {
        folderVo.setSubscribed(false);
    }
    folderVo.setCourseKey(course.getResourceableId());
    folderVo.setCourseNodeId(bcNode.getIdent());
    folderVo.setWrite(secCallback.canWrite());
    folderVo.setRead(secCallback.canRead());
    folderVo.setDelete(secCallback.canDelete());
    folderVo.setList(secCallback.canList());
    return folderVo;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FolderVO(org.olat.restapi.support.vo.FolderVO) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 14 with OlatNamedContainerImpl

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

the class BCCourseNode method getSecurisedNodeFolderContainer.

public static OlatNamedContainerImpl getSecurisedNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv, IdentityEnvironment ienv) {
    boolean isOlatAdmin = ienv.getRoles().isOLATAdmin();
    boolean isGuestOnly = ienv.getRoles().isGuestOnly();
    UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ienv, courseEnv);
    NodeEvaluation ne = node.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
    OlatNamedContainerImpl container = getNodeFolderContainer(node, courseEnv);
    VFSSecurityCallback secCallback = new FolderNodeCallback(container.getRelPath(), ne, isOlatAdmin, isGuestOnly, null);
    container.setLocalSecurityCallback(secCallback);
    return container;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) FolderNodeCallback(org.olat.course.nodes.bc.FolderNodeCallback) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 15 with OlatNamedContainerImpl

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

the class BCCourseNode method getNodeFolderContainer.

/**
 * Get a named container of a node with the node title as its name.
 * @param node
 * @param courseEnv
 * @return
 */
public static OlatNamedContainerImpl getNodeFolderContainer(BCCourseNode node, CourseEnvironment courseEnv) {
    String path = getFoldernodePathRelToFolderBase(courseEnv, node);
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(path, null);
    OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(node.getShortTitle(), rootFolder);
    return namedFolder;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)

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