chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r991878 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl: ./ atompub/ webservices/
Date Thu, 02 Sep 2010 10:02:11 GMT
Author: fmui
Date: Thu Sep  2 10:02:10 2010
New Revision: 991878

URL: http://svn.apache.org/viewvc?rev=991878&view=rev
Log:
- made server configuration more flexible

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java?rev=991878&r1=991877&r2=991878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
Thu Sep  2 10:02:10 2010
@@ -41,12 +41,19 @@ public class CmisRepositoryContextListen
 
     private static final Log log = LogFactory.getLog(CmisRepositoryContextListener.class.getName());
 
+    private static final String CONFIG_INIT_PARAM = "org.apache.chemistry.opencmis.REPOSITORY_CONFIG_FILE";
     private static final String CONFIG_FILENAME = "/repository.properties";
     private static final String PROPERTY_CLASS = "class";
 
     public void contextInitialized(ServletContextEvent sce) {
+        // get config file name or use default
+        String configFilename = sce.getServletContext().getInitParameter(CONFIG_INIT_PARAM);
+        if (configFilename == null) {
+            configFilename = CONFIG_FILENAME;
+        }
+
         // create services factory
-        CmisServiceFactory factory = createServiceFactory(CONFIG_FILENAME);
+        CmisServiceFactory factory = createServiceFactory(configFilename);
 
         // set the services factory into the servlet context
         sce.getServletContext().setAttribute(SERVICES_FACTORY, factory);
@@ -54,8 +61,7 @@ public class CmisRepositoryContextListen
 
     public void contextDestroyed(ServletContextEvent sce) {
         // destroy services factory
-        CmisServiceFactory factory = (CmisServiceFactory) sce.getServletContext()
-                .getAttribute(SERVICES_FACTORY);
+        CmisServiceFactory factory = (CmisServiceFactory) sce.getServletContext().getAttribute(SERVICES_FACTORY);
         if (factory != null) {
             factory.destroy();
         }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=991878&r1=991877&r2=991878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
Thu Sep  2 10:02:10 2010
@@ -88,12 +88,11 @@ public class CmisAtomPubServlet extends 
         dispatcher = new Dispatcher();
 
         try {
-            dispatcher
-                    .addResource(AtomPubUtils.RESOURCE_TYPES, METHOD_GET, RepositoryService.class,
"getTypeChildren");
+            dispatcher.addResource(AtomPubUtils.RESOURCE_TYPES, METHOD_GET, RepositoryService.class,
"getTypeChildren");
             dispatcher.addResource(AtomPubUtils.RESOURCE_TYPESDESC, METHOD_GET, RepositoryService.class,
                     "getTypeDescendants");
-            dispatcher.addResource(AtomPubUtils.RESOURCE_TYPE, METHOD_GET, RepositoryService.class,
-                    "getTypeDefinition");
+            dispatcher
+                    .addResource(AtomPubUtils.RESOURCE_TYPE, METHOD_GET, RepositoryService.class,
"getTypeDefinition");
             dispatcher.addResource(AtomPubUtils.RESOURCE_CHILDREN, METHOD_GET, NavigationService.class,
"getChildren");
             dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, METHOD_GET, NavigationService.class,
                     "getDescendants");
@@ -118,8 +117,7 @@ public class CmisAtomPubServlet extends 
                     "createRelationship");
             dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, METHOD_PUT, ObjectService.class,
"updateProperties");
             dispatcher.addResource(AtomPubUtils.RESOURCE_ENTRY, METHOD_DELETE, ObjectService.class,
"deleteObject");
-            dispatcher
-                    .addResource(AtomPubUtils.RESOURCE_DESCENDANTS, METHOD_DELETE, ObjectService.class,
"deleteTree");
+            dispatcher.addResource(AtomPubUtils.RESOURCE_DESCENDANTS, METHOD_DELETE, ObjectService.class,
"deleteTree");
             dispatcher.addResource(AtomPubUtils.RESOURCE_CHECKEDOUT, METHOD_POST, VersioningService.class,
"checkOut");
             dispatcher.addResource(AtomPubUtils.RESOURCE_VERSIONS, METHOD_GET, VersioningService.class,
                     "getAllVersions");
@@ -188,6 +186,10 @@ public class CmisAtomPubServlet extends 
             CmisServiceFactory factory = (CmisServiceFactory) getServletContext().getAttribute(
                     CmisRepositoryContextListener.SERVICES_FACTORY);
 
+            if (factory == null) {
+                throw new CmisRuntimeException("Service factory not available! Configuration
problem?");
+            }
+
             // get the service
             service = factory.getService(context);
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=991878&r1=991877&r2=991878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
Thu Sep  2 10:02:10 2010
@@ -34,6 +34,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
@@ -61,7 +62,15 @@ public abstract class AbstractService {
         ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
                 MessageContext.SERVLET_CONTEXT);
 
-        return (CmisServiceFactory) servletContext.getAttribute(CmisRepositoryContextListener.SERVICES_FACTORY);
+        // get services factory
+        CmisServiceFactory factory = (CmisServiceFactory) servletContext
+                .getAttribute(CmisRepositoryContextListener.SERVICES_FACTORY);
+
+        if (factory == null) {
+            throw new CmisRuntimeException("Service factory not available! Configuration
problem?");
+        }
+
+        return factory;
     }
 
     /**



Mime
View raw message