Search in sources :

Example 71 with MetaInfo

use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.

the class SendDocumentsByEMailController method setFiles.

protected void setFiles(VFSContainer rootContainer, List<VFSLeaf> leafs) {
    this.files = leafs;
    StringBuilder subjectSb = new StringBuilder();
    if (StringHelper.containsNonWhitespace(subjectElement.getValue())) {
        subjectSb.append(subjectElement.getValue()).append('\n').append('\n');
    }
    StringBuilder bodySb = new StringBuilder();
    if (StringHelper.containsNonWhitespace(bodyElement.getValue())) {
        bodySb.append(bodyElement.getValue()).append('\n').append('\n');
    }
    attachments = new ArrayList<File>();
    long fileSize = 0l;
    for (VFSLeaf file : files) {
        MetaInfo infos = null;
        if (file instanceof MetaTagged) {
            infos = ((MetaTagged) file).getMetaInfo();
        }
        // subject
        appendToSubject(file, infos, subjectSb);
        // body
        appendMetadatas(file, infos, bodySb);
        appendBusinessPath(rootContainer, file, bodySb);
        bodySb.append('\n').append('\n');
        fileSize += file.getSize();
        if (allowAttachments && file instanceof LocalFileImpl) {
            File f = ((LocalFileImpl) file).getBasefile();
            attachments.add(f);
        }
    }
    int mailQuota = CoreSpringFactory.getImpl(MailModule.class).getMaxSizeForAttachement();
    long fileSizeInMB = fileSize / (1024l * 1024l);
    if (allowAttachments) {
        if (fileSizeInMB > mailQuota) {
            attachments.clear();
            setFormWarning("send.mail.fileToBigForAttachments", new String[] { String.valueOf(mailQuota), String.valueOf(fileSizeInMB) });
        } else {
            List<FileInfo> infos = new ArrayList<FileInfo>(files.size());
            for (VFSLeaf file : files) {
                final String name = file.getName();
                final double size = file.getSize() / (1024.0 * 1024.0);
                final String sizeStr = formatMb.format(size);
                final String cssClass = CSSHelper.createFiletypeIconCssClassFor(file.getName());
                infos.add(new FileInfo(name, sizeStr, cssClass));
            }
            attachmentsLayout.contextPut("attachments", infos);
        }
    }
    subjectElement.setValue(subjectSb.toString());
    bodyElement.setValue(bodySb.toString());
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) ArrayList(java.util.ArrayList) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) MailModule(org.olat.core.util.mail.MailModule) File(java.io.File)

Example 72 with MetaInfo

use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.

the class ConvertToGTACourseNode method convertMetada.

private void convertMetada(VFSContainer source, VFSContainer target, String name, TaskDefinition taskDef, Solution solDef) {
    VFSItem sourceItem = source.resolve(name);
    VFSItem targetItem = target.resolve(name);
    if (sourceItem instanceof MetaTagged && targetItem instanceof MetaTagged) {
        MetaTagged taggedSource = (MetaTagged) sourceItem;
        MetaInfo metaSource = taggedSource.getMetaInfo();
        MetaTagged taggedTarget = (MetaTagged) targetItem;
        MetaInfo metaTarget = taggedTarget.getMetaInfo();
        if (metaSource != null) {
            if (taskDef != null) {
                if (StringHelper.containsNonWhitespace(metaSource.getTitle())) {
                    taskDef.setTitle(metaSource.getTitle());
                }
                taskDef.setDescription(metaSource.getComment());
            }
            if (solDef != null) {
                if (StringHelper.containsNonWhitespace(metaSource.getTitle())) {
                    solDef.setTitle(metaSource.getTitle());
                }
            }
            if (metaTarget != null) {
                metaTarget.copyValues(metaSource);
                metaTarget.write();
            }
        }
    }
}
Also used : MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 73 with MetaInfo

use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.

the class DocumentPoolNotificationsHandler method createSubscriptionInfo.

private void createSubscriptionInfo(VFSContainer container, String prefixBusinessPath, Date compareDate, SubscriptionInfo si, Publisher p, Translator translator) {
    List<FileInfo> fInfos = FolderManager.getFileInfos(((OlatRelPathImpl) container).getRelPath(), compareDate);
    for (FileInfo infos : fInfos) {
        String title = infos.getRelPath();
        // known exclude prefixes
        if (title != null && title.indexOf("/.") != -1 && FileUtils.isMetaFilename(title)) {
            // skip this file, continue with next item in folder
            continue;
        }
        MetaInfo metaInfo = infos.getMetaInfo();
        String iconCssClass = null;
        if (metaInfo != null) {
            if (metaInfo.getTitle() != null) {
                title += " (" + metaInfo.getTitle() + ")";
            }
            iconCssClass = metaInfo.getIconCssClass();
        }
        Identity ident = infos.getAuthor();
        Date modDate = infos.getLastModified();
        String desc = translator.translate("notifications.document.entry", new String[] { title, NotificationHelper.getFormatedName(ident) });
        String urlToSend = null;
        String businessPath = null;
        if (p.getBusinessPath() != null) {
            businessPath = prefixBusinessPath + infos.getRelPath() + "]";
            urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
        }
        si.addSubscriptionListItem(new SubscriptionListItem(desc, urlToSend, businessPath, modDate, iconCssClass));
    }
}
Also used : SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) FileInfo(org.olat.core.commons.modules.bc.FileInfo) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) Identity(org.olat.core.id.Identity) Date(java.util.Date)

Example 74 with MetaInfo

use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.

the class ImageHandler method getInformations.

@Override
public MediaInformations getInformations(Object mediaObject) {
    String title = null;
    String description = null;
    if (mediaObject instanceof MetaTagged) {
        MetaInfo meta = ((MetaTagged) mediaObject).getMetaInfo();
        title = meta.getTitle();
        description = meta.getComment();
    }
    return new Informations(title, description);
}
Also used : MediaInformations(org.olat.modules.portfolio.MediaInformations) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo)

Example 75 with MetaInfo

use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.

the class ImageHandler method getThumbnail.

@Override
public VFSLeaf getThumbnail(MediaLight media, Size size) {
    String storagePath = media.getStoragePath();
    VFSLeaf thumbnail = null;
    if (StringHelper.containsNonWhitespace(storagePath)) {
        VFSContainer storageContainer = fileStorage.getMediaContainer(media);
        VFSItem item = storageContainer.resolve(media.getRootFilename());
        if (item instanceof VFSLeaf) {
            VFSLeaf leaf = (VFSLeaf) item;
            if (leaf instanceof MetaTagged) {
                MetaInfo metaInfo = ((MetaTagged) leaf).getMetaInfo();
                thumbnail = metaInfo.getThumbnail(size.getHeight(), size.getWidth(), true);
            }
        }
    }
    return thumbnail;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem)

Aggregations

MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)108 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)86 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)58 VFSItem (org.olat.core.util.vfs.VFSItem)52 VFSContainer (org.olat.core.util.vfs.VFSContainer)40 Date (java.util.Date)18 OutputStream (java.io.OutputStream)14 File (java.io.File)12 IOException (java.io.IOException)12 Versionable (org.olat.core.util.vfs.version.Versionable)12 InputStream (java.io.InputStream)10 ArrayList (java.util.ArrayList)10 FolderEvent (org.olat.core.commons.modules.bc.FolderEvent)10 MediaResource (org.olat.core.gui.media.MediaResource)10 Identity (org.olat.core.id.Identity)10 VFSMediaResource (org.olat.core.util.vfs.VFSMediaResource)10 FileInfo (org.olat.core.commons.modules.bc.FileInfo)8 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)8 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)8 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)8