Search in sources :

Example 21 with LocalFolderImpl

use of org.olat.core.util.vfs.LocalFolderImpl 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;
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 22 with LocalFolderImpl

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

the class VideoPosterUploadForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    remainingSpace = Quota.UNLIMITED;
    videoResourceFileroot = new LocalFolderImpl(FileResourceManager.getInstance().getFileResourceRootImpl(videoResource).getBasefile());
    metaDataFolder = VFSManager.getOrCreateContainer(videoResourceFileroot, "media");
    posterField = uifactory.addFileElement(getWindowControl(), "poster", "video.config.poster", formLayout);
    posterField.limitToMimeType(imageMimeTypes, "poster.error.filetype", null);
    posterField.setMaxUploadSizeKB(picUploadlimitKB, null, null);
    posterField.setPreview(ureq.getUserSession(), true);
    posterField.addActionListener(FormEvent.ONCHANGE);
    posterField.setHelpTextKey("poster.help", null);
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    buttonGroupLayout.setElementCssClass("o_sel_upload_buttons");
    uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("track.upload", buttonGroupLayout);
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 23 with LocalFolderImpl

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

the class ImsRepositoryResolver method getDocumentChangeLog.

/**
 * reads the files in the ../changelog directory, and generates a
 * <code>QTIChangeLogMessage</code> per file.
 *
 * @return qti changelog messages or an empty array if no changelog exists.
 * @see QTIChangeLogMessage
 */
public QTIChangeLogMessage[] getDocumentChangeLog() {
    VFSContainer dirRoot = new LocalFolderImpl(fUnzippedDirRoot);
    VFSContainer dirChangelog = (VFSContainer) dirRoot.resolve("changelog");
    if (dirChangelog == null) {
        // no change log
        return new QTIChangeLogMessage[0];
    }
    List<VFSItem> items = dirChangelog.getItems();
    // PRECONDITION: only changelog files in the changelog directory
    QTIChangeLogMessage[] logArr = new QTIChangeLogMessage[items.size()];
    String filName;
    String msg;
    int i = 0;
    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss");
    for (Iterator<VFSItem> iter = items.iterator(); iter.hasNext(); ) {
        VFSLeaf file = (VFSLeaf) iter.next();
        filName = file.getName();
        String[] parts = filName.split("\\.");
        msg = FileUtils.load(file.getInputStream(), "utf-8");
        try {
            logArr[i] = new QTIChangeLogMessage(msg, parts[1].equals("all"), formatter.parse(parts[0]).getTime());
            i++;
        } catch (ParseException e) {
            log.error("", e);
        }
    }
    return logArr;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) QTIChangeLogMessage(org.olat.ims.qti.QTIChangeLogMessage) ParseException(java.text.ParseException)

Example 24 with LocalFolderImpl

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

the class ImsRepositoryResolver method hasAutocompleteFiles.

/**
 * @see org.olat.ims.qti.process.Resolver#hasAutocompleteFiles()
 */
public boolean hasAutocompleteFiles() {
    VFSContainer vfsUnzippedRoot = new LocalFolderImpl(fUnzippedDirRoot);
    VFSItem vfsAutocompleteJsItem = vfsUnzippedRoot.resolve(QTI_FIB_AUTOCOMPLETE_JS_FILE);
    if (vfsAutocompleteJsItem != null) {
        VFSItem vfsAutocompleteCssItem = vfsUnzippedRoot.resolve(QTI_FIB_AUTOCOMPLETE_CSS_FILE);
        if (vfsAutocompleteCssItem != null) {
            return true;
        }
    }
    return false;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 25 with LocalFolderImpl

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

the class TestFileResource method validate.

/**
 * @param unzippedDir
 * @return True if is of type.
 */
public static boolean validate(File unzippedDir) {
    // no longer needed.
    VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedDir);
    VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
    // getDocument(..) ensures that InputStream is closed in every case.
    Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    return validateQti(doc, new ResourceEvaluation(false)).isValid();
}
Also used : ResourceEvaluation(org.olat.fileresource.types.ResourceEvaluation) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.dom4j.Document) QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Aggregations

LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)122 File (java.io.File)82 VFSContainer (org.olat.core.util.vfs.VFSContainer)76 VFSItem (org.olat.core.util.vfs.VFSItem)38 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)30 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)10 Document (org.dom4j.Document)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)8 OLATResource (org.olat.resource.OLATResource)8 Date (java.util.Date)6 Document (org.apache.lucene.document.Document)6 Element (org.dom4j.Element)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)6 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)6 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6