forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r482002 - /forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
Date Mon, 04 Dec 2006 00:45:54 GMT
Author: rgardler
Date: Sun Dec  3 16:45:53 2006
New Revision: 482002

URL: http://svn.apache.org/viewvc?view=rev&rev=482002
Log:
@refactor extract specialist output processing methods

Modified:
    forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java

Modified: forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java?view=diff&rev=482002&r1=482001&r2=482002
==============================================================================
--- forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
(original)
+++ forrest/trunk/whiteboard/forrest2/core/src/core/org/apache/forrest/core/Controller.java
Sun Dec  3 16:45:53 2006
@@ -454,33 +454,9 @@
 	public AbstractOutputDocument getOutputDocument(final URI requestURI)
 			throws MalformedURLException, ProcessingException {
 		if (requestURI.getPath().endsWith(this.sourceURLExtension)) {
-			final AbstractSourceDocument doc = this
-					.getSourceDocuments(requestURI);
-			final StringBuffer content = new StringBuffer();
-			try {
-				content.append(doc.getContentAsString());
-			} catch (final IOException e) {
-				content.append("<error>Unable to read source document for ");
-				content.append(requestURI);
-				content.append("</error>");
-			}
-
-			final DefaultOutputDocument output = new DefaultOutputDocument(
-					requestURI, content.toString());
-			return output;
+			return getSourceDocumentAsOutput(requestURI);
 		} else if (requestURI.getPath().endsWith(this.internalURLExtension)) {
-			final InternalDocument doc = this.getInternalDocument(requestURI);
-			final StringBuffer content = new StringBuffer();
-			try {
-				content.append(doc.getContentAsString());
-			} catch (final IOException e) {
-				content.append("<error>Unable to read source document for ");
-				content.append(requestURI);
-				content.append("</error>");
-			}
-			final DefaultOutputDocument output = new DefaultOutputDocument(
-					requestURI, content.toString());
-			return output;
+			return getInternalDocumentAsOutput(requestURI);
 		}
 
 		AbstractOutputDocument output = this.outputDocCache.get(requestURI);
@@ -492,6 +468,38 @@
 						"Unable to create the output documents for "
 								+ requestURI + " because " + e.getMessage(), e);
 			}
+		return output;
+	}
+
+	private DefaultOutputDocument getInternalDocumentAsOutput(final URI requestURI) throws ProcessingException
{
+		final InternalDocument doc = this.getInternalDocument(requestURI);
+		final StringBuffer content = new StringBuffer();
+		try {
+			content.append(doc.getContentAsString());
+		} catch (final IOException e) {
+			content.append("<error>Unable to read source document for ");
+			content.append(requestURI);
+			content.append("</error>");
+		}
+		final DefaultOutputDocument output = new DefaultOutputDocument(
+				requestURI, content.toString());
+		return output;
+	}
+
+	private DefaultOutputDocument getSourceDocumentAsOutput(final URI requestURI) throws MalformedURLException,
ProcessingException {
+		final AbstractSourceDocument doc = this
+				.getSourceDocuments(requestURI);
+		final StringBuffer content = new StringBuffer();
+		try {
+			content.append(doc.getContentAsString());
+		} catch (final IOException e) {
+			content.append("<error>Unable to read source document for ");
+			content.append(requestURI);
+			content.append("</error>");
+		}
+
+		final DefaultOutputDocument output = new DefaultOutputDocument(
+				requestURI, content.toString());
 		return output;
 	}
 }



Mime
View raw message