cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gonza...@apache.org
Subject [cxf-fediz] 02/03: Add relativePath to Spring RP Plugin
Date Tue, 14 Nov 2017 17:55:32 GMT
This is an automated email from the ASF dual-hosted git repository.

gonzalad pushed a commit to branch 1.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf-fediz.git

commit 47e79c4f7d080b77979f69c011eca56f2080fa87
Author: gonzalad <adr_gonzalez@yahoo.fr>
AuthorDate: Tue Nov 14 18:40:27 2017 +0100

    Add relativePath to Spring RP Plugin
    
    The new relativePath allows to reference files
    in fediz_config.xml from a relative location.
---
 .../cxf/fediz/spring/FederationConfigImpl.java     | 23 ++++++++++++++++++++++
 .../cxf/fediz/spring/FederationConfigImpl.java     | 23 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
index 736d847..45ded7b 100644
--- a/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
+++ b/plugins/spring/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
@@ -38,6 +38,7 @@ public class FederationConfigImpl implements FederationConfig, ServletContextAwa
 
     private Resource configFile;
     private String contextName;
+    private String relativePath;
 
     private ServletContext servletContext;
     private FedizConfigurator configurator = new FedizConfigurator();
@@ -81,9 +82,28 @@ public class FederationConfigImpl implements FederationConfig, ServletContextAwa
             LOG.error("Federation context '" + context + "' not found.");
             throw new IllegalStateException("Federation context '" + context + "' not found.");
         }
+        initializeRelativePath(ctx);
         return ctx;
     }
 
+    private void initializeRelativePath(FedizContext ctx) {
+        if (relativePath != null && relativePath.length() > 0) {
+            ctx.setRelativePath(relativePath);
+        }
+        if (ctx.getRelativePath() == null) {
+            String catalinaBase = System.getProperty("catalina.base");
+            if (catalinaBase != null && catalinaBase.length() > 0) {
+                ctx.setRelativePath(catalinaBase);
+            }
+        }
+        if (ctx.getRelativePath() == null) {
+            String jettyHome = System.getProperty("jetty.home");
+            if (jettyHome != null && jettyHome.length() > 0) {
+                ctx.setRelativePath(jettyHome);
+            }
+        }
+    }
+
     @Override
     public FedizContext getFedizContext() {
         if (servletContext != null) {
@@ -101,4 +121,7 @@ public class FederationConfigImpl implements FederationConfig, ServletContextAwa
         this.servletContext = servletContext;
     }
 
+    public void setRelativePath(String relativePath) {
+        this.relativePath = relativePath;
+    }
 }
diff --git a/plugins/spring3/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
b/plugins/spring3/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
index 736d847..45ded7b 100644
--- a/plugins/spring3/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
+++ b/plugins/spring3/src/main/java/org/apache/cxf/fediz/spring/FederationConfigImpl.java
@@ -38,6 +38,7 @@ public class FederationConfigImpl implements FederationConfig, ServletContextAwa
 
     private Resource configFile;
     private String contextName;
+    private String relativePath;
 
     private ServletContext servletContext;
     private FedizConfigurator configurator = new FedizConfigurator();
@@ -81,9 +82,28 @@ public class FederationConfigImpl implements FederationConfig, ServletContextAwa
             LOG.error("Federation context '" + context + "' not found.");
             throw new IllegalStateException("Federation context '" + context + "' not found.");
         }
+        initializeRelativePath(ctx);
         return ctx;
     }
 
+    private void initializeRelativePath(FedizContext ctx) {
+        if (relativePath != null && relativePath.length() > 0) {
+            ctx.setRelativePath(relativePath);
+        }
+        if (ctx.getRelativePath() == null) {
+            String catalinaBase = System.getProperty("catalina.base");
+            if (catalinaBase != null && catalinaBase.length() > 0) {
+                ctx.setRelativePath(catalinaBase);
+            }
+        }
+        if (ctx.getRelativePath() == null) {
+            String jettyHome = System.getProperty("jetty.home");
+            if (jettyHome != null && jettyHome.length() > 0) {
+                ctx.setRelativePath(jettyHome);
+            }
+        }
+    }
+
     @Override
     public FedizContext getFedizContext() {
         if (servletContext != null) {
@@ -101,4 +121,7 @@ public class FederationConfigImpl implements FederationConfig, ServletContextAwa
         this.servletContext = servletContext;
     }
 
+    public void setRelativePath(String relativePath) {
+        this.relativePath = relativePath;
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <commits@cxf.apache.org>.

Mime
View raw message