@Override public Map<String, Object> readAttributes( final Path path, final String attributes, final LinkOption... options ) throws UnsupportedOperationException, IllegalArgumentException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attributes", attributes ); final String[] s = split( attributes ); if ( s[ 0 ].length() == 0 ) { throw new IllegalArgumentException( attributes ); } final ExtendedAttributeView view = getFileAttributeView( toPathImpl( path ), s[ 0 ], options ); if ( view == null ) { throw new UnsupportedOperationException( "View '" + s[ 0 ] + "' not available" ); } return view.readAttributes( s[ 1 ].split( "," ) ); }
@Override public void setAttribute( final Path path, final String attribute, final Object value, final LinkOption... options ) throws UnsupportedOperationException, IllegalArgumentException, ClassCastException, IOException, SecurityException { checkNotNull( "path", path ); checkNotEmpty( "attributes", attribute ); if ( attribute.equals( FileSystemState.FILE_SYSTEM_STATE_ATTR ) ) { try { state = FileSystemState.valueOf( value.toString() ); FileSystemState.valueOf( value.toString() ); } catch ( final Exception ex ) { state = FileSystemState.NORMAL; } hadCommitOnBatchState = false; return; } final String[] s = split( attribute ); if ( s[ 0 ].length() == 0 ) { throw new IllegalArgumentException( attribute ); } final ExtendedAttributeView view = getFileAttributeView( toPathImpl( path ), s[ 0 ], options ); if ( view == null ) { throw new UnsupportedOperationException( "View '" + s[ 0 ] + "' not available" ); } view.setAttribute( s[ 1 ], value ); }
@Override public <A extends BasicFileAttributes> A readAttributes( final Path path, final Class<A> type, final LinkOption... options ) throws NoSuchFileException, UnsupportedOperationException, IOException, SecurityException { checkNotNull( "path", path ); checkNotNull( "type", type ); final JGitPathImpl gPath = toPathImpl( path ); final Pair<PathType, ObjectId> pathResult = checkPath( gPath.getFileSystem().gitRepo(), gPath.getRefTree(), gPath.getPath() ); if ( pathResult.getK1().equals( NOT_FOUND ) ) { throw new NoSuchFileException( path.toString() ); } if ( type == BasicFileAttributesImpl.class || type == BasicFileAttributes.class || type == VersionAttributes.class ) { final JGitVersionAttributeView view = getFileAttributeView( path, JGitVersionAttributeView.class, options ); return (A) view.readAttributes(); } return null; }
outStream3.close(); final JGitVersionAttributeView attrs = PROVIDER.getFileAttributeView( path3, JGitVersionAttributeView.class ); PROVIDER.getFileAttributeView( PROVIDER.getPath( URI.create( "git://user_branch@getfileattriview-test-repo/not_exists.txt" ) ), BasicFileAttributeView.class ); failBecauseExceptionWasNotThrown( NoSuchFileException.class ); } catch ( Exception e ) { assertThat( PROVIDER.getFileAttributeView( path3, MyInvalidFileAttributeView.class ) ).isNull(); final BasicFileAttributeView attrsRoot = PROVIDER.getFileAttributeView( rootPath, BasicFileAttributeView.class );