22
33import com .bhyoo .onedrive .client .auth .AbstractAuthHelper ;
44import com .bhyoo .onedrive .client .auth .AuthHelper ;
5+ import com .bhyoo .onedrive .container .AsyncJobMonitor ;
56import com .bhyoo .onedrive .container .items .*;
67import com .bhyoo .onedrive .container .items .pointer .BasePointer ;
78import com .bhyoo .onedrive .container .items .pointer .IdPointer ;
@@ -292,15 +293,15 @@ public RemoteItem[] getShared() throws ErrorResponseException {
292293 * @param srcId item's id that wants to be copied
293294 * @param destId location's id that wants to be placed the copied item
294295 *
295- * @return URL {@code String } that can monitor status of copying process
296+ * @return monitor {@link AsyncJobMonitor } that can monitor status of copying process
296297 *
297298 * @throws ErrorResponseException if error happens while requesting copying operation. such as invalid copying
298299 * request
299300 * @throws InvalidJsonException if fail to parse response of copying request into json. it caused by server side
300301 * not by SDK.
301302 */
302- @ NotNull
303- public String copyItem ( @ NotNull String srcId , @ NotNull String destId ) throws ErrorResponseException {
303+ public @ NotNull AsyncJobMonitor copyItem ( @ NotNull String srcId , @ NotNull String destId )
304+ throws ErrorResponseException {
304305 byte [] content = ("{\" parentReference\" :{\" id\" :\" " + destId + "\" }}" ).getBytes ();
305306 return copyItem (ITEM_ID_PREFIX + srcId + "/action.copy" , content );
306307 }
@@ -312,48 +313,46 @@ public String copyItem(@NotNull String srcId, @NotNull String destId) throws Err
312313 *
313314 * @see Client#copyItem(String, String)
314315 */
315- @ NotNull
316- public String copyItem (@ NotNull String srcId , @ NotNull String destId , @ NotNull String newName )
316+ public @ NotNull AsyncJobMonitor copyItem (@ NotNull String srcId , @ NotNull String destId , @ NotNull String newName )
317317 throws ErrorResponseException {
318318 byte [] content = ("{\" parentReference\" :{\" id\" :\" " + destId + "\" },\" name\" :\" " + newName + "\" }" ).getBytes ();
319319 return copyItem (ITEM_ID_PREFIX + srcId + "/" + COPY , content );
320320 }
321321
322- @ NotNull
323- public String copyItem ( @ NotNull String srcId , @ NotNull PathPointer destPath ) throws ErrorResponseException {
322+ public @ NotNull AsyncJobMonitor copyItem ( @ NotNull String srcId , @ NotNull PathPointer destPath )
323+ throws ErrorResponseException {
324324 byte [] content = ("{\" parentReference\" :" + destPath .toJson () + "}" ).getBytes ();
325325 return copyItem (ITEM_ID_PREFIX + srcId + "/" + COPY , content );
326326 }
327327
328- @ NotNull
329- public String copyItem (@ NotNull String srcId , @ NotNull PathPointer dest , @ NotNull String newName )
328+ public @ NotNull AsyncJobMonitor copyItem (@ NotNull String srcId , @ NotNull PathPointer dest , @ NotNull String newName )
330329 throws ErrorResponseException {
331330 byte [] content = ("{\" parentReference\" :" + dest .toJson () + ",\" name\" :\" " + newName + "\" }" ).getBytes ();
332331 return copyItem (ITEM_ID_PREFIX + srcId + "/" + COPY , content );
333332 }
334333
335- @ NotNull
336- public String copyItem ( @ NotNull PathPointer srcPath , @ NotNull String destId ) throws ErrorResponseException {
334+ public @ NotNull AsyncJobMonitor copyItem ( @ NotNull PathPointer srcPath , @ NotNull String destId )
335+ throws ErrorResponseException {
337336 byte [] content = ("{\" parentReference\" :{\" id\" :\" " + destId + "\" }}" ).getBytes ();
338337 return copyItem (srcPath .resolveOperator (COPY ), content );
339338 }
340339
341- @ NotNull
342- public String copyItem ( @ NotNull PathPointer srcPath , @ NotNull String destId , @ NotNull String newName )
343- throws ErrorResponseException {
340+ public @ NotNull AsyncJobMonitor copyItem ( @ NotNull PathPointer srcPath ,
341+ @ NotNull String destId ,
342+ @ NotNull String newName ) throws ErrorResponseException {
344343 byte [] content = ("{\" parentReference\" :{\" id\" :\" " + destId + "\" },\" name\" :\" " + newName + "\" }" ).getBytes ();
345344 return copyItem (srcPath .resolveOperator (COPY ), content );
346345 }
347346
348- @ NotNull
349- public String copyItem ( @ NotNull BasePointer src , @ NotNull BasePointer dest ) throws ErrorResponseException {
347+ public @ NotNull AsyncJobMonitor copyItem ( @ NotNull BasePointer src , @ NotNull BasePointer dest )
348+ throws ErrorResponseException {
350349 byte [] content = ("{\" parentReference\" :" + dest .toJson () + "}" ).getBytes ();
351350 return copyItem (src .resolveOperator (COPY ), content );
352351 }
353352
354- @ NotNull
355- public String copyItem ( @ NotNull BasePointer src , @ NotNull BasePointer dest , @ NotNull String newName )
356- throws ErrorResponseException {
353+ public @ NotNull AsyncJobMonitor copyItem ( @ NotNull BasePointer src ,
354+ @ NotNull BasePointer dest ,
355+ @ NotNull String newName ) throws ErrorResponseException {
357356 byte [] content = ("{\" parentReference\" :" + dest .toJson () + ",\" name\" :\" " + newName + "\" }" ).getBytes ();
358357 return copyItem (src .resolveOperator (COPY ), content );
359358 }
@@ -366,23 +365,23 @@ public String copyItem(@NotNull BasePointer src, @NotNull BasePointer dest, @Not
366365 * {@code api} is a escaped {@code String}
367366 * @param content HTTP body
368367 *
369- * @return URL {@code String } that can monitor status of copying process
368+ * @return monitor {@link AsyncJobMonitor } that can monitor status of copying process
370369 *
371370 * @throws ErrorResponseException if error happens while requesting copying operation. such as invalid copying
372371 * request
373372 * @throws InvalidJsonException if fail to parse response of copying request into json. it caused by server side
374373 * not by SDK.
375374 */
376- @ NotNull
377- private String copyItem ( @ NotNull String api , @ NotNull byte [] content ) throws ErrorResponseException {
375+ private @ NotNull AsyncJobMonitor copyItem ( @ NotNull String api , @ NotNull byte [] content )
376+ throws ErrorResponseException {
378377 authHelper .checkExpired ();
379378
380379 SyncResponse response = requestTool .postMetadata (api , content );
381380
382381 // if not 202 Accepted raise ErrorResponseException
383382 requestTool .errorHandling (response , HTTP_ACCEPTED );
384383
385- return response .getHeader ().get ("Location" ).get (0 );
384+ return new AsyncJobMonitor ( response .getHeader ().get ("Location" ).get (0 ) );
386385 }
387386
388387
0 commit comments