Search in sources :

Example 1 with FilesfileIdParent

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);
    }
}
Also used : FoldersFolderIdBody(ch.cyberduck.core.box.io.swagger.client.model.FoldersFolderIdBody) FilesfileIdParent(ch.cyberduck.core.box.io.swagger.client.model.FilesfileIdParent) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Folder(ch.cyberduck.core.box.io.swagger.client.model.Folder) FilesFileIdBody(ch.cyberduck.core.box.io.swagger.client.model.FilesFileIdBody) FoldersApi(ch.cyberduck.core.box.io.swagger.client.api.FoldersApi) FilesApi(ch.cyberduck.core.box.io.swagger.client.api.FilesApi) FoldersfolderIdParent(ch.cyberduck.core.box.io.swagger.client.model.FoldersfolderIdParent) File(ch.cyberduck.core.box.io.swagger.client.model.File) ApiException(ch.cyberduck.core.box.io.swagger.client.ApiException)

Aggregations

DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)1 ApiException (ch.cyberduck.core.box.io.swagger.client.ApiException)1 FilesApi (ch.cyberduck.core.box.io.swagger.client.api.FilesApi)1 FoldersApi (ch.cyberduck.core.box.io.swagger.client.api.FoldersApi)1 File (ch.cyberduck.core.box.io.swagger.client.model.File)1 FilesFileIdBody (ch.cyberduck.core.box.io.swagger.client.model.FilesFileIdBody)1 FilesfileIdParent (ch.cyberduck.core.box.io.swagger.client.model.FilesfileIdParent)1 Folder (ch.cyberduck.core.box.io.swagger.client.model.Folder)1 FoldersFolderIdBody (ch.cyberduck.core.box.io.swagger.client.model.FoldersFolderIdBody)1 FoldersfolderIdParent (ch.cyberduck.core.box.io.swagger.client.model.FoldersfolderIdParent)1