@Override public Path move(final Path source, final Path target) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException { return Paths.convert(ioService.move(Paths.convert(source), Paths.convert(target))); }
@Test public void testMove() { tested.move(ROOT_PATH, ROOT_PATH); verify(ioService, times(1)) .move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class)); }
@Test public void testMove() { tested.move(ROOT_PATH, ROOT_PATH); verify(ioService, times(1)) .move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class)); }
@Override public Path move(Path source, Path target, CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { if (!authManager.authorize(toResource(source), getUser())) { throw new SecurityException(); } if (!authManager.authorize(toResource(target), getUser())) { throw new SecurityException(); } return service.move(source, target, options); }
@Override public Path move(Path source, Path target, CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { if (!authManager.authorize(toResource(source), getUser())) { throw new SecurityException(); } if (!authManager.authorize(toResource(target), getUser())) { throw new SecurityException(); } return service.move(source, target, options); }
ioService.move(csvTempPath, csvPath); return;
@Override public List<VersionRecord> revertHistory(final String alias, final Path path, final String _comment, final VersionRecord record) { final org.uberfire.java.nio.file.Path history = ioService.get(URI.create(record.uri())); Space space = spaces.resolveSpace(path.toURI()).orElseThrow(() -> new IllegalArgumentException("Cannot resolve space from path: " + path)); final String comment; if (_comment == null || _comment.trim().isEmpty()) { comment = "revert history from commit {" + record.comment() + "}"; } else { comment = _comment; } ioService.move(history, convert(path), REPLACE_EXISTING, new CommentedOption(sessionInfo.getId(), sessionInfo.getIdentity().getIdentifier(), null, comment)); return new ArrayList<>(repositoryService.getRepositoryInfo(space, alias).getInitialVersionList()); } }
@Override public List<VersionRecord> revertHistory(final String alias, final Path path, final String _comment, final VersionRecord record) { final org.uberfire.java.nio.file.Path history = ioService.get(URI.create(record.uri())); final String comment; if (_comment == null || _comment.trim().isEmpty()) { comment = "revert history from commit {" + record.comment() + "}"; } else { comment = _comment; } ioService.move(history, convert(path), REPLACE_EXISTING, new CommentedOption(sessionInfo.getId(), sessionInfo.getIdentity().getIdentifier(), null, comment)); return new ArrayList<VersionRecord>(repositoryService.getRepositoryInfo(alias).getInitialVersionList()); } }
@Test public void renameWorkaround() { Path dataObjectPath = PathFactory.newPath("TestDataObject", "file:///dataobjects/TestDataObject.java"); DataModelerRenameWorkaroundHelper renameHelper = mock(DataModelerRenameWorkaroundHelper.class); List<DataModelerRenameWorkaroundHelper> renameHelpers = Arrays.asList(renameHelper); when(renameHelperInstance.iterator()).thenReturn(renameHelpers.iterator()); dataModelerService.renameWorkaround(dataObjectPath, "NewName", "New content", "Comment"); verify(ioService, times(1)).startBatch(any(FileSystem.class)); verify(ioService, times(1)).move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class), any(CommentedOption.class)); verify(renameHelper, times(1)).postProcess(any(Path.class), any(Path.class)); verify(ioService, times(1)).endBatch(); }
@Test public void testMigrateDiagramFailed() { when(path.toURI()).thenReturn(FILE_URI); when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true); when(optionFactory.makeCommentedOption(COMMIT_MESSAGE)).thenReturn(commentedOption); MigrationResult migrationResult = editorService.migrateDiagram(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE); verify(ioService, never()).move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class), any(CommentedOption.class)); verify(ioService, never()).startBatch(any(FileSystem.class)); verify(ioService, never()).endBatch(); assertTrue(migrationResult.hasError()); Assert.assertEquals(BPMNDiagramEditorService.ServiceError.MIGRATION_ERROR_PROCESS_ALREADY_EXIST, migrationResult.getError()); } }
@Test public void postProcess() { DataObject dataObject = new DataObjectImpl("test", "TestSource"); dataObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningSolution.class))); generationResult.setDataObject(dataObject); Package _package = mock(Package.class); when(_package.getPackageMainResourcesPath()).thenReturn(PathFactory.newPath("dataObjects", "file:///dataObjects")); when(kieModuleService.resolvePackage(sourcePath)).thenReturn(_package); when(ioService.exists(any())).thenReturn(true); renameHelper.postProcess(sourcePath, destinationPath); verify(ioService, times(1)).move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class)); }
@Test public void testMigrateDiagramSuccessful() { when(path.toURI()).thenReturn(FILE_URI); when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false); when(optionFactory.makeCommentedOption(COMMIT_MESSAGE)).thenReturn(commentedOption); MigrationResult migrationResult = editorService.migrateDiagram(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE); verify(ioService, times(1)).move(sourcePathCaptor.capture(), targetPathCaptor.capture(), eq(commentedOption)); assertEquals(FILE_URI, sourcePathCaptor.getValue().toUri().toString()); assertEquals(EXPECTED_FILE_URI, targetPathCaptor.getValue().toUri().toString()); verify(ioService, times(1)).startBatch(any(FileSystem.class)); verify(ioService, times(1)).endBatch(); assertFalse(migrationResult.hasError()); assertNull(migrationResult.getError()); assertEquals(EXPECTED_FILE_URI, migrationResult.getPath().toURI()); }
timeout(1)).move(eq(targetNioPath), eq(renamedNioPath), any(CommentedOption.class));
ioService.move(_path, _target, serviceHelper.makeCommentedOption("File [" + path.toURI() + "] renamed to [" + targetPath.toURI() + "].")
try { ioService.startBatch(newModulePath.getFileSystem()); ioService.move(projectDirectory, newModulePath, commentedOptionFactory.makeCommentedOption(comment));
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 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); } } } } }
@Override public org.uberfire.backend.vfs.Path rename(final org.uberfire.backend.vfs.Path path, final String newName, final String comment) { final Path newPath = getPluginPath(newName); if (getIoService().exists(newPath)) { throw new FileAlreadyExistsException(newPath.toString()); } try { getIoService().startBatch(fileSystem, commentedOption(comment)); removeRegistry(convert(path).getParent()); getIoService().move(convert(path).getParent(), newPath); } finally { getIoService().endBatch(); } final String oldPluginName = convert(path).getParent().getFileName().toString(); final org.uberfire.backend.vfs.Path result = convert(newPath.resolve(path.getFileName())); final PluginContent pluginContent = getPluginContent(result); String registry = createRegistry(pluginContent); pluginRenamedEvent.fire(new PluginRenamed(oldPluginName, pluginContent, sessionInfo)); return result; }