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());
}
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();
}
}
}
}
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));
}
}
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);
}
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;
}
Aggregations