Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 3f2e5a6

Browse files
author
synapticloop
committed
fixed javadoc
1 parent 3067fd5 commit 3f2e5a6

18 files changed

Lines changed: 125 additions & 99 deletions

src/main/java/synapticloop/b2/B2ApiClient.java

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package synapticloop.b2;
22

3+
import java.io.File;
4+
import java.io.IOException;
5+
import java.io.InputStream;
6+
import java.util.List;
7+
import java.util.Map;
8+
39
/*
410
* Copyright (c) 2016 Synapticloop.
511
*
@@ -20,17 +26,45 @@
2026
import org.apache.http.HttpEntity;
2127
import org.apache.http.impl.client.CloseableHttpClient;
2228
import org.apache.http.impl.client.HttpClients;
29+
2330
import synapticloop.b2.exception.B2ApiException;
24-
import synapticloop.b2.request.*;
25-
import synapticloop.b2.response.*;
31+
import synapticloop.b2.request.B2AuthorizeAccountRequest;
32+
import synapticloop.b2.request.B2CancelLargeFileRequest;
33+
import synapticloop.b2.request.B2CreateBucketRequest;
34+
import synapticloop.b2.request.B2DeleteBucketRequest;
35+
import synapticloop.b2.request.B2DeleteFileVersionRequest;
36+
import synapticloop.b2.request.B2DownloadFileByIdRequest;
37+
import synapticloop.b2.request.B2DownloadFileByNameRequest;
38+
import synapticloop.b2.request.B2FinishLargeFileRequest;
39+
import synapticloop.b2.request.B2GetFileInfoRequest;
40+
import synapticloop.b2.request.B2GetUploadPartUrlRequest;
41+
import synapticloop.b2.request.B2GetUploadUrlRequest;
42+
import synapticloop.b2.request.B2HeadFileByIdRequest;
43+
import synapticloop.b2.request.B2HideFileRequest;
44+
import synapticloop.b2.request.B2ListBucketsRequest;
45+
import synapticloop.b2.request.B2ListFileNamesRequest;
46+
import synapticloop.b2.request.B2ListFileVersionsRequest;
47+
import synapticloop.b2.request.B2ListPartsRequest;
48+
import synapticloop.b2.request.B2ListUnfinishedLargeFilesRequest;
49+
import synapticloop.b2.request.B2StartLargeFileRequest;
50+
import synapticloop.b2.request.B2UpdateBucketRequest;
51+
import synapticloop.b2.request.B2UploadFileRequest;
52+
import synapticloop.b2.request.B2UploadPartRequest;
53+
import synapticloop.b2.response.B2AuthorizeAccountResponse;
54+
import synapticloop.b2.response.B2BucketResponse;
55+
import synapticloop.b2.response.B2DeleteFileVersionResponse;
56+
import synapticloop.b2.response.B2DownloadFileResponse;
57+
import synapticloop.b2.response.B2FileResponse;
58+
import synapticloop.b2.response.B2FinishLargeFileResponse;
59+
import synapticloop.b2.response.B2GetUploadPartUrlResponse;
60+
import synapticloop.b2.response.B2GetUploadUrlResponse;
61+
import synapticloop.b2.response.B2HideFileResponse;
62+
import synapticloop.b2.response.B2ListFilesResponse;
63+
import synapticloop.b2.response.B2ListPartsResponse;
64+
import synapticloop.b2.response.B2StartLargeFileResponse;
65+
import synapticloop.b2.response.B2UploadPartResponse;
2666
import synapticloop.b2.util.ChecksumHelper;
2767

28-
import java.io.File;
29-
import java.io.IOException;
30-
import java.io.InputStream;
31-
import java.util.List;
32-
import java.util.Map;
33-
3468
/**
3569
* This is a wrapper class for the underlying calls to the request/response
3670
* classes.
@@ -359,8 +393,11 @@ public B2FileResponse uploadFile(String bucketId, String fileName, File file) th
359393
* see <a href="https://www.backblaze.com/b2/docs/content-types.html">https://www.backblaze.com/b2/docs/content-types.html</a>
360394
* for a list of content type mappings.
361395
* @param fileInfo the file info map which will be set as 'X-Bz-Info-' headers
396+
*
362397
* @return The unique identifier for the file
398+
*
363399
* @throws B2ApiException if there was an error uploading the file
400+
* @throws IOException if there was an error with the underlying transport
364401
*/
365402
public B2StartLargeFileResponse startLargeFileUpload(String bucketId, String fileName, String mimeType, Map<String, String> fileInfo) throws B2ApiException, IOException {
366403
return new B2StartLargeFileRequest(client, b2AuthorizeAccountResponse, bucketId, fileName, mimeType, fileInfo).getResponse();
@@ -370,8 +407,11 @@ public B2StartLargeFileResponse startLargeFileUpload(String bucketId, String fil
370407
* Cancel large file upload
371408
*
372409
* @param fileId The ID returned by b2_start_large_file.
410+
*
373411
* @return File response
412+
*
374413
* @throws B2ApiException if there was an error canceling the upload
414+
* @throws IOException if there was an error with the underlying transport
375415
*/
376416
public B2FileResponse cancelLargeFileUpload(String fileId) throws B2ApiException, IOException {
377417
return new B2CancelLargeFileRequest(client, b2AuthorizeAccountResponse, fileId).getResponse();
@@ -381,8 +421,12 @@ public B2FileResponse cancelLargeFileUpload(String fileId) throws B2ApiException
381421
* Finish large file upload. Converts the parts that have been uploaded into a single B2 file.
382422
*
383423
* @param fileId The ID returned by b2_start_large_file.
424+
* @param partSha1Array the array of sha1 sums for each of the parts in order
425+
*
384426
* @return File response
427+
*
385428
* @throws B2ApiException if there was an error finishing the upload
429+
* @throws IOException if there was an error communicating with the API service
386430
*/
387431
public B2FinishLargeFileResponse finishLargeFileUpload(String fileId, String[] partSha1Array) throws B2ApiException, IOException {
388432
return new B2FinishLargeFileRequest(client, b2AuthorizeAccountResponse, fileId, partSha1Array).getResponse();
@@ -395,20 +439,27 @@ public B2FinishLargeFileResponse finishLargeFileUpload(String fileId, String[] p
395439
* @param partNumber A number from 1 to 10000. The parts uploaded for one file must have contiguous numbers, starting with 1.
396440
* @param entity Part content body
397441
* @param sha1Checksum the checksum for the part
442+
*
398443
* @return Upload response
444+
*
399445
* @throws B2ApiException if there was an error uploading the file
446+
* @throws IOException if there was an error communicating with the API service
400447
*/
401448
public B2UploadPartResponse uploadLargeFilePart(String fileId, int partNumber, HttpEntity entity, String sha1Checksum) throws B2ApiException, IOException {
402449
final B2GetUploadPartUrlResponse b2GetUploadUrlResponse = new B2GetUploadPartUrlRequest(client, b2AuthorizeAccountResponse, fileId).getResponse();
403450
return new B2UploadPartRequest(client, b2AuthorizeAccountResponse, b2GetUploadUrlResponse, partNumber, entity, sha1Checksum).getResponse();
404451
}
405452

406453
/**
407-
* Lists information about large file uploads that have been started, but have not been finished or canceled.
454+
* Lists information about large file uploads that have been started, but have not been finished or cancelled.
408455
* Uploads are listed in the order they were started, with the oldest one first
409456
*
410457
* @param bucketId the id of the bucket
458+
* @param startFileId the start fileId to list from
459+
* @param maxFileCount the maximum number of files to return
460+
*
411461
* @return An array of objects, each one describing one unfinished file
462+
*
412463
* @throws B2ApiException if there was an error listing the files
413464
* @throws IOException if there was an error communicating with the API service
414465
*/
@@ -420,7 +471,9 @@ public B2ListFilesResponse listUnfinishedLargeFiles(String bucketId, String star
420471
* @param fileId The ID returned by b2_start_large_file. This is the file whose parts will be listed.
421472
* @param startPartNumber Null to start
422473
* @param maxPartCount The maximum number of parts to return
474+
*
423475
* @return This call returns at most 1000 entries, but it can be called repeatedly to scan through all of the parts for an upload.
476+
*
424477
* @throws B2ApiException if there was an error listing the parts
425478
* @throws IOException if there was an error communicating with the API service
426479
*/

src/main/java/synapticloop/b2/exception/B2ApiException.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ private void parse(String json) {
7171

7272
/**
7373
* @param retry Value in seconds
74+
*
75+
* @return the exception with retry
7476
*/
7577
public B2ApiException withRetry(Integer retry) {
7678
this.retry = retry;
@@ -118,6 +120,7 @@ public int getStatus() {
118120

119121
/**
120122
* Retry-After header value (in seconds)
123+
*
121124
* @return Value in seconds or null if not Retry-After header in response
122125
*/
123126
public Integer getRetry() {

src/main/java/synapticloop/b2/request/B2DeleteFileVersionRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package synapticloop.b2.request;
22

3-
import java.io.IOException;
4-
53
/*
64
* Copyright (c) 2016 Synapticloop.
75
*
@@ -18,6 +16,8 @@
1816
* this source code or binaries.
1917
*/
2018

19+
import java.io.IOException;
20+
2121
import org.apache.http.impl.client.CloseableHttpClient;
2222
import org.apache.http.util.EntityUtils;
2323

src/main/java/synapticloop/b2/request/B2DownloadFileByIdRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package synapticloop.b2.request;
22

3-
import java.io.IOException;
4-
53
/*
64
* Copyright (c) 2016 Synapticloop.
75
*
@@ -18,6 +16,8 @@
1816
* this source code or binaries.
1917
*/
2018

19+
import java.io.IOException;
20+
2121
import org.apache.http.HttpHeaders;
2222
import org.apache.http.impl.client.CloseableHttpClient;
2323

src/main/java/synapticloop/b2/request/B2DownloadFileByNameRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package synapticloop.b2.request;
22

3-
import java.io.IOException;
4-
53
/*
64
* Copyright (c) 2016 Synapticloop.
75
*
@@ -18,6 +16,8 @@
1816
* this source code or binaries.
1917
*/
2018

19+
import java.io.IOException;
20+
2121
import org.apache.http.HttpHeaders;
2222
import org.apache.http.impl.client.CloseableHttpClient;
2323

src/main/java/synapticloop/b2/request/B2GetUploadPartUrlRequest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package synapticloop.b2.request;
22

3+
import java.io.IOException;
4+
35
/*
46
* Copyright (c) 2016 iterate GmbH.
57
*
@@ -18,12 +20,11 @@
1820

1921
import org.apache.http.impl.client.CloseableHttpClient;
2022
import org.apache.http.util.EntityUtils;
23+
2124
import synapticloop.b2.exception.B2ApiException;
2225
import synapticloop.b2.response.B2AuthorizeAccountResponse;
2326
import synapticloop.b2.response.B2GetUploadPartUrlResponse;
2427

25-
import java.io.IOException;
26-
2728
public class B2GetUploadPartUrlRequest extends BaseB2Request {
2829
private static final String B2_GET_UPLOAD_URL = BASE_API_VERSION + "b2_get_upload_part_url";
2930

@@ -47,6 +48,7 @@ public B2GetUploadPartUrlRequest(CloseableHttpClient client, B2AuthorizeAccountR
4748
* @return the upload url response
4849
*
4950
* @throws B2ApiException if something went wrong
51+
* @throws IOException if there was an error communicating with the API service
5052
*/
5153
public B2GetUploadPartUrlResponse getResponse() throws B2ApiException, IOException {
5254
return new B2GetUploadPartUrlResponse(EntityUtils.toString(executePost().getEntity()));

src/main/java/synapticloop/b2/request/B2HeadFileByIdRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package synapticloop.b2.request;
22

3-
import java.io.IOException;
4-
53
/*
64
* Copyright (c) 2016 Synapticloop.
75
*
@@ -18,6 +16,8 @@
1816
* this source code or binaries.
1917
*/
2018

19+
import java.io.IOException;
20+
2121
import org.apache.http.impl.client.CloseableHttpClient;
2222

2323
import synapticloop.b2.exception.B2ApiException;

src/main/java/synapticloop/b2/request/B2HideFileRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package synapticloop.b2.request;
22

3-
import java.io.IOException;
4-
53
/*
64
* Copyright (c) 2016 Synapticloop.
75
*
@@ -18,6 +16,8 @@
1816
* this source code or binaries.
1917
*/
2018

19+
import java.io.IOException;
20+
2121
import org.apache.http.impl.client.CloseableHttpClient;
2222
import org.apache.http.util.EntityUtils;
2323

src/main/java/synapticloop/b2/request/B2StartLargeFileRequest.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package synapticloop.b2.request;
22

3+
import java.io.IOException;
4+
import java.util.Map;
5+
36
/*
47
* Copyright (c) 2016 iterate GmbH.
58
*
@@ -20,15 +23,13 @@
2023
import org.apache.http.util.EntityUtils;
2124
import org.slf4j.Logger;
2225
import org.slf4j.LoggerFactory;
26+
2327
import synapticloop.b2.exception.B2ApiException;
2428
import synapticloop.b2.response.B2AuthorizeAccountResponse;
2529
import synapticloop.b2.response.B2ResponseHeaders;
2630
import synapticloop.b2.response.B2StartLargeFileResponse;
2731
import synapticloop.b2.util.URLEncoder;
2832

29-
import java.io.IOException;
30-
import java.util.Map;
31-
3233
public class B2StartLargeFileRequest extends BaseB2Request {
3334
private static final Logger LOGGER = LoggerFactory.getLogger(B2StartLargeFileRequest.class);
3435

@@ -38,13 +39,16 @@ public class B2StartLargeFileRequest extends BaseB2Request {
3839
/**
3940
* Create a new B2 Start large file request
4041
*
42+
* @param client the HTTP client to use
4143
* @param b2AuthorizeAccountResponse the authorise account response
4244
* @param bucketId the id of the bucket to upload to
4345
* @param fileName the name of the file
4446
* @param mimeType the mimeType (optional, will default to 'b2/x-auto' which
4547
* backblaze will attempt to determine automatically)
4648
* @param fileInfo the file info map which are passed through as key value
4749
* pairs in a jsonObject named 'fileInfo'
50+
*
51+
* @throws B2ApiException if something went wrong
4852
*/
4953
public B2StartLargeFileRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse,
5054
String bucketId, String fileName,
@@ -58,15 +62,23 @@ public B2StartLargeFileRequest(CloseableHttpClient client, B2AuthorizeAccountRes
5862
} else {
5963
this.addProperty(B2RequestProperties.KEY_CONTENT_TYPE, mimeType);
6064
}
65+
6166
// Add 'X-Bz-Info-*' headers
6267
if (null != fileInfo) {
63-
int fileInfoSize = fileInfo.size();
6468
for (final String key : fileInfo.keySet()) {
6569
this.addHeader(B2ResponseHeaders.HEADER_X_BZ_INFO_PREFIX + URLEncoder.encode(key), URLEncoder.encode(fileInfo.get(key)));
6670
}
6771
}
6872
}
6973

74+
/**
75+
* Return the start large file response
76+
*
77+
* @return the start large file response
78+
*
79+
* @throws B2ApiException if something went wrong
80+
* @throws IOException if there was an error communicating with the API service
81+
*/
7082
public B2StartLargeFileResponse getResponse() throws B2ApiException, IOException {
7183
return new B2StartLargeFileResponse(EntityUtils.toString(executePost().getEntity()));
7284
}

src/main/java/synapticloop/b2/request/BaseB2Request.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package synapticloop.b2.request;
22

3-
import java.io.IOException;
4-
import java.net.URI;
5-
import java.net.URISyntaxException;
6-
import java.util.Collections;
7-
import java.util.HashMap;
8-
import java.util.Map;
9-
103
/*
114
* Copyright (c) 2016 Synapticloop.
125
*
@@ -23,6 +16,13 @@
2316
* this source code or binaries.
2417
*/
2518

19+
import java.io.IOException;
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
22+
import java.util.Collections;
23+
import java.util.HashMap;
24+
import java.util.Map;
25+
2626
import org.apache.http.HttpEntity;
2727
import org.apache.http.HttpHeaders;
2828
import org.apache.http.HttpStatus;

0 commit comments

Comments
 (0)