use of org.olat.modules.portfolio.Media in project openolat by klemens.
the class MediaDAOTest method createMedia.
@Test
public void createMedia() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-1");
Media media = mediaDao.createMedia("Media", "Media description", "Media content", "Forum", "[Media:0]", null, 10, id);
dbInstance.commit();
Assert.assertNotNull(media);
Assert.assertNotNull(media.getKey());
Assert.assertNotNull(media.getCreationDate());
Assert.assertNotNull(media.getCollectionDate());
Assert.assertEquals(id, media.getAuthor());
Media reloadedMedia = mediaDao.loadByKey(media.getKey());
Assert.assertNotNull(reloadedMedia);
Assert.assertEquals(media, reloadedMedia);
Assert.assertEquals(id, reloadedMedia.getAuthor());
Assert.assertEquals("Media", reloadedMedia.getTitle());
Assert.assertEquals("Media description", reloadedMedia.getDescription());
Assert.assertEquals("[Media:0]", reloadedMedia.getBusinessPath());
Assert.assertEquals(id, reloadedMedia.getAuthor());
}
use of org.olat.modules.portfolio.Media in project openolat by klemens.
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 klemens.
the class TextHandler method createMedia.
@Override
public Media createMedia(AbstractArtefact artefact) {
String title = artefact.getTitle();
String description = artefact.getDescription();
String content = artefact.getFulltextContent();
if (!StringHelper.containsNonWhitespace(content)) {
content = oldPortfolioManager.getArtefactFullTextContent(artefact);
}
String businessPath = artefact.getBusinessPath();
if (businessPath == null) {
businessPath = "[PortfolioV2:0][MediaCenter:0]";
}
Media media = mediaDao.createMedia(title, description, content, TEXT_MEDIA, businessPath, artefact.getKey().toString(), artefact.getSignature(), artefact.getAuthor());
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
return media;
}
use of org.olat.modules.portfolio.Media in project openolat by klemens.
the class VideoHandler method createMedia.
public Media createMedia(String title, String description, File file, String filename, String businessPath, Identity author) {
Media media = mediaDao.createMedia(title, description, filename, VIDEO_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 klemens.
the class MediaCenterController method doImportArtefactV1.
private Media doImportArtefactV1(AbstractArtefact oldArtefact) {
Media media = null;
MediaHandler handler = portfolioService.getMediaHandler(oldArtefact.getResourceableTypeName());
if (handler != null) {
media = handler.createMedia(oldArtefact);
}
return media;
}
Aggregations