changeset 905:afd82fe0c48a

move Texter servlet to its own maven module
author robcast
date Tue, 03 May 2011 12:18:08 +0200
parents 4f8f2b9ab539
children 28d007673346
files pdf/pom.xml pom.xml servlet2/src/main/java/digilib/servlet/Texter.java servlet3/src/main/java/digilib/servlet/Texter.java text/pom.xml text/src/main/java/digilib/servlet/Texter.java webapp/pom.xml
diffstat 7 files changed, 353 insertions(+), 449 deletions(-) [+]
line wrap: on
line diff
--- a/pdf/pom.xml	Tue Apr 26 21:02:31 2011 +0200
+++ b/pdf/pom.xml	Tue May 03 12:18:08 2011 +0200
@@ -1,73 +1,80 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>digilib</artifactId>
-    <groupId>digilib</groupId>
-    <version>2.0-SNAPSHOT</version>
-  </parent>
-  <groupId>digilib</groupId>
-  <artifactId>digilib-pdf</artifactId>
-  <version>2.0-SNAPSHOT</version>
-  <name>digilib-pdf</name>
-  <description>The Digital Image Library - PDF generation servlet</description>
-  <url>http://digilib.berlios.de</url>
-  <dependencies>
-    <dependency>
-      <groupId>digilib</groupId>
-      <artifactId>digilib-common</artifactId>
-      <type>jar</type>
-      <scope>compile</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.itextpdf</groupId>
-      <artifactId>itextpdf</artifactId>
-      <type>jar</type>
-      <scope>compile</scope>
-    </dependency>
-    <dependency>
-      <groupId>javax.servlet</groupId>
-      <artifactId>servlet-api</artifactId>
-      <version>2.3</version>
-      <type>jar</type>
-      <scope>provided</scope>
-    </dependency>
-  </dependencies>
-  <profiles>
-    <profile>
-      <id>servlet2</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-        <property>
-          <name>servletapi</name>
-          <value>2</value>
-        </property>
-      </activation>
-      <dependencies>
-        <dependency>
-          <groupId>digilib</groupId>
-          <artifactId>digilib-servlet2</artifactId>
-          <type>jar</type>
-          <scope>provided</scope>
-        </dependency>
-      </dependencies>
-    </profile>
-    <profile>
-      <id>servlet3</id>
-      <activation>
-        <property>
-          <name>servletapi</name>
-          <value>3</value>
-        </property>
-      </activation>
-      <dependencies>
-        <dependency>
-          <groupId>digilib</groupId>
-          <artifactId>digilib-servlet3</artifactId>
-          <type>jar</type>
-          <scope>provided</scope>
-        </dependency>
-      </dependencies>
-    </profile>
-  </profiles>
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>digilib</artifactId>
+		<groupId>digilib</groupId>
+		<version>2.0-SNAPSHOT</version>
+	</parent>
+	<groupId>digilib</groupId>
+	<artifactId>digilib-pdf</artifactId>
+	<version>2.0-SNAPSHOT</version>
+	<name>digilib-pdf</name>
+	<description>The Digital Image Library - PDF generation servlet</description>
+	<url>http://digilib.berlios.de</url>
+	<dependencies>
+		<dependency>
+			<groupId>digilib</groupId>
+			<artifactId>digilib-common</artifactId>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>com.itextpdf</groupId>
+			<artifactId>itextpdf</artifactId>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+	</dependencies>
+	<profiles>
+		<profile>
+			<id>servlet2</id>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+				<property>
+					<name>servletapi</name>
+					<value>2</value>
+				</property>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>digilib</groupId>
+					<artifactId>digilib-servlet2</artifactId>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>javax.servlet</groupId>
+					<artifactId>servlet-api</artifactId>
+					<version>2.3</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+			</dependencies>
+		</profile>
+		<profile>
+			<id>servlet3</id>
+			<activation>
+				<property>
+					<name>servletapi</name>
+					<value>3</value>
+				</property>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>digilib</groupId>
+					<artifactId>digilib-servlet3</artifactId>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>org.mortbay.jetty</groupId>
+					<artifactId>servlet-api</artifactId>
+					<version>3.0.20100224</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+			</dependencies>
+		</profile>
+	</profiles>
 </project>
\ No newline at end of file
--- a/pom.xml	Tue Apr 26 21:02:31 2011 +0200
+++ b/pom.xml	Tue May 03 12:18:08 2011 +0200
@@ -189,5 +189,6 @@
     <module>servlet2</module>
     <module>servlet3</module>
     <module>pdf</module>
+    <module>text</module>
   </modules>
 </project>
\ No newline at end of file
--- a/servlet2/src/main/java/digilib/servlet/Texter.java	Tue Apr 26 21:02:31 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/* Texter.java -- Servlet for displaying text  
- * Digital Image Library servlet components  
- * Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
- *  
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.  Please read license.txt for the full details. A copy of
- * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html  
- * You should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA  
- * 
- * Created on 15.09.2003 by casties  
- */
-
-package digilib.servlet;
-
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-
-import digilib.auth.AuthOps;
-import digilib.image.ImageOpException;
-import digilib.io.DocuDirCache;
-import digilib.io.FileOps;
-import digilib.io.FileOps.FileClass;
-import digilib.io.TextFile;
-
-/**
- * Servlet for displaying text
- * 
- * 
- * @author casties
- *  
- */
-public class Texter extends HttpServlet {
-
-    private static final long serialVersionUID = 6678666342141409867L;
-
-    /** Servlet version */
-	public static String tlVersion = "0.1b3";
-
-	/** DigilibConfiguration instance */
-	DigilibServletConfiguration dlConfig = null;
-
-	/** general logger */
-	Logger logger = Logger.getLogger("digilib.texter");
-
-    /** logger for accounting requests */
-    protected static Logger accountlog = Logger.getLogger("account.texter.request");
-
-	/** FileOps instance */
-	FileOps fileOp;
-
-	/** AuthOps instance */
-	AuthOps authOp;
-
-	/** ServletOps instance */
-	ServletOps servletOp;
-
-	/** DocuDirCache instance */
-	DocuDirCache dirCache;
-
-	/** use authentication */
-	boolean useAuthentication = false;
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
-	 */
-	public void init(ServletConfig config) throws ServletException {
-		super.init(config);
-
-		System.out.println("***** Digital Image Library Text Servlet (version "
-				+ tlVersion + ") *****");
-
-		// get our ServletContext
-		ServletContext context = config.getServletContext();
-		// see if there is a Configuration instance
-		dlConfig = (DigilibServletConfiguration) context
-				.getAttribute("digilib.servlet.configuration");
-		if (dlConfig == null) {
-			// no Configuration
-			throw new ServletException("No Configuration!");
-		}
-		// say hello in the log file
-		logger.info("***** Digital Image Library Text Servlet (version "
-				+ tlVersion + ") *****");
-
-		// set our AuthOps
-		useAuthentication = dlConfig.getAsBoolean("use-authorization");
-		authOp = (AuthOps) dlConfig.getValue("servlet.auth.op");
-		// DocuDirCache instance
-		dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
-	 *      javax.servlet.http.HttpServletResponse)
-	 */
-	protected void doGet(HttpServletRequest request,
-			HttpServletResponse response) throws ServletException, IOException {
-        accountlog.info("GET from " + request.getRemoteAddr());
-		// do the processing
-		processRequest(request, response);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
-	 *      javax.servlet.http.HttpServletResponse)
-	 */
-	protected void doPost(HttpServletRequest request,
-			HttpServletResponse response) throws ServletException, IOException {
-        accountlog.info("POST from " + request.getRemoteAddr());
-		// do the processing
-		processRequest(request, response);
-	}
-
-	protected void processRequest(HttpServletRequest request,
-			HttpServletResponse response) {
-		
-		/*
-		 * request parameters
-		 */
-        // create new request with defaults
-        DigilibServletRequest dlRequest = new DigilibServletRequest(request);
-		try {
-			
-			/*
-			 * find the file to load/send
-			 */
-			TextFile f = getTextFile(dlRequest, "/txt");
-			if (f != null) {
-				ServletOps.sendFile(f.getFile(), null, null, response, logger);
-			} else {
-				f = getTextFile(dlRequest, "");
-				if (f != null) {
-					ServletOps.sendFile(f.getFile(), null, null, response, logger);
-				} else {
-					response.sendError(HttpServletResponse.SC_NOT_FOUND, "Text-File not found!");
-					//ServletOps.htmlMessage("No Text-File!", response);
-				}
-			}
-			
-		} catch (ImageOpException e) {
-            // most likely wrong file format...
-            logger.error("ERROR sending text file: ", e);
-            try {
-                response.sendError(HttpServletResponse.SC_BAD_REQUEST);
-            } catch (IOException e1) {
-                logger.error("ERROR sending error: ", e1);
-            }
-        } catch (IOException e) {
-            logger.error("ERROR sending text file: ", e);
-        }
-    }
-	
-
-	/**
-	 * Looks for a file in the given subDirectory.
-	 * 
-	 * @param dlRequest
-	 *            The received request which has the file path.
-	 * @param subDirectory
-	 *            The subDirectory of the file path where the file should
-	 *            be found.
-	 * @return The wanted Textfile or null if there wasn't a file.
-	 */
-
-	private TextFile getTextFile(DigilibServletRequest dlRequest, String subDirectory) {
-		String loadPathName = dlRequest.getFilePath() + subDirectory;
-		// find the file(set)
-		return (TextFile) dirCache.getFile(loadPathName, dlRequest.getAsInt("pn"), 
-		        FileClass.TEXT);
-	}
-}
\ No newline at end of file
--- a/servlet3/src/main/java/digilib/servlet/Texter.java	Tue Apr 26 21:02:31 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/* Texter.java -- Servlet for displaying text  
- * Digital Image Library servlet components  
- * Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
- *  
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.  Please read license.txt for the full details. A copy of
- * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html  
- * You should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA  
- * 
- * Created on 15.09.2003 by casties  
- */
-
-package digilib.servlet;
-
-import java.io.IOException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-
-import digilib.auth.AuthOps;
-import digilib.image.ImageOpException;
-import digilib.io.DocuDirCache;
-import digilib.io.FileOps;
-import digilib.io.FileOps.FileClass;
-import digilib.io.TextFile;
-
-/**
- * Servlet for displaying text
- * 
- * 
- * @author casties
- *  
- */
-public class Texter extends HttpServlet {
-
-    private static final long serialVersionUID = 6678666342141409867L;
-
-    /** Servlet version */
-	public static String tlVersion = "0.1b3";
-
-	/** DigilibConfiguration instance */
-	DigilibConfiguration dlConfig = null;
-
-	/** general logger */
-	Logger logger = Logger.getLogger("digilib.texter");
-
-    /** logger for accounting requests */
-    protected static Logger accountlog = Logger.getLogger("account.texter.request");
-
-	/** FileOps instance */
-	FileOps fileOp;
-
-	/** AuthOps instance */
-	AuthOps authOp;
-
-	/** ServletOps instance */
-	ServletOps servletOp;
-
-	/** DocuDirCache instance */
-	DocuDirCache dirCache;
-
-	/** use authentication */
-	boolean useAuthentication = false;
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
-	 */
-	public void init(ServletConfig config) throws ServletException {
-		super.init(config);
-
-		System.out.println("***** Digital Image Library Text Servlet (version "
-				+ tlVersion + ") *****");
-
-		// get our ServletContext
-		ServletContext context = config.getServletContext();
-		// see if there is a Configuration instance
-		dlConfig = (DigilibConfiguration) context
-				.getAttribute("digilib.servlet.configuration");
-		if (dlConfig == null) {
-			// no Configuration
-			throw new ServletException("No Configuration!");
-		}
-		// say hello in the log file
-		logger.info("***** Digital Image Library Text Servlet (version "
-				+ tlVersion + ") *****");
-
-		// set our AuthOps
-		useAuthentication = dlConfig.getAsBoolean("use-authorization");
-		authOp = (AuthOps) dlConfig.getValue("servlet.auth.op");
-		// DocuDirCache instance
-		dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
-	 *      javax.servlet.http.HttpServletResponse)
-	 */
-	protected void doGet(HttpServletRequest request,
-			HttpServletResponse response) throws ServletException, IOException {
-        accountlog.info("GET from " + request.getRemoteAddr());
-		// do the processing
-		processRequest(request, response);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
-	 *      javax.servlet.http.HttpServletResponse)
-	 */
-	protected void doPost(HttpServletRequest request,
-			HttpServletResponse response) throws ServletException, IOException {
-        accountlog.info("POST from " + request.getRemoteAddr());
-		// do the processing
-		processRequest(request, response);
-	}
-
-	protected void processRequest(HttpServletRequest request,
-			HttpServletResponse response) {
-		
-		/*
-		 * request parameters
-		 */
-        // create new request with defaults
-        DigilibServletRequest dlRequest = new DigilibServletRequest(request);
-		try {
-			
-			/*
-			 * find the file to load/send
-			 */
-			TextFile f = getTextFile(dlRequest, "/txt");
-			if (f != null) {
-				ServletOps.sendFile(f.getFile(), null, null, response, logger);
-			} else {
-				f = getTextFile(dlRequest, "");
-				if (f != null) {
-					ServletOps.sendFile(f.getFile(), null, null, response, logger);
-				} else {
-					response.sendError(HttpServletResponse.SC_NOT_FOUND, "Text-File not found!");
-					//ServletOps.htmlMessage("No Text-File!", response);
-				}
-			}
-			
-		} catch (ImageOpException e) {
-            // most likely wrong file format...
-            logger.error("ERROR sending text file: ", e);
-            try {
-                response.sendError(HttpServletResponse.SC_BAD_REQUEST);
-            } catch (IOException e1) {
-                logger.error("ERROR sending error: ", e1);
-            }
-        } catch (IOException e) {
-            logger.error("ERROR sending text file: ", e);
-        }
-    }
-	
-
-	/**
-	 * Looks for a file in the given subDirectory.
-	 * 
-	 * @param dlRequest
-	 *            The received request which has the file path.
-	 * @param subDirectory
-	 *            The subDirectory of the file path where the file should
-	 *            be found.
-	 * @return The wanted Textfile or null if there wasn't a file.
-	 */
-
-	private TextFile getTextFile(DigilibRequest dlRequest, String subDirectory) {
-		String loadPathName = dlRequest.getFilePath() + subDirectory;
-		// find the file(set)
-		return (TextFile) dirCache.getFile(loadPathName, dlRequest.getAsInt("pn"), 
-		        FileClass.TEXT);
-	}
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/text/pom.xml	Tue May 03 12:18:08 2011 +0200
@@ -0,0 +1,74 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>digilib</artifactId>
+		<groupId>digilib</groupId>
+		<version>2.0-SNAPSHOT</version>
+	</parent>
+	<groupId>digilib</groupId>
+	<artifactId>text</artifactId>
+	<version>2.0-SNAPSHOT</version>
+	<name>digilib-text</name>
+	<dependencies>
+		<dependency>
+			<groupId>digilib</groupId>
+			<artifactId>digilib-common</artifactId>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+	</dependencies>
+	<description>The Digital Image Library - text (plain or XML) serving servlet</description>
+	<url>http://digilib.berlios.de</url>
+	<profiles>
+		<profile>
+			<id>servlet2</id>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+				<property>
+					<name>servletapi</name>
+					<value>2</value>
+				</property>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>digilib</groupId>
+					<artifactId>digilib-servlet2</artifactId>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>javax.servlet</groupId>
+					<artifactId>servlet-api</artifactId>
+					<version>2.3</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+			</dependencies>
+		</profile>
+		<profile>
+			<id>servlet3</id>
+			<activation>
+				<property>
+					<name>servletapi</name>
+					<value>3</value>
+				</property>
+			</activation>
+			<dependencies>
+				<dependency>
+					<groupId>digilib</groupId>
+					<artifactId>digilib-servlet3</artifactId>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+				<dependency>
+					<groupId>org.mortbay.jetty</groupId>
+					<artifactId>servlet-api</artifactId>
+					<version>3.0.20100224</version>
+					<type>jar</type>
+					<scope>provided</scope>
+				</dependency>
+			</dependencies>
+		</profile>
+	</profiles>
+</project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/text/src/main/java/digilib/servlet/Texter.java	Tue May 03 12:18:08 2011 +0200
@@ -0,0 +1,189 @@
+/* Texter.java -- Servlet for displaying text  
+ * Digital Image Library servlet components  
+ * Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
+ *  
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.  Please read license.txt for the full details. A copy of
+ * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html  
+ * You should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA  
+ * 
+ * Created on 15.09.2003 by casties  
+ */
+
+package digilib.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+
+import digilib.auth.AuthOps;
+import digilib.image.ImageOpException;
+import digilib.io.DocuDirCache;
+import digilib.io.FileOps;
+import digilib.io.FileOps.FileClass;
+import digilib.io.TextFile;
+
+/**
+ * Servlet for displaying text
+ * 
+ * 
+ * @author casties
+ *  
+ */
+public class Texter extends HttpServlet {
+
+    private static final long serialVersionUID = 6678666342141409867L;
+
+    /** Servlet version */
+	public static String tlVersion = "0.1b3";
+
+	/** DigilibConfiguration instance */
+	DigilibServletConfiguration dlConfig = null;
+
+	/** general logger */
+	Logger logger = Logger.getLogger("digilib.texter");
+
+    /** logger for accounting requests */
+    protected static Logger accountlog = Logger.getLogger("account.texter.request");
+
+	/** FileOps instance */
+	FileOps fileOp;
+
+	/** AuthOps instance */
+	AuthOps authOp;
+
+	/** ServletOps instance */
+	ServletOps servletOp;
+
+	/** DocuDirCache instance */
+	DocuDirCache dirCache;
+
+	/** use authentication */
+	boolean useAuthentication = false;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
+	 */
+	public void init(ServletConfig config) throws ServletException {
+		super.init(config);
+
+		System.out.println("***** Digital Image Library Text Servlet (version "
+				+ tlVersion + ") *****");
+
+		// get our ServletContext
+		ServletContext context = config.getServletContext();
+		// see if there is a Configuration instance
+		dlConfig = (DigilibServletConfiguration) context
+				.getAttribute("digilib.servlet.configuration");
+		if (dlConfig == null) {
+			// no Configuration
+			throw new ServletException("No Configuration!");
+		}
+		// say hello in the log file
+		logger.info("***** Digital Image Library Text Servlet (version "
+				+ tlVersion + ") *****");
+
+		// set our AuthOps
+		useAuthentication = dlConfig.getAsBoolean("use-authorization");
+		authOp = (AuthOps) dlConfig.getValue("servlet.auth.op");
+		// DocuDirCache instance
+		dirCache = (DocuDirCache) dlConfig.getValue("servlet.dir.cache");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
+	 *      javax.servlet.http.HttpServletResponse)
+	 */
+	protected void doGet(HttpServletRequest request,
+			HttpServletResponse response) throws ServletException, IOException {
+        accountlog.info("GET from " + request.getRemoteAddr());
+		// do the processing
+		processRequest(request, response);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
+	 *      javax.servlet.http.HttpServletResponse)
+	 */
+	protected void doPost(HttpServletRequest request,
+			HttpServletResponse response) throws ServletException, IOException {
+        accountlog.info("POST from " + request.getRemoteAddr());
+		// do the processing
+		processRequest(request, response);
+	}
+
+	protected void processRequest(HttpServletRequest request,
+			HttpServletResponse response) {
+		
+		/*
+		 * request parameters
+		 */
+        // create new request with defaults
+        DigilibServletRequest dlRequest = new DigilibServletRequest(request);
+		try {
+			
+			/*
+			 * find the file to load/send
+			 */
+			TextFile f = getTextFile(dlRequest, "/txt");
+			if (f != null) {
+				ServletOps.sendFile(f.getFile(), null, null, response, logger);
+			} else {
+				f = getTextFile(dlRequest, "");
+				if (f != null) {
+					ServletOps.sendFile(f.getFile(), null, null, response, logger);
+				} else {
+					response.sendError(HttpServletResponse.SC_NOT_FOUND, "Text-File not found!");
+					//ServletOps.htmlMessage("No Text-File!", response);
+				}
+			}
+			
+		} catch (ImageOpException e) {
+            // most likely wrong file format...
+            logger.error("ERROR sending text file: ", e);
+            try {
+                response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            } catch (IOException e1) {
+                logger.error("ERROR sending error: ", e1);
+            }
+        } catch (IOException e) {
+            logger.error("ERROR sending text file: ", e);
+        }
+    }
+	
+
+	/**
+	 * Looks for a file in the given subDirectory.
+	 * 
+	 * @param dlRequest
+	 *            The received request which has the file path.
+	 * @param subDirectory
+	 *            The subDirectory of the file path where the file should
+	 *            be found.
+	 * @return The wanted Textfile or null if there wasn't a file.
+	 */
+
+	private TextFile getTextFile(DigilibServletRequest dlRequest, String subDirectory) {
+		String loadPathName = dlRequest.getFilePath() + subDirectory;
+		// find the file(set)
+		return (TextFile) dirCache.getFile(loadPathName, dlRequest.getAsInt("pn"), 
+		        FileClass.TEXT);
+	}
+}
\ No newline at end of file
--- a/webapp/pom.xml	Tue Apr 26 21:02:31 2011 +0200
+++ b/webapp/pom.xml	Tue May 03 12:18:08 2011 +0200
@@ -91,5 +91,16 @@
         </dependency>
       </dependencies>
     </profile>
+    <profile>
+      <id>text</id>
+      <dependencies>
+        <dependency>
+          <groupId>digilib</groupId>
+          <artifactId>digilib-text</artifactId>
+          <type>jar</type>
+          <scope>compile</scope>
+        </dependency>
+      </dependencies>
+    </profile>
   </profiles>
 </project>