@Override public boolean isSupported(final Path source, final Path copy) { if(vault.contains(source) && vault.contains(copy)) { return proxy.withTarget(target).isSupported(source, copy); } return new DefaultCopyFeature(session).withTarget(target).isSupported(source, copy); }
@Override public boolean isRecursive(final Path source, final Path target) { if(proxy.isSupported(source, target)) { return proxy.isRecursive(source, target); } return copy.isRecursive(source, target); }
@Override public Path copy(final Path source, final Path copy, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(vault.contains(copy)) { // Write header to be reused in writer final Cryptor cryptor = vault.getCryptor(); final FileHeader header = cryptor.fileHeaderCryptor().create(); status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header)); status.setNonces(new RandomNonceGenerator()); } if(vault.contains(source) && vault.contains(copy)) { return vault.decrypt(session, proxy.withTarget(target).copy( vault.contains(source) ? vault.encrypt(session, source) : source, vault.contains(copy) ? vault.encrypt(session, copy) : copy, status, callback)); } else { // Copy files from or into vault requires to pass through encryption features final Path target = new DefaultCopyFeature(session).withTarget(this.target).copy( vault.contains(source) ? vault.encrypt(session, source) : source, vault.contains(copy) ? vault.encrypt(session, copy) : copy, status, callback); if(vault.contains(copy)) { return vault.decrypt(session, target); } return target; } }
@Override public Path transfer(final Session<?> session, final Session<?> destination, final Path source, final Local n, final TransferOptions options, final TransferStatus status, final ConnectionCallback connectionCallback, final PasswordCallback passwordCallback, final ProgressListener listener, final StreamListener streamListener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Transfer file %s with options %s", source, options)); } listener.message(MessageFormat.format(LocaleFactory.localizedString("Copying {0} to {1}", "Status"), source.getName(), mapping.get(source).getName())); if(source.isDirectory()) { if(!status.isExists()) { final Directory feature = destination.getFeature(Directory.class); feature.mkdir(mapping.get(source), null, status); status.setComplete(); } } else { // Transfer final Copy feature = new DefaultCopyFeature(session).withTarget(destination); feature.copy(source, mapping.get(source), status, connectionCallback); this.addTransferred(status.getLength()); } return source; }
public SDSDelegatingCopyFeature(final SDSSession session, final SDSNodeIdProvider nodeid, final SDSCopyFeature proxy) { this.nodeid = nodeid; this.proxy = proxy; this.copy = new DefaultCopyFeature(session); }
@Override public boolean isSupported(final Path source, final Path target) { if(proxy.isSupported(source, target)) { return true; } return copy.isSupported(source, target); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(proxy.isSupported(source, target)) { return proxy.copy(source, target, status, callback); } // Copy between encrypted and unencrypted data room if(nodeid.isEncrypted(target)) { // File key must be set for new upload nodeid.setFileKey(status); } return copy.copy(source, target, status, callback); }
return (T) new DefaultCopyFeature(this);
return (T) new DefaultCopyFeature(this);