Search in sources :

Example 16 with DisabledTransferPrompt

use of ch.cyberduck.core.transfer.DisabledTransferPrompt in project cyberduck by iterate-ch.

the class TransferPromptControllerFactory method create.

public TransferPrompt create(final Controller c, final Transfer transfer, final SessionPool source, final SessionPool destination) {
    final String clazz = PreferencesFactory.get().getProperty(String.format("factory.transferpromptcallback.%s.class", transfer.getType().name()));
    if (null == clazz) {
        throw new FactoryException(String.format("No implementation given for factory %s", this.getClass().getSimpleName()));
    }
    try {
        final Class<TransferPrompt> name = (Class<TransferPrompt>) Class.forName(clazz);
        final Constructor<TransferPrompt> constructor = ConstructorUtils.getMatchingAccessibleConstructor(name, c.getClass(), transfer.getClass(), source.getClass(), destination.getClass());
        if (null == constructor) {
            log.warn(String.format("No matching constructor for parameter %s", c.getClass()));
            // Call default constructor for disabled implementations
            return name.newInstance();
        }
        return constructor.newInstance(c, transfer, source, destination);
    } catch (InstantiationException | InvocationTargetException | ClassNotFoundException | IllegalAccessException e) {
        log.error(String.format("Failure loading callback class %s. %s", clazz, e.getMessage()));
        return new DisabledTransferPrompt();
    }
}
Also used : DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) InvocationTargetException(java.lang.reflect.InvocationTargetException) TransferPrompt(ch.cyberduck.core.transfer.TransferPrompt) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt)

Example 17 with DisabledTransferPrompt

use of ch.cyberduck.core.transfer.DisabledTransferPrompt in project cyberduck by iterate-ch.

the class TransferDictionaryTest method testSerializeComplete.

@Test
public void testSerializeComplete() throws Exception {
    // Test transfer to complete with existing directory
    final Host host = new Host(new TestProtocol());
    final Transfer t = new DownloadTransfer(host, new Path("/t", EnumSet.of(Path.Type.directory)), new NullLocal("t") {

        @Override
        public boolean exists() {
            return true;
        }

        @Override
        public AttributedList<Local> list(final Filter<String> filter) {
            return AttributedList.emptyList();
        }

        @Override
        public boolean isFile() {
            return false;
        }

        @Override
        public boolean isDirectory() {
            return true;
        }
    });
    final NullSession session = new NullTransferSession(host);
    new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()).run(session);
    assertTrue(t.isComplete());
    final Transfer serialized = new TransferDictionary().deserialize(t.serialize(SerializerFactory.get()));
    assertNotSame(t, serialized);
    assertTrue(serialized.isComplete());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) TestProtocol(ch.cyberduck.core.TestProtocol) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) SingleTransferWorker(ch.cyberduck.core.worker.SingleTransferWorker) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) NullTransferSession(ch.cyberduck.core.NullTransferSession) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) AttributedList(ch.cyberduck.core.AttributedList) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) NullLocal(ch.cyberduck.core.NullLocal) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) SyncTransfer(ch.cyberduck.core.transfer.SyncTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Test(org.junit.Test)

Example 18 with DisabledTransferPrompt

use of ch.cyberduck.core.transfer.DisabledTransferPrompt in project cyberduck by iterate-ch.

the class SDSSingleTransferWorkerTest method testDownloadVersioned.

@Test
public void testDownloadVersioned() throws Exception {
    final SDSNodeIdProvider fileid = new SDSNodeIdProvider(session);
    final Path room = new SDSDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile = new DefaultTemporaryFileService().create(test.getName());
    {
        final byte[] content = RandomUtils.nextBytes(39864);
        final TransferStatus writeStatus = new TransferStatus().withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
        final StatusOutputStream<Node> out = new SDSMultipartWriteFeature(session, fileid).write(test, writeStatus, new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
        out.close();
    }
    final byte[] content = RandomUtils.nextBytes(39864);
    final TransferStatus writeStatus = new TransferStatus().exists(true).withLength(content.length).withChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
    final StatusOutputStream<Node> out = new SDSMultipartWriteFeature(session, fileid).write(test, writeStatus, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(writeStatus, writeStatus).withLimit((long) content.length).transfer(new ByteArrayInputStream(content), out);
    out.close();
    final String versionId = test.attributes().getVersionId();
    assertEquals(versionId, new SDSAttributesFinderFeature(session, fileid).find(test).getVersionId());
    assertEquals(versionId, new DefaultAttributesFinderFeature(session).find(test).getVersionId());
    final Transfer t = new DownloadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(test, localFile)), new NullFilter<>());
    assertTrue(new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {
    }.run(session));
    byte[] compare = new byte[content.length];
    assertArrayEquals(content, IOUtils.toByteArray(localFile.getInputStream()));
    test.attributes().setVersionId(versionId);
    assertEquals(versionId, new DefaultAttributesFinderFeature(session).find(test).getVersionId());
    new SDSDeleteFeature(session, fileid).delete(Arrays.asList(test, room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    localFile.delete();
    session.close();
}
Also used : Delete(ch.cyberduck.core.features.Delete) SDSDeleteFeature(ch.cyberduck.core.sds.SDSDeleteFeature) TestProtocol(ch.cyberduck.core.TestProtocol) TransferAction(ch.cyberduck.core.transfer.TransferAction) Node(ch.cyberduck.core.sds.io.swagger.client.model.Node) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) SDSAttributesFinderFeature(ch.cyberduck.core.sds.SDSAttributesFinderFeature) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) DefaultTemporaryFileService(ch.cyberduck.core.local.DefaultTemporaryFileService) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) StatusOutputStream(ch.cyberduck.core.io.StatusOutputStream) Local(ch.cyberduck.core.Local) SDSMultipartWriteFeature(ch.cyberduck.core.sds.SDSMultipartWriteFeature) Host(ch.cyberduck.core.Host) SDSNodeIdProvider(ch.cyberduck.core.sds.SDSNodeIdProvider) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) SDSDirectoryFeature(ch.cyberduck.core.sds.SDSDirectoryFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) SHA256ChecksumCompute(ch.cyberduck.core.io.SHA256ChecksumCompute) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) AbstractSDSTest(ch.cyberduck.core.sds.AbstractSDSTest) IntegrationTest(ch.cyberduck.test.IntegrationTest) Test(org.junit.Test)

Example 19 with DisabledTransferPrompt

use of ch.cyberduck.core.transfer.DisabledTransferPrompt in project cyberduck by iterate-ch.

the class CryptoDropboxSingleTransferWorkerTest method testUpload.

@Test
public void testUpload() throws Exception {
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path dir1 = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    new DefaultLocalDirectoryFeature().mkdir(localDirectory1);
    final byte[] content = RandomUtils.nextBytes(62768);
    final Path file1 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile1 = new Local(localDirectory1, file1.getName());
    final OutputStream out1 = localFile1.getOutputStream(false);
    IOUtils.write(content, out1);
    out1.close();
    final Path file2 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local localFile2 = new Local(localDirectory1, file2.getName());
    final OutputStream out2 = localFile2.getOutputStream(false);
    IOUtils.write(content, out2);
    out2.close();
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Transfer t = new UploadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(dir1, localDirectory1)), new NullFilter<>());
    assertTrue(new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledNotificationService()) {
    }.run(session));
    assertTrue(new CryptoFindFeature(session, new DropboxFindFeature(session), cryptomator).find(dir1));
    assertEquals(content.length, new CryptoAttributesFeature(session, new DefaultAttributesFinderFeature(session), cryptomator).find(file1).getSize());
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        final InputStream in = new CryptoReadFeature(session, new DropboxReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
        assertArrayEquals(content, buffer.toByteArray());
    }
    assertEquals(content.length, new CryptoAttributesFeature(session, new DefaultAttributesFinderFeature(session), cryptomator).find(file2).getSize());
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
        final InputStream in = new CryptoReadFeature(session, new DropboxReadFeature(session), cryptomator).read(file1, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
        new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer);
        assertArrayEquals(content, buffer.toByteArray());
    }
    cryptomator.getFeature(session, Delete.class, new DropboxDeleteFeature(session)).delete(Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    localFile1.delete();
    localFile2.delete();
    localDirectory1.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) TestProtocol(ch.cyberduck.core.TestProtocol) TransferAction(ch.cyberduck.core.transfer.TransferAction) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) SingleTransferWorker(ch.cyberduck.core.worker.SingleTransferWorker) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultLocalDirectoryFeature(ch.cyberduck.core.local.DefaultLocalDirectoryFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) DropboxReadFeature(ch.cyberduck.core.dropbox.DropboxReadFeature) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DropboxDeleteFeature(ch.cyberduck.core.dropbox.DropboxDeleteFeature) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) Local(ch.cyberduck.core.Local) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) Host(ch.cyberduck.core.Host) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) TransferItem(ch.cyberduck.core.transfer.TransferItem) DropboxFindFeature(ch.cyberduck.core.dropbox.DropboxFindFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractDropboxTest(ch.cyberduck.core.AbstractDropboxTest) Test(org.junit.Test)

Example 20 with DisabledTransferPrompt

use of ch.cyberduck.core.transfer.DisabledTransferPrompt in project cyberduck by iterate-ch.

the class SDSSingleTransferWorkerTest method testTransferExistingFolder.

@Test
public void testTransferExistingFolder() throws Exception {
    final SDSNodeIdProvider fileid = new SDSNodeIdProvider(session);
    final Local folder = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    new DefaultLocalDirectoryFeature().mkdir(folder);
    final Path room = new SDSDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final Transfer t = new UploadTransfer(session.getHost(), room, folder);
    final BytecountStreamListener counter = new BytecountStreamListener();
    assertTrue(new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() {

        @Override
        public TransferAction prompt(final TransferItem file) {
            return TransferAction.overwrite;
        }
    }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), counter, new DisabledLoginCallback(), new DisabledNotificationService()) {
    }.run(session));
    assertTrue(t.isComplete());
    assertTrue(new SDSFindFeature(session, fileid).find(room));
    new SDSDeleteFeature(session, fileid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) SDSDeleteFeature(ch.cyberduck.core.sds.SDSDeleteFeature) TransferAction(ch.cyberduck.core.transfer.TransferAction) TransferOptions(ch.cyberduck.core.transfer.TransferOptions) SDSFindFeature(ch.cyberduck.core.sds.SDSFindFeature) DefaultLocalDirectoryFeature(ch.cyberduck.core.local.DefaultLocalDirectoryFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledTransferErrorCallback(ch.cyberduck.core.transfer.DisabledTransferErrorCallback) Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledNotificationService(ch.cyberduck.core.notification.DisabledNotificationService) Local(ch.cyberduck.core.Local) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) SDSNodeIdProvider(ch.cyberduck.core.sds.SDSNodeIdProvider) DisabledTransferPrompt(ch.cyberduck.core.transfer.DisabledTransferPrompt) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) UploadTransfer(ch.cyberduck.core.transfer.UploadTransfer) SDSDirectoryFeature(ch.cyberduck.core.sds.SDSDirectoryFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferSpeedometer(ch.cyberduck.core.transfer.TransferSpeedometer) TransferItem(ch.cyberduck.core.transfer.TransferItem) AbstractSDSTest(ch.cyberduck.core.sds.AbstractSDSTest) IntegrationTest(ch.cyberduck.test.IntegrationTest) Test(org.junit.Test)

Aggregations

DisabledTransferPrompt (ch.cyberduck.core.transfer.DisabledTransferPrompt)42 TransferOptions (ch.cyberduck.core.transfer.TransferOptions)40 TransferSpeedometer (ch.cyberduck.core.transfer.TransferSpeedometer)40 DisabledTransferErrorCallback (ch.cyberduck.core.transfer.DisabledTransferErrorCallback)38 Transfer (ch.cyberduck.core.transfer.Transfer)38 DisabledNotificationService (ch.cyberduck.core.notification.DisabledNotificationService)37 Test (org.junit.Test)37 UploadTransfer (ch.cyberduck.core.transfer.UploadTransfer)36 TransferItem (ch.cyberduck.core.transfer.TransferItem)34 TransferAction (ch.cyberduck.core.transfer.TransferAction)33 DisabledStreamListener (ch.cyberduck.core.io.DisabledStreamListener)31 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)27 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)27 Path (ch.cyberduck.core.Path)26 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)25 Delete (ch.cyberduck.core.features.Delete)25 Local (ch.cyberduck.core.Local)24 IntegrationTest (ch.cyberduck.test.IntegrationTest)23 Host (ch.cyberduck.core.Host)22 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)22