@Override public Map<String, Object> readAttributes(final Path path) throws UnsupportedOperationException, IllegalArgumentException, IOException { final Map<String, Object> attributes = new HashMap<String, Object>(ioService.readAttributes(Paths.convert(path))); final Object _lastModifiedTime = attributes.get("lastModifiedTime"); if (_lastModifiedTime != null) { attributes.put("lastModifiedTime", new Date(((FileTime) _lastModifiedTime).toMillis())); } final Object _lastAccessTime = attributes.get("lastAccessTime"); if (_lastAccessTime != null) { attributes.put("lastAccessTime", new Date(((FileTime) _lastAccessTime).toMillis())); } final Object _creationTime = attributes.get("creationTime"); if (_creationTime != null) { attributes.put("creationTime", new Date(((FileTime) _creationTime).toMillis())); } return attributes; }
@Override public Map<String, Object> readAttributes(Path path) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.readAttributes(path); }
@Override public Map<String, Object> readAttributes(Path path) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.readAttributes(path); }
@Override public Map<String, Object> readAttributes(Path path, String attributes) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.readAttributes(path, attributes); }
@Override public Map<String, Object> readAttributes(Path path, String attributes) throws UnsupportedOperationException, NoSuchFileException, IllegalArgumentException, IOException, SecurityException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.readAttributes(path, attributes); }
@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); }
@Override public Map<String, Object> setUpAttributes(final Path path, final Metadata metadata) { try { Map<String, Object> attributes; try { attributes = ioService.readAttributes(Paths.convert(path)); } catch (final NoSuchFileException ex) { attributes = new HashMap<String, Object>(); } if (metadata != null) { attributes = configAttrs(attributes, metadata); } return BasicFileAttributesUtil.cleanup(attributes); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Override public Map<String, Object> setUpAttributes(final Path path, final Metadata metadata) { try { Map<String, Object> attributes; try { attributes = ioService.readAttributes(Paths.convert(path)); } catch (final NoSuchFileException ex) { attributes = new HashMap<String, Object>(); } if (metadata != null) { attributes = configAttrs(attributes, metadata); } return BasicFileAttributesUtil.cleanup(attributes); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } }
@Override public List<FileDiff> diff(final PullRequest pullRequest) { final Repository repository = configuredRepositories.getRepositoryByRepositoryAlias(pullRequest.getTargetRepository()); this.createHiddenBranch(pullRequest); String diff = String.format("diff:%s,%s", pullRequest.getTargetBranch(), this.buildHiddenBranchName(pullRequest)); final List<FileDiff> diffs = (List<FileDiff>) this.ioService.readAttributes(convert(repository.getRoot()), diff); this.deleteHiddenBranch(pullRequest); return diffs; }
@Override public List<FileDiff> diff(final PullRequest pullRequest) { final Repository repository = repositoryService.getRepositoryFromSpace(spaces.getSpace(pullRequest.getTargetSpace()), pullRequest.getTargetRepository()); this.createHiddenBranch(pullRequest); String diff = String.format("diff:%s,%s", pullRequest.getTargetBranch(), this.buildHiddenBranchName(pullRequest)); final List<FileDiff> diffs = (List<FileDiff>) this.ioService.readAttributes(convert(repository.getBranch(pullRequest.getSourceBranch()).get().getPath()), diff); this.deleteHiddenBranch(pullRequest); return diffs; }
when(refactoringQueryService.query(any(RefactoringPageRequest.class))).thenReturn(pageRowPageResponse); when(ioService.readAttributes(any())).thenThrow(new NoSuchFileException());
final Map<String, Object> attrsValue = ioService().readAttributes(path); final Map<String, Object> attrsValue2 = ioService().readAttributes(path);
final Map<String, Object> attrsValue = ioService().readAttributes(path); final Map<String, Object> attrsValue2 = ioService().readAttributes(path);
@Test(expected = NoSuchFileException.class) public void readAttributesNoSuchFileException() { final Path path = getDirectoryPath().resolveSibling("somethingXXX"); ioService().deleteIfExists(path); ioService().readAttributes(path); } }
@Test(expected = NoSuchFileException.class) public void readAttributesNoSuchFileException() { final Path path = getDirectoryPath().resolveSibling("somethingXXX"); ioService().deleteIfExists(path); ioService().readAttributes(path); } }
Map<String, Object> attrs = ioService().readAttributes(file);
Map<String, Object> attrs = ioService().readAttributes(file);
@Test public void createDirectories() { final Path dir = getComposedDirectoryPath(); assertFalse(ioService().exists(dir)); ioService().createDirectories(dir, new FileAttribute<Object>() { @Override public String name() { return "custom"; } @Override public Object value() { return dateValue; } }); assertTrue(ioService().exists(dir)); assertTrue(ioService().exists(dir.getParent())); assertNotNull(ioService().exists(dir.getParent().getFileName())); Map<String, Object> attrs = ioService().readAttributes(dir); assertEquals(createDirectoriesAttrSize(), attrs.size()); ioService().delete(dir); ioService().exists(dir.getParent()); }
@Test public void createDirectories() { final Path dir = getComposedDirectoryPath(); assertFalse(ioService().exists(dir)); ioService().createDirectories(dir, new FileAttribute<Object>() { @Override public String name() { return "custom"; } @Override public Object value() { return dateValue; } }); assertTrue(ioService().exists(dir)); assertTrue(ioService().exists(dir.getParent())); assertNotNull(ioService().exists(dir.getParent().getFileName())); Map<String, Object> attrs = ioService().readAttributes(dir); assertEquals(createDirectoriesAttrSize(), attrs.size()); ioService().delete(dir); ioService().exists(dir.getParent()); }