[Yanel-commits] rev 20567 - in public/yanel/trunk/src: contributions/resources/wiki contributions/resources/wiki/config contributions/resources/wiki/src/build contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources core/java/org/wyona/yanel/core realms/yanel-website/content/rtd

josias at wyona.com josias at wyona.com
Tue Dec 5 10:06:35 CET 2006


Author: josias
Date: 2006-12-05 10:06:32 +0100 (Tue, 05 Dec 2006)
New Revision: 20567

Added:
   public/yanel/trunk/src/contributions/resources/wiki/config/
   public/yanel/trunk/src/contributions/resources/wiki/config/wikiParser.config
   public/yanel/trunk/src/contributions/resources/wiki/src/build/spring-wiki-config.xml
Modified:
   public/yanel/trunk/src/contributions/resources/wiki/build.xml
   public/yanel/trunk/src/contributions/resources/wiki/src/build/dependencies.xml
   public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/Yanel.java
   public/yanel/trunk/src/realms/yanel-website/content/rtd/wiki.rtd
Log:
fixed bug #5067: replaced wiki parser factory by spring

Modified: public/yanel/trunk/src/contributions/resources/wiki/build.xml
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/build.xml	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/contributions/resources/wiki/build.xml	2006-12-05 09:06:32 UTC (rev 20567)
@@ -41,6 +41,7 @@
   </target>
 
   <target name="copy-dependencies" depends="init">
+    <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes" file="src/build/spring-wiki-config.xml"/>
     <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/lib">
       <fileset refid="maven2.resource.fileset"/>
       <mapper type="flatten"/>

Added: public/yanel/trunk/src/contributions/resources/wiki/config/wikiParser.config
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/config/wikiParser.config	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/contributions/resources/wiki/config/wikiParser.config	2006-12-05 09:06:32 UTC (rev 20567)
@@ -0,0 +1 @@
+wiki-syntax: jspWikiParser

Modified: public/yanel/trunk/src/contributions/resources/wiki/src/build/dependencies.xml
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/src/build/dependencies.xml	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/build/dependencies.xml	2006-12-05 09:06:32 UTC (rev 20567)
@@ -12,12 +12,7 @@
                   version="2.3" scope="provided" />
       <dependency groupId="log4j" artifactId="log4j"
                   version="1.2.8"/>
-      <dependency groupId="wyona-org-wiki-parser" artifactId="wiki-parser-factory"
-                  version="r19560"/>
 
-      <dependency groupId="wyona-org-wiki-parser" artifactId="jsp-wiki-parser"
-                  version="0.0.1-dev-r20084"/>
-
       <dependency groupId="wyona-org-yanel" artifactId="yanel-core"
                   version="${yanel.source.version}"/>
       <dependency groupId="wyona-org-commons" artifactId="wyona-org-commons"
@@ -34,12 +29,12 @@
       <dependency groupId="com-ecyrd-jspwiki" artifactId="JSPWiki-patched"
                   version="2.4.71"/>
 
+      <dependency groupId="wyona-org-wiki-parser" artifactId="jsp-wiki-parser"
+                  version="0.0.1-dev-r20369"/>
       <dependency groupId="wyona-org-wiki-parser" artifactId="wiki-parser-factory"
                   version="r19560"/>
-      <dependency groupId="wyona-org-wiki-parser" artifactId="jsp-wiki-parser"
-                  version="0.0.1-dev-r20084"/>
-      <dependency groupId="wyona-org-wiki-parser" artifactId="wyona-wiki-parser"
-                  version="r16766"/>
+      <!-- dependency groupId="wyona-org-wiki-parser" artifactId="wyona-wiki-parser"
+                  version="r16766"/ -->
       <dependency groupId="apache-org-lucene" artifactId="lucene-highlighter"
                   version="1.x"/>
       <dependency groupId="apache-org-commons" artifactId="jrcs-diff"

Added: public/yanel/trunk/src/contributions/resources/wiki/src/build/spring-wiki-config.xml
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/src/build/spring-wiki-config.xml	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/build/spring-wiki-config.xml	2006-12-05 09:06:32 UTC (rev 20567)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+  <bean id="jspWikiParser" class="org.wyona.jspwiki.WikiParser"/>
+</beans>


Property changes on: public/yanel/trunk/src/contributions/resources/wiki/src/build/spring-wiki-config.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java	2006-12-05 09:06:32 UTC (rev 20567)
@@ -16,12 +16,11 @@
 
 package org.wyona.yanel.impl.resources;
 
-import java.io.BufferedWriter;
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Writer;
-import java.io.PrintWriter;
 import java.util.HashMap;
 
 import javax.servlet.http.HttpServletRequest;
@@ -36,8 +35,6 @@
 import org.apache.log4j.Category;
 
 import org.wyona.wikiparser.IWikiParser;
-import org.wyona.wikiparser.IWikiParserFactory;
-import org.wyona.wikiparser.WikiParserFactory;
 
 import org.wyona.yanel.core.Path;
 import org.wyona.yanel.core.Resource;
@@ -60,8 +57,8 @@
     private final String XML_MIME_TYPE = "application/xml";
     private DocumentBuilderFactory dbf = null;
     private Repository repository  = null;
-    private String context = null;
     private HashMap properties = new HashMap();
+    private String defaultWikiParserBeanId = "jspWikiParser";
     
     /**
      * 
@@ -92,14 +89,9 @@
             String path2Resource = path.toString();
             path2Resource = path2Resource.substring(0, path2Resource.lastIndexOf("/") + 1);
             
-            //these fields are specified via interface
-            int type = 1;//is the jspWikiParser
+            String wikiParserBeanId = getWikiSyntax(path);
             InputStream inputStream = rp.getRepo().getInputStream(new org.wyona.yarep.core.Path(rp.getPath().toString()));
-            //instantiate wiki parser via factory
-            
-            IWikiParserFactory wikiparserFactory = new WikiParserFactory();
-            IWikiParser wikiParser = wikiparserFactory.create(type, inputStream);
-            //wikiParser does the transformation
+            IWikiParser wikiParser = (IWikiParser) yanel.getBeanFactory().getBean(wikiParserBeanId);
             wikiParser.parse(inputStream);
             
             Transformer transformer = null;
@@ -116,8 +108,6 @@
             LinkChecker linkChecker = new LinkChecker(path2Resource);
             SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
             saxParser.parse(wikiParser.getInputStream(), linkChecker);
-            //transformer.setParameter("yanel.contextPath", context);
-            //transformer.setParameter("yanel.path2Resource", path2Resource);
             java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
             transformer.transform(new StreamSource(linkChecker.getInputStream()), new StreamResult(baos));
             
@@ -134,7 +124,6 @@
      * 
      */
     public View getView(HttpServletRequest request, String viewId) {
-        context = request.getContextPath();
         return getView(new Path(request.getServletPath()), viewId);
     }
 
@@ -184,6 +173,49 @@
     }
     
     /**
+     * this method will get the wikiparser type for this resource 
+     * first it will look up the rti resp. rtd than 
+     * it will look in the config file for this resource if none of the could be found
+     * it will use the default hard coded in this class  
+     */
+    private String getWikiSyntax(Path path) {
+        String wikiParserBeanId = null;
+        try {
+            RepoPath rpRTI = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), yanel.getRepositoryFactory("RTIRepositoryFactory"));
+            java.io.BufferedReader br = new java.io.BufferedReader(rpRTI.getRepo().getReader(new org.wyona.yarep.core.Path(new Path(rpRTI.getPath().toString()).getRTIPath().toString())));
+
+            while ((wikiParserBeanId = br.readLine()) != null) {
+                if (wikiParserBeanId.indexOf("wiki-syntax:") == 0) {
+                    wikiParserBeanId = wikiParserBeanId.substring(13);
+                    log.debug("found wiki-syntax in rti file: " + wikiParserBeanId);
+                    return wikiParserBeanId;
+                }
+            }
+            File configFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile()
+                    .getParentFile()
+                    .getAbsolutePath(), "config" + File.separator + "wikiParser.config");
+            log.debug("configFile : " + configFile.getAbsolutePath());
+            br = new java.io.BufferedReader(new java.io.FileReader(configFile));
+            while ((wikiParserBeanId = br.readLine()) != null) {
+                if (wikiParserBeanId.indexOf("wiki-syntax:") == 0) {
+                    wikiParserBeanId = wikiParserBeanId.substring(13);
+                    log.debug("found wiki-syntax in config file: " + wikiParserBeanId);
+                    return wikiParserBeanId;
+                }
+            }
+        } catch (IOException ioe) {
+            log.error("IOException");
+        } catch (Exception e) {
+            log.error("Exception" + e);//was warn
+        } finally {
+            wikiParserBeanId = defaultWikiParserBeanId;    
+        }
+        log.debug("using fallback default wikiParser!");
+        return wikiParserBeanId;
+    }
+    
+
+    /**
      * @return the empty wiki resource as String 
      */
     private String getEmptyWiki(String title) {

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/Yanel.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/Yanel.java	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/Yanel.java	2006-12-05 09:06:32 UTC (rev 20567)
@@ -31,7 +31,7 @@
     private ResourceTypeRegistry rtr = null;
     private ApplicationContext applicationContext;
     
-    private static final String SPRING_CONFIG_FILE = "spring-yanel-config.xml"; 
+    private static final String SPRING_CONFIG_FILE = "spring-*-config.xml"; 
 
     private static Yanel yanel = null;
 

Modified: public/yanel/trunk/src/realms/yanel-website/content/rtd/wiki.rtd
===================================================================
--- public/yanel/trunk/src/realms/yanel-website/content/rtd/wiki.rtd	2006-12-05 08:34:16 UTC (rev 20566)
+++ public/yanel/trunk/src/realms/yanel-website/content/rtd/wiki.rtd	2006-12-05 09:06:32 UTC (rev 20567)
@@ -1 +1,2 @@
 <{http://www.wyona.org/yanel/resource/1.0}wiki/>
+wiki-syntax: jspWikiParser




More information about the Yanel-commits mailing list