import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import gnu.regexp.RE;
+import gnu.regexp.REMatch;
+import gnu.regexp.REMatchEnumeration;
+import gnu.regexp.REException;
+
+
import org.apache.commons.net.smtp.SMTPClient;
import org.apache.commons.net.smtp.SMTPReply;
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.XSLTInputHandler;
+//import org.apache.fop.apps.Driver;
+//import org.apache.fop.apps.XSLTInputHandler;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import mircoders.module.ModuleContent;
import mircoders.module.ModuleImages;
import mircoders.module.ModuleTopics;
+import mircoders.pdf.PDFGenerator;
import mircoders.search.AudioSearchTerm;
import mircoders.search.ContentSearchTerm;
import mircoders.search.ImagesSearchTerm;
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.72 2003/04/10 03:31:47 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.73 2003/04/14 19:19:16 john Exp $
*
*/
}
/*
+ * Method for dynamically generating a pdf using iText
+ */
+
+
+ public void getpdf(HttpServletRequest req, HttpServletResponse res)
+ throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
+ String ID_REQUEST_PARAM = "id";
+ try {
+ String idParam = req.getParameter(ID_REQUEST_PARAM);
+ if (idParam != null) {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ PDFGenerator pdfMaker = new PDFGenerator(out);
+
+ RE re = new RE("[0-9]+");
+
+
+ REMatch[] idMatches=re.getAllMatches(idParam);
+
+ if (idMatches.length > 1){
+ pdfMaker.addLine();
+ for (int i = 0; i < idMatches.length; i++){
+ REMatch aMatch = idMatches[i];
+ String id=aMatch.toString();
+ EntityContent contentEnt = (EntityContent)contentModule.getById(id);
+ pdfMaker.addIndexItem(contentEnt);
+
+ }
+ }
+
+ for (int i = 0; i < idMatches.length; i++){
+ REMatch aMatch = idMatches[i];
+
+ String id=aMatch.toString();
+
+ EntityContent contentEnt = (EntityContent)contentModule.getById(id);
+ pdfMaker.add(contentEnt);
+
+ }
+
+ pdfMaker.stop();
+ res.setContentType("application/pdf");
+ byte[] content = out.toByteArray();
+ res.setContentLength(content.length);
+ res.getOutputStream().write(content);
+ res.getOutputStream().flush();
+
+ }
+ else {
+ throw new ServletModuleExc("Missing id.");
+ }
+ }
+ catch (Throwable t) {
+ logger.error(t.toString());
+ throw new ServletModuleFailure(t);
+ }
+
+ }
+
+
+ /*
* Method for dynamically generating a pdf from a fo file
+ * (deprecated until fop gets its act together regarding floats)
*/
+
+ /*
public void getpdf(HttpServletRequest req, HttpServletResponse res)
throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
String ID_REQUEST_PARAM = "id";
throw new ServletModuleExc("Can't generate a PDF because the config tells me not to.");
}
}
-
+ */
protected String createOneTimePasswd(){
Random r = new Random();
int random = r.nextInt();
public void handleError(HttpServletRequest aRequest, HttpServletResponse aResponse,PrintWriter out, Throwable anException) {
try {
logger.error("error: " + anException);
+ anException.printStackTrace();
Map data = new HashMap();
data.put("errorstring", anException.getMessage());