|
16 | 16 | * this source code or binaries. |
17 | 17 | */ |
18 | 18 |
|
19 | | -import java.io.IOException; |
20 | | - |
21 | 19 | import org.apache.http.impl.client.CloseableHttpClient; |
22 | 20 | import org.apache.http.util.EntityUtils; |
23 | 21 |
|
| 22 | +import java.io.IOException; |
| 23 | + |
24 | 24 | import synapticloop.b2.exception.B2ApiException; |
25 | 25 | import synapticloop.b2.response.B2AuthorizeAccountResponse; |
26 | 26 | import synapticloop.b2.response.B2ListFilesResponse; |
27 | 27 |
|
28 | 28 | /** |
29 | | - * <p>Lists all of the versions of all of the files contained in one bucket, in |
30 | | - * alphabetical order by file name, and by reverse of date/time uploaded for |
| 29 | + * <p>Lists all of the versions of all of the files contained in one bucket, in |
| 30 | + * alphabetical order by file name, and by reverse of date/time uploaded for |
31 | 31 | * versions of files with the same name.</p> |
32 | | - * |
| 32 | + * <p> |
33 | 33 | * This is the interaction class for the <strong>b2_list_file_versions</strong> api calls, this was |
34 | 34 | * generated from the backblaze api documentation - which can be found here: |
35 | | - * |
| 35 | + * <p> |
36 | 36 | * <a href="http://www.backblaze.com/b2/docs/b2_list_file_versions.html">http://www.backblaze.com/b2/docs/b2_list_file_versions.html</a> |
37 | | - * |
| 37 | + * |
38 | 38 | * @author synapticloop |
39 | 39 | */ |
40 | 40 | public class B2ListFileVersionsRequest extends BaseB2Request { |
41 | | - private static final String B2_LIST_FILE_VERSIONS = BASE_API_VERSION + "b2_list_file_versions"; |
| 41 | + private static final String B2_LIST_FILE_VERSIONS = BASE_API_VERSION + "b2_list_file_versions"; |
42 | 42 |
|
43 | | - private static final int DEFAULT_MAX_FILE_COUNT = 100; |
| 43 | + private static final int DEFAULT_MAX_FILE_COUNT = 100; |
44 | 44 |
|
45 | | - /** |
46 | | - * Create a list files request |
47 | | - * |
48 | | - * |
49 | | - * @param client The HTTP client to use |
50 | | - * @param b2AuthorizeAccountResponse the authorize account response |
51 | | - * @param bucketId The id of the bucket to look for file names in. |
52 | | - */ |
53 | | - public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, |
54 | | - String bucketId) { |
55 | | - this(client, b2AuthorizeAccountResponse, bucketId, DEFAULT_MAX_FILE_COUNT); |
56 | | - } |
| 45 | + /** |
| 46 | + * Create a list files request |
| 47 | + * |
| 48 | + * @param client The HTTP client to use |
| 49 | + * @param b2AuthorizeAccountResponse the authorize account response |
| 50 | + * @param bucketId The id of the bucket to look for file names in. |
| 51 | + */ |
| 52 | + public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, |
| 53 | + String bucketId) { |
| 54 | + this(client, b2AuthorizeAccountResponse, bucketId, DEFAULT_MAX_FILE_COUNT); |
| 55 | + } |
57 | 56 |
|
58 | | - /** |
59 | | - * Create a list files request |
60 | | - * |
61 | | - * @param client The HTTP client to use |
62 | | - * @param b2AuthorizeAccountResponse the authorize account response |
63 | | - * @param bucketId The id of the bucket to look for file names in. |
64 | | - * @param maxFileCount The maximum number of files to return from this call. |
65 | | - * The default value is 100, and the maximum allowed is 1000. |
66 | | - */ |
67 | | - public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, |
68 | | - String bucketId, Integer maxFileCount) { |
69 | | - this(client, b2AuthorizeAccountResponse, bucketId, maxFileCount, null, null); |
70 | | - } |
| 57 | + /** |
| 58 | + * Create a list files request |
| 59 | + * |
| 60 | + * @param client The HTTP client to use |
| 61 | + * @param b2AuthorizeAccountResponse the authorize account response |
| 62 | + * @param bucketId The id of the bucket to look for file names in. |
| 63 | + * @param maxFileCount The maximum number of files to return from this call. |
| 64 | + * The default value is 100, and the maximum allowed is 1000. |
| 65 | + */ |
| 66 | + public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, |
| 67 | + String bucketId, Integer maxFileCount) { |
| 68 | + this(client, b2AuthorizeAccountResponse, bucketId, maxFileCount, null, null, null, null); |
| 69 | + } |
71 | 70 |
|
72 | | - /** |
73 | | - * Create a list files request |
74 | | - * |
75 | | - * @param client The HTTP client to use |
76 | | - * @param b2AuthorizeAccountResponse the authorize account response |
77 | | - * @param bucketId The id of the bucket to look for file names in. |
78 | | - * @param maxFileCount The maximum number of files to return from this call. |
79 | | - * The default value is 100, and the maximum allowed is 1000. |
80 | | - * @param startFileName The first file name to return. If there are no files |
81 | | - * with this name, the first version of the file with the first name after |
82 | | - * the given name will be the first in the list. If startFileId is also |
83 | | - * specified, the name-and-id pair is the starting point. If there is a |
84 | | - * file with the given name and ID, it will be first in the list. |
85 | | - * Otherwise, the first file version that comes after the given name and |
86 | | - * ID will be first in the list. |
87 | | - * @param startFileId The first file ID to return. startFileName must also |
88 | | - * be provided if startFileId is specified. (See startFileName.) |
89 | | - */ |
90 | | - public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, |
91 | | - String bucketId, Integer maxFileCount, String startFileName, String startFileId) { |
92 | | - super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_FILE_VERSIONS); |
| 71 | + /** |
| 72 | + * Create a list files request |
| 73 | + * |
| 74 | + * @param client The HTTP client to use |
| 75 | + * @param b2AuthorizeAccountResponse the authorize account response |
| 76 | + * @param bucketId The id of the bucket to look for file names in. |
| 77 | + * @param maxFileCount The maximum number of files to return from this call. |
| 78 | + * The default value is 100, and the maximum allowed is 1000. |
| 79 | + * @param startFileName The first file name to return. If there are no files |
| 80 | + * with this name, the first version of the file with the first name after |
| 81 | + * the given name will be the first in the list. If startFileId is also |
| 82 | + * specified, the name-and-id pair is the starting point. If there is a |
| 83 | + * file with the given name and ID, it will be first in the list. |
| 84 | + * Otherwise, the first file version that comes after the given name and |
| 85 | + * ID will be first in the list. |
| 86 | + * @param startFileId The first file ID to return. startFileName must also |
| 87 | + * @param prefix Files returned will be limited to those with the given prefix. Defaults to the empty string, which matches all files. |
| 88 | + * @param delimiter Files returned will be limited to those within the top folder, or any one subfolder. Defaults to NULL. Folder names will also be returned. The delimiter character will be used to "break" file names into folders. |
| 89 | + */ |
| 90 | + public B2ListFileVersionsRequest(CloseableHttpClient client, B2AuthorizeAccountResponse b2AuthorizeAccountResponse, |
| 91 | + String bucketId, Integer maxFileCount, String startFileName, String startFileId, |
| 92 | + String prefix, String delimiter) { |
| 93 | + super(client, b2AuthorizeAccountResponse, b2AuthorizeAccountResponse.getApiUrl() + B2_LIST_FILE_VERSIONS); |
93 | 94 |
|
94 | | - this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId); |
95 | | - this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount); |
96 | | - if(null != startFileName) { |
97 | | - this.addProperty(B2RequestProperties.KEY_START_FILE_NAME, startFileName); |
98 | | - } |
99 | | - if(null != startFileId) { |
100 | | - this.addProperty(B2RequestProperties.KEY_START_FILE_ID, startFileId); |
101 | | - } |
102 | | - } |
| 95 | + this.addProperty(B2RequestProperties.KEY_BUCKET_ID, bucketId); |
| 96 | + this.addProperty(B2RequestProperties.KEY_MAX_FILE_COUNT, maxFileCount); |
| 97 | + if(null != startFileName) { |
| 98 | + this.addProperty(B2RequestProperties.KEY_START_FILE_NAME, startFileName); |
| 99 | + } |
| 100 | + if(null != startFileId) { |
| 101 | + this.addProperty(B2RequestProperties.KEY_START_FILE_ID, startFileId); |
| 102 | + } |
| 103 | + if(null != prefix) { |
| 104 | + this.addProperty(B2RequestProperties.KEY_PREFIX, prefix); |
| 105 | + } |
| 106 | + if(null != delimiter) { |
| 107 | + this.addProperty(B2RequestProperties.KEY_DELIMITER, delimiter); |
| 108 | + } |
| 109 | + } |
103 | 110 |
|
104 | | - /** |
105 | | - * Return the list file versions response |
106 | | - * |
107 | | - * @return the list file versions response |
108 | | - * |
109 | | - * @throws B2ApiException if something went wrong |
110 | | - * @throws IOException if there was an error communicating with the API service |
111 | | - */ |
112 | | - public B2ListFilesResponse getResponse() throws B2ApiException, IOException { |
113 | | - return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity())); |
114 | | - } |
| 111 | + /** |
| 112 | + * Return the list file versions response |
| 113 | + * |
| 114 | + * @return the list file versions response |
| 115 | + * @throws B2ApiException if something went wrong |
| 116 | + * @throws IOException if there was an error communicating with the API service |
| 117 | + */ |
| 118 | + public B2ListFilesResponse getResponse() throws B2ApiException, IOException { |
| 119 | + return new B2ListFilesResponse(EntityUtils.toString(executePost().getEntity())); |
| 120 | + } |
115 | 121 | } |
0 commit comments