jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1717620 - in /jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex: JcrRemotingServlet.java ProtectedRemoveManager.java
Date Wed, 02 Dec 2015 12:25:40 GMT
Author: chetanm
Date: Wed Dec  2 12:25:40 2015
New Revision: 1717620

URL: http://svn.apache.org/viewvc?rev=1717620&view=rev
Log:
JCR-3934 - Error occured while loading protected handler config in JcrRemotingServlet

Modified the init logic to fetch the config as inputstream from ServletContext and use that
to initialize ProtectedRemoveManager

Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ProtectedRemoveManager.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java?rev=1717620&r1=1717619&r2=1717620&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JcrRemotingServlet.java
Wed Dec  2 12:25:40 2015
@@ -237,7 +237,7 @@ public abstract class JcrRemotingServlet
 
     /**
      * the 'protectedhandlers-config' init paramter. this parameter contains the XML
-     * configuration file for protected item remove handlers. 
+     * configuration file for protected item remove handlers.
      */
     public static final String INIT_PARAM_PROTECTED_HANDLERS_CONFIG = "protectedhandlers-config";
     
@@ -272,10 +272,22 @@ public abstract class JcrRemotingServlet
         }
 
         String protectedHandlerConfig = getServletConfig().getInitParameter(INIT_PARAM_PROTECTED_HANDLERS_CONFIG);
+        InputStream in = null;
         try {
-            protectedRemoveManager = new ProtectedRemoveManager(protectedHandlerConfig);
+            protectedRemoveManager = new ProtectedRemoveManager();
+            in = getServletContext().getResourceAsStream(protectedHandlerConfig);
+            if (in != null){
+                protectedRemoveManager.load(in);
+            }
         } catch (IOException e) {
-            log.debug("Unable to create ProtectedRemoveManager from " + protectedHandlerConfig
+ ". " + e.getMessage());
+            log.debug("Unable to create ProtectedRemoveManager from " + protectedHandlerConfig
, e);
+        } finally{
+            if (in != null){
+                try {
+                    in.close();
+                } catch (IOException ignore) {
+                }
+            }
         }
 
         // Determine the configured location for temporary files used when

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ProtectedRemoveManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ProtectedRemoveManager.java?rev=1717620&r1=1717619&r2=1717620&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ProtectedRemoveManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ProtectedRemoveManager.java
Wed Dec  2 12:25:40 2015
@@ -36,6 +36,10 @@ class ProtectedRemoveManager {
 
     private List<ProtectedItemRemoveHandler> handlers = new ArrayList<ProtectedItemRemoveHandler>();
 
+    ProtectedRemoveManager(){
+
+    }
+
     ProtectedRemoveManager(String config) throws IOException {
 
     	 if (config == null) {
@@ -46,8 +50,7 @@ class ProtectedRemoveManager {
         	 if (file.exists()) {         
  				try {
                     InputStream fis = new FileInputStream(file);
- 					ProtectedRemoveConfig prConfig = new ProtectedRemoveConfig(this);
- 					prConfig.parse(fis);
+                    load(fis);
  				} catch (FileNotFoundException e) {
  					throw new IOException(e.getMessage(), e);
  				}            
@@ -62,6 +65,11 @@ class ProtectedRemoveManager {
          }    	 
     }
 
+    void load(InputStream fis) throws IOException {
+        ProtectedRemoveConfig prConfig = new ProtectedRemoveConfig(this);
+        prConfig.parse(fis);
+    }
+
     boolean remove(Session session, String itemPath) throws RepositoryException {
         for (ProtectedItemRemoveHandler handler : handlers) {
             if (handler.remove(session, itemPath)) {



Mime
View raw message