Search in sources :

Example 1 with Children

use of ch.cyberduck.core.eue.io.swagger.client.model.Children in project cyberduck by iterate-ch.

the class EueResourceIdProvider method getFileId.

@Override
public String getFileId(final Path file, final ListProgressListener listener) throws BackgroundException {
    try {
        if (StringUtils.isNotBlank(file.attributes().getFileId())) {
            return file.attributes().getFileId();
        }
        if (cache.contains(new SimplePathPredicate(file))) {
            final String cached = cache.get(new SimplePathPredicate(file));
            if (log.isDebugEnabled()) {
                log.debug(String.format("Return cached fileid %s for file %s", cached, file));
            }
            return cached;
        }
        if (file.isRoot()) {
            return ROOT;
        }
        int offset = 0;
        UiFsModel fsModel;
        final int chunksize = new HostPreferences(session.getHost()).getInteger("eue.listing.chunksize");
        do {
            final String parentResourceId = this.getFileId(file.getParent(), listener);
            switch(parentResourceId) {
                case EueResourceIdProvider.ROOT:
                case EueResourceIdProvider.TRASH:
                    fsModel = new ListResourceAliasApi(new EueApiClient(session)).resourceAliasAliasGet(parentResourceId, null, null, null, null, chunksize, offset, null, null);
                    break;
                default:
                    fsModel = new ListResourceApi(new EueApiClient(session)).resourceResourceIdGet(parentResourceId, null, null, null, null, chunksize, offset, null, null);
            }
            for (Children child : fsModel.getUifs().getChildren()) {
                // Case insensitive
                if (child.getUifs().getName().equalsIgnoreCase(file.getName())) {
                    return getResourceIdFromResourceUri(child.getUifs().getResourceURI());
                }
            }
            offset += chunksize;
        } while (fsModel.getUifs().getChildren().size() == chunksize);
        throw new NotfoundException(file.getAbsolute());
    } catch (ApiException e) {
        throw new EueExceptionMappingService().map("Failure to read attributes of {0}", e, file);
    }
}
Also used : NotfoundException(ch.cyberduck.core.exception.NotfoundException) ListResourceAliasApi(ch.cyberduck.core.eue.io.swagger.client.api.ListResourceAliasApi) SimplePathPredicate(ch.cyberduck.core.SimplePathPredicate) ListResourceApi(ch.cyberduck.core.eue.io.swagger.client.api.ListResourceApi) Children(ch.cyberduck.core.eue.io.swagger.client.model.Children) UiFsModel(ch.cyberduck.core.eue.io.swagger.client.model.UiFsModel) HostPreferences(ch.cyberduck.core.preferences.HostPreferences) ApiException(ch.cyberduck.core.eue.io.swagger.client.ApiException)

Example 2 with Children

use of ch.cyberduck.core.eue.io.swagger.client.model.Children in project cyberduck by iterate-ch.

the class EueListService method list.

protected AttributedList<Path> list(final Path directory, final ListProgressListener listener, final int chunksize) throws BackgroundException {
    final AttributedList<Path> children = new AttributedList<>();
    final EueApiClient client = new EueApiClient(session);
    try {
        int offset = 0;
        UiFsModel fsModel;
        do {
            final String resourceId = fileid.getFileId(directory, listener);
            switch(resourceId) {
                case EueResourceIdProvider.ROOT:
                case EueResourceIdProvider.TRASH:
                    fsModel = new ListResourceAliasApi(client).resourceAliasAliasGet(resourceId, null, null, null, null, chunksize, offset, Collections.singletonList(EueAttributesFinderFeature.OPTION_WIN_32_PROPS), null);
                    break;
                default:
                    fsModel = new ListResourceApi(client).resourceResourceIdGet(resourceId, null, null, null, null, chunksize, offset, Collections.singletonList(EueAttributesFinderFeature.OPTION_WIN_32_PROPS), null);
                    break;
            }
            for (Children child : fsModel.getUifs().getChildren()) {
                final EnumSet<Path.Type> type;
                switch(child.getUifs().getResourceType()) {
                    case "aliascontainer":
                        type = EnumSet.of(Path.Type.directory, Path.Type.placeholder);
                        break;
                    case "container":
                        type = EnumSet.of(Path.Type.directory);
                        break;
                    default:
                        type = EnumSet.of(Path.Type.file);
                }
                children.add(new Path(directory, child.getUifs().getName(), type, attributes.toAttributes(child.getUifs(), child.getUiwin32(), EueShareFeature.findShareForResource(session.userShares(), EueResourceIdProvider.getResourceIdFromResourceUri(child.getUifs().getResourceURI())))));
                listener.chunk(directory, children);
            }
            offset += chunksize;
        } while (fsModel.getUifs().getChildren().size() == chunksize);
        return children;
    } catch (ApiException e) {
        throw new EueExceptionMappingService().map("Listing directory {0} failed", e, directory);
    }
}
Also used : Path(ch.cyberduck.core.Path) ListResourceAliasApi(ch.cyberduck.core.eue.io.swagger.client.api.ListResourceAliasApi) AttributedList(ch.cyberduck.core.AttributedList) ListResourceApi(ch.cyberduck.core.eue.io.swagger.client.api.ListResourceApi) Children(ch.cyberduck.core.eue.io.swagger.client.model.Children) UiFsModel(ch.cyberduck.core.eue.io.swagger.client.model.UiFsModel) ApiException(ch.cyberduck.core.eue.io.swagger.client.ApiException)

Aggregations

ApiException (ch.cyberduck.core.eue.io.swagger.client.ApiException)2 ListResourceAliasApi (ch.cyberduck.core.eue.io.swagger.client.api.ListResourceAliasApi)2 ListResourceApi (ch.cyberduck.core.eue.io.swagger.client.api.ListResourceApi)2 Children (ch.cyberduck.core.eue.io.swagger.client.model.Children)2 UiFsModel (ch.cyberduck.core.eue.io.swagger.client.model.UiFsModel)2 AttributedList (ch.cyberduck.core.AttributedList)1 Path (ch.cyberduck.core.Path)1 SimplePathPredicate (ch.cyberduck.core.SimplePathPredicate)1 NotfoundException (ch.cyberduck.core.exception.NotfoundException)1 HostPreferences (ch.cyberduck.core.preferences.HostPreferences)1