Search in sources :

Example 6 with ListService

use of ch.cyberduck.core.ListService in project cyberduck by iterate-ch.

the class SessionListWorker method run.

@Override
public AttributedList<Path> run(final Session<?> session) throws BackgroundException {
    try {
        if (this.isCached()) {
            final AttributedList<Path> list = cache.get(directory);
            listener.chunk(directory, list);
            return list;
        }
        final ListService service = session.getFeature(ListService.class);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Run with feature %s", service));
        }
        return service.list(directory, listener);
    } catch (ListCanceledException e) {
        return e.getChunk();
    }
}
Also used : Path(ch.cyberduck.core.Path) ListService(ch.cyberduck.core.ListService) ListCanceledException(ch.cyberduck.core.exception.ListCanceledException)

Example 7 with ListService

use of ch.cyberduck.core.ListService in project cyberduck by iterate-ch.

the class AbstractSharepointListService method list.

@Override
public final AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
    if ((!session.isSingleSite() && directory.isRoot()) || (session.isSingleSite() && session.isHome(directory))) {
        return getRoot(directory, listener);
    }
    final AttributedList<Path> result = processList(directory, listener);
    if (result != AttributedList.<Path>emptyList()) {
        return result;
    }
    final GraphSession.ContainerItem container = session.getContainer(directory);
    if (container.getCollectionPath().map(p -> container.isContainerInCollection() && SITES_CONTAINER.equals(p.getName())).orElse(false)) {
        return addSiteItems(directory, listener);
    }
    final Optional<ListService> collectionListService = container.getCollectionPath().map(p -> {
        if (SITES_CONTAINER.equals(p.getName())) {
            return new SitesListService(session, fileid);
        } else if (DRIVES_CONTAINER.equals(p.getName())) {
            return new SiteDrivesListService(session, fileid);
        }
        return null;
    });
    if (collectionListService.isPresent() && (!container.isDefined() || container.isCollectionInContainer())) {
        return collectionListService.get().list(directory, listener);
    }
    return new GraphItemListService(session, fileid).list(directory, listener);
}
Also used : Path(ch.cyberduck.core.Path) AttributedList(ch.cyberduck.core.AttributedList) ListProgressListener(ch.cyberduck.core.ListProgressListener) SitesListService(ch.cyberduck.core.onedrive.features.sharepoint.SitesListService) Path(ch.cyberduck.core.Path) SiteDrivesListService(ch.cyberduck.core.onedrive.features.sharepoint.SiteDrivesListService) Optional(java.util.Optional) ListService(ch.cyberduck.core.ListService) BackgroundException(ch.cyberduck.core.exception.BackgroundException) GraphFileIdProvider(ch.cyberduck.core.onedrive.features.GraphFileIdProvider) SharepointListService(ch.cyberduck.core.onedrive.SharepointListService) SitesListService(ch.cyberduck.core.onedrive.features.sharepoint.SitesListService) SiteDrivesListService(ch.cyberduck.core.onedrive.features.sharepoint.SiteDrivesListService) ListService(ch.cyberduck.core.ListService) SharepointListService(ch.cyberduck.core.onedrive.SharepointListService) SitesListService(ch.cyberduck.core.onedrive.features.sharepoint.SitesListService) SiteDrivesListService(ch.cyberduck.core.onedrive.features.sharepoint.SiteDrivesListService)

Example 8 with ListService

use of ch.cyberduck.core.ListService in project cyberduck by iterate-ch.

the class SharepointListServiceTest method testListDefaultDriveOverwrite.

@Test
public void testListDefaultDriveOverwrite() throws Exception {
    final ListService list = new SharepointListService(session, fileid);
    final AttributedList<Path> drives = list.list(new Path(SharepointListService.DEFAULT_NAME, "Drives", EnumSet.of(Path.Type.directory)), new DisabledListProgressListener());
    final Path drive = drives.get(0);
    new PathAttributesHomeFeature(session, () -> drive, new GraphAttributesFinderFeature(session, fileid), new RootPathContainerService()).find();
    list.list(drive, new DisabledListProgressListener());
}
Also used : ListService(ch.cyberduck.core.ListService) Path(ch.cyberduck.core.Path) PathAttributesHomeFeature(ch.cyberduck.core.shared.PathAttributesHomeFeature) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) RootPathContainerService(ch.cyberduck.core.shared.RootPathContainerService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 9 with ListService

use of ch.cyberduck.core.ListService in project cyberduck by iterate-ch.

the class FTPDefaultListServiceTest method testListDefault.

@Test
public void testListDefault() throws Exception {
    final ListService list = new FTPDefaultListService(session, new CompositeFileEntryParser(Collections.singletonList(new UnixFTPEntryParser())), FTPListService.Command.list);
    final Path directory = new FTPWorkdirService(session).find();
    final Path file = new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new FTPTouchFeature(session).touch(file, new TransferStatus());
    assertTrue(list.list(directory, new DisabledListProgressListener()).contains(file));
    new FTPDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) UnixFTPEntryParser(org.apache.commons.net.ftp.parser.UnixFTPEntryParser) CompositeFileEntryParser(ch.cyberduck.core.ftp.parser.CompositeFileEntryParser) ListService(ch.cyberduck.core.ListService) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) FTPWorkdirService(ch.cyberduck.core.ftp.FTPWorkdirService) FTPTouchFeature(ch.cyberduck.core.ftp.FTPTouchFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 10 with ListService

use of ch.cyberduck.core.ListService in project cyberduck by iterate-ch.

the class FTPListServiceTest method testList.

@Test
public void testList() throws Exception {
    final ListService service = new FTPListService(session, null, TimeZone.getDefault());
    final Path directory = new FTPWorkdirService(session).find();
    final Path file = new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new FTPTouchFeature(session).touch(file, new TransferStatus());
    final Permission permission = new Permission(Permission.Action.read_write, Permission.Action.read_write, Permission.Action.read_write);
    final AttributedList<Path> list = service.list(directory, new DisabledListProgressListener() {

        @Override
        public void chunk(final Path parent, AttributedList<Path> list) {
            assertFalse(list.isEmpty());
        }
    });
    assertTrue(list.contains(file));
    new FTPDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) ListService(ch.cyberduck.core.ListService) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Permission(ch.cyberduck.core.Permission) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) FTPWorkdirService(ch.cyberduck.core.ftp.FTPWorkdirService) FTPTouchFeature(ch.cyberduck.core.ftp.FTPTouchFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Aggregations

ListService (ch.cyberduck.core.ListService)12 Path (ch.cyberduck.core.Path)12 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)7 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)7 IntegrationTest (ch.cyberduck.test.IntegrationTest)7 Test (org.junit.Test)7 AbstractFTPTest (ch.cyberduck.core.ftp.AbstractFTPTest)6 FTPWorkdirService (ch.cyberduck.core.ftp.FTPWorkdirService)6 Delete (ch.cyberduck.core.features.Delete)5 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)4 FTPTouchFeature (ch.cyberduck.core.ftp.FTPTouchFeature)4 AttributedList (ch.cyberduck.core.AttributedList)3 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)3 BackgroundException (ch.cyberduck.core.exception.BackgroundException)3 ConnectionCanceledException (ch.cyberduck.core.exception.ConnectionCanceledException)3 FTPDeleteFeature (ch.cyberduck.core.ftp.FTPDeleteFeature)3 CompositeFileEntryParser (ch.cyberduck.core.ftp.parser.CompositeFileEntryParser)3 LinkedHashMap (java.util.LinkedHashMap)3 ListProgressListener (ch.cyberduck.core.ListProgressListener)2 Directory (ch.cyberduck.core.features.Directory)2