marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [3/5] git commit: safer code for the templates initialization
Date Mon, 11 Nov 2013 10:14:21 GMT
safer code for the templates initialization


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/31ec52d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/31ec52d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/31ec52d7

Branch: refs/heads/develop
Commit: 31ec52d7aa22a58004bb0a8ea3da7c95c738ba20
Parents: b2c7945
Author: Sergio Fernández <wikier@apache.org>
Authored: Sun May 19 22:33:18 2013 +0200
Committer: Sergio Fernández <wikier@apache.org>
Committed: Mon Nov 11 10:11:46 2013 +0100

----------------------------------------------------------------------
 .../core/api/templating/TemplatingService.java  |  6 +++++
 .../templating/TemplatingServiceImpl.java       | 28 +++++++++++---------
 2 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/31ec52d7/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/TemplatingService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/TemplatingService.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/TemplatingService.java
index 7a17f87..0ee9a8b 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/TemplatingService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/templating/TemplatingService.java
@@ -38,6 +38,12 @@ public interface TemplatingService {
 
     public final static String DEFAULT_REST_FILE = "overview-index.html";
     
+    final static String ADMIN_TPL = "admin.ftl";
+    
+    final static String ERROR_404_TPL = "404.ftl";
+    
+    final static String RDF_HTML_TPL = "rdfhtml.ftl";
+    
     static final String DEFAULT_PROJECT = "marmotta";
     
     static final String DEFAULT_STYLE = "blue";

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/31ec52d7/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java
index 1d78adf..e19b770 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/templating/TemplatingServiceImpl.java
@@ -80,21 +80,25 @@ public class TemplatingServiceImpl implements TemplatingService {
         common.put("LOGO", configurationService.getStringConfiguration("kiwi.pages.project."+project+".logo",
project+".png"));
         common.put("FOOTER", configurationService.getStringConfiguration("kiwi.pages.project."+project+".footer",
"(footer not properly configured for project "+project+")"));
 
-        templateDir =new File(configurationService.getHome()+TemplatingService.PATH);
+        templateDir = new File(configurationService.getHome(), TemplatingService.PATH);
 
         if (!templateDir.exists()) templateDir.mkdirs();
 
-        for (String fName: new String[] {"admin.ftl", "404.ftl", "rdfhtml.ftl"}) {
-        final File dT = new File(templateDir, fName);
-        if (!dT.exists()) {
-            try {
-                log.info("Default Template not found, using fallback...");
-                final InputStream str = this.getClass().getResourceAsStream(TemplatingService.PATH+fName);
-                FileUtils.copyInputStreamToFile(str, dT);
-            } catch (IOException e) {
-                log.error("Could not create fallback template, templating might react weird!",
e);
-            }
-        }                                      }
+        for (String fName: new String[] { 
+        		TemplatingService.ADMIN_TPL, 
+        		TemplatingService.ERROR_404_TPL, 
+        		TemplatingService.RDF_HTML_TPL }) {
+	        final File dT = new File(templateDir, fName);
+	        if (!dT.exists()) {
+	            try {
+	                log.warn("Default template not found at {}, copying fallback...", dT.getAbsolutePath());
+	                final InputStream str = this.getClass().getResourceAsStream(TemplatingService.PATH
+ fName);
+	                FileUtils.copyInputStreamToFile(str, dT);
+	            } catch (IOException e) {
+	                log.error("Could not create fallback template, templating might react weird!",
e);
+	            }
+	        }                                     
+        }
 	}
 	
     /**


Mime
View raw message