You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2011/07/20 09:55:46 UTC
svn commit: r1148641 - in /incubator/stanbol/trunk/cmsadapter: crx-rmi/
jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRepositoryAccess.java
launchers/lite/src/main/bundles/list.xml pom.xml
Author: suat
Date: Wed Jul 20 07:55:45 2011
New Revision: 1148641
URL: http://svn.apache.org/viewvc?rev=1148641&view=rev
Log:
STANBOL 296:
-Removed crx-rmi bundle from CMS Adapter
-Removed related entry from the launcher
-Added usage URLRemoteRepository to JCRRepositoryAccess if it is unable to get session with RMIRemoteRepository
Removed:
incubator/stanbol/trunk/cmsadapter/crx-rmi/
Modified:
incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRepositoryAccess.java
incubator/stanbol/trunk/cmsadapter/launchers/lite/src/main/bundles/list.xml
incubator/stanbol/trunk/cmsadapter/pom.xml
Modified: incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRepositoryAccess.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRepositoryAccess.java?rev=1148641&r1=1148640&r2=1148641&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRepositoryAccess.java (original)
+++ incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRepositoryAccess.java Wed Jul 20 07:55:45 2011
@@ -16,6 +16,7 @@
*/
package org.apache.stanbol.cmsadapter.jcr.repository;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -37,6 +38,7 @@ import javax.jcr.query.QueryResult;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.jackrabbit.rmi.repository.RMIRemoteRepository;
+import org.apache.jackrabbit.rmi.repository.URLRemoteRepository;
import org.apache.stanbol.cmsadapter.servicesapi.model.web.CMSObject;
import org.apache.stanbol.cmsadapter.servicesapi.model.web.ConnectionInfo;
import org.apache.stanbol.cmsadapter.servicesapi.model.web.ObjectTypeDefinition;
@@ -54,17 +56,43 @@ public class JCRRepositoryAccess impleme
private static final Logger log = LoggerFactory.getLogger(JCRRepositoryAccess.class);
+ /**
+ * Tries to get a {@link Session} first through a {@link RMIRemoteRepository}. If the attempt is
+ * unsuccessful it tries {@link URLRemoteRepository}. If the second attempt is also unsuccessful, throws a
+ * {@link RepositoryAccessException}, otherwise returns a {@link Session} object.
+ *
+ * @param connectionInfo
+ * @return {@link Session} if it was able to get one
+ * @throws RepositoryAccessException
+ */
@Override
public Session getSession(ConnectionInfo connectionInfo) throws RepositoryAccessException {
- Repository repository = new RMIRemoteRepository(connectionInfo.getRepositoryURL());
+
Session session = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(JCRRepositoryAccess.class.getClassLoader());
+ session = getSessionByRMI(connectionInfo);
+ if (session == null) {
+ session = getSessionByURL(connectionInfo);
+ }
+ if (session == null) {
+ throw new RepositoryAccessException("Failed to get JCR Session");
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ return session;
+ }
+
+ private Session getSessionByRMI(ConnectionInfo connectionInfo) {
+ Repository repository = new RMIRemoteRepository(connectionInfo.getRepositoryURL());
+ Session session = null;
+ try {
String workspaceName = connectionInfo.getWorkspaceName();
- String username = connectionInfo.getPassword();
+ String username = connectionInfo.getUsername();
String password = connectionInfo.getPassword();
if (workspaceName == null || workspaceName.equals("") || workspaceName.equals("default")) {
@@ -76,13 +104,41 @@ public class JCRRepositoryAccess impleme
}
} catch (LoginException e) {
- throw new RepositoryAccessException("Error at login:", e);
+ log.debug("Failed to get JCR session by RMIRemoteRepository");
+ log.debug("Error message: " + e.getMessage());
} catch (RepositoryException e) {
- throw new RepositoryAccessException("Error at obtaining session", e);
- } finally {
- Thread.currentThread().setContextClassLoader(cl);
+ log.debug("Failed to get JCR session by RMIRemoteRepository");
+ log.debug("Error message: " + e.getMessage());
}
+ return session;
+ }
+ private Session getSessionByURL(ConnectionInfo connectionInfo) {
+ Session session = null;
+ try {
+ Repository repository = new URLRemoteRepository(connectionInfo.getRepositoryURL());
+ String workspaceName = connectionInfo.getWorkspaceName();
+ String username = connectionInfo.getUsername();
+ String password = connectionInfo.getPassword();
+
+ if (workspaceName == null || workspaceName.equals("") || workspaceName.equals("default")) {
+
+ session = repository.login(new SimpleCredentials(username, password.toCharArray()));
+ } else {
+ session = repository.login(new SimpleCredentials(username, password.toCharArray()),
+ workspaceName);
+ }
+
+ } catch (LoginException e) {
+ log.debug("Failed to get JCR session by URLRemoteRepository");
+ log.debug("Error message: " + e.getMessage());
+ } catch (RepositoryException e) {
+ log.debug("Failed to get JCR session by URLRemoteRepository");
+ log.debug("Error message: " + e.getMessage());
+ } catch (MalformedURLException e) {
+ log.debug("Failed to get JCR session by URLRemoteRepository");
+ log.debug("Error message: " + e.getMessage());
+ }
return session;
}
Modified: incubator/stanbol/trunk/cmsadapter/launchers/lite/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/launchers/lite/src/main/bundles/list.xml?rev=1148641&r1=1148640&r2=1148641&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/launchers/lite/src/main/bundles/list.xml (original)
+++ incubator/stanbol/trunk/cmsadapter/launchers/lite/src/main/bundles/list.xml Wed Jul 20 07:55:45 2011
@@ -434,12 +434,6 @@
</artifactId>
<version>0.9.0-incubating-SNAPSHOT</version>
</bundle>
- <bundle>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>crx-rmi
- </artifactId>
- <version>0.9.0-incubating-SNAPSHOT</version>
- </bundle>
<!-- Content hub -->
<bundle>
Modified: incubator/stanbol/trunk/cmsadapter/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/pom.xml?rev=1148641&r1=1148640&r2=1148641&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/pom.xml (original)
+++ incubator/stanbol/trunk/cmsadapter/pom.xml Wed Jul 20 07:55:45 2011
@@ -35,7 +35,6 @@
<module>cmis</module>
<module>web</module>
<module>rest-client</module>
- <module>crx-rmi</module>
<module>launchers/lite</module>
</modules>
</project>