use of org.olat.core.util.vfs.VFSItem in project OpenOLAT by OpenOLAT.
the class ProjectBrokerCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
boolean dataFound = false;
String dropboxPath = DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), this);
OlatRootFolderImpl dropboxDir = new OlatRootFolderImpl(dropboxPath, null);
String returnboxPath = ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), this);
OlatRootFolderImpl returnboxDir = new OlatRootFolderImpl(returnboxPath, null);
if (!dropboxDir.exists() && !returnboxDir.exists()) {
return false;
}
String exportDirName = "projectbroker_" + Formatter.makeStringFilesystemSave(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
try {
String projectBrokerTableExport = ProjectBrokerExportGenerator.createCourseResultsOverviewTable(this, course, locale);
String tableExportFileName = ExportUtil.createFileNameWithTimeStamp(getShortTitle() + "-projectbroker_overview", "xls");
exportStream.putNextEntry(new ZipEntry(exportDirName + "/" + tableExportFileName));
IOUtils.write(projectBrokerTableExport, exportStream, "UTF-8");
exportStream.closeEntry();
} catch (IOException e) {
log.error("", e);
}
// copy dropboxes to tmp dir
if (dropboxDir.exists()) {
// OLAT-6426 archive only dropboxes of users that handed in at least one file -> prevent empty folders in archive
for (VFSItem themaItem : dropboxDir.getItems()) {
if (!(themaItem instanceof VFSContainer))
continue;
List<VFSItem> userFolderArray = ((VFSContainer) themaItem).getItems();
for (VFSItem userFolder : userFolderArray) {
if (!VFSManager.isDirectoryAndNotEmpty(userFolder))
continue;
String path = exportDirName + "/dropboxes/" + themaItem.getName();
ZipUtil.addToZip(userFolder, path, exportStream);
}
}
}
// copy returnboxes to tmp dir
if (returnboxDir.exists()) {
for (VFSItem themaItem : returnboxDir.getItems()) {
if (!(themaItem instanceof VFSContainer))
continue;
List<VFSItem> userFolderArray = ((VFSContainer) themaItem).getItems();
for (VFSItem userFolder : userFolderArray) {
if (!VFSManager.isDirectoryAndNotEmpty(userFolder))
continue;
String path = exportDirName + "/returnboxes/" + themaItem.getName();
ZipUtil.addToZip(userFolder, path, exportStream);
}
}
}
return dataFound;
}
use of org.olat.core.util.vfs.VFSItem in project OpenOLAT by OpenOLAT.
the class GTASampleSolutionsEditController method updateModel.
private void updateModel() {
List<Solution> solutionList = gtaManager.getSolutions(courseEnv, gtaNode);
List<SolutionRow> rows = new ArrayList<>(solutionList.size());
for (Solution solution : solutionList) {
String filename = solution.getFilename();
String author = null;
VFSItem item = solutionContainer.resolve(filename);
if (item instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
author = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
}
}
DownloadLink downloadLink = null;
if (item instanceof VFSLeaf) {
downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), filename, null, (VFSLeaf) item, solutionTable);
}
rows.add(new SolutionRow(solution, author, downloadLink));
}
solutionModel.setObjects(rows);
solutionTable.reset();
}
use of org.olat.core.util.vfs.VFSItem in project OpenOLAT by OpenOLAT.
the class GTASampleSolutionsEditController method doCreateSolutionEditor.
private void doCreateSolutionEditor(UserRequest ureq, Solution solution) {
String documentName = solution.getFilename();
VFSItem item = solutionContainer.resolve(documentName);
if (item == null) {
item = solutionContainer.createChildLeaf(documentName);
} else {
documentName = VFSManager.rename(solutionContainer, documentName);
item = solutionContainer.createChildLeaf(documentName);
}
if (item instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
if (metaInfo != null) {
metaInfo.setAuthor(getIdentity());
}
metaInfo.write();
}
newSolutionEditorCtrl = WysiwygFactory.createWysiwygController(ureq, getWindowControl(), solutionContainer, documentName, "media", true, true);
newSolutionEditorCtrl.getRichTextConfiguration().disableMedia();
newSolutionEditorCtrl.getRichTextConfiguration().setAllowCustomMediaFactory(false);
newSolutionEditorCtrl.setNewFile(true);
newSolutionEditorCtrl.setUserObject(solution);
listenTo(newSolutionEditorCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", newSolutionEditorCtrl.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.util.vfs.VFSItem in project OpenOLAT by OpenOLAT.
the class PFPeekviewController method addItems.
private void addItems(VFSContainer container, List<VFSLeaf> allLeafs) {
// exclude files which are also excluded in FolderComponent
for (VFSItem vfsItem : container.getItems(attachmentExcludeFilter)) {
if (vfsItem instanceof VFSLeaf) {
// add leaf to our list
VFSLeaf leaf = (VFSLeaf) vfsItem;
allLeafs.add(leaf);
} else if (vfsItem instanceof VFSContainer) {
// do it recursively for all children
VFSContainer childContainer = (VFSContainer) vfsItem;
addItems(childContainer, allLeafs);
} else {
// hu?
}
}
}
use of org.olat.core.util.vfs.VFSItem in project OpenOLAT by OpenOLAT.
the class ScormDirectoryHelper method getScoDirectory.
/**
* Return the container where the LMS save the datas for a user.
* @param username
* @param courseEnv
* @param node
* @return
*/
public static VFSContainer getScoDirectory(String username, CourseEnvironment courseEnv, ScormCourseNode node) {
Long courseId = courseEnv.getCourseResourceableId();
VFSItem userFolder = ScormDirectoryHelper.getScormRootFolder().resolve(username);
if (userFolder != null) {
VFSItem scoFolder = userFolder.resolve(courseId.toString() + "-" + node.getIdent());
if (scoFolder instanceof VFSContainer) {
return (VFSContainer) scoFolder;
}
}
return null;
}
Aggregations