use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project openolat by klemens.
the class ForumHelper method getArchiveContainer.
public static final VFSContainer getArchiveContainer(UserRequest ureq, Forum forum) {
VFSContainer container = new OlatRootFolderImpl(FolderConfig.getUserHomes() + File.separator + ureq.getIdentity().getName() + "/private/archive", null);
// append export timestamp to avoid overwriting previous export
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss");
String folder = "forum_" + forum.getKey().toString() + "_" + formatter.format(new Date());
VFSItem vfsItem = container.resolve(folder);
if (vfsItem == null || !(vfsItem instanceof VFSContainer)) {
vfsItem = container.createChildContainer(folder);
}
container = (VFSContainer) vfsItem;
return container;
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl 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;
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project openolat by klemens.
the class ConvertToGTACourseNode method convertReturnbox.
private void convertReturnbox(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
String returnbox = ReturnboxController.getReturnboxPathRelToFolderRoot(courseEnv, sourceNode);
OlatRootFolderImpl returnContainer = new OlatRootFolderImpl(returnbox, null);
for (VFSItem item : returnContainer.getItems()) {
if (item instanceof VFSContainer) {
VFSContainer userContainer = (VFSContainer) item;
String username = userContainer.getName();
Identity assessedIdentity = securityManager.findIdentityByName(username);
if (assessedIdentity != null) {
VFSContainer correctionContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
boolean returned = false;
for (VFSItem returnedItem : userContainer.getItems()) {
if (returnedItem instanceof VFSLeaf) {
VFSLeaf correctionDocument = correctionContainer.createChildLeaf(returnedItem.getName());
VFSManager.copyContent((VFSLeaf) returnedItem, correctionDocument);
convertMetada(userContainer, correctionContainer, returnedItem.getName(), null, null);
returned = true;
}
}
if (returned) {
setTaskStatus(taskList, assessedIdentity, TaskProcess.grading, gtaNode);
}
}
}
}
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project openolat by klemens.
the class ConvertToGTACourseNode method convertDropbox.
private void convertDropbox(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, CourseEnvironment courseEnv) {
String dropbox = DropboxController.getDropboxPathRelToFolderRoot(courseEnv, sourceNode);
OlatRootFolderImpl dropboxContainer = new OlatRootFolderImpl(dropbox, null);
for (VFSItem userDropbox : dropboxContainer.getItems()) {
if (userDropbox instanceof VFSContainer) {
VFSContainer userDropContainer = (VFSContainer) userDropbox;
String username = userDropContainer.getName();
Identity assessedIdentity = securityManager.findIdentityByName(username);
if (assessedIdentity != null) {
VFSContainer sumbitContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedIdentity);
boolean dropped = false;
for (VFSItem dropppedItem : userDropContainer.getItems()) {
if (dropppedItem instanceof VFSLeaf) {
VFSLeaf submittedDocument = sumbitContainer.createChildLeaf(dropppedItem.getName());
VFSManager.copyContent((VFSLeaf) dropppedItem, submittedDocument);
convertMetada(userDropContainer, sumbitContainer, dropppedItem.getName(), null, null);
dropped = true;
}
}
if (dropped) {
setTaskStatus(taskList, assessedIdentity, TaskProcess.submit, gtaNode);
}
}
}
}
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl 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);
}
Aggregations