private void registerIntoFileSystem(final File file, final String name, final org.uberfire.java.nio.file.Path targetPath) { final org.uberfire.java.nio.file.Path targetFilePath = targetPath.resolve(name); try { ioService.copy(new FileInputStream(file), targetFilePath); } catch (Exception e) { LOG.error("Error writing file [" + name + "] into " + "path [" + targetFilePath + "]", e); } }
protected void createHiddenBranch(final PullRequest pullRequest) { final Path source = this.buildPath(pullRequest.getSourceRepository(), pullRequest.getSourceBranch()); final Path target = this.buildHiddenPath(pullRequest); ioService.copy(source, target); if (logger.isDebugEnabled()) { logger.debug("Hidden branch {} created.", target.toString()); } }
protected void createHiddenBranch(final PullRequest pullRequest) { final Path source = this.buildPath(pullRequest.getSourceRepository(), pullRequest.getSourceBranch()); final Path target = this.buildHiddenPath(pullRequest); ioService.copy(source, target); if (logger.isDebugEnabled()) { logger.debug("Hidden branch {} created.", target.toString()); } }
@Override public long copy(InputStream in, Path target, CopyOption... options) throws IOException, FileAlreadyExistsException, DirectoryNotEmptyException, UnsupportedOperationException, SecurityException { if (!authManager.authorize(toResource(target), getUser())) { throw new SecurityException(); } return service.copy(in, target, options); }
@Override public long copy(Path source, OutputStream out) throws IOException, SecurityException { if (!authManager.authorize(toResource(source), getUser())) { throw new SecurityException(); } return service.copy(source, out); }
@Override public long copy(Path source, OutputStream out) throws IOException, SecurityException { if (!authManager.authorize(toResource(source), getUser())) { throw new SecurityException(); } return service.copy(source, out); }
private void mergePullRequest(final PullRequest pullRequest) { final Path source = this.buildHiddenPath(pullRequest); final Path target = this.buildPath(pullRequest.getTargetRepository(), pullRequest.getTargetBranch()); ioService.copy(source, target, new MergeCopyOption()); if (logger.isDebugEnabled()) { logger.debug("Merged from <{}> to <{}>", source.toString(), target.toString()); } }
@Override public long copy(InputStream in, Path target, CopyOption... options) throws IOException, FileAlreadyExistsException, DirectoryNotEmptyException, UnsupportedOperationException, SecurityException { if (!authManager.authorize(toResource(target), getUser())) { throw new SecurityException(); } return service.copy(in, target, options); }
private void mergePullRequest(final PullRequest pullRequest) { final Path source = this.buildHiddenPath(pullRequest); final Path target = this.buildPath(pullRequest.getTargetRepository(), pullRequest.getTargetBranch()); ioService.copy(source, target, new MergeCopyOption()); if (logger.isDebugEnabled()) { logger.debug("Merged from <{}> to <{}>", source.toString(), target.toString()); } }
@Override public Path copy(final Path source, final Path target) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException { return Paths.convert(ioService.copy(Paths.convert(source), Paths.convert(target))); }
@Test public void testCopy() { tested.copy(ROOT_PATH, ROOT_PATH); verify(ioService, times(1)) .copy(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class)); }
@Test public void testCopy() { tested.copy(ROOT_PATH, ROOT_PATH); verify(ioService, times(1)) .copy(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class)); }
@Override public void copy(Path source, Path dest){ if (!isActive()) { return; } checkNotNull( "source", source ); checkNotNull( "dest", dest ); getIOService().copy(source, dest); }
@Override public Path copy(Path source, Path target, CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException { if (!authManager.authorize(toResource(source), getUser())) { throw new SecurityException(); } if (!authManager.authorize(toResource(target), getUser())) { throw new SecurityException(); } return service.copy(source, target, options); }
@Override public Path copy(Path source, Path target, CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException { if (!authManager.authorize(toResource(source), getUser())) { throw new SecurityException(); } if (!authManager.authorize(toResource(target), getUser())) { throw new SecurityException(); } return service.copy(source, target, options); }
@Override public void copy(Path source, Path dest) { checkNotNull( "source", source ); checkNotNull( "dest", dest ); ioService.copy(source, dest); }
@Test public void testIndexingCopiedResources() throws IOException, InterruptedException { //Add test files loadProperties("file1.properties", getBasePath(this.getClass().getSimpleName() + "_1")); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index searchFor(new TermQuery(new Term("title", "lucene")), 1); //Copy one of the files returned by the previous search ioService().copy(getBasePath(this.getClass().getSimpleName() + "_1").resolve("file1.properties"), getBasePath(this.getClass().getSimpleName() + "_2").resolve("file1.properties")); Thread.sleep(5000); //wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index searchFor(new TermQuery(new Term("title", "lucene")), 2); }
@Test public void testAcceptPullRequest() { PullRequest pullRequest = service.createPullRequest("child/a", "develop", "parent/a", "master"); service.acceptPullRequest(pullRequest); List<PullRequest> pullRequests = service.getPullRequestsByBranch(0, 0, pullRequest.getTargetRepository(), pullRequest.getTargetBranch()); assertEquals(PullRequestStatus.MERGED, pullRequests.get(0).getStatus()); verify(ioService).copy(any(Path.class), any(Path.class), any(MergeCopyOption.class)); }
@Test(expected = FileAlreadyExistsException.class) public void copyFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("alreadyExistsTest"); ioService().deleteIfExists(path); ioService().createDirectories(path); ioService().write(path.resolve("myFile.txt"), "ooooo!"); ioService().write(path.resolve("mytarget"), "xooooo!"); ioService().copy(path.resolve("myFile.txt"), path.resolve("mytarget")); }
@Test(expected = FileAlreadyExistsException.class) public void copyFileAlreadyExistsException() { final Path path = getDirectoryPath().resolveSibling("alreadyExistsTest"); ioService().deleteIfExists(path); ioService().createDirectories(path); ioService().write(path.resolve("myFile.txt"), "ooooo!"); ioService().write(path.resolve("mytarget"), "xooooo!"); ioService().copy(path.resolve("myFile.txt"), path.resolve("mytarget")); }