use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class CoursefolderWebDAVMergeSource method loadMergedContainers.
@Override
protected List<VFSContainer> loadMergedContainers() {
List<VFSContainer> containers = new ArrayList<>();
Map<String, VFSContainer> terms = null;
VirtualContainer noTermContainer = null;
VirtualContainer finishedContainer = null;
boolean useTerms = webDAVModule.isTermsFoldersEnabled();
if (useTerms) {
// prepare no-terms folder for all resources without semester term info or private date
terms = new HashMap<String, VFSContainer>();
noTermContainer = new VirtualContainer("_other");
} else {
finishedContainer = new VirtualContainer("_finished");
}
boolean prependReference = webDAVModule.isPrependCourseReferenceToTitle();
UniqueNames container = new UniqueNames();
List<RepositoryEntry> editorEntries = repositoryManager.queryByOwner(getIdentity(), "CourseModule");
appendCourses(editorEntries, true, containers, useTerms, terms, noTermContainer, finishedContainer, prependReference, container);
// add courses as participant and coaches
if (webDAVModule.isEnableLearnersParticipatingCourses()) {
List<RepositoryEntry> entries = repositoryManager.getLearningResourcesAsParticipantAndCoach(getIdentity(), "CourseModule");
appendCourses(entries, false, containers, useTerms, terms, noTermContainer, finishedContainer, prependReference, container);
}
// add bookmarked courses
if (webDAVModule.isEnableLearnersBookmarksCourse()) {
List<RepositoryEntry> bookmarkedEntries = repositoryManager.getLearningResourcesAsBookmark(getIdentity(), identityEnv.getRoles(), "CourseModule", 0, -1);
appendCourses(bookmarkedEntries, false, containers, useTerms, terms, noTermContainer, finishedContainer, prependReference, container);
}
if (useTerms) {
// add no-terms folder if any have been found
if (noTermContainer.getItems().size() > 0) {
addContainerToList(noTermContainer, containers);
}
} else if (finishedContainer.getItems().size() > 0) {
addContainerToList(finishedContainer, containers);
}
return containers;
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class BulkAssessmentTask method processReturnFile.
private void processReturnFile(AssessableCourseNode courseNode, BulkAssessmentRow row, UserCourseEnvironment uce, File assessedFolder) {
String assessedId = row.getAssessedId();
Identity identity = uce.getIdentityEnvironment().getIdentity();
VFSContainer returnBox = getReturnBox(uce, courseNode, identity);
if (returnBox != null) {
for (String returnFilename : row.getReturnFiles()) {
File returnFile = new File(assessedFolder, returnFilename);
VFSItem currentReturnLeaf = returnBox.resolve(returnFilename);
if (currentReturnLeaf != null) {
// remove the current file (delete make a version if it is enabled)
currentReturnLeaf.delete();
}
VFSLeaf returnLeaf = returnBox.createChildLeaf(returnFilename);
if (returnFile.exists()) {
try {
InputStream inStream = new FileInputStream(returnFile);
VFSManager.copyContent(inStream, returnLeaf);
} catch (FileNotFoundException e) {
log.error("Cannot copy return file " + returnFilename + " from " + assessedId, e);
}
}
}
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class CertificateAndEfficiencyStatementListController method doCollectArtefact.
private void doCollectArtefact(UserRequest ureq, String title, Long efficiencyStatementKey) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE);
if (artHandler != null && artHandler.isEnabled() && assessedIdentity.equals(getIdentity())) {
AbstractArtefact artefact = artHandler.createArtefact();
// only author can create artefact
artefact.setAuthor(getIdentity());
// no business path becouse we cannot launch an efficiency statement
artefact.setCollectionDate(new Date());
artefact.setTitle(translate("artefact.title", new String[] { title }));
EfficiencyStatement fullStatement = esm.getUserEfficiencyStatementByKey(efficiencyStatementKey);
artHandler.prefillArtefactAccordingToSource(artefact, fullStatement);
ePFCollCtrl = new ArtefactWizzardStepsController(ureq, getWindowControl(), artefact, (VFSContainer) null);
listenTo(ePFCollCtrl);
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class CertificatesManagerImpl method addPdfTemplate.
private boolean addPdfTemplate(String name, File file, CertificateTemplateImpl template) {
String dir = templatesStorage.generateDir();
VFSContainer templateDir = templatesStorage.getContainer(dir);
VFSLeaf templateLeaf;
String renamedName = VFSManager.rename(templateDir, name);
if (renamedName != null) {
templateLeaf = templateDir.createChildLeaf(renamedName);
} else {
templateLeaf = templateDir.createChildLeaf(name);
}
try (InputStream inStream = Files.newInputStream(file.toPath())) {
if (VFSManager.copyContent(inStream, templateLeaf)) {
template.setName(name);
template.setPath(dir + templateLeaf.getName());
return true;
}
} catch (IOException ex) {
log.error("", ex);
}
return false;
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class CertificateAndEfficiencyStatementController method popupArtefactCollector.
/**
* opens the collect-artefact wizard
*
* @param ureq
*/
private void popupArtefactCollector(UserRequest ureq) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EfficiencyStatementArtefact.ARTEFACT_TYPE);
if (artHandler != null && artHandler.isEnabled()) {
AbstractArtefact artefact = artHandler.createArtefact();
// only author can create artefact
artefact.setAuthor(getIdentity());
// no business path becouse we cannot launch an efficiency statement
artefact.setCollectionDate(new Date());
artefact.setTitle(translate("artefact.title", new String[] { efficiencyStatement.getCourseTitle() }));
artHandler.prefillArtefactAccordingToSource(artefact, efficiencyStatement);
ePFCollCtrl = new ArtefactWizzardStepsController(ureq, getWindowControl(), artefact, (VFSContainer) null);
listenTo(ePFCollCtrl);
// set flag for js-window-resizing (see velocity)
mainVC.contextPut("collectwizard", true);
}
}
Aggregations