Restructure JCR repository wrappers
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / main / java / org / argeo / jcr / ArgeoJcrUtils.java
index ed4ba421f53ac03c420ad6c7b6a3c9e2ac1d8485..90bf0f0f48255bbd3c005486d0d0ece86d1c95a6 100644 (file)
@@ -36,9 +36,21 @@ public class ArgeoJcrUtils implements ArgeoJcrConstants {
         */
        public static Repository getRepositoryByUri(
                        RepositoryFactory repositoryFactory, String uri) {
+               return getRepositoryByUri(repositoryFactory, uri, null);
+       }
+
+       /**
+        * Wraps the call to the repository factory based on parameter
+        * {@link ArgeoJcrConstants#JCR_REPOSITORY_URI} in order to simplify it and
+        * protect against future API changes.
+        */
+       public static Repository getRepositoryByUri(
+                       RepositoryFactory repositoryFactory, String uri, String alias) {
                try {
                        Map<String, String> parameters = new HashMap<String, String>();
                        parameters.put(JCR_REPOSITORY_URI, uri);
+                       if (alias != null)
+                               parameters.put(JCR_REPOSITORY_ALIAS, alias);
                        return repositoryFactory.getRepository(parameters);
                } catch (RepositoryException e) {
                        throw new ArgeoException(