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
) {
40 Map
<String
, String
> parameters
= new HashMap
<String
, String
>();
41 parameters
.put(JCR_REPOSITORY_URI
, uri
);
42 return repositoryFactory
.getRepository(parameters
);
43 } catch (RepositoryException e
) {
44 throw new ArgeoException(
45 "Unexpected exception when trying to retrieve repository with uri "
50 private ArgeoJcrUtils() {