3 import java
.util
.HashMap
;
6 import javax
.jcr
.Repository
;
7 import javax
.jcr
.RepositoryException
;
8 import javax
.jcr
.RepositoryFactory
;
10 import org
.argeo
.ArgeoException
;
12 /** Utilities related to Argeo model in JCR */
13 public class ArgeoJcrUtils
implements ArgeoJcrConstants
{
15 * Wraps the call to the repository factory based on parameter
16 * {@link ArgeoJcrConstants#JCR_REPOSITORY_ALIAS} in order to simplify it
17 * and protect against future API changes.
19 public static Repository
getRepositoryByAlias(
20 RepositoryFactory repositoryFactory
, String alias
) {
22 Map
<String
, String
> parameters
= new HashMap
<String
, String
>();
23 parameters
.put(JCR_REPOSITORY_ALIAS
, alias
);
24 return repositoryFactory
.getRepository(parameters
);
25 } catch (RepositoryException e
) {
26 throw new ArgeoException(
27 "Unexpected exception when trying to retrieve repository with alias "
33 * Wraps the call to the repository factory based on parameter
34 * {@link ArgeoJcrConstants#JCR_REPOSITORY_URI} in order to simplify it and
35 * protect against future API changes.
37 public static Repository
getRepositoryByUri(
38 RepositoryFactory repositoryFactory
, String uri
) {
39 return getRepositoryByUri(repositoryFactory
, uri
, null);
43 * Wraps the call to the repository factory based on parameter
44 * {@link ArgeoJcrConstants#JCR_REPOSITORY_URI} in order to simplify it and
45 * protect against future API changes.
47 public static Repository
getRepositoryByUri(
48 RepositoryFactory repositoryFactory
, String uri
, String alias
) {
50 Map
<String
, String
> parameters
= new HashMap
<String
, String
>();
51 parameters
.put(JCR_REPOSITORY_URI
, uri
);
53 parameters
.put(JCR_REPOSITORY_ALIAS
, alias
);
54 return repositoryFactory
.getRepository(parameters
);
55 } catch (RepositoryException e
) {
56 throw new ArgeoException(
57 "Unexpected exception when trying to retrieve repository with uri "
62 private ArgeoJcrUtils() {