use of ch.cyberduck.core.storegate.io.swagger.client.api.FilesApi in project cyberduck by iterate-ch.
the class StoregateTimestampFeature method setTimestamp.
@Override
public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException {
try {
final FilesApi files = new FilesApi(session.getClient());
files.filesUpdateFile(fileid.getFileId(file, new DisabledListProgressListener()), new UpdateFilePropertiesRequest().modified(new DateTime(status.getTimestamp())));
} catch (ApiException e) {
throw new StoregateExceptionMappingService(fileid).map("Failure to write attributes of {0}", e, file);
}
}
use of ch.cyberduck.core.storegate.io.swagger.client.api.FilesApi in project cyberduck by iterate-ch.
the class StoregateListService method list.
@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
if (directory.isRoot()) {
final AttributedList<Path> list = new AttributedList<>();
for (RootFolder root : session.roots()) {
switch(root.getRootFolderType()) {
// My Files
case 0:
case // Common
1:
final PathAttributes attr = new PathAttributes().withFileId(root.getId());
attr.setModificationDate(root.getModified().getMillis());
attr.setCreationDate(root.getCreated().getMillis());
list.add(new Path(PathNormalizer.normalize(root.getName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attr));
break;
}
}
listener.chunk(directory, list);
return list;
} else {
try {
final AttributedList<Path> children = new AttributedList<>();
final StoregateAttributesFinderFeature attributes = new StoregateAttributesFinderFeature(session, fileid);
int pageIndex = 0;
FileContents files;
do {
files = new FilesApi(this.session.getClient()).filesGet(URIEncoder.encode(fileid.getPrefixedPath(directory)), pageIndex, chunksize, "Name asc", // All
0, true, false, false);
for (File f : files.getFiles()) {
final PathAttributes attrs = attributes.toAttributes(f);
final EnumSet<Path.Type> type = (f.getFlags() & 1) == 1 ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file);
final Path p = new Path(directory, f.getName(), type, attrs);
children.add(p);
listener.chunk(directory, children);
}
pageIndex++;
} while (children.size() < files.getTotalRowCount());
return children;
} catch (ApiException e) {
throw new StoregateExceptionMappingService(fileid).map("Listing directory {0} failed", e, directory);
}
}
}
use of ch.cyberduck.core.storegate.io.swagger.client.api.FilesApi in project cyberduck by iterate-ch.
the class StoregateCopyFeature method copy.
@Override
public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback, final StreamListener listener) throws BackgroundException {
try {
final CopyFileRequest copy = new CopyFileRequest().name(target.getName()).parentID(fileid.getFileId(target.getParent(), new DisabledListProgressListener())).mode(// Overwrite
1);
final File file = new FilesApi(session.getClient()).filesCopy(fileid.getFileId(source, new DisabledListProgressListener()), copy);
listener.sent(status.getLength());
fileid.cache(target, file.getId());
return target.withAttributes(new StoregateAttributesFinderFeature(session, fileid).toAttributes(file));
} catch (ApiException e) {
throw new StoregateExceptionMappingService(fileid).map("Cannot copy {0}", e, source);
}
}
use of ch.cyberduck.core.storegate.io.swagger.client.api.FilesApi in project cyberduck by iterate-ch.
the class StoregateDirectoryFeature method mkdir.
@Override
public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
try {
final FilesApi files = new FilesApi(session.getClient());
final CreateFolderRequest request = new CreateFolderRequest();
request.setName(folder.getName());
request.setParentID(fileid.getFileId(folder.getParent(), new DisabledListProgressListener()));
final File f = files.filesCreateFolder(request);
fileid.cache(folder, f.getId());
return folder.withAttributes(new StoregateAttributesFinderFeature(session, fileid).toAttributes(f));
} catch (ApiException e) {
throw new StoregateExceptionMappingService(fileid).map("Cannot create folder {0}", e, folder);
}
}
use of ch.cyberduck.core.storegate.io.swagger.client.api.FilesApi in project cyberduck by iterate-ch.
the class StoregateIdProvider 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;
}
final String id = new FilesApi(session.getClient()).filesGet_1(URIEncoder.encode(this.getPrefixedPath(file))).getId();
this.cache(file, id);
return id;
} catch (ApiException e) {
throw new StoregateExceptionMappingService(this).map("Failure to read attributes of {0}", e, file);
}
}
Aggregations