use of org.olat.portfolio.model.artefacts.FileArtefact 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.portfolio.model.artefacts.FileArtefact in project OpenOLAT by OpenOLAT.
the class EPCreateFileArtefactStepForm00 method saveUpload.
private void saveUpload() {
VFSLeaf contFile = vfsTemp.createChildLeaf(fileupload.getUploadFileName());
VFSManager.copyContent(fileupload.getUploadInputStream(), contFile);
((FileArtefact) artefact).setFilename(fileupload.getUploadFileName());
}
use of org.olat.portfolio.model.artefacts.FileArtefact in project OpenOLAT by OpenOLAT.
the class EPArtefactManagerTest method testSaveFileArtefactWithAllProperties.
@Test
public void testSaveFileArtefactWithAllProperties() {
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact);
assertTrue(artefact instanceof FileArtefact);
FileArtefact fileArtefact = (FileArtefact) artefact;
fileArtefact.setBusinessPath("[CourseModule:526834956][path=/test/test.html:0]");
fileArtefact.setCollectionDate(new Date());
fileArtefact.setDescription("A description of the file artefact");
fileArtefact.setFulltextContent("The text of the artefact");
fileArtefact.setReflexion("A deep reflexion caused by this artefact");
fileArtefact.setSignature(90);
fileArtefact.setSource("A file");
fileArtefact.setTitle("File artefact");
epFrontendManager.updateArtefact(artefact);
dbInstance.commitAndCloseSession();
assertNotNull(artefact.getKey());
// reload the artefact
AbstractArtefact persistedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof FileArtefact);
assertEquals("[CourseModule:526834956][path=/test/test.html:0]", persistedArtefact.getBusinessPath());
assertNotNull(persistedArtefact.getCollectionDate());
assertEquals("A description of the file artefact", persistedArtefact.getDescription());
assertEquals("The text of the artefact", persistedArtefact.getFulltextContent());
assertEquals("A deep reflexion caused by this artefact", persistedArtefact.getReflexion());
assertEquals(90, persistedArtefact.getSignature());
assertEquals("A file", persistedArtefact.getSource());
assertEquals("File artefact", persistedArtefact.getTitle());
}
use of org.olat.portfolio.model.artefacts.FileArtefact in project openolat by klemens.
the class EPArtefactManagerTest method testSaveFileArtefactWithAllProperties.
@Test
public void testSaveFileArtefactWithAllProperties() {
AbstractArtefact artefact = epFrontendManager.createAndPersistArtefact(ident1, "bc");
assertNotNull(artefact);
assertTrue(artefact instanceof FileArtefact);
FileArtefact fileArtefact = (FileArtefact) artefact;
fileArtefact.setBusinessPath("[CourseModule:526834956][path=/test/test.html:0]");
fileArtefact.setCollectionDate(new Date());
fileArtefact.setDescription("A description of the file artefact");
fileArtefact.setFulltextContent("The text of the artefact");
fileArtefact.setReflexion("A deep reflexion caused by this artefact");
fileArtefact.setSignature(90);
fileArtefact.setSource("A file");
fileArtefact.setTitle("File artefact");
epFrontendManager.updateArtefact(artefact);
dbInstance.commitAndCloseSession();
assertNotNull(artefact.getKey());
// reload the artefact
AbstractArtefact persistedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof FileArtefact);
assertEquals("[CourseModule:526834956][path=/test/test.html:0]", persistedArtefact.getBusinessPath());
assertNotNull(persistedArtefact.getCollectionDate());
assertEquals("A description of the file artefact", persistedArtefact.getDescription());
assertEquals("The text of the artefact", persistedArtefact.getFulltextContent());
assertEquals("A deep reflexion caused by this artefact", persistedArtefact.getReflexion());
assertEquals(90, persistedArtefact.getSignature());
assertEquals("A file", persistedArtefact.getSource());
assertEquals("File artefact", persistedArtefact.getTitle());
}
use of org.olat.portfolio.model.artefacts.FileArtefact in project openolat by klemens.
the class EPCreateFileArtefactStepForm00 method saveUpload.
private void saveUpload() {
VFSLeaf contFile = vfsTemp.createChildLeaf(fileupload.getUploadFileName());
VFSManager.copyContent(fileupload.getUploadInputStream(), contFile);
((FileArtefact) artefact).setFilename(fileupload.getUploadFileName());
}
Aggregations