@@ -184,6 +184,25 @@ public Deposition createDeposition(final Metadata m) throws UnsupportedOperation
184
184
}
185
185
return null ;
186
186
}
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
+ }
187
206
188
207
/**
189
208
* Created by agupta on 19.11.18. to get the list of files for a particular
@@ -282,20 +301,21 @@ public static void main(String[] args) throws UnsupportedOperationException, IOE
282
301
// new Date(),
283
302
// "API test",
284
303
// "API test",
304
+ // "1.0",
285
305
// Metadata.AccessRight.CLOSED);
286
306
//
287
307
// Deposition deposition = client.createDeposition(firstTry);
288
- // System.out.println(deposition.id);
289
- HttpResponse <JsonNode > jsonResponse = Unirest .post ("https://sandbox.zenodo.org/" +API .Deposit .Files ).routeParam ("id" , Integer .toString (252134 ))
308
+
309
+ HttpResponse <JsonNode > jsonResponse = Unirest .post ("https://sandbox.zenodo.org/" +API .Deposit .Files ).routeParam ("id" , Integer .toString (252680 ))
290
310
.header ("Authorization" , "Bearer " + sandboxToken )
291
311
.header ("accept" , "application/json" )
292
312
.field ("filename" , "archive.zip" )
293
313
.field ("file" , new File ("/home/ankur/SHK/zenodo/archive.zip" ))
294
314
.asJson ();
295
315
System .out .println (jsonResponse .getStatus ());
296
- FileMetadata firstFile = new FileMetadata (new File ("/home/ankur/SHK/zenodo/archive.zip" ));
297
- DepositionFile newFile = client .uploadFile (firstFile ,252119 );
298
- System .out .println ("File Uploaded " + newFile .id + " " + newFile .filename );
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);
299
319
List <Deposition > depositions = client .getDepositions ();
300
320
for (Deposition d : depositions )
301
321
System .out .println (d .title + " " + d .created + " " + d .id );
@@ -304,7 +324,9 @@ public static void main(String[] args) throws UnsupportedOperationException, IOE
304
324
for (DepositionFile f : files ) {
305
325
System .out .println (f .filename + " " + f .id + " " + f .filesize + " " + f .links .download );
306
326
}
307
- // client.deleteDeposition(d.id);
327
+
328
+
329
+
308
330
309
331
}
310
332
}
0 commit comments