cleanup coding style of getpdf() method
authormh <mh>
Sun, 21 Jul 2002 22:50:14 +0000 (22:50 +0000)
committermh <mh>
Sun, 21 Jul 2002 22:50:14 +0000 (22:50 +0000)
source/mircoders/servlet/ServletModuleOpenIndy.java

index cd4cbd5..2b8e463 100755 (executable)
@@ -42,9 +42,12 @@ import mircoders.media.MediaRequest;
  *    open-postings to the newswire
  *
  * @author $Author: mh $
- * @version $Revision: 1.37 $ $Date: 2002/07/21 22:41:45 $
+ * @version $Revision: 1.38 $ $Date: 2002/07/21 22:50:14 $
  *
  * $Log: ServletModuleOpenIndy.java,v $
+ * Revision 1.38  2002/07/21 22:50:14  mh
+ * cleanup coding style of getpdf() method
+ *
  * Revision 1.37  2002/07/21 22:41:45  mh
  * make use of new MediaRequest class. A big cleanup and optimization.
  *
@@ -367,11 +370,9 @@ public class ServletModuleOpenIndy extends ServletModule
     deliver(req, res, mergeData, postingFormDoneTemplate);
   }
 
-/**
-  *  Method for dynamically generating a pdf from a fo file
-  */
-
-
+  /*
+   * Method for dynamically generating a pdf from a fo file
+   */
   public void getpdf(HttpServletRequest req, HttpServletResponse res)
     throws ServletModuleException, ServletModuleUserException {
     String ID_REQUEST_PARAM = "id";
@@ -379,9 +380,9 @@ public class ServletModuleOpenIndy extends ServletModule
     String generateFO=MirConfig.getProp("GenerateFO");
     String generatePDF=MirConfig.getProp("GeneratePDF");
 
-    //don't do anything if we are not making FO files, or if we are pregenerating PDF's
+    //don't do anything if we are not making FO files, or if we are
+    //pregenerating PDF's
     if (generateFO.equals("yes") && generatePDF.equals("no")){
-    
       //fop complains unless you do the logging this way
       Logger log = null;
       Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
@@ -390,20 +391,21 @@ public class ServletModuleOpenIndy extends ServletModule
     
       String producerStorageRoot=MirConfig.getProp("Producer.StorageRoot");
       String producerDocRoot=MirConfig.getProp("Producer.DocRoot");
-      String templateDir = MirConfig.getPropWithHome("HTMLTemplateProcessor.Dir");
+      String templateDir=MirConfig.getPropWithHome("HTMLTemplateProcessor.Dir");
       String xslSheet=templateDir + "/" 
-                    + MirConfig.getProp("Producer.PrintableContent.html2foStyleSheetName");
+        + MirConfig.getProp("Producer.PrintableContent.html2foStyleSheetName");
       try {
         String idParam = req.getParameter(ID_REQUEST_PARAM);
-        if (idParam != null){
-          EntityContent contentEnt = (EntityContent)contentModule.getById(idParam);
-         String publishPath = contentEnt.getValue("publish_path");
-         String foFile = producerStorageRoot + producerDocRoot + "/" 
-                        + publishPath + "/" + idParam + ".fo";
+        if (idParam != null) {
+          EntityContent contentEnt =
+            (EntityContent)contentModule.getById(idParam);
+          String publishPath = contentEnt.getValue("publish_path");
+          String foFile = producerStorageRoot + producerDocRoot + "/" 
+                          + publishPath + "/" + idParam + ".fo";
           XSLTInputHandler input = new XSLTInputHandler(new File(foFile), 
                                                        new File(xslSheet));
           
-         ByteArrayOutputStream out = new ByteArrayOutputStream();
+          ByteArrayOutputStream out = new ByteArrayOutputStream();
           res.setContentType("application/pdf");
 
           Driver driver = new Driver();
@@ -416,16 +418,13 @@ public class ServletModuleOpenIndy extends ServletModule
           res.setContentLength(content.length);
           res.getOutputStream().write(content);
           res.getOutputStream().flush();
-       } 
-        else {
-         throw new ServletModuleUserException("Can't generate a PDF without an id parameter.");
-       }
-      } 
-      catch (Exception ex) {
+        } else {
+          throw new ServletModuleUserException("Missing id parameter.");
+        }
+      } catch (Exception ex) {
        throw new ServletModuleException(ex.toString());
       }
-    }
-    else {
+    } else {
       throw new ServletModuleUserException("Can't generate a PDF because the config tells me not to.");
     }
   }