Search in sources :

Example 41 with VFSContainer

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;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) VirtualContainer(org.olat.core.util.vfs.VirtualContainer)

Example 42 with VFSContainer

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);
                }
            }
        }
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) FileNotFoundException(java.io.FileNotFoundException) VFSItem(org.olat.core.util.vfs.VFSItem) Identity(org.olat.core.id.Identity) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 43 with VFSContainer

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);
    }
}
Also used : ArtefactWizzardStepsController(org.olat.portfolio.ui.artefacts.collect.ArtefactWizzardStepsController) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) CertificateAndEfficiencyStatement(org.olat.course.certificate.ui.CertificateAndEfficiencyStatementListModel.CertificateAndEfficiencyStatement)

Example 44 with VFSContainer

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;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) InputStream(java.io.InputStream) VFSContainer(org.olat.core.util.vfs.VFSContainer) IOException(java.io.IOException)

Example 45 with VFSContainer

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);
    }
}
Also used : ArtefactWizzardStepsController(org.olat.portfolio.ui.artefacts.collect.ArtefactWizzardStepsController) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date)

Aggregations

VFSContainer (org.olat.core.util.vfs.VFSContainer)962 VFSItem (org.olat.core.util.vfs.VFSItem)364 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)338 File (java.io.File)170 Test (org.junit.Test)136 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)86 Identity (org.olat.core.id.Identity)86 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)76 RepositoryEntry (org.olat.repository.RepositoryEntry)76 IOException (java.io.IOException)74 InputStream (java.io.InputStream)64 ArrayList (java.util.ArrayList)64 Date (java.util.Date)60 URI (java.net.URI)56 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)42 OutputStream (java.io.OutputStream)40 HttpResponse (org.apache.http.HttpResponse)38 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)34 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)34 BlogFileResource (org.olat.fileresource.types.BlogFileResource)34