Commits

Sebastian Sdorra committed bfe52aa

improve import api

Comments (0)

Files changed (2)

scm-core/src/main/java/sonia/scm/repository/AbstactImportHandler.java

 import java.io.File;
 import java.io.IOException;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
    *
    * @param manager
    *
+   *
+   * @return
    * @throws IOException
    * @throws RepositoryException
    */
   @Override
-  public void importRepositories(RepositoryManager manager)
+  public List<String> importRepositories(RepositoryManager manager)
           throws IOException, RepositoryException
   {
+    List<String> imported = new ArrayList<String>();
+
     if (logger.isTraceEnabled())
     {
       logger.trace("search for repositories to import");
 
       if (repository == null)
       {
-        importRepository(manager, repositoryName);
+        if (importRepository(manager, repositoryName))
+        {
+          imported.add(repositoryName);
+        }
       }
       else if (logger.isDebugEnabled())
       {
         logger.debug("repository {} is allready managed", repositoryName);
       }
     }
+
+    return imported;
   }
 
   /**
    * @param manager
    * @param repositoryName
    *
+   *
+   * @return
    * @throws IOException
    * @throws RepositoryException
    */
-  private void importRepository(RepositoryManager manager,
-                                String repositoryName)
+  private boolean importRepository(RepositoryManager manager,
+                                   String repositoryName)
           throws IOException, RepositoryException
   {
+    boolean result = false;
     Repository repository =
       createRepository(getRepositoryDirectory(repositoryName), repositoryName);
 
       }
 
       manager.importRepository(repository);
+      result = true;
     }
     else if (logger.isWarnEnabled())
     {
       logger.warn("could not create repository object for {}", repositoryName);
     }
+
+    return result;
   }
 
   //~--- get methods ----------------------------------------------------------

scm-core/src/main/java/sonia/scm/repository/ImportHandler.java

 
 import java.io.IOException;
 
+import java.util.List;
+
 /**
  * Searches and import existing repositories.
  *
    *
    * @param manager The global {@link RepositoryManager}
    *
+   *
+   * @return a {@link List} names of imported repositories
    * @throws IOException
    * @throws RepositoryException
    */
-  public void importRepositories(RepositoryManager manager)
+  public List<String> importRepositories(RepositoryManager manager)
           throws IOException, RepositoryException;
 }