Search in sources :

Example 16 with OlatNamedContainerImpl

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

the class DropboxController method getUploadLimit.

/**
 * Get upload limit for dropbox of a certain user. The upload can be limited
 * by available-folder space, max folder size or configurated upload-limit.
 * @param ureq
 * @return max upload limit in KB
 */
private int getUploadLimit() {
    String dropboxPath = getRelativeDropBoxFilePath(getIdentity());
    Quota dropboxQuota = QuotaManager.getInstance().getCustomQuota(dropboxPath);
    if (dropboxQuota == null) {
        dropboxQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
    }
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getRelativeDropBoxFilePath(getIdentity()), null);
    VFSContainer dropboxContainer = new OlatNamedContainerImpl(getIdentity().getName(), rootFolder);
    FullAccessWithQuotaCallback secCallback = new FullAccessWithQuotaCallback(dropboxQuota);
    rootFolder.setLocalSecurityCallback(secCallback);
    return QuotaManager.getInstance().getUploadLimitKB(dropboxQuota.getQuotaKB(), dropboxQuota.getUlLimitKB(), dropboxContainer);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 17 with OlatNamedContainerImpl

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

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

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 19 with OlatNamedContainerImpl

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

the class CoursesFoldersTest method deleteFolder.

@Test
public void deleteFolder() throws IOException, URISyntaxException {
    // add some folders
    OlatNamedContainerImpl folder = BCCourseNode.getNodeFolderContainer((BCCourseNode) bcNode, course1.getCourseEnvironment());
    VFSItem item = folder.resolve("FolderToDelete");
    if (item == null) {
        folder.createChildContainer("FolderToDelete");
    }
    assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getNodeURI()).path("files").path("FolderToDelete").build();
    HttpDelete method = conn.createDelete(uri, MediaType.APPLICATION_JSON);
    HttpResponse response = conn.execute(method);
    assertEquals(200, response.getStatusLine().getStatusCode());
    VFSItem deletedItem = folder.resolve("FolderToDelete");
    assertNull(deletedItem);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) HttpDelete(org.apache.http.client.methods.HttpDelete) VFSItem(org.olat.core.util.vfs.VFSItem) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Example 20 with OlatNamedContainerImpl

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

the class CoursesFoldersTest method testCreateFolders.

@Test
public void testCreateFolders() throws IOException, URISyntaxException {
    assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getNodeURI()).path("files").path("NewFolder1").path("NewFolder2").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("NewFolder1");
    assertNotNull(item);
    assertTrue(item instanceof VFSContainer);
    VFSContainer newFolder1 = (VFSContainer) item;
    VFSItem item2 = newFolder1.resolve("NewFolder2");
    assertNotNull(item2);
    assertTrue(item2 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)

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