forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r495450 - in /forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr: output.xmap src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
Date Fri, 12 Jan 2007 00:15:10 GMT
Author: thorsten
Date: Thu Jan 11 16:15:09 2007
New Revision: 495450

URL: http://svn.apache.org/viewvc?view=rev&rev=495450
Log:
Using new input stream support for the the generator to sli down the class and add cli support.
Still there are some brokenlinks that I need to figure out to add full cli support against
a running solr server.

Modified:
    forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/output.xmap
    forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java

Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/output.xmap
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/output.xmap?view=diff&rev=495450&r1=495449&r2=495450
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/output.xmap (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/output.xmap Thu
Jan 11 16:15:09 2007
@@ -31,10 +31,8 @@
       <!-- Update generator will send the command to the solr server and
         generate the server response -->
       <map:match pattern="**.do">
-        <map:generate type="solrUpdate">
+        <map:generate type="solrUpdate" src="cocoon:/{1}">
           <map:parameter name="destinationUrl" value="{properties:solr.update.url}"/>
-          <map:parameter name="srcUrlBase" value="http://{request:serverName}:{request:serverPort}/{request:contextPath}/"/>
-          <map:parameter name="srcId" value="{1}"/>
         </map:generate>
         <map:serialize type="xml"/>
       </map:match>

Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java?view=diff&rev=495450&r1=495449&r2=495450
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
(original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.solr/src/java/org/apache/forrest/solr/client/SolrUpdateGenerator.java
Thu Jan 11 16:15:09 2007
@@ -1,27 +1,21 @@
 package org.apache.forrest.solr.client;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.environment.Context;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.excalibur.source.Source;
 import org.apache.excalibur.xml.sax.SAXParser;
 import org.apache.forrest.http.client.PostFile;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
 public class SolrUpdateGenerator extends ServiceableGenerator {
-    private static final String SRC_ID = "srcId";
-
-    private static final String SRC_URL_BASE = "srcUrlBase";
-
-    private static final String SERVER = "http://localhost:8888/";
-
+    
     private static final String DESTINATION_URL = "destinationUrl";
 
     private static final String SOLR_UPDATE_URL = "http://localhost:8983/solr/update";
@@ -30,29 +24,32 @@
 
     private SAXParser parser;
 
+    private String destination;
+
     public void setup(SourceResolver resolver, Map objectModel, String src,
             Parameters par) throws ProcessingException, SAXException, IOException {
         super.setup(resolver, objectModel, src, par);
-            try {
-                init(par);
-            } catch (ServiceException e) {
-                throw  new ProcessingException (e);
-            }
-    }
-
-    private void init(Parameters par) throws MalformedURLException, IOException,
-             SAXException, ServiceException {
-        String destination = par.getParameter(DESTINATION_URL, SOLR_UPDATE_URL);
-        String base = par.getParameter(SRC_URL_BASE, SERVER);
-        String srcId = par.getParameter(SRC_ID, null);
-        String srcUrl = base + srcId;
-        post = new PostFile(destination, srcUrl);
-        // Set up to read the input file
-        parser = (SAXParser) manager.lookup(SAXParser.ROLE);
+        destination = par.getParameter(DESTINATION_URL, SOLR_UPDATE_URL);
     }
 
     public void generate() throws IOException, SAXException, ProcessingException {
-        parser.parse(new InputSource(post.getResponseBodyAsStream()),contentHandler);
+        Source inputSource = null;
+        try {
+            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+            inputSource = resolver.resolveURI(this.source);
+            if (inputSource.exists()) {
+                post = new PostFile(destination, inputSource.getInputStream());
+                // Set up parser to parse the input file
+                parser = (SAXParser) manager.lookup(SAXParser.ROLE);
+                parser.parse(new InputSource(post.getResponseBodyAsStream()),contentHandler);
+            }else{
+                throw new ProcessingException("source: "+this.source+" does not exits");
+            }
+            
+        } catch (ServiceException e) {
+            throw new ProcessingException(e);
+        }
+        
     }
 
 }



Mime
View raw message