forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r488491 - /forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java
Date Tue, 19 Dec 2006 01:30:00 GMT
Author: rgardler
Date: Mon Dec 18 17:29:59 2006
New Revision: 488491

URL: http://svn.apache.org/viewvc?view=rev&rev=488491
Log:
A reader to implement the site: protocol in Forrest 1

Added:
    forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java
  (with props)

Added: forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java?view=auto&rev=488491
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java
(added)
+++ forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java
Mon Dec 18 17:29:59 2006
@@ -0,0 +1,38 @@
+package org.apache.forrest.reader;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.forrest.core.IController;
+import org.apache.forrest.core.document.AbstractOutputDocument;
+import org.apache.forrest.core.document.AbstractSourceDocument;
+import org.apache.forrest.core.exception.ProcessingException;
+import org.apache.forrest.core.locationMap.AbstractSourceNode;
+import org.apache.forrest.core.matcher.AbstractMatcher;
+import org.apache.forrest.core.reader.AbstractReader;
+
+/**
+ * Reads a document using the "site:" psuedo protocol
+ * from Forrest 1.
+ *
+ */
+public class Forrest1SiteElementReader extends AbstractReader {
+
+	public AbstractSourceDocument read(IController controller, URI requestURI, AbstractSourceNode
sourceNode, AbstractMatcher matcher) throws ProcessingException {
+		URI siteURI;
+		AbstractOutputDocument siteDoc;
+		try {
+			siteURI = new URI("classpath:/xdocs/site.xml");
+			siteDoc = controller.getOutputDocument(siteURI);
+			String href = siteDoc.getValue(requestURI.getSchemeSpecificPart() + "@href");
+			return controller.getSourceDocuments(new URI(href));
+		} catch (URISyntaxException e) {
+			// Should never be thrown
+			throw new ProcessingException("Unable create URI for site.xml document", e);
+		} catch (MalformedURLException e) {
+			throw new ProcessingException("Unable to get site.xml document", e);
+		}
+	}
+
+}

Propchange: forrest/trunk/whiteboard/forrest2/core/src/examples/forrest1SeedSite/src/org/apache/forrest/reader/Forrest1SiteElementReader.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message