use of ch.cyberduck.core.box.io.swagger.client.model.FilesfileIdParent in project cyberduck by iterate-ch.
the class BoxMoveFeature method move.
@Override
public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback delete, final ConnectionCallback callback) throws BackgroundException {
try {
if (status.isExists()) {
new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(renamed), callback, delete);
}
final String id = fileid.getFileId(file, new DisabledListProgressListener());
if (file.isDirectory()) {
final Folder result = new FoldersApi(new BoxApiClient(session.getClient())).putFoldersId(id, new FoldersFolderIdBody().name(renamed.getName()).parent(new FoldersfolderIdParent().id(fileid.getFileId(renamed.getParent(), new DisabledListProgressListener()))), null, BoxAttributesFinderFeature.DEFAULT_FIELDS);
fileid.cache(file, null);
fileid.cache(renamed, id);
return renamed.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
}
final File result = new FilesApi(new BoxApiClient(session.getClient())).putFilesId(id, new FilesFileIdBody().name(renamed.getName()).parent(new FilesfileIdParent().id(fileid.getFileId(renamed.getParent(), new DisabledListProgressListener()))), null, BoxAttributesFinderFeature.DEFAULT_FIELDS);
fileid.cache(file, null);
fileid.cache(renamed, id);
return renamed.withAttributes(new BoxAttributesFinderFeature(session, fileid).toAttributes(result));
} catch (ApiException e) {
throw new BoxExceptionMappingService(fileid).map("Cannot rename {0}", e, file);
}
}
Aggregations