Merge branch 'github-pr-224'
[arvados.git] / sdk / java-v2 / src / main / java / org / arvados / client / facade / ArvadosFacade.java
index b80b528fe5bbbb30825e34d90406f72b32e68443..8b65cebc59a0d20d0c9ba1b6add34aaf65e2a584 100644 (file)
@@ -28,6 +28,7 @@ import java.io.File;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 public class ArvadosFacade {
 
@@ -120,6 +121,8 @@ public class ArvadosFacade {
      * Created collection has a default name and is uploaded to user's 'Home' project.
      *
      * @see ArvadosFacade#upload(List, String, String)
+     * @param files    list of files to be uploaded within new collection
+     * @return collection object mapped from JSON that is returned from server after successful upload
      */
     public Collection upload(List<File> files) {
         return upload(files, null, null);
@@ -130,6 +133,8 @@ public class ArvadosFacade {
      * Created collection has a default name and is uploaded to user's 'Home' project.
      *
      * @see ArvadosFacade#upload(List, String, String)
+     * @param file file to be uploaded
+     * @return collection object mapped from JSON that is returned from server after successful upload
      */
     public Collection upload(File file) {
         return upload(Collections.singletonList(file), null, null);
@@ -157,6 +162,10 @@ public class ArvadosFacade {
      * Uploads a file to a specified collection.
      *
      * @see ArvadosFacade#uploadToExistingCollection(List, String)
+     * @param file           file to be uploaded to existing collection. Filenames must be unique
+     *                       in comparison with files already existing within collection.
+     * @param collectionUUID UUID of collection to which files should be uploaded
+     * @return collection object mapped from JSON that is returned from server after successful upload
      */
     public Collection uploadToExistingCollection(File file, String collectionUUID) {
         return fileUploader.uploadToExistingCollection(Collections.singletonList(file), collectionUUID);
@@ -193,6 +202,21 @@ public class ArvadosFacade {
         return collectionsApiClient.create(collection);
     }
 
+    /**
+     * Uploads multiple files to an existing collection.
+     *
+     * @param collectionUUID UUID of collection to which the files are to be copied
+     * @param files          map of files to be copied to existing collection.
+     *                       The map consists of a pair in the form of a filename and a filename
+     *                       along with the Portable data hash
+     * @return collection object mapped from JSON that is returned from server after successful copied
+     */
+    public Collection updateWithReplaceFiles(String collectionUUID, Map<String, String> files) {
+        CollectionReplaceFiles replaceFilesRequest = new CollectionReplaceFiles();
+        replaceFilesRequest.getReplaceFiles().putAll(files);
+        return collectionsApiClient.update(collectionUUID, replaceFilesRequest);
+    }
+
     /**
      * Returns current user information based on Api Token provided via configuration
      *
@@ -268,6 +292,18 @@ public class ArvadosFacade {
         return collectionsApiClient.list(listArgument);
     }
 
+    /**
+     * Gets project details by uuid.
+     *
+     * @param projectUuid uuid of project
+     * @return Group object containing information about project
+     */
+    public Group getProjectByUuid(String projectUuid) {
+        Group project = groupsApiClient.get(projectUuid);
+        log.debug("Retrieved " + project.getName() + " with UUID: " + project.getUuid());
+        return project;
+    }
+
     /**
      * Creates new project that will be a subproject of "home" for current user.
      *