@Override public Path copy(final Path path, final String newName, final String comment) { LOGGER.info("User:" + identity.getIdentifier() + " copying file [" + path.getFileName() + "] to [" + newName + "]"); checkRestrictions(path); try { final Path targetPath = pathNamingService.buildTargetPath(path, newName); return copyPath(path, newName, targetPath, comment); } catch (final RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Path copy(final Path path, final String newName, final String comment) { LOGGER.info("User:" + identity.getIdentifier() + " copying file [" + path.getFileName() + "] to [" + newName + "]"); checkRestrictions(path); try { final Path targetPath = pathNamingService.buildTargetPath(path, newName); return copyPath(path, newName, targetPath, comment); } catch (final RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Path copy(final Path path, final String newName, final Path targetDirectory, final String comment) { if (targetDirectory == null) { return copy(path, newName, comment); } LOGGER.info("User:" + identity.getIdentifier() + " copying file [" + path.getFileName() + "] to [" + newName + "]"); checkRestrictions(path); try { final Path targetPath = pathNamingService.buildTargetPath(path, targetDirectory, newName); return copyPath(path, newName, targetPath, comment); } catch (final RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Path copy(final Path path, final String newName, final Path targetDirectory, final String comment) { if (targetDirectory == null) { return copy(path, newName, comment); } LOGGER.info("User:" + identity.getIdentifier() + " copying file [" + path.getFileName() + "] to [" + newName + "]"); checkRestrictions(path); try { final Path targetPath = pathNamingService.buildTargetPath(path, targetDirectory, newName); return copyPath(path, newName, targetPath, comment); } catch (final RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
when(pathNamingService.buildTargetPath(path, getExpectedDef().getName())).thenReturn(renamedPath); org.uberfire.java.nio.file.Path renamedNioPath = Paths.convert(renamedPath);
private String targetFileName(final String originalFileName, final String newFileName) { final Path path = PathFactory.newPath(originalFileName, PATH_PREFIX + originalFileName); fileSystemTestingUtils.getIoService().write(Paths.convert(path), "content"); return pathNamingService.buildTargetPath(path, newFileName).getFileName(); }
private String targetFileName(final String originalFileName, final String newFileName) { final Path path = PathFactory.newPath(originalFileName, PATH_PREFIX + originalFileName); fileSystemTestingUtils.getIoService().write(Paths.convert(path), "content"); return pathNamingService.buildTargetPath(path, newFileName).getFileName(); }
@Test public void buildTargetPathForFolderInAnotherDirectoryTest() { Path originalPath = createFolder("parent/folder"); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-folder"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName, targetPath.toURI()); }
@Test public void buildTargetPathForFolderInAnotherDirectoryTest() { Path originalPath = createFolder("parent/folder"); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-folder"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName, targetPath.toURI()); }
@Test public void buildTargetPathForFileInAnotherDirectoryTest() { String extension = ".txt"; Path originalPath = createFile("parent/file" + extension); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-file"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName + extension, targetPath.toURI()); }
@Test public void buildTargetPathForResourceTypeFileInAnotherDirectoryTest() { String extension = ".resource.xml.txt"; Path originalPath = createFile("parent/resource-file" + extension); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-resource-file"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName + extension, targetPath.toURI()); }
@Test public void buildTargetPathForResourceTypeFileInAnotherDirectoryTest() { String extension = ".resource.xml.txt"; Path originalPath = createFile("parent/resource-file" + extension); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-resource-file"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName + extension, targetPath.toURI()); }
@Test public void buildTargetPathForFileInAnotherDirectoryTest() { String extension = ".txt"; Path originalPath = createFile("parent/file" + extension); Path targetParentDirectory = createFolder("new-parent"); String targetFileName = "new-file"; Path targetPath = pathNamingService.buildTargetPath(originalPath, targetParentDirectory, targetFileName); assertEquals(targetParentDirectory.toURI() + "/" + targetFileName + extension, targetPath.toURI()); }
Path renamePath(final Path path, final String newName, final String comment) { final org.uberfire.java.nio.file.Path _path = Paths.convert(path); final org.uberfire.java.nio.file.Path _target = Paths.convert(pathNamingService.buildTargetPath(path, newName)); final Path targetPath = Paths.convert(_target); try { ioService.startBatch(_target.getFileSystem()); ioService.move(_path, _target, new CommentedOption(sessionInfo != null ? sessionInfo.getId() : "--", identity.getIdentifier(), null, comment)); //Delegate additional changes required for a rename to applicable Helpers for (RenameHelper helper : helpers) { if (helper.supports(targetPath)) { helper.postProcess(path, targetPath); } } } catch (final Exception e) { throw new RuntimeException(e); } finally { endBatch(); } return Paths.convert(_target); }
Path renamePath(final Path path, final String newName, final String comment) { final org.uberfire.java.nio.file.Path _path = Paths.convert(path); final org.uberfire.java.nio.file.Path _target = Paths.convert(pathNamingService.buildTargetPath(path, newName)); final Path targetPath = Paths.convert(_target); try { ioService.startBatch(_target.getFileSystem()); ioService.move(_path, _target, new CommentedOption(sessionInfo != null ? sessionInfo.getId() : "--", identity.getIdentifier(), null, comment)); //Delegate additional changes required for a rename to applicable Helpers for (RenameHelper helper : helpers) { if (helper.supports(targetPath)) { helper.postProcess(path, targetPath); } } } catch (final Exception e) { throw new RuntimeException(e); } finally { endBatch(); } return Paths.convert(_target); }
void copyPathIfExists(final Path path, final String newName, final String comment) { final org.uberfire.java.nio.file.Path _path = Paths.convert(path); if (Files.exists(_path)) { final org.uberfire.java.nio.file.Path _target = Paths.convert(pathNamingService.buildTargetPath(path, newName)); ioService.copy(_path, _target, new CommentedOption(sessionInfo.getId(), identity.getIdentifier(), null, comment) ); //Delegate additional changes required for a copy to applicable Helpers if (_target != null && helpers != null) { final Path targetPath = Paths.convert(_target); for (CopyHelper helper : helpers) { if (helper.supports(targetPath)) { helper.postProcess(path, targetPath); } } } } }
void copyPathIfExists(final Path path, final String newName, final String comment) { final org.uberfire.java.nio.file.Path _path = Paths.convert(path); if (Files.exists(_path)) { final org.uberfire.java.nio.file.Path _target = Paths.convert(pathNamingService.buildTargetPath(path, newName)); ioService.copy(_path, _target, new CommentedOption(sessionInfo.getId(), identity.getIdentifier(), null, comment) ); //Delegate additional changes required for a copy to applicable Helpers if (_target != null && helpers != null) { final Path targetPath = Paths.convert(_target); for (CopyHelper helper : helpers) { if (helper.supports(targetPath)) { helper.postProcess(path, targetPath); } } } } }
void renamePathIfExists(final Path path, final String newName, final String comment) { final org.uberfire.java.nio.file.Path _path = Paths.convert(path); if (Files.exists(_path)) { final org.uberfire.java.nio.file.Path _target = Paths.convert(pathNamingService.buildTargetPath(path, newName)); ioService.move(_path, _target, new CommentedOption(sessionInfo.getId(), identity.getIdentifier(), null, comment) ); //Delegate additional changes required for a rename to applicable Helpers if (_target != null) { final Path targetPath = Paths.convert(_target); for (RenameHelper helper : helpers) { if (helper.supports(targetPath)) { helper.postProcess(path, targetPath); } } } } }
void renamePathIfExists(final Path path, final String newName, final String comment) { final org.uberfire.java.nio.file.Path _path = Paths.convert(path); if (Files.exists(_path)) { final org.uberfire.java.nio.file.Path _target = Paths.convert(pathNamingService.buildTargetPath(path, newName)); ioService.move(_path, _target, new CommentedOption(sessionInfo.getId(), identity.getIdentifier(), null, comment) ); //Delegate additional changes required for a rename to applicable Helpers if (_target != null) { final Path targetPath = Paths.convert(_target); for (RenameHelper helper : helpers) { if (helper.supports(targetPath)) { helper.postProcess(path, targetPath); } } } } }
private String targetFolderName(final String originalFolderName, final String newFolderName) { final Path path = PathFactory.newPath("file", PATH_PREFIX + originalFolderName + "/file"); fileSystemTestingUtils.getIoService().write(Paths.convert(path), "content"); return pathNamingService.buildTargetPath(Paths.convert(Paths.convert(path).getParent()), newFolderName).getFileName(); }