@Test public void testMove() throws BackgroundException { final Directory directory = new MantaDirectoryFeature(session); final Touch touch = new MantaTouchFeature(session); final Move move = new MantaMoveFeature(session); final Delete delete = new MantaDeleteFeature(session); final AttributesFinder attributesFinder = new MantaAttributesFinderFeature(session); final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), "", new TransferStatus()); Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); directory.mkdir(targetDirectory, null, null); assertNotNull(attributesFinder.find(targetDirectory)); Path touchedFile = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); touch.touch(touchedFile, new TransferStatus().withMime("x-application/cyberduck")); assertNotNull(attributesFinder.find(touchedFile)); Path rename = new Path(targetDirectory, touchedFile.getName(), EnumSet.of(Path.Type.file)); assertTrue(move.isSupported(touchedFile, rename)); assertEquals(rename, move.move(touchedFile, rename, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback())); assertNotNull(attributesFinder.find(rename)); assertFalse(new MantaFindFeature(session).find(touchedFile)); assertTrue(new MantaFindFeature(session).find(rename)); delete.delete(Collections.singletonList(targetDirectory), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback) throws BackgroundException { try { session.getClient().move(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(MantaException e) { throw new MantaExceptionMappingService().map("Cannot rename {0}", e, file); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Cannot rename {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file); } }
MantaMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback) throws BackgroundException { try { session.getClient().move(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(MantaException e) { throw new MantaExceptionMappingService().map("Cannot rename {0}", e, file); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Cannot rename {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file); } } }
MantaMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback) throws BackgroundException { try { session.getClient().move(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(MantaException e) { throw new MantaExceptionMappingService().map("Cannot rename {0}", e, file); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Cannot rename {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file); } } MantaMoveFeature(MantaSession session); }
MantaMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback) throws BackgroundException { try { session.getClient().move(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(MantaException e) { throw new MantaExceptionMappingService().map("Cannot rename {0}", e, file); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Cannot rename {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file); } } MantaMoveFeature(MantaSession session); @Override Path move(final Path file, final Path renamed, final TransferStatus status,
                     final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback); @Override boolean isRecursive(final Path source, final Path target); @Override boolean isSupported(final Path source, final Path target); }
MantaMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback) throws BackgroundException { try { session.getClient().move(file.getAbsolute(), renamed.getAbsolute()); return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new PathAttributes(file.attributes())); } catch(MantaException e) { throw new MantaExceptionMappingService().map("Cannot rename {0}", e, file); } catch(MantaClientHttpResponseException e) { throw new MantaHttpExceptionMappingService().map("Cannot rename {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file); } } MantaMoveFeature(MantaSession session); @Override Path move(final Path file, final Path renamed, final TransferStatus status,
                     final Delete.Callback deleteCallback, final ConnectionCallback connectionCallback); @Override boolean isRecursive(final Path source, final Path target); @Override boolean isSupported(final Path source, final Path target);  }