fixed issue 37396: remove support to print fop documents in a different server
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 27 Nov 2017 15:04:47 +0100
changeset 33050 77c78710f26e
parent 33049 639a31dffd9c
child 33051 6a9db69516b2
fixed issue 37396: remove support to print fop documents in a different server

This feature was not used nor documented.
lib/runtime/renderFoRmi.jar
src-core/.classpath
src-core/src/org/openbravo/base/ConfigParameters.java
src-core/src/org/openbravo/base/HttpBaseServlet.java
src-core/utils/rmi/Readme.txt
src-core/utils/rmi/classes/rmi/.keep
src-core/utils/rmi/java.policy
src-core/utils/rmi/lib/.keep
src-core/utils/rmi/logs/.keep
src-core/utils/rmi/src/rmi/RenderFo.java
src-core/utils/rmi/src/rmi/RenderFoI.java
src-db/database/sourcedata/AD_MODEL_OBJECT_PARA.xml
Binary file lib/runtime/renderFoRmi.jar has changed
--- a/src-core/.classpath	Mon Nov 27 19:16:22 2017 +0100
+++ b/src-core/.classpath	Mon Nov 27 15:04:47 2017 +0100
@@ -5,7 +5,6 @@
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/commons-dbcp-1.4.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/commons-pool-1.5.6.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/fop-1.1.jar"/>
-	<classpathentry kind="lib" path="/openbravo/lib/runtime/renderFoRmi.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/avalon-framework-4.1.5.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/commons-fileupload-1.2.2.jar"/>
 	<classpathentry kind="lib" path="/openbravo/lib/runtime/xercesImpl.jar"/>
--- a/src-core/src/org/openbravo/base/ConfigParameters.java	Mon Nov 27 19:16:22 2017 +0100
+++ b/src-core/src/org/openbravo/base/ConfigParameters.java	Mon Nov 27 15:04:47 2017 +0100
@@ -49,7 +49,6 @@
   private final String strFileFormat;
   public final String strSystemLanguage;
   public final String strDefaultServlet;
-  public final String strServidorRenderFo;
   private final String stcFileProperties;
   public final String strReplaceWhat;
   private final String poolFileName;
@@ -113,7 +112,6 @@
 
     strSystemLanguage = getSystemLanguage();
     strLocalReplaceWith = getResolvedParameter(context, "ReplaceWith");
-    strServidorRenderFo = getResolvedParameter(context, "ServidorRenderFo");
     strTextDividedByZero = getResolvedParameter(context, "TextDividedByZero");
 
     poolFileName = getResolvedParameter(context, "PoolFile");
--- a/src-core/src/org/openbravo/base/HttpBaseServlet.java	Mon Nov 27 19:16:22 2017 +0100
+++ b/src-core/src/org/openbravo/base/HttpBaseServlet.java	Mon Nov 27 15:04:47 2017 +0100
@@ -15,17 +15,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.StringReader;
-import java.rmi.Naming;
 import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -56,8 +51,6 @@
 import org.openbravo.xmlEngine.XmlEngine;
 import org.xml.sax.XMLReader;
 
-import rmi.RenderFoI;
-
 /**
  * This class is intended to be extended by the HttpSecureAppServlet and provides methods for basic
  * management of request/response, database connections, transactions, FOP rendering, and others
@@ -575,42 +568,7 @@
    */
 
   protected void renderFO(String strFo, OutputStream out) throws ServletException {
-    // Check validity of the certificate
-    // Create a trust manager that does not validate certificate chains
-    TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
-      public java.security.cert.X509Certificate[] getAcceptedIssuers() {
-        return null;
-      }
-
-      public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-      }
-
-      public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-      }
-
-      @SuppressWarnings("unused")
-      // external implementation
-      public boolean isServerTrusted(java.security.cert.X509Certificate[] cert) {
-        return true;
-      }
-
-      @SuppressWarnings("unused")
-      // external implementation
-      public boolean isClientTrusted(java.security.cert.X509Certificate[] cert) {
-        return true;
-      }
-    } };
-    // Install the all-trusting trust manager
     try {
-      SSLContext sc = SSLContext.getInstance("SSL");
-      sc.init(null, trustAllCerts, new java.security.SecureRandom());
-      HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
-    } catch (Exception e) {
-    }
-
-    try {
-      if (log4j.isDebugEnabled())
-        log4j.debug("Beginning of renderFO");
       FopFactory fopFactoryInstance = getFopFactory();
       if (globalParameters.haveFopConfig()) {
         // Take FOP Configuration using userconfig.xml file
@@ -620,47 +578,29 @@
 
       final String foTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + strFo;
 
-      if ((globalParameters.strServidorRenderFo == null)
-          || (globalParameters.strServidorRenderFo.equals(""))) {
+      log4j.debug(strFo);
 
-        if (log4j.isDebugEnabled())
-          log4j.debug(strFo);
+      Source sr = new StreamSource(new StringReader(foTemplate));
 
-        Source sr = new StreamSource(new StringReader(foTemplate));
+      // Configure FOP for PDF output. Define a user agent with a listener used to log information
+      // along the rendering the process
+      FOUserAgent foUserAgent = fopFactoryInstance.newFOUserAgent();
+      foUserAgent.getEventBroadcaster().addEventListener(new FopEventListener());
+      Fop fop = fopFactoryInstance.newFop("application/pdf", foUserAgent, out);
 
-        if (log4j.isDebugEnabled())
-          log4j.debug(sr.toString());
+      // Setup JAXP using identity transformer
+      TransformerFactory factory = TransformerFactory.newInstance();
+      Transformer transformer = factory.newTransformer();
 
-        // Configure FOP for PDF output. Define a user agent with a listener used to log information
-        // along the rendering the process
-        FOUserAgent foUserAgent = fopFactoryInstance.newFOUserAgent();
-        foUserAgent.getEventBroadcaster().addEventListener(new FopEventListener());
-        Fop fop = fopFactoryInstance.newFop("application/pdf", foUserAgent, out);
+      // Resulting SAX events (the generated FO) must be piped through to FOP
+      Result res = new SAXResult(fop.getDefaultHandler());
 
-        // Setup JAXP using identity transformer
-        TransformerFactory factory = TransformerFactory.newInstance();
-        Transformer transformer = factory.newTransformer();
+      // Start XSLT transformation and FOP processing
+      transformer.transform(sr, res);
 
-        // Resulting SAX events (the generated FO) must be piped through to FOP
-        Result res = new SAXResult(fop.getDefaultHandler());
-
-        // Start XSLT transformation and FOP processing
-        transformer.transform(sr, res);
-
-        if (log4j.isDebugEnabled()) {
-          FormattingResults foResults = fop.getResults();
-          log4j.debug("Generated " + foResults.getPageCount() + " pages in total.");
-          log4j.debug("End of renderFO");
-        }
-
-      } else {
-
-        RenderFoI render = (RenderFoI) Naming.lookup("rmi://"
-            + globalParameters.strServidorRenderFo + "/RenderFo");
-
-        byte[] content = render.computeRenderFo(strFo);
-        out.write(content);
-        out.flush();
+      if (log4j.isDebugEnabled()) {
+        FormattingResults foResults = fop.getResults();
+        log4j.debug("Generated " + foResults.getPageCount() + " pages in total.");
       }
     } catch (java.lang.IllegalStateException il) {
       return;
--- a/src-core/utils/rmi/Readme.txt	Mon Nov 27 19:16:22 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-Installation guide for RenderFO:
-
-In the server side:
-
-1.- Edit src/rmi/RenderFo.java, replace:
-  -@basepath@: path where RenderFo is installed (log will be written there). A folder named "log" has to be created within that path
-  -@RenderFoAddress@: IP address or public DNS name of RenderFO server
-
-2.- Compile both classes (RenderFoI.java and RenderFo.java). 
-  -Requirements:
-    -jdk1.3 or higher
-    -xalan.jar, fop.jar, comm.jar, log4j.jar and rmi/classes (.) in classpath
- 
-3.- Generate rmi infrastructure. In command line execute: rmic -d ./classes rmi.RenderFo
-  It will generate stub and skel classes, to communicate rmi client and server
-    -Requirements:
-    -jdk1.3 or higher
-    -xalan.jar, fop.jar, comm.jar and log4j.jar in classpath
-  -Requirements:
-    -jdk1.3 or higher and jdk/bin folder in execution path
-    -xalan.jar, fop.jar, comm.jar, log4j.jar and rmi/classes (.) in classpath
-
-4.- Create a jar file with generated classes: jar -cvf RenderFoRmi.jar *
-  This jar file will be deployed in rmi client
-
-5.- Running the server:
-  5.1.- Command line
-    start rmiregistry
-    java -Djava.rmi.server.hostname=@RenderFoAddress@ -Djava.security.policy=@basepath@\java.policy -Djava.rmi.server.codebase=file:@basepath@\classes/ -cp @basepath@\lib\fop.jar;@basepath@\lib\avalon-framework-cvs-20020806.jar;@basepath@\lib\batik.jar;@basepath@\lib\xalan-2.4.1.jar;@basepath@\lib\xercesImpl-2.2.1.jar;@basepath@\lib\xml-apis.jar;@basepath@\lib\log4j-1.2.8.jar;@basepath@\classes; -Xmx512m -Xms256m rmi.RenderFo
-  5.2.- As a service in a windows box. Using ServiceInstaller tool (replace $JAVA_HOME$ variable by its value):
-    -5.2.1.- Install rmiRegistry service:
-      SERVICE NAME: rmiRegistry
-      DISPLAY NAME: rmiRegistry
-      STARTUP: manual
-      DEPENDENCIES: 
-      EXECUTABLE: $JAVA_HOME$\rmiregistry.exe
-      ARGUMENTS:
-      WORKING DIRECTORY: $JAVA_HOME$
-
-    -5.2.2.- Install RenderFo service:
-      a) without proxy
-      SERVICE NAME: rmiRenderFo
-      DISPLAY NAME: rmiRenderFo
-      STARTUP: manual
-      DEPENDENCIES: rmiRegistry
-      EXECUTABLE: $JAVA_HOME$\java.exe
-      ARGUMENTS: -Djava.rmi.server.hostname=@RenderFoAddress@ -Djava.security.policy=c:\rmi\java.policy -Djava.rmi.server.codebase=file:@basepath@\classes/ -cp @basepath@\lib\fop.jar;@basepath@\lib\avalon-framework-cvs-20020806.jar;@basepath@\lib\batik.jar;@basepath@\lib\xalan-2.4.1.jar;@basepath@\lib\xercesImpl-2.2.1.jar;@basepath@\lib\xml-apis.jar;@basepath@\lib\log4j-1.2.8.jar;@basepath@\classes; -Xmx512m -Xms256m rmi.RenderFo
-      WORKING DIRECTORY: $JAVA_HOME$
-
-      a) with proxy
-      SERVICE NAME: rmiRenderFo
-      DISPLAY NAME: rmiRenderFo
-      STARTUP: manual
-      DEPENDENCIES: rmiRegistry
-      EXECUTABLE: $JAVA_HOME$\java.exe
-      ARGUMENTS: -Djava.rmi.server.hostname=@RenderFoAddress@ -Dhttp.proxyHost=@ProxyAddress@ -Dhttp.proxyPort=8080 -Djava.security.policy=@basepath@\java.policy -Djava.rmi.server.codebase=@basepath@\classes/ -cp @basepath@\lib\fop.jar;@basepath@\lib\avalon-framework-cvs-20020806.jar;@basepath@\lib\batik.jar;@basepath@\lib\xalan-2.4.1.jar;@basepath@\lib\xercesImpl-2.2.1.jar;@basepath@\lib\xml-apis.jar;@basepath@\lib\log4j-1.2.8.jar;@basepath@\classes; -Xmx512m -Xms256m rmi.RenderFo
-      WORKING DIRECTORY: $JAVA_HOME$
-
-In the client side (running in a tomcat server):
-1.- Copy renderFoRmi.jar to an accessible path for the execution context (eg. if executing from tomcat, tomcat\common\lib)
-
-2.- Edit web.xml file
-  <context-param>
-    <param-name>ServidorRenderFo</param-name>
-    <param-value>@RenderFoAddress@</param-value>
-  </context-param>
\ No newline at end of file
--- a/src-core/utils/rmi/java.policy	Mon Nov 27 19:16:22 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-grant {
-permission java.security.AllPermission;
-};
\ No newline at end of file
--- a/src-core/utils/rmi/src/rmi/RenderFo.java	Mon Nov 27 19:16:22 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- ************************************************************************************
- * Copyright (C) 2001-2011 Openbravo S.L.U.
- * Licensed under the Apache Software License version 2.0
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to  in writing,  software  distributed
- * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
- * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
- * specific language governing permissions and limitations under the License.
- ************************************************************************************
- */
-
-package rmi;
-
-import java.rmi.server.*;
-import java.rmi.registry.*;
-
-import java.io.*;
-import java.lang.*;
-import org.apache.fop.apps.Driver;
-import org.apache.fop.apps.Version;
-import java.net.*;
-import java.rmi.*;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import rmi.*;
-import org.xml.sax.*;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.SimpleLayout;
-import org.apache.log4j.FileAppender;
-
-public class RenderFo extends UnicastRemoteObject implements RenderFoI {
-
-  private String strFo;
-  static Logger logger = Logger.getLogger(RenderFo.class);
-
-  public RenderFo() throws RemoteException {
-  }
-
-  public RenderFo(String strFo) throws RemoteException {
-    this.strFo = strFo;
-  }
-
-  public Object execute() throws RemoteException {
-    return computeRenderFo(strFo);
-  }
-
-  public byte[] computeRenderFo(String strFo) throws RemoteException {
-    byte[] content = null;
-    try {
-      StringReader sr = new StringReader(strFo);
-      InputSource inputFo = new InputSource(sr);
-      ByteArrayOutputStream out = new ByteArrayOutputStream();
-      Driver driver = new Driver(inputFo, out);
-      driver.run();
-      content = out.toByteArray();
-      out.close();
-    } catch (Exception e) {
-      Throwable t = (Throwable) e;
-      logger.error("computeRenderFo exception: " + e.getMessage());
-      e.printStackTrace();
-    }
-    return content;
-  }
-
-  // Registration for RMI serving:
-  public static void main(String[] args) {
-    SimpleLayout layout = new SimpleLayout();
-
-    FileAppender appender = null;
-
-    Date today = new Date();
-
-    // format the date in the form "Wed 27 Aug, 2003"
-    SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy");
-    String strToday = formatter.format(today);
-
-    String strFileName = "renderFo" + strToday + ".log";
-
-    try {
-      appender = new FileAppender(layout, "@basepath@\\logs\\" + strFileName, false); // eg.
-                                                                                      // @basepath@
-                                                                                      // = c:\\rmi
-    } catch (Exception e) {
-    }
-
-    logger.addAppender(appender);
-    logger.setLevel((Level) Level.WARN);
-
-    System.setSecurityManager(new RMISecurityManager());
-
-    try {
-      RenderFo render = new RenderFo();
-      Naming.bind("//@RenderFoAddress@/RenderFo", render);
-      logger.warn("RenderFo ready");
-    } catch (Exception e) {
-      logger.error("Error binding:" + e.getMessage());
-      e.printStackTrace();
-    }
-  }
-}
--- a/src-core/utils/rmi/src/rmi/RenderFoI.java	Mon Nov 27 19:16:22 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-/*
- ************************************************************************************
- * Copyright (C) 2001-2011 Openbravo S.L.U.
- * Licensed under the Apache Software License version 2.0
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to  in writing,  software  distributed
- * under the License is distributed  on  an  "AS IS"  BASIS,  WITHOUT  WARRANTIES  OR
- * CONDITIONS OF ANY KIND, either  express  or  implied.  See  the  License  for  the
- * specific language governing permissions and limitations under the License.
- ************************************************************************************
- */
-
-//: c15:rmi:PerfectTimeI.java
-// The PerfectTime remote interface.
-package rmi;
-
-import java.rmi.*;
-import java.io.*;
-import org.xml.sax.*;
-
-public interface RenderFoI extends Remote {
-  byte[] computeRenderFo(String strFo) throws RemoteException;
-} // /:~
\ No newline at end of file
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT_PARA.xml	Mon Nov 27 19:16:22 2017 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT_PARA.xml	Mon Nov 27 15:04:47 2017 +0100
@@ -54,16 +54,6 @@
 <!--52DDD9C0FCA04D65BE27B3D80AE7DEBD-->  <VALUE><![CDATA[../../../../../web]]></VALUE>
 <!--52DDD9C0FCA04D65BE27B3D80AE7DEBD--></AD_MODEL_OBJECT_PARA>
 
-<!--634945C93F6F451EAD0C9E9B71B6BD89--><AD_MODEL_OBJECT_PARA>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <AD_MODEL_OBJECT_PARA_ID><![CDATA[634945C93F6F451EAD0C9E9B71B6BD89]]></AD_MODEL_OBJECT_PARA_ID>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <AD_MODEL_OBJECT_ID><![CDATA[F22C501A5088415DBD7D9DC2134D5DA9]]></AD_MODEL_OBJECT_ID>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <LINE><![CDATA[180]]></LINE>
-<!--634945C93F6F451EAD0C9E9B71B6BD89-->  <NAME><![CDATA[ServidorRenderFo]]></NAME>
-<!--634945C93F6F451EAD0C9E9B71B6BD89--></AD_MODEL_OBJECT_PARA>
-
 <!--66854144AE8D4F8A935B7E2C6C3E4DA5--><AD_MODEL_OBJECT_PARA>
 <!--66854144AE8D4F8A935B7E2C6C3E4DA5-->  <AD_MODEL_OBJECT_PARA_ID><![CDATA[66854144AE8D4F8A935B7E2C6C3E4DA5]]></AD_MODEL_OBJECT_PARA_ID>
 <!--66854144AE8D4F8A935B7E2C6C3E4DA5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>