use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementMediaHandler method createMedia.
@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
Media media = null;
if (mediaObject instanceof EfficiencyStatement) {
EfficiencyStatement statement = (EfficiencyStatement) mediaObject;
String xml = myXStream.toXML(statement);
media = mediaDao.createMedia(title, description, xml, EFF_MEDIA, businessPath, null, 90, author);
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
}
return media;
}
use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.
the class FileHandler method createMedia.
@Override
public Media createMedia(AbstractArtefact artefact) {
Media media = null;
if (artefact instanceof FileArtefact) {
VFSContainer artefactFolder = oldPortfolioManager.getArtefactContainer(artefact);
String filename = ((FileArtefact) artefact).getFilename();
String extension = FileUtils.getFileSuffix(filename);
String type = FILE_TYPE;
if ("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension) || "png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension)) {
type = ImageHandler.IMAGE_TYPE;
}
String businessPath = artefact.getBusinessPath();
if (businessPath == null) {
businessPath = "[PortfolioV2:0][MediaCenter:0]";
}
media = mediaDao.createMedia(artefact.getTitle(), artefact.getDescription(), filename, type, businessPath, artefact.getKey().toString(), artefact.getSignature(), artefact.getAuthor());
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
File mediaDir = fileStorage.generateMediaSubDirectory(media);
String storagePath = fileStorage.getRelativePath(mediaDir);
mediaDao.updateStoragePath(media, storagePath, filename);
VFSContainer mediaContainer = fileStorage.getMediaContainer(media);
VFSManager.copyContent(artefactFolder, mediaContainer);
}
return media;
}
use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.
the class FileHandler method createMedia.
public Media createMedia(String title, String description, File file, String filename, String businessPath, Identity author) {
Media media = mediaDao.createMedia(title, description, filename, FILE_TYPE, businessPath, null, 60, author);
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
File mediaDir = fileStorage.generateMediaSubDirectory(media);
File mediaFile = new File(mediaDir, filename);
FileUtils.copyFileToFile(file, mediaFile, false);
String storagePath = fileStorage.getRelativePath(mediaDir);
mediaDao.updateStoragePath(media, storagePath, filename);
return media;
}
use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.
the class TextHandler method createMedia.
@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
Media media = mediaDao.createMedia(title, description, (String) mediaObject, TEXT_MEDIA, businessPath, null, 60, author);
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
return media;
}
use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.
the class MediaDAO method deleteMedia.
public void deleteMedia(Media media) {
if (StringHelper.containsNonWhitespace(media.getRootFilename())) {
VFSContainer container = fileStorage.getMediaContainer(media);
VFSItem item = container.resolve(media.getRootFilename());
if (item instanceof VFSLeaf) {
((VFSLeaf) item).delete();
}
}
Media reloadedMedia = dbInstance.getCurrentEntityManager().getReference(MediaImpl.class, media.getKey());
dbInstance.getCurrentEntityManager().remove(reloadedMedia);
}
Aggregations