Skip to content

Commit afd8798

Browse files
authored
Merge pull request #17633 from iterate-ch/bugfix/GH-17620
Handle parser failures as interoperability error.
2 parents af5d856 + d27feca commit afd8798

18 files changed

+146
-21
lines changed

onedrive/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</parent>
2424
<artifactId>onedrive</artifactId>
2525
<properties>
26-
<onedrive-java-client-version>3.2.4</onedrive-java-client-version>
26+
<onedrive-java-client-version>3.3.0</onedrive-java-client-version>
2727
</properties>
2828
<dependencies>
2929
<dependency>

onedrive/src/main/java/ch/cyberduck/core/onedrive/AbstractSharepointSession.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.commons.lang3.StringUtils;
3232
import org.nuxeo.onedrive.client.ODataQuery;
3333
import org.nuxeo.onedrive.client.OneDriveAPIException;
34+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3435
import org.nuxeo.onedrive.client.types.Drive;
3536
import org.nuxeo.onedrive.client.types.DriveItem;
3637
import org.nuxeo.onedrive.client.types.GroupItem;
@@ -115,11 +116,14 @@ public DriveItem getItem(final Path file, final boolean resolveLastItem) throws
115116
return (DriveItem) remoteMetadata.getItem();
116117
}
117118
}
118-
catch(OneDriveAPIException oneDriveAPIException) {
119-
throw new GraphExceptionMappingService(fileid).map(oneDriveAPIException);
119+
catch(OneDriveAPIException e) {
120+
throw new GraphExceptionMappingService(fileid).map(e);
120121
}
121-
catch(IOException ioException) {
122-
throw new DefaultIOExceptionMappingService().map(ioException);
122+
catch(IOException e) {
123+
throw new DefaultIOExceptionMappingService().map(e);
124+
}
125+
catch(OneDriveRuntimeException e) {
126+
throw new GraphExceptionMappingService(fileid).map(e.getCause());
123127
}
124128
}
125129
return ownItem;

onedrive/src/main/java/ch/cyberduck/core/onedrive/GraphSession.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.nuxeo.onedrive.client.ODataQuery;
5252
import org.nuxeo.onedrive.client.OneDriveAPI;
5353
import org.nuxeo.onedrive.client.OneDriveAPIException;
54+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
5455
import org.nuxeo.onedrive.client.RequestExecutor;
5556
import org.nuxeo.onedrive.client.RequestHeader;
5657
import org.nuxeo.onedrive.client.Users;
@@ -229,6 +230,9 @@ public void login(final LoginCallback prompt, final CancelCallback cancel) throw
229230
catch(IOException e) {
230231
throw new DefaultIOExceptionMappingService().map(e);
231232
}
233+
catch(OneDriveRuntimeException e) {
234+
throw new GraphExceptionMappingService(fileid).map(e.getCause());
235+
}
232236
}
233237

234238
@Override
@@ -295,7 +299,7 @@ public <T> T _getFeature(final Class<T> type) {
295299
return (T) new GraphUrlProvider();
296300
}
297301
if(type == Share.class) {
298-
return (T) new GraphSharedLinkFeature(this);
302+
return (T) new GraphSharedLinkFeature(this, fileid);
299303
}
300304
if(type == Versioning.class) {
301305
return (T) new GraphVersioningFeature(this, fileid);

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphAttributesFinderFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import org.apache.commons.lang3.StringUtils;
3232
import org.nuxeo.onedrive.client.OneDriveAPIException;
33+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3334
import org.nuxeo.onedrive.client.types.DriveItem;
3435
import org.nuxeo.onedrive.client.types.DriveItemVersion;
3536
import org.nuxeo.onedrive.client.types.File;
@@ -85,6 +86,9 @@ private DriveItem.Metadata toMetadata(final Path file, final DriveItem item) thr
8586
catch(IOException e) {
8687
throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file);
8788
}
89+
catch(OneDriveRuntimeException e) {
90+
throw new GraphExceptionMappingService(fileid).map("Failure to read attributes of {0}", e.getCause(), file);
91+
}
8892
}
8993

9094
@Override

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphCopyFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.nuxeo.onedrive.client.CopyOperation;
3636
import org.nuxeo.onedrive.client.Files;
3737
import org.nuxeo.onedrive.client.OneDriveAPIException;
38+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3839
import org.nuxeo.onedrive.client.types.DriveItem;
3940

4041
import java.io.IOException;
@@ -88,6 +89,9 @@ public Path copy(final Path file, final Path target, final TransferStatus status
8889
catch(IOException e) {
8990
throw new DefaultIOExceptionMappingService().map("Cannot copy {0}", e, file);
9091
}
92+
catch(OneDriveRuntimeException e) {
93+
throw new GraphExceptionMappingService(fileid).map("Cannot copy {0}", e.getCause(), file);
94+
}
9195
}
9296

9397
@Override

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphDeleteFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import org.nuxeo.onedrive.client.Files;
3030
import org.nuxeo.onedrive.client.OneDriveAPIException;
31+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3132
import org.nuxeo.onedrive.client.types.DriveItem;
3233

3334
import java.io.IOException;
@@ -60,6 +61,9 @@ public void delete(final Map<Path, TransferStatus> files, final PasswordCallback
6061
catch(IOException e) {
6162
throw new DefaultIOExceptionMappingService().map("Cannot delete {0}", e, file);
6263
}
64+
catch(OneDriveRuntimeException e) {
65+
throw new GraphExceptionMappingService(fileid).map("Cannot delete {0}", e.getCause(), file);
66+
}
6367
}
6468
}
6569

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphDirectoryFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import org.nuxeo.onedrive.client.Files;
3131
import org.nuxeo.onedrive.client.OneDriveAPIException;
32+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3233
import org.nuxeo.onedrive.client.types.DriveItem;
3334

3435
import java.io.IOException;
@@ -61,6 +62,9 @@ public Path mkdir(final Write<DriveItem.Metadata> writer, final Path directory,
6162
catch(IOException e) {
6263
throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, directory);
6364
}
65+
catch(OneDriveRuntimeException e) {
66+
throw new GraphExceptionMappingService(fileid).map("Cannot create folder {0}", e.getCause(), directory);
67+
}
6468
}
6569

6670
@Override

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphLockFeature.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.http.HttpStatus;
2929
import org.nuxeo.onedrive.client.Files;
3030
import org.nuxeo.onedrive.client.OneDriveAPIException;
31+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3132
import org.nuxeo.onedrive.client.types.DriveItem;
3233

3334
import java.io.IOException;
@@ -53,10 +54,13 @@ public String lock(final Path file) throws BackgroundException {
5354
if(e.getResponseCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
5455
throw new LockedException(e.getMessage(), e);
5556
}
56-
throw new GraphExceptionMappingService(fileid).map("Failure to checkout file {0}", e, file);
57+
throw new GraphExceptionMappingService(fileid).map("Failure to write attributes of {0}", e, file);
5758
}
5859
catch(IOException e) {
59-
throw new DefaultIOExceptionMappingService().map(e, file);
60+
throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, file);
61+
}
62+
catch(OneDriveRuntimeException e) {
63+
throw new GraphExceptionMappingService(fileid).map("Failure to write attributes of {0}", e.getCause(), file);
6064
}
6165
}
6266

@@ -69,10 +73,13 @@ public void unlock(final Path file, final String token) throws BackgroundExcepti
6973
new AlphanumericRandomStringService().random()));
7074
}
7175
catch(OneDriveAPIException e) {
72-
throw new GraphExceptionMappingService(fileid).map("Failure to check in file {0}", e, file);
76+
throw new GraphExceptionMappingService(fileid).map("Failure to write attributes of {0}", e, file);
7377
}
7478
catch(IOException e) {
75-
throw new DefaultIOExceptionMappingService().map(e, file);
79+
throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, file);
80+
}
81+
catch(OneDriveRuntimeException e) {
82+
throw new GraphExceptionMappingService(fileid).map("Failure to write attributes of {0}", e.getCause(), file);
7683
}
7784
}
7885
}

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphMoveFeature.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.logging.log4j.Logger;
3636
import org.nuxeo.onedrive.client.Files;
3737
import org.nuxeo.onedrive.client.OneDriveAPIException;
38+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
3839
import org.nuxeo.onedrive.client.PatchOperation;
3940
import org.nuxeo.onedrive.client.types.DriveItem;
4041
import org.nuxeo.onedrive.client.types.FileSystemInfo;
@@ -96,6 +97,9 @@ public Path move(final Path file, final Path renamed, final TransferStatus statu
9697
catch(IOException e) {
9798
throw new DefaultIOExceptionMappingService().map("Cannot rename {0}", e, file);
9899
}
100+
catch(OneDriveRuntimeException e) {
101+
throw new GraphExceptionMappingService(fileid).map("Cannot rename {0}", e.getCause(), file);
102+
}
99103
}
100104

101105
@Override

onedrive/src/main/java/ch/cyberduck/core/onedrive/features/GraphQuotaFeature.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import org.nuxeo.onedrive.client.ODataQuery;
2727
import org.nuxeo.onedrive.client.OneDriveAPIException;
28+
import org.nuxeo.onedrive.client.OneDriveRuntimeException;
2829
import org.nuxeo.onedrive.client.types.Drive;
2930
import org.nuxeo.onedrive.client.types.DriveItem;
3031

@@ -62,15 +63,17 @@ public Space get() throws BackgroundException {
6263
catch(IOException e) {
6364
throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, home);
6465
}
65-
final org.nuxeo.onedrive.client.types.Quota quota = metadata.getQuota();
66-
if(quota != null) {
67-
Long used = quota.getUsed();
66+
catch(OneDriveRuntimeException e) {
67+
throw new GraphExceptionMappingService(fileid).map("Failure to read attributes of {0}", e.getCause(), home);
68+
}
69+
if(metadata.getQuota() != null) {
70+
Long used = metadata.getQuota().getUsed();
6871
if(used != null) {
69-
Long remaining = quota.getRemaining();
72+
Long remaining = metadata.getQuota().getRemaining();
7073
if(remaining != null && (used != 0 || remaining != 0)) {
7174
return new Space(used, remaining);
7275
}
73-
Long total = quota.getTotal();
76+
Long total = metadata.getQuota().getTotal();
7477
if(total != null && (used != 0 || total != 0)) {
7578
return new Space(used, total - used);
7679
}

0 commit comments

Comments
 (0)