Search in sources :

Example 6 with JavaIOItem

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

the class VFSResource method getCreation.

@Override
public long getCreation() {
    try {
        if (item instanceof JavaIOItem) {
            JavaIOItem ioItem = (JavaIOItem) item;
            BasicFileAttributes attrs = Files.readAttributes(ioItem.getBasefile().toPath(), BasicFileAttributes.class);
            return attrs.creationTime().toMillis();
        }
        return 0;
    } catch (IOException e) {
        log.warn("getCreationFail" + item, e);
        return 0;
    }
}
Also used : JavaIOItem(org.olat.core.util.vfs.JavaIOItem) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Example 7 with JavaIOItem

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

the class CollectVideoMediaController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String title = mediaReference == null ? null : mediaReference.getTitle();
    titleEl = uifactory.addTextElement("artefact.title", "artefact.title", 255, title, formLayout);
    titleEl.setMandatory(true);
    String desc = mediaReference == null ? null : mediaReference.getDescription();
    descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("artefact.descr", "artefact.descr", desc, 8, 60, formLayout, getWindowControl());
    descriptionEl.getEditorConfiguration().setPathInStatusBar(false);
    fileEl = uifactory.addFileElement(getWindowControl(), "artefact.file", "artefact.file", formLayout);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    fileEl.setMaxUploadSizeKB(250000, null, null);
    fileEl.setPreview(ureq.getUserSession(), true);
    fileEl.setDeleteEnabled(true);
    if (mediaReference != null) {
        fileEl.setEnabled(false);
        VFSItem item = fileHandler.getVideoItem(mediaReference);
        if (item instanceof JavaIOItem) {
            fileEl.setInitialFile(((JavaIOItem) item).getBasefile());
        }
    }
    categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categories, formLayout, getTranslator());
    categoriesEl.setHelpText(translate("categories.hint"));
    categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
    categoriesEl.setAllowDuplicates(false);
    Date collectDate = mediaReference == null ? new Date() : mediaReference.getCollectionDate();
    String date = Formatter.getInstance(getLocale()).formatDate(collectDate);
    uifactory.addStaticTextElement("artefact.collect.date", "artefact.collect.date", date, formLayout);
    if (StringHelper.containsNonWhitespace(businessPath)) {
        String link = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
        uifactory.addStaticTextElement("artefact.collect.link", "artefact.collect.link", link, formLayout);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("save", "save", buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : JavaIOItem(org.olat.core.util.vfs.JavaIOItem) VFSItem(org.olat.core.util.vfs.VFSItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Example 8 with JavaIOItem

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

the class CollectFileMediaController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_collect_document_form");
    String title = mediaReference == null ? null : mediaReference.getTitle();
    titleEl = uifactory.addTextElement("artefact.title", "artefact.title", 255, title, formLayout);
    titleEl.setElementCssClass("o_sel_pf_collect_title");
    titleEl.setMandatory(true);
    String desc = mediaReference == null ? null : mediaReference.getTitle();
    descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("artefact.descr", "artefact.descr", desc, 8, 60, formLayout, getWindowControl());
    descriptionEl.getEditorConfiguration().setPathInStatusBar(false);
    fileEl = uifactory.addFileElement(getWindowControl(), "artefact.file", "artefact.file", formLayout);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    if (mediaReference != null) {
        fileEl.setEnabled(false);
        VFSItem item = fileHandler.getItem(mediaReference);
        if (item instanceof JavaIOItem) {
            fileEl.setInitialFile(((JavaIOItem) item).getBasefile());
        }
    }
    categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categories, formLayout, getTranslator());
    categoriesEl.setHelpText(translate("categories.hint"));
    categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
    categoriesEl.setAllowDuplicates(false);
    // String source = "Forum";
    // uifactory.addStaticTextElement("artefact.source", "artefact.source", source, formLayout);
    Date collectDate = mediaReference == null ? new Date() : mediaReference.getCollectionDate();
    String date = Formatter.getInstance(getLocale()).formatDate(collectDate);
    uifactory.addStaticTextElement("artefact.collect.date", "artefact.collect.date", date, formLayout);
    if (StringHelper.containsNonWhitespace(businessPath)) {
        String link = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
        uifactory.addStaticTextElement("artefact.collect.link", "artefact.collect.link", link, formLayout);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("save", "save", buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : JavaIOItem(org.olat.core.util.vfs.JavaIOItem) VFSItem(org.olat.core.util.vfs.VFSItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Example 9 with JavaIOItem

use of org.olat.core.util.vfs.JavaIOItem in project openolat by klemens.

the class CollectImageMediaController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_pf_collect_image_form");
    String title = mediaReference == null ? null : mediaReference.getTitle();
    titleEl = uifactory.addTextElement("artefact.title", "artefact.title", 255, title, formLayout);
    titleEl.setElementCssClass("o_sel_pf_collect_title");
    titleEl.setMandatory(true);
    String desc = mediaReference == null ? null : mediaReference.getDescription();
    descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("artefact.descr", "artefact.descr", desc, 8, 60, formLayout, getWindowControl());
    descriptionEl.getEditorConfiguration().setPathInStatusBar(false);
    fileEl = uifactory.addFileElement(getWindowControl(), "artefact.file", "artefact.file", formLayout);
    fileEl.limitToMimeType(imageMimeTypes, null, null);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    fileEl.setMaxUploadSizeKB(10000, null, null);
    fileEl.setPreview(ureq.getUserSession(), true);
    if (mediaReference != null) {
        fileEl.setEnabled(false);
        VFSItem item = fileHandler.getImage(mediaReference);
        if (item instanceof JavaIOItem) {
            fileEl.setInitialFile(((JavaIOItem) item).getBasefile());
        }
    }
    categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categories, formLayout, getTranslator());
    categoriesEl.setHelpText(translate("categories.hint"));
    categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
    categoriesEl.setAllowDuplicates(false);
    Date collectDate = mediaReference == null ? new Date() : mediaReference.getCollectionDate();
    String date = Formatter.getInstance(getLocale()).formatDate(collectDate);
    uifactory.addStaticTextElement("artefact.collect.date", "artefact.collect.date", date, formLayout);
    if (StringHelper.containsNonWhitespace(businessPath)) {
        String link = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
        uifactory.addStaticTextElement("artefact.collect.link", "artefact.collect.link", link, formLayout);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("save", "save", buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : JavaIOItem(org.olat.core.util.vfs.JavaIOItem) VFSItem(org.olat.core.util.vfs.VFSItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Example 10 with JavaIOItem

use of org.olat.core.util.vfs.JavaIOItem in project openolat by klemens.

the class CollectVideoMediaController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String title = mediaReference == null ? null : mediaReference.getTitle();
    titleEl = uifactory.addTextElement("artefact.title", "artefact.title", 255, title, formLayout);
    titleEl.setMandatory(true);
    String desc = mediaReference == null ? null : mediaReference.getDescription();
    descriptionEl = uifactory.addRichTextElementForStringDataMinimalistic("artefact.descr", "artefact.descr", desc, 8, 60, formLayout, getWindowControl());
    descriptionEl.getEditorConfiguration().setPathInStatusBar(false);
    fileEl = uifactory.addFileElement(getWindowControl(), "artefact.file", "artefact.file", formLayout);
    fileEl.addActionListener(FormEvent.ONCHANGE);
    fileEl.setMaxUploadSizeKB(250000, null, null);
    fileEl.setPreview(ureq.getUserSession(), true);
    fileEl.setDeleteEnabled(true);
    if (mediaReference != null) {
        fileEl.setEnabled(false);
        VFSItem item = fileHandler.getVideoItem(mediaReference);
        if (item instanceof JavaIOItem) {
            fileEl.setInitialFile(((JavaIOItem) item).getBasefile());
        }
    }
    categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categories, formLayout, getTranslator());
    categoriesEl.setHelpText(translate("categories.hint"));
    categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
    categoriesEl.setAllowDuplicates(false);
    Date collectDate = mediaReference == null ? new Date() : mediaReference.getCollectionDate();
    String date = Formatter.getInstance(getLocale()).formatDate(collectDate);
    uifactory.addStaticTextElement("artefact.collect.date", "artefact.collect.date", date, formLayout);
    if (StringHelper.containsNonWhitespace(businessPath)) {
        String link = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
        uifactory.addStaticTextElement("artefact.collect.link", "artefact.collect.link", link, formLayout);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("save", "save", buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
}
Also used : JavaIOItem(org.olat.core.util.vfs.JavaIOItem) VFSItem(org.olat.core.util.vfs.VFSItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Date(java.util.Date)

Aggregations

JavaIOItem (org.olat.core.util.vfs.JavaIOItem)12 IOException (java.io.IOException)6 Date (java.util.Date)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 File (java.io.File)4 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 ZipEntry (java.util.zip.ZipEntry)4 ZipFile (java.util.zip.ZipFile)4 LimitedContentWriter (org.olat.core.util.io.LimitedContentWriter)4 ShieldInputStream (org.olat.core.util.io.ShieldInputStream)4 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)2