[
https://issues.apache.org/jira/browse/CMIS-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Joseph Vychtrle updated CMIS-336:
---------------------------------
Summary: Local binding with JcrServiceFactory with jackRabbit
implementation (was: Local binding with JcrServiceFactory)
> Local binding with JcrServiceFactory with jackRabbit implementation
> -------------------------------------------------------------------
>
> Key: CMIS-336
> URL: https://issues.apache.org/jira/browse/CMIS-336
> Project: Chemistry
> Issue Type: Bug
> Components: opencmis-server-jcr
> Affects Versions: OpenCMIS 0.3.0
> Reporter: Joseph Vychtrle
> Priority: Critical
>
> Hey, there is something wrong, because the loop in JcrServiceFactory is
> searching for properties starting with jcr.*, but right after in
> RepositoryFactoryImpl (Jackrabbit impl) it is searched for
> "org.apache.jackrabbit.repository.home" in the same collection of properties
> ... that doesn't make sense. even if org.apache.jackrabbit.repository.home is
> there, it doesn't start with PREFIX_JCR_CONFIG so it is not put into
> jcrConfig collection that goes to RepositoryFactoryImpl.getRepository()
> It would make sense if "Map<String, String> map = null; because there is "if
> (parameters == null)" condition in RepositoryFactoryImpl, but it it is not
> It happens in the init method
> {code:title=JcrServiceFactory.java|borderStyle=solid}
> private TypeManager typeManager;
> private Map<String, String> jcrConfig;
> private String mountPath;
> private JcrRepository jcrRepository;
> @Override
> public void init(Map<String, String> parameters) {
> typeManager = new TypeManager();
> readConfiguration(parameters);
> jcrRepository = new JcrRepository(acquireJcrRepository(jcrConfig),
> mountPath, typeManager);
> }
> {code}
> {code:title=JcrServiceFactory.java|borderStyle=solid}
> private void readConfiguration(Map<String, String> parameters) {
> Map<String, String> map = new HashMap<String, String>();
> List<String> keys = new ArrayList<String>(parameters.keySet());
> Collections.sort(keys);
> /* the loop is searching for properties starting with jcr.* */
>
> for (String key : keys) {
> if (key.startsWith(PREFIX_JCR_CONFIG)) {
> String jcrKey = key.substring(PREFIX_JCR_CONFIG.length());
> String jcrValue =
> replaceSystemProperties(parameters.get(key));
> map.put(jcrKey, jcrValue);
> }
> else if (MOUNT_PATH_CONFIG.equals(key)) {
> mountPath = parameters.get(key);
> log.debug("Configuration: " + MOUNT_PATH_CONFIG + '=' +
> mountPath);
> }
> else {
> log.warn("Configuration: unrecognized key: " + key);
> }
> }
> jcrConfig = Collections.unmodifiableMap(map);
> log.debug("Configuration: jcr=" + jcrConfig);
> }
> {code}
> But here the parameter Map is empty {} and it returns null; because it is
> searching for RepositoryFactoryImpl.REPOSITORY_HOME, which is
> org.apache.jackrabbit.repository.home
> {code:title=RepositoryFactoryImpl.java|borderStyle=solid}
> /* parameters = jcrConfig */
> public Repository getRepository(Map parameters) throws RepositoryException {
> if (parameters == null) {
> return getRepository(null, Collections.emptyMap());
> } else if (parameters.containsKey(REPOSITORY_HOME)) {
> String home = parameters.get(REPOSITORY_HOME).toString();
> return getRepository(home, parameters);
> } else if (parameters.containsKey(JcrUtils.REPOSITORY_URI)) {
> Object parameter = parameters.get(JcrUtils.REPOSITORY_URI);
> try {
> URI uri = new URI(parameter.toString().trim());
> String scheme = uri.getScheme();
> if (("file".equalsIgnoreCase(scheme)
> || "jcr-jackrabbit".equalsIgnoreCase(scheme))
> && uri.getAuthority() == null) {
> File file = new File(uri.getPath());
> if (file.isFile()) {
> return null; // Not a (possibly missing) directory
> } else {
> return getRepository(file.getPath(), parameters);
> }
> } else {
> return null; // not a file: or jcr-jackrabbit: URI
> }
> } catch (URISyntaxException e) {
> return null; // not a valid URI
> }
> } else {
> return null; // unknown or insufficient parameters
> }
> }
> {code}
> {code:xml}
> <dependencies>
> <dependency>
> <groupId>javax.jcr</groupId>
> <artifactId>jcr</artifactId>
> <version>2.0</version>
> <scope>compile</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.jackrabbit</groupId>
> <artifactId>jackrabbit-core</artifactId>
> <version>2.2.4</version>
> <scope>compile</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.jackrabbit</groupId>
> <artifactId>jackrabbit-api</artifactId>
> <version>2.2.4</version>
> <scope>compile</scope>
> </dependency>
> <dependency>
> <groupId>org.slf4j</groupId>
> <artifactId>slf4j-log4j12</artifactId>
> <version>1.5.11</version>
> <scope>compile</scope>
> </dependency>
> <dependency>
> <groupId>org.testng</groupId>
> <artifactId>testng</artifactId>
> <version>5.14</version>
> <type>jar</type>
> <scope>compile</scope>
> </dependency>
>
> <dependency>
> <groupId>org.apache.chemistry.opencmis</groupId>
> <artifactId>chemistry-opencmis-server-jcr</artifactId>
> <version>0.3.0-incubating-SNAPSHOT</version>
> <classifier>classes</classifier>
> </dependency>
> <dependency>
> <groupId>org.apache.chemistry.opencmis</groupId>
>
> <artifactId>chemistry-opencmis-client-bindings</artifactId>
> <version>0.3.0-incubating-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>org.apache.chemistry.opencmis</groupId>
> <artifactId>chemistry-opencmis-client-api</artifactId>
> <version>0.3.0-incubating-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>org.apache.chemistry.opencmis</groupId>
> <artifactId>chemistry-opencmis-client-impl</artifactId>
> <version>0.3.0-incubating-SNAPSHOT</version>
> </dependency>
>
> </dependencies>
> {code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira