@Override public Metadata getMetadata(org.uberfire.java.nio.file.Path path) { try { return new MetadataCreator(path, configIOService, sessionInfo, ioService.getFileAttributeView(path, DublinCoreView.class), ioService.getFileAttributeView(path, DiscussionView.class), ioService.getFileAttributeView(path, OtherMetaView.class), ioService.getFileAttributeView(path, VersionAttributeView.class), ioService.getFileAttributeView(path, GeneratedAttributesView.class)).create(); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public Metadata getMetadata(org.uberfire.java.nio.file.Path path) { try { return new MetadataCreator(path, configIOService, sessionInfo, ioService.getFileAttributeView(path, DublinCoreView.class), ioService.getFileAttributeView(path, DiscussionView.class), ioService.getFileAttributeView(path, OtherMetaView.class), ioService.getFileAttributeView(path, VersionAttributeView.class), ioService.getFileAttributeView(path, GeneratedAttributesView.class)).create(); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type) throws IllegalArgumentException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.getFileAttributeView(path, type); }
@Override public List<String> getTags(final org.uberfire.java.nio.file.Path resource) { checkNotNull("resource", resource); final OtherMetaView otherMetaView = ioService.getFileAttributeView(resource, OtherMetaView.class); if (otherMetaView != null) { return otherMetaView.readAttributes().tags(); } else { return Collections.emptyList(); } }
@Override public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type) throws IllegalArgumentException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.getFileAttributeView(path, type); }
@Override public List<String> getTags(final org.uberfire.java.nio.file.Path resource) { checkNotNull("MetadataServiceImpl.resource", resource); final OtherMetaView otherMetaView = ioService.getFileAttributeView(resource, OtherMetaView.class); if (otherMetaView != null) { return otherMetaView.readAttributes().tags(); } else { return Collections.emptyList(); } }
@Override public List<VersionRecord> loadVersionRecords(Path path) { if (ioService.exists(path)) { ArrayList<VersionRecord> portableRecords = new ArrayList<VersionRecord>(); for (VersionRecord versionRecord : ioService.getFileAttributeView(path, VersionAttributeView.class).readAttributes().history().records()) { portableRecords.add(makePortable(versionRecord)); } return portableRecords; } else { return new ArrayList<VersionRecord>(); } }
@Override public List<VersionRecord> loadVersionRecords(Path path) { if (ioService.exists(path)) { ArrayList<VersionRecord> portableRecords = new ArrayList<VersionRecord>(); for (VersionRecord versionRecord : ioService.getFileAttributeView(path, VersionAttributeView.class).readAttributes().history().records()) { portableRecords.add(makePortable(versionRecord)); } return portableRecords; } else { return new ArrayList<VersionRecord>(); } }
@Override public KObject toKObject(Path path) { //Default indexing for (Class<? extends FileAttributeView> view : views) { ioService.getFileAttributeView(path, view); } final FileAttribute<?>[] attrs = ioService.convert(ioService.readAttributes(path)); return KObjectUtil.toKObject(path, attrs); }
@Override public KObject toKObject(Path path) { //Default indexing for (Class<? extends FileAttributeView> view : views) { ioService.getFileAttributeView(path, view); } final FileAttribute<?>[] attrs = ioService.convert(ioService.readAttributes(path)); return KObjectUtil.toKObject(path, attrs); }
@Test public void testGetEmptyTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock()); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(0, tags.size()); }
final VersionAttributeView versionAttributeView = ioService.getFileAttributeView(convert(repo.getRoot()), VersionAttributeView.class); final List<VersionRecord> records = versionAttributeView.readAttributes().history().records();
@Test public void testGetEmptyTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock()); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(0, tags.size()); }
@Test public void testGetEmptyTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock()); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(0, tags.size()); }
final List<SearchPageRow> result = new ArrayList<SearchPageRow>( pathResult.size() ); for ( final Path path : pathResult ) { final DublinCoreView dcoreView = ioService.getFileAttributeView( path, DublinCoreView.class ); final VersionAttributeView versionAttributeView = ioService.getFileAttributeView( path, VersionAttributeView.class );
@Test public void testGetTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock() { List<String> tags = new ArrayList<String>() {{ add("tag1"); }}; @Override public List<String> tags() { return tags; } }); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(1, tags.size()); } }
@Test public void testGetTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock() { List<String> tags = new ArrayList<String>() {{ add("tag1"); }}; @Override public List<String> tags() { return tags; } }); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(1, tags.size()); } }
@Test public void testGetTags() { when(otherMetaView.readAttributes()).thenReturn(new OtherMetaAttributesMock() { List<String> tags = new ArrayList<String>() {{ add("tag1"); }}; @Override public List<String> tags() { return tags; } }); when(ioService.getFileAttributeView(path, OtherMetaView.class)).thenReturn(otherMetaView); final List<String> tags = service.getTags(path); assertNotNull(tags); assertEquals(1, tags.size()); } }
assertNotNull(ioService().getFileAttributeView(file, BasicFileAttributeView.class)); assertNull(ioService().getFileAttributeView(file, MyAttrsView.class)); assertNotNull(ioService().getFileAttributeView(file, XDublinCoreView.class)); final DublinCoreAttributes attr = ioService().getFileAttributeView(file, XDublinCoreView.class).readAttributes(); assertEquals("AuthorName", assertNotNull(ioService().getFileAttributeView(file, BasicFileAttributeView.class)); assertNull(ioService().getFileAttributeView(file, MyAttrsView.class)); assertNotNull(ioService().getFileAttributeView(file, XDublinCoreView.class));
ioService.endBatch(); VersionAttributeView v = ioService.getFileAttributeView(f11, VersionAttributeView.class); assertNotNull(v); ioService.readAllString(f11)); v = ioService.getFileAttributeView(f11, VersionAttributeView.class); assertNotNull(v);