protected <V extends AbstractBasicFileAttributeView> V newView( final AttrHolder holder, final Class<V> type ) { if ( NeedsPreloadedAttrs.class.isAssignableFrom( type ) && holder.getAttrStorage().getContent().size() == 0 ) { readAttributes( (Path) holder ); } try { final Constructor<V> constructor = (Constructor<V>) type.getConstructors()[ 0 ]; final V view = constructor.newInstance( holder ); holder.addAttrView( view ); return view; } catch ( final Exception e ) { } return null; }
public DiscussionView( final AbstractPath path ) { super( path ); final Map<String, Object> content = path.getAttrStorage().getContent();
public OtherMetaView( final AbstractPath path ) { super( path ); final Map<String, Object> content = path.getAttrStorage().getContent();
@Override public Object getAttribute( final Path path, final String attribute ) throws UnsupportedOperationException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); Object value; try { value = Files.getAttribute( path, attribute ); } catch ( UnsupportedOperationException ex ) { value = null; } if ( value == null && path instanceof AttrHolder ) { final AttrHolder holder = ( (AttrHolder) path ); final String[] attr = split( attribute ); if ( holder.getAttrStorage().getContent().isEmpty() ) { loadDotFile( path ); } return holder.getAttrStorage().getAllContent().get( attr[ 1 ] ); } return value; }
public DublinCoreView( final AbstractPath path ) { super( path ); final Map<String, Object> content = path.getAttrStorage().getContent();
@Override public <T extends BasicFileAttributes> T readAttributes() throws org.kie.commons.java.nio.IOException { if ( attrs == null ) { final BasicFileAttributes basicAtts = ( (BasicFileAttributeView) path.getAttrView( BasicFileAttributeView.class ) ).readAttributes(); attrs = new DublinCoreAttributes( basicAtts, (String) path.getAttrStorage().getContent().get( "dcore.author" ) ); } return (T) attrs; }
@Override public Map<String, Object> readAttributes( final Path path, final String attributes ) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attributes", attributes ); final Properties original = new Properties( Files.readAttributes( path, attributes ) ); if ( attributes.equals( "*" ) && exists( dot( path ) ) ) { boolean isAttrHolder = path instanceof AttrHolder; if ( isAttrHolder && ( (AttrHolder) path ).getAttrStorage().getContent().size() > 0 ) { return ( (AttrHolder) path ).getAttrStorage().getAllContent(); } final Properties content = new Properties(); content.load( newInputStream( dot( path ) ) ); content.putAll( original ); if ( isAttrHolder ) { ( (AttrHolder) path ).getAttrStorage().loadContent( content ); } return content; } return original; }
assertFalse( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() ); assertTrue( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() );
assertTrue( ioService().exists( dot( file ) ) ); assertFalse( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() ); assertTrue( ( (AttrHolder) file ).getAttrStorage().getContent().isEmpty() );