|
25 | 25 | /**
|
26 | 26 | * Created by benhermann on 31.05.17.
|
27 | 27 | */
|
28 |
| -public class ZenodoClient { |
| 28 | +public class ZenodoClient implements ZenodoAPI { |
29 | 29 |
|
30 | 30 | private static final String productionToken = "E7MJ0NJUzEwLKk9FH5f3xcaj2DgSgxZpR83kEn2EneMuR42YkeD7dM3Znn6b";
|
31 | 31 | private static final String sandboxToken = "HWiH1QCdIj81fj0a9vB9knBzfH8puk55NXiEZqkumpILavP2BHgKnjgUEyc9";
|
@@ -185,25 +185,6 @@ public Deposition createDeposition(final Metadata m) throws UnsupportedOperation
|
185 | 185 | return null;
|
186 | 186 | }
|
187 | 187 |
|
188 |
| - public Deposition createDepositionwithVersion(final Metadata m, Integer depositionId) { |
189 |
| - HttpRequestWithBody post = preparePostRequest(baseURL + API.Deposit.NewVersion); |
190 |
| - post.routeParam("id", depositionId.toString()); |
191 |
| - String data = "{}"; |
192 |
| - if (m != null) |
193 |
| - data = objectMapper.writeValue(new Object() { |
194 |
| - public Metadata metadata = m; |
195 |
| - }); |
196 |
| - RequestBodyEntity completePost = post.body(data); |
197 |
| - try { |
198 |
| - HttpResponse<Deposition> response = completePost.asObject(Deposition.class); |
199 |
| - return response.getBody(); |
200 |
| - |
201 |
| - } catch (UnirestException e) { |
202 |
| - e.printStackTrace(); |
203 |
| - } |
204 |
| - return null; |
205 |
| - } |
206 |
| - |
207 | 188 | /**
|
208 | 189 | * Created by agupta on 19.11.18. to get the list of files for a particular
|
209 | 190 | * deposition
|
@@ -293,40 +274,40 @@ private HttpRequestWithBody prepareDeleteRequest(String url) {
|
293 | 274 | "Bearer " + token);
|
294 | 275 | }
|
295 | 276 |
|
296 |
| - public static void main(String[] args) throws UnsupportedOperationException, IOException, UnirestException { |
297 |
| - ZenodoClient client = new ZenodoClient(sandboxURL, sandboxToken); |
298 |
| - System.out.println(client.test()); |
299 |
| - |
300 |
| -// Metadata firstTry = new Metadata(Metadata.UploadType.DATASET, |
301 |
| -// new Date(), |
302 |
| -// "API test", |
303 |
| -// "API test", |
304 |
| -// "1.0", |
305 |
| -// Metadata.AccessRight.CLOSED); |
| 277 | +// public static void main(String[] args) throws UnsupportedOperationException, IOException, UnirestException { |
| 278 | +// ZenodoClient client = new ZenodoClient(sandboxURL, sandboxToken); |
| 279 | +// System.out.println(client.test()); |
| 280 | +// |
| 281 | +//// Metadata firstTry = new Metadata(Metadata.UploadType.DATASET, |
| 282 | +//// new Date(), |
| 283 | +//// "API test", |
| 284 | +//// "API test", |
| 285 | +//// "1.0", |
| 286 | +//// Metadata.AccessRight.CLOSED); |
| 287 | +//// |
| 288 | +//// Deposition deposition = client.createDeposition(firstTry); |
| 289 | +// |
| 290 | +// HttpResponse<JsonNode> jsonResponse = Unirest.post("https://sandbox.zenodo.org/"+API.Deposit.Files).routeParam("id", Integer.toString(252680)) |
| 291 | +// .header("Authorization", "Bearer "+ sandboxToken) |
| 292 | +// .header("accept", "application/json") |
| 293 | +// .field("filename", "archive.zip") |
| 294 | +// .field("file", new File("/home/ankur/SHK/zenodo/archive.zip")) |
| 295 | +// .asJson(); |
| 296 | +// System.out.println(jsonResponse.getStatus()); |
| 297 | +//// FileMetadata firstFile = new FileMetadata(new File("/home/ankur/SHK/zenodo/archive.zip")); |
| 298 | +//// DepositionFile newFile = client.uploadFile(firstFile,252119); |
| 299 | +//// System.out.println("File Uploaded " + newFile.id + " " + newFile.filename); |
| 300 | +// List<Deposition> depositions = client.getDepositions(); |
| 301 | +// for (Deposition d : depositions) |
| 302 | +// System.out.println(d.title + " " + d.created + " " + d.id); |
| 303 | +// |
| 304 | +// List<DepositionFile> files = client.getFiles(252123); |
| 305 | +// for (DepositionFile f : files) { |
| 306 | +// System.out.println(f.filename + " " + f.id + " " + f.filesize + " " + f.links.download); |
| 307 | +// } |
306 | 308 | //
|
307 |
| -// Deposition deposition = client.createDeposition(firstTry); |
308 |
| - |
309 |
| - HttpResponse<JsonNode> jsonResponse = Unirest.post("https://sandbox.zenodo.org/"+API.Deposit.Files).routeParam("id", Integer.toString(252680)) |
310 |
| - .header("Authorization", "Bearer "+ sandboxToken) |
311 |
| - .header("accept", "application/json") |
312 |
| - .field("filename", "archive.zip") |
313 |
| - .field("file", new File("/home/ankur/SHK/zenodo/archive.zip")) |
314 |
| - .asJson(); |
315 |
| - System.out.println(jsonResponse.getStatus()); |
316 |
| -// FileMetadata firstFile = new FileMetadata(new File("/home/ankur/SHK/zenodo/archive.zip")); |
317 |
| -// DepositionFile newFile = client.uploadFile(firstFile,252119); |
318 |
| -// System.out.println("File Uploaded " + newFile.id + " " + newFile.filename); |
319 |
| - List<Deposition> depositions = client.getDepositions(); |
320 |
| - for (Deposition d : depositions) |
321 |
| - System.out.println(d.title + " " + d.created + " " + d.id); |
322 |
| - |
323 |
| - List<DepositionFile> files = client.getFiles(252123); |
324 |
| - for (DepositionFile f : files) { |
325 |
| - System.out.println(f.filename + " " + f.id + " " + f.filesize + " " + f.links.download); |
326 |
| - } |
327 |
| - |
328 |
| - |
329 |
| - |
330 |
| - |
331 |
| - } |
| 309 | +// |
| 310 | +// |
| 311 | +// |
| 312 | +// } |
332 | 313 | }
|
0 commit comments