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);
}
}
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);
}
}
Aggregations