use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.
the class BinderListController method doOpenBinder.
protected BinderController doOpenBinder(UserRequest ureq, BinderRef row) {
SynchedBinder binder = portfolioService.loadAndSyncBinder(row);
if (binder.isChanged()) {
showInfo("warning.binder.synched");
}
BinderController selectedBinderCtrl = doOpenBinder(ureq, binder.getBinder());
if (row instanceof BinderRow) {
VFSLeaf image = portfolioService.getPosterImageLeaf(binder.getBinder());
((BinderRow) row).setBackgroundImage(image);
}
return selectedBinderCtrl;
}
use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.
the class BinderListController method forgePortfolioRow.
protected BinderRow forgePortfolioRow(BinderStatistics binderRow) {
String openLinkId = "open_" + (++counter);
FormLink openLink = uifactory.addFormLink(openLinkId, "open", "open", null, flc, Link.LINK);
openLink.setIconRightCSS("o_icon o_icon_start");
VFSLeaf image = portfolioService.getPosterImageLeaf(binderRow);
BinderRow row = new BinderRow(binderRow, image, openLink);
openLink.setUserObject(row);
return row;
}
use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.
the class FileHandler 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;
}
use of org.olat.core.util.vfs.VFSLeaf 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);
}
use of org.olat.core.util.vfs.VFSLeaf in project OpenOLAT by OpenOLAT.
the class VersionManagerTest method testDeleteRevisions_withSameFile.
/**
* The test create an original file and 3 revisions with exactly
* the same content. We delete the original and the first version.
* We check that version 2 and 3 survives and that the file exists.
*
* @throws IOException
*/
@Test
public void testDeleteRevisions_withSameFile() throws IOException {
OlatRootFolderImpl rootTest = new OlatRootFolderImpl("/ver-" + UUID.randomUUID(), null);
String filename = getRandomName();
VFSLeaf file = rootTest.createChildLeaf(filename);
OutputStream out = file.getOutputStream(false);
InputStream in = VersionManagerTest.class.getResourceAsStream("test.txt");
int byteCopied = IOUtils.copy(in, out);
IOUtils.closeQuietly(in);
assertFalse(byteCopied == 0);
assertTrue(file instanceof Versionable);
// save a first version
Versionable versionedFile = (Versionable) file;
InputStream in1 = VersionManagerTest.class.getResourceAsStream("test.txt");
versionedFile.getVersions().addVersion(id2, "Version 1", in1);
IOUtils.closeQuietly(in1);
// save a second version
InputStream in2 = VersionManagerTest.class.getResourceAsStream("test.txt");
versionedFile.getVersions().addVersion(id2, "Version 2", in2);
IOUtils.closeQuietly(in2);
// save a third version
InputStream in3 = VersionManagerTest.class.getResourceAsStream("test.txt");
versionedFile.getVersions().addVersion(id2, "Version 3", in2);
IOUtils.closeQuietly(in3);
// delete revisions
versionManager.deleteRevisions(versionedFile, versionedFile.getVersions().getRevisions().subList(0, 2));
// check number of versions
VFSItem reloadFile = rootTest.resolve(filename);
assertTrue(reloadFile instanceof Versionable);
Versionable reloadedVersionedFile = (Versionable) reloadFile;
List<VFSRevision> revisions = reloadedVersionedFile.getVersions().getRevisions();
Assert.assertNotNull(revisions);
Assert.assertEquals(1, revisions.size());
// check surviving versions
Assert.assertEquals("Version 2", revisions.get(0).getComment());
Assert.assertEquals("Version 3", reloadedVersionedFile.getVersions().getComment());
// check that the last backup file exists
RevisionFileImpl revision2 = (RevisionFileImpl) revisions.get(0);
VFSLeaf revision2File = revision2.getFile();
Assert.assertNotNull(revision2File);
Assert.assertTrue(revision2File.exists());
// check if there is only one backup file
VFSContainer versionContainer = versionManager.getCanonicalVersionFolder(file.getParentContainer(), false);
Assert.assertNotNull(versionContainer);
List<VFSItem> items = versionContainer.getItems(new SystemItemFilter());
Assert.assertNotNull(items);
Assert.assertEquals(2, items.size());
}
Aggregations