use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method deleteAllAttachmentFilesOfProject.
private void deleteAllAttachmentFilesOfProject(Project project, CourseEnvironment courseEnv, CourseNode cNode) {
VFSContainer attachmentDir = new OlatRootFolderImpl(getAttamchmentRelativeRootPath(project, courseEnv, cNode), null);
attachmentDir.delete();
logDebug("deleteAllAttachmentFilesOfProject path=" + attachmentDir);
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method saveAttachedFile.
public void saveAttachedFile(Project project, String fileName, VFSLeaf uploadedItem, CourseEnvironment courseEnv, CourseNode cNode) {
logDebug("saveAttachedFile file-name=" + uploadedItem.getName());
OlatRootFolderImpl uploadVFSContainer = new OlatRootFolderImpl(getAttamchmentRelativeRootPath(project, courseEnv, cNode), null);
logDebug("saveAttachedFile uploadVFSContainer.relPath=" + uploadVFSContainer.getRelPath());
// only one attachment, delete other file
for (Iterator<VFSItem> iterator = uploadVFSContainer.getItems().iterator(); iterator.hasNext(); ) {
VFSItem item = iterator.next();
// Project.getAttachmentFileName is the previous file-name, will not be deleted; student could have open detail-project page with previous attachemnt-link
if (!item.getName().equals(project.getAttachmentFileName())) {
item.delete();
}
}
VFSLeaf newFile = (VFSLeaf) uploadVFSContainer.resolve(fileName);
if (newFile == null) {
newFile = uploadVFSContainer.createChildLeaf(fileName);
}
BufferedInputStream in = new BufferedInputStream(uploadedItem.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(newFile.getOutputStream(false));
boolean success = false;
if (in != null) {
success = FileUtils.copy(in, out);
}
FileUtils.closeSafely(in);
FileUtils.closeSafely(out);
logDebug("saveAttachedFile success=" + success);
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.
the class ForumRTFFormatter method makeTempVFSContainer.
/**
* Generates a new temporary VFSContainer.
* @return the temp container.
*/
private VFSContainer makeTempVFSContainer() {
Long forumKey = getForumKey();
String dateStamp = String.valueOf(System.currentTimeMillis());
// TODO: (LD) could this filename regarded as unique or use System.nanoTime() instead?
String fileName = "forum" + forumKey.toString() + "_" + dateStamp;
LocalFolderImpl tempFolder = new OlatRootFolderImpl("/tmp/" + fileName, null);
return tempFolder;
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.
the class FeedManagerImpl method getQuota.
@Override
public Quota getQuota(OLATResourceable feed) {
OlatRootFolderImpl container = feedFileStorage.getResourceContainer(feed);
Quota quota = QuotaManager.getInstance().getCustomQuota(container.getRelPath());
if (quota == null) {
Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_FEEDS);
quota = QuotaManager.getInstance().createQuota(container.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
return quota;
}
use of org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl in project OpenOLAT by OpenOLAT.
the class ForumManager method getForumContainer.
public VFSContainer getForumContainer(Long forumKey) {
OlatRootFolderImpl fContainer = new OlatRootFolderImpl("/forum", null);
VFSItem forumContainer = fContainer.resolve(forumKey.toString());
if (forumContainer == null) {
return fContainer.createChildContainer(forumKey.toString());
} else if (forumContainer instanceof VFSContainer) {
return (VFSContainer) forumContainer;
}
log.error("The following forum container is not a directory: " + forumContainer);
return null;
}
Aggregations