Skip to content

Commit 379c42e

Browse files
committed
fix old api of Client.copyTo, rename Operator.UPLOAD_CREATE_SESSION
1 parent eff6283 commit 379c42e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/main/java/com/bhyoo/onedrive/client/Client.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,46 +316,46 @@ public String copyItem(@NotNull String srcId, @NotNull String destId) throws Err
316316
public String copyItem(@NotNull String srcId, @NotNull String destId, @NotNull String newName)
317317
throws ErrorResponseException {
318318
byte[] content = ("{\"parentReference\":{\"id\":\"" + destId + "\"},\"name\":\"" + newName + "\"}").getBytes();
319-
return copyItem(ITEM_ID_PREFIX + srcId + "/action.copy", content);
319+
return copyItem(ITEM_ID_PREFIX + srcId + "/" + COPY, content);
320320
}
321321

322322
@NotNull
323323
public String copyItem(@NotNull String srcId, @NotNull PathPointer destPath) throws ErrorResponseException {
324324
byte[] content = ("{\"parentReference\":" + destPath.toJson() + "}").getBytes();
325-
return copyItem(ITEM_ID_PREFIX + srcId + "/action.copy", content);
325+
return copyItem(ITEM_ID_PREFIX + srcId + "/" + COPY, content);
326326
}
327327

328328
@NotNull
329329
public String copyItem(@NotNull String srcId, @NotNull PathPointer dest, @NotNull String newName)
330330
throws ErrorResponseException {
331331
byte[] content = ("{\"parentReference\":" + dest.toJson() + ",\"name\":\"" + newName + "\"}").getBytes();
332-
return copyItem(ITEM_ID_PREFIX + srcId + "/action.copy", content);
332+
return copyItem(ITEM_ID_PREFIX + srcId + "/" + COPY, content);
333333
}
334334

335335
@NotNull
336336
public String copyItem(@NotNull PathPointer srcPath, @NotNull String destId) throws ErrorResponseException {
337337
byte[] content = ("{\"parentReference\":{\"id\":\"" + destId + "\"}}").getBytes();
338-
return copyItem(srcPath.resolveOperator(Operator.ACTION_COPY), content);
338+
return copyItem(srcPath.resolveOperator(COPY), content);
339339
}
340340

341341
@NotNull
342342
public String copyItem(@NotNull PathPointer srcPath, @NotNull String destId, @NotNull String newName)
343343
throws ErrorResponseException {
344344
byte[] content = ("{\"parentReference\":{\"id\":\"" + destId + "\"},\"name\":\"" + newName + "\"}").getBytes();
345-
return copyItem(srcPath.resolveOperator(Operator.ACTION_COPY), content);
345+
return copyItem(srcPath.resolveOperator(COPY), content);
346346
}
347347

348348
@NotNull
349349
public String copyItem(@NotNull BasePointer src, @NotNull BasePointer dest) throws ErrorResponseException {
350350
byte[] content = ("{\"parentReference\":" + dest.toJson() + "}").getBytes();
351-
return copyItem(src.resolveOperator(Operator.ACTION_COPY), content);
351+
return copyItem(src.resolveOperator(COPY), content);
352352
}
353353

354354
@NotNull
355355
public String copyItem(@NotNull BasePointer src, @NotNull BasePointer dest, @NotNull String newName)
356356
throws ErrorResponseException {
357357
byte[] content = ("{\"parentReference\":" + dest.toJson() + ",\"name\":\"" + newName + "\"}").getBytes();
358-
return copyItem(src.resolveOperator(Operator.ACTION_COPY), content);
358+
return copyItem(src.resolveOperator(COPY), content);
359359
}
360360

361361

@@ -567,18 +567,18 @@ private DownloadFuture _downloadAsync(@NotNull String api, @NotNull Path downloa
567567
public UploadFuture uploadFile(@NotNull String parentId, @NotNull Path filePath) {
568568
String fileName = filePath.getFileName().toString();
569569
return requestTool.upload(
570-
ITEM_ID_PREFIX + parentId + ":/" + fileName + ":/" + UPLOAD_CREATE_SESSION, filePath);
570+
ITEM_ID_PREFIX + parentId + ":/" + fileName + ":/" + CREATE_UPLOAD_SESSION, filePath);
571571
}
572572

573573
public UploadFuture uploadFile(@NotNull IdPointer parentId, @NotNull Path filePath) {
574574
String fileName = filePath.getFileName().toString();
575575
return requestTool.upload(
576-
parentId.toASCIIApi() + ":/" + fileName + ":/" + UPLOAD_CREATE_SESSION, filePath);
576+
parentId.toASCIIApi() + ":/" + fileName + ":/" + CREATE_UPLOAD_SESSION, filePath);
577577
}
578578

579579
public UploadFuture uploadFile(@NotNull PathPointer parentPath, @NotNull Path filePath) {
580580
String fileName = filePath.getFileName().toString();
581-
return requestTool.upload(parentPath.resolve(fileName).resolveOperator(UPLOAD_CREATE_SESSION), filePath);
581+
return requestTool.upload(parentPath.resolve(fileName).resolveOperator(CREATE_UPLOAD_SESSION), filePath);
582582
}
583583

584584

src/main/java/com/bhyoo/onedrive/container/items/pointer/Operator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* @author <a href="mailto:[email protected]" target="_top">isac322</a>
55
*/
66
public enum Operator {
7-
ACTION_COPY("copy"),
7+
COPY("copy"),
88
ACTION_CREATE_LINK("action.createLink"),
99
CHILDREN("children"),
1010
CONTENT("content"),
1111
SEARCH("search"),
1212
DELTA("delta"),
1313
THUMBNAILS("thumbnails"),
14-
UPLOAD_CREATE_SESSION("createUploadSession");
14+
CREATE_UPLOAD_SESSION("createUploadSession");
1515

1616
private final String operator;
1717

0 commit comments

Comments
 (0)