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);
}
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");
}
}
}
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);
}
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);
}
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);
}
Aggregations