Search in sources :

Example 1 with LocalImpl

use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.

the class GuiDemoFileChooserController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == chooserCtr) {
        // catch the events from the file chooser controller here
        if (event instanceof FileChoosenEvent) {
            // User pressed select button, get selected item from controller
            VFSItem selectedItem = FileChooserUIFactory.getSelectedItem((FileChoosenEvent) event);
            // for this demo just get file path and display an info message
            LocalImpl localFile = (LocalImpl) selectedItem;
            String absPath = localFile.getBasefile().getAbsolutePath();
            String relPath = absPath.substring(webappRootFile.getAbsolutePath().length());
            getWindowControl().setInfo("user selected /static" + relPath);
        } else if (event == Event.CANCELLED_EVENT) {
            // user pressed cancel
            getWindowControl().setInfo("user cancelled");
        } else if (event == Event.FAILED_EVENT) {
            // selection failed for unknown reason
            getWindowControl().setError("Ups, an error occured");
        }
    }
}
Also used : VFSItem(org.olat.core.util.vfs.VFSItem) FileChoosenEvent(org.olat.core.commons.controllers.filechooser.FileChoosenEvent) LocalImpl(org.olat.core.util.vfs.LocalImpl)

Example 2 with LocalImpl

use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.

the class WebDocumentRunController method getWebDocument.

private LocalFileImpl getWebDocument(RepositoryEntry entry) {
    OLATResource resource = entry.getOlatResource();
    VFSContainer fResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    LocalFileImpl document = null;
    for (VFSItem item : fResourceFileroot.getItems()) {
        if (item instanceof VFSLeaf && item instanceof LocalImpl) {
            LocalFileImpl localItem = (LocalFileImpl) item;
            if (localItem != null && !localItem.getBasefile().isHidden()) {
                document = (LocalFileImpl) item;
            }
        }
    }
    return document;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResource(org.olat.resource.OLATResource) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) VFSItem(org.olat.core.util.vfs.VFSItem) LocalImpl(org.olat.core.util.vfs.LocalImpl)

Example 3 with LocalImpl

use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_10_3_0 method processExportFolder.

private void processExportFolder(RepositoryEntry courseRe) {
    try {
        VFSContainer courseFolder = CourseFactory.getCourseBaseContainer(courseRe.getOlatResource().getResourceableId());
        VFSItem exportFolder = courseFolder.resolve(ICourse.EXPORTED_DATA_FOLDERNAME);
        if (exportFolder != null && exportFolder.exists() && exportFolder instanceof LocalImpl) {
            File exportDir = ((LocalImpl) exportFolder).getBasefile();
            if (exportDir.exists()) {
                FileUtils.deleteDirsAndFiles(exportDir.toPath());
            }
        }
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) IOException(java.io.IOException) LocalImpl(org.olat.core.util.vfs.LocalImpl) File(java.io.File)

Example 4 with LocalImpl

use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.

the class QTI21QPoolServiceProvider method createItem.

public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
    AssessmentItemBuilder itemBuilder = null;
    Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
    switch(type) {
        case sc:
            itemBuilder = new SingleChoiceAssessmentItemBuilder(translator.translate("new.sc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case mc:
            itemBuilder = new MultipleChoiceAssessmentItemBuilder(translator.translate("new.mc"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case kprim:
            itemBuilder = new KPrimAssessmentItemBuilder(translator.translate("new.kprim"), translator.translate("new.answer"), qtiService.qtiSerializer());
            break;
        case match:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer());
            break;
        case matchdraganddrop:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer());
            break;
        case matchtruefalse:
            itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translator.translate("match.unanswered"), translator.translate("match.true"), translator.translate("match.false"), qtiService.qtiSerializer());
            break;
        case fib:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib"), EntryType.text, qtiService.qtiSerializer());
            break;
        case numerical:
            itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer());
            break;
        case essay:
            itemBuilder = new EssayAssessmentItemBuilder(translator.translate("new.essay"), qtiService.qtiSerializer());
            break;
        case upload:
            itemBuilder = new UploadAssessmentItemBuilder(translator.translate("new.upload"), qtiService.qtiSerializer());
            break;
        case drawing:
            itemBuilder = new DrawingAssessmentItemBuilder(translator.translate("new.drawing"), qtiService.qtiSerializer());
            break;
        case hotspot:
            itemBuilder = new HotspotAssessmentItemBuilder(translator.translate("new.hotspot"), qtiService.qtiSerializer());
            break;
        case hottext:
            itemBuilder = new HottextAssessmentItemBuilder(translator.translate("new.hottext"), translator.translate("new.hottext.start"), translator.translate("new.hottext.text"), qtiService.qtiSerializer());
            break;
        default:
            return null;
    }
    AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
    assessmentItem.setLabel(title);
    assessmentItem.setTitle(title);
    AssessmentItemMetadata itemMetadata = new AssessmentItemMetadata();
    itemMetadata.setQuestionType(type);
    QTI21ImportProcessor processor = new QTI21ImportProcessor(identity, locale);
    QuestionItemImpl qitem = processor.processItem(assessmentItem, "", null, "OpenOLAT", Settings.getVersion(), itemMetadata);
    VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
    VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
    File itemFile = ((LocalImpl) leaf).getBasefile();
    qtiService.persistAssessmentObject(itemFile, assessmentItem);
    // create imsmanifest
    ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
    manifest.appendAssessmentItem(itemFile.getName());
    manifest.write(new File(itemFile.getParentFile(), "imsmanifest.xml"));
    return qitem;
}
Also used : HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) VFSContainer(org.olat.core.util.vfs.VFSContainer) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) SingleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.SingleChoiceAssessmentItemBuilder) HottextAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HottextAssessmentItemBuilder) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder) EssayAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.EssayAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) AssessmentItemBuilder(org.olat.ims.qti21.model.xml.AssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MultipleChoiceAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MultipleChoiceAssessmentItemBuilder) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) FIBAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder) KPrimAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.KPrimAssessmentItemBuilder) Translator(org.olat.core.gui.translator.Translator) AssessmentItemMetadata(org.olat.ims.qti21.model.xml.AssessmentItemMetadata) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) UploadAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.UploadAssessmentItemBuilder) LocalImpl(org.olat.core.util.vfs.LocalImpl) File(java.io.File) DrawingAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.DrawingAssessmentItemBuilder)

Example 5 with LocalImpl

use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.

the class WorkThreadInformations method setInfoFiles.

public static void setInfoFiles(String filePath, VFSLeaf leaf) {
    try {
        File file = new File(WebappHelper.getUserDataRoot(), "threadInfos");
        if (!file.exists()) {
            file.mkdirs();
        }
        if (leaf instanceof LocalImpl) {
            filePath = ((LocalImpl) leaf).getBasefile().getAbsolutePath();
        }
        File infoFile = new File(file, Thread.currentThread().getName());
        FileUtils.save(infoFile, filePath, "UTF-8");
    } catch (Exception e) {
        log.error("Cannot write info message about FolderIndexerWorker: " + filePath, e);
    }
}
Also used : LocalImpl(org.olat.core.util.vfs.LocalImpl) File(java.io.File)

Aggregations

LocalImpl (org.olat.core.util.vfs.LocalImpl)18 File (java.io.File)10 IOException (java.io.IOException)10 VFSItem (org.olat.core.util.vfs.VFSItem)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 BufferedOutputStream (java.io.BufferedOutputStream)4 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 BufferedInputStream (java.io.BufferedInputStream)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 ZipEntry (java.util.zip.ZipEntry)2 ZipInputStream (java.util.zip.ZipInputStream)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 FileChoosenEvent (org.olat.core.commons.controllers.filechooser.FileChoosenEvent)2 Translator (org.olat.core.gui.translator.Translator)2 AssertException (org.olat.core.logging.AssertException)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2