diff --git a/JasperReportsWebApp/.classpath b/JasperReportsWebApp/.classpath new file mode 100644 index 0000000000..5aec6fc719 --- /dev/null +++ b/JasperReportsWebApp/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/JasperReportsWebApp/.project b/JasperReportsWebApp/.project new file mode 100644 index 0000000000..12f20db14f --- /dev/null +++ b/JasperReportsWebApp/.project @@ -0,0 +1,12 @@ + + + JasperReportsWebApp + + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/JasperReportsWebApp/RUN_build.bat b/JasperReportsWebApp/RUN_build.bat new file mode 100644 index 0000000000..8109888069 --- /dev/null +++ b/JasperReportsWebApp/RUN_build.bat @@ -0,0 +1,15 @@ +@CALL ..\utils_dev\myDevEnv.bat +@IF NOT %COMPIERE_ENV%==Y GOTO NOBUILD + +@echo Cleanup ... +@%JAVA_HOME%\bin\java -Dant.home="." %ANT_PROPERTIES% org.apache.tools.ant.Main clean + +@echo Building ... +@%JAVA_HOME%\bin\java -Dant.home="." %ANT_PROPERTIES% org.apache.tools.ant.Main main + +@REM @pause +@REM @exit + +:NOBUILD +@Echo Check myDevEnv.bat (copy from myDevEnvTemplate.bat) +@REM @Pause diff --git a/JasperReportsWebApp/RUN_build.sh b/JasperReportsWebApp/RUN_build.sh new file mode 100644 index 0000000000..b9768666a0 --- /dev/null +++ b/JasperReportsWebApp/RUN_build.sh @@ -0,0 +1,18 @@ +# Module compiling script +# Ported from Windows script Marek Mosiewicz + + +SAVED_DIR=`pwd` #save current dir +cd `dirname $0`/../utils_dev #change dir to place where script resides - doesn not work with sym links +UTILS_DEV=`pwd` #this is compiere source +cd $SAVED_DIR #back to the saved directory + +. $UTILS_DEV/myDevEnv.sh #call environment +echo done +if [ ! $COMPIERE_ENV==Y ] ; then + echo "Can't set developemeent environemnt - check myDevEnv.sh" + exit 1 +fi + +echo running Ant +$JAVA_HOME/bin/java -Dant.home="." $ANT_PROPERTIES org.apache.tools.ant.Main diff --git a/JasperReportsWebApp/build.xml b/JasperReportsWebApp/build.xml new file mode 100644 index 0000000000..03b05531a0 --- /dev/null +++ b/JasperReportsWebApp/build.xml @@ -0,0 +1,63 @@ + + + + + + + + Build the UI subproject within the Compiere project. + + + + + + + + + + + + + + + + + + + ------ Compiling webApp + + + + + + + + ------ Executing xdoclet + + + + + ------ packaging + + + + + ------ deploying interfaces to JasperReports + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JasperReportsWebApp/deploy/WebApp.ear/META-INF/application.xml b/JasperReportsWebApp/deploy/WebApp.ear/META-INF/application.xml new file mode 100644 index 0000000000..fa7c460f01 --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/META-INF/application.xml @@ -0,0 +1,17 @@ + + + Web App + + webAppEJB.jar + + + + webApp.war + /webApp + + + diff --git a/JasperReportsWebApp/deploy/WebApp.ear/META-INF/ejb-jar.xml b/JasperReportsWebApp/deploy/WebApp.ear/META-INF/ejb-jar.xml new file mode 100644 index 0000000000..3f7e18a484 --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/META-INF/ejb-jar.xml @@ -0,0 +1,69 @@ + + + + + + No Description. + Generated by XDoclet + + + + + + + Compiere Server MD5 hash computation + + compiere/MD5 + + org.compiere.interfaces.MD5Home + org.compiere.interfaces.MD5 + org.compiere.ejb.MD5Bean + Stateless + Bean + + + ejb/compiere/MD5 + Session + org.compiere.interfaces.MD5Home + org.compiere.interfaces.MD5 + compiere/MD5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JasperReportsWebApp/deploy/WebApp.ear/META-INF/jboss.xml b/JasperReportsWebApp/deploy/WebApp.ear/META-INF/jboss.xml new file mode 100644 index 0000000000..ff00bff041 --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/META-INF/jboss.xml @@ -0,0 +1,18 @@ + + + + + + + + + compiere/MD5 + ejb/compiere/MD5 + + + + + + + + diff --git a/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/WEB-INF/jboss-web.xml b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..32155d3c44 --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/WEB-INF/jboss-web.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + ejb/compiere/MD5 + ejb/compiere/MD5 + + + + + + diff --git a/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/WEB-INF/web.xml b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/WEB-INF/web.xml new file mode 100644 index 0000000000..046410ec5e --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/WEB-INF/web.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + GetMD5File + Name for GetMD5File + + org.compiere.web.GetMD5FileServlet + + + A parameter + A value + + + + + + GetMD5File + /GetMD5File + + + + + + + + + + + + ejb/compiere/MD5 + Session + org.compiere.interfaces.MD5Home + org.compiere.interfaces.MD5 + + + diff --git a/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/index.html b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/index.html new file mode 100644 index 0000000000..971dec5b01 --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/index.html @@ -0,0 +1,37 @@ + + + + + Compiere Jasper integration + + + + + + + + + + + + + + SourceForge.net Logo +

Compiere Jasper Integration


+

under construction

web designer wanted!


+Please visite the sourceforge project page here
+If you want to join the project don't hesitate to contact
Developers, web designer and testers are welcomed

+Access directly to latest files here
and the documentation here
+Browse the JavaDoc here

Don't hesitate to use the forums it is the best place for any help
+ +
License information: the Open software presented here is under GPL license, but you must agree each license of each specific part included (ie: Compiere,jasperreports,iText, ant,..) each Trademark is propritary of its owner
+
+ + + diff --git a/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/standalone.jrxml b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/standalone.jrxml new file mode 100644 index 0000000000..04400fb026 --- /dev/null +++ b/JasperReportsWebApp/deploy/WebApp.ear/webApp.war/standalone.jrxml @@ -0,0 +1,152 @@ + + + + + + + <band height="782"> + <staticText> + <reportElement x="0" y="50" width="150" height="40"/> + <textElement/> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="50" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="50" width="150" height="40"/><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="100" width="150" height="40"/> + <textElement> + <font size="12"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="100" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="100" width="150" height="40"/><textElement><font size="14"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="150" width="150" height="40"/> + <textElement> + <font fontName="serif" size="12" pdfFontName="Times-Roman"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="150" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="150" width="150" height="40"/><textElement><font fontName="serif" size="12" pdfFontName="Times-Roman"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="200" width="150" height="40"/> + <textElement> + <font fontName="serif" size="12" isBold="true" isItalic="true" pdfFontName="Times-BoldItalic"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="200" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="200" width="150" height="40"/><textElement><font fontName="serif" size="12" isBold="true" isItalic="true" pdfFontName="Times-BoldItalic"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="250" width="150" height="40"/> + <textElement> + <font fontName="Comic Sans MS" size="12" isBold="false" pdfFontName="COMIC.TTF"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="250" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="250" width="150" height="40"/><textElement><font fontName="Comic Sans MS" size="12" isBold="false" pdfFontName="COMIC.TTF"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="300" width="150" height="40"/> + <textElement> + <font fontName="Comic Sans MS" size="12" isBold="true" pdfFontName="COMICBD.TTF"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="300" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="300" width="150" height="40"/><textElement><font fontName="Comic Sans MS" size="12" isBold="true" pdfFontName="COMICBD.TTF"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="350" width="150" height="40"/> + <textElement> + <font fontName="monospaced" size="12" isItalic="true" isUnderline="true" pdfFontName="Courier-Oblique"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="350" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="350" width="150" height="40"/><textElement><font fontName="monospaced" size="12" isItalic="true" isUnderline="true" pdfFontName="Courier-Oblique"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="400" width="150" height="40"/> + <textElement> + <font fontName="monospaced" size="12" isBold="true" isStrikeThrough="true" pdfFontName="Courier-Bold"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="400" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="400" width="150" height="40"/><textElement><font fontName="monospaced" size="12" isBold="true" isStrikeThrough="true" pdfFontName="Courier-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement x="0" y="450" width="150" height="40" forecolor="#ff0000"/> + <textElement> + <font size="14"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="450" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="450" width="150" height="40" forecolor="red"/><textElement><font size="14"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="0" y="500" width="150" height="40" forecolor="#ff00" backcolor="#ffff00"/> + <textElement> + <font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="500" width="390" height="40"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="500" width="150" height="40" forecolor="green" backcolor="#FFFF00" mode="Opaque"/><textElement><font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="0" y="550" width="150" height="90" forecolor="#ff" backcolor="#ffdd99"/> + <textElement textAlignment="Center" verticalAlignment="Middle"> + <font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="550" width="390" height="90"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="550" width="150" height="90" forecolor="blue" backcolor="#FFDD99" mode="Opaque"/><textElement textAlignment="Center" verticalAlignment="Middle"><font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + <staticText> + <reportElement mode="Opaque" x="0" y="650" width="150" height="90" forecolor="#ff0000" backcolor="#99ddff"/> + <textElement textAlignment="Right" verticalAlignment="Bottom"> + <font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/> + </textElement> + <text><![CDATA[The quick brown fox jumps over the lazy dog.]]></text> + </staticText> + <staticText> + <reportElement x="160" y="650" width="390" height="90"/> + <textElement/> + <text><![CDATA[<staticText><reportElement x="0" y="650" width="150" height="90" forecolor="red" backcolor="#99DDFF" mode="Opaque"/><textElement textAlignment="Right" verticalAlignment="Bottom"><font fontName="serif" size="12" isBold="true" pdfFontName="Times-Bold"/></textElement><text>The quick brown fox jumps over the lazy dog.</text></staticText>]]></text> + </staticText> + </band> + + diff --git a/JasperReportsWebApp/packaging-build.xml b/JasperReportsWebApp/packaging-build.xml new file mode 100644 index 0000000000..e913996ab6 --- /dev/null +++ b/JasperReportsWebApp/packaging-build.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JasperReportsWebApp/src/META-INF/application.xml b/JasperReportsWebApp/src/META-INF/application.xml new file mode 100644 index 0000000000..fa7c460f01 --- /dev/null +++ b/JasperReportsWebApp/src/META-INF/application.xml @@ -0,0 +1,17 @@ + + + Web App + + webAppEJB.jar + + + + webApp.war + /webApp + + + diff --git a/JasperReportsWebApp/src/META-INF/ejb-jar.xml b/JasperReportsWebApp/src/META-INF/ejb-jar.xml new file mode 100644 index 0000000000..81ee087bde --- /dev/null +++ b/JasperReportsWebApp/src/META-INF/ejb-jar.xml @@ -0,0 +1,69 @@ + + + + + + No Description. + Generated by XDoclet + + + + + + + Compiere Server MD5 hash computation + + compiere/MD5 + + org.compiere.interfaces.MD5Home + org.compiere.interfaces.MD5 + org.compiere.ejb.MD5Bean + Stateless + Bean + + + ejb/compiere/MD5 + Session + org.compiere.interfaces.MD5Home + org.compiere.interfaces.MD5 + compiere/MD5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JasperReportsWebApp/src/META-INF/jboss.xml b/JasperReportsWebApp/src/META-INF/jboss.xml new file mode 100644 index 0000000000..ca60ebc742 --- /dev/null +++ b/JasperReportsWebApp/src/META-INF/jboss.xml @@ -0,0 +1,18 @@ + + + + + + + + + compiere/MD5 + ejb/compiere/MD5 + + + + + + + + diff --git a/JasperReportsWebApp/src/WEB-INF/jboss-web.xml b/JasperReportsWebApp/src/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..3074a41536 --- /dev/null +++ b/JasperReportsWebApp/src/WEB-INF/jboss-web.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + ejb/compiere/MD5 + ejb/compiere/MD5 + + + + \ No newline at end of file diff --git a/JasperReportsWebApp/src/WEB-INF/web.xml b/JasperReportsWebApp/src/WEB-INF/web.xml new file mode 100644 index 0000000000..770301b2ea --- /dev/null +++ b/JasperReportsWebApp/src/WEB-INF/web.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + GetMD5File + Name for GetMD5File + + org.compiere.web.GetMD5FileServlet + + + A parameter + A value + + + + + + + + GetMD5File + /GetMD5File + + + + + + + + + + + + ejb/compiere/MD5 + Session + org.compiere.interfaces.MD5Home + org.compiere.interfaces.MD5 + + + diff --git a/JasperReportsWebApp/src/org/compiere/ejb/MD5Bean.java b/JasperReportsWebApp/src/org/compiere/ejb/MD5Bean.java new file mode 100644 index 0000000000..93e9e6cfc6 --- /dev/null +++ b/JasperReportsWebApp/src/org/compiere/ejb/MD5Bean.java @@ -0,0 +1,143 @@ +/* + * Créé le 22 mars 2005 + * + * TODO Pour changer le modèle de ce fichier généré, allez à : + * Fenêtre - Préférences - Java - Style de code - Modèles de code + */ +package org.compiere.ejb; + +import java.net.URL; +import java.rmi.RemoteException; + +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; + +import org.compiere.util.CLogger; +import org.compiere.utils.DigestOfFile; + +/** + * @ejb:bean name="compiere/MD5" + * display-name="Compiere Server MD5 hash computation" + * type="Stateless" + * transaction-type="Bean" + * jndi-name="ejb/compiere/MD5" + * view-type="remote" + * + * @ejb:ejb-ref ejb-name="compiere/MD5" + * ref-name="compiere/MD5" + */ +public class MD5Bean implements SessionBean { + + private static final long serialVersionUID = 1L; + /** + * + */ + private CLogger log = null; + + public MD5Bean() { + super(); + log = CLogger.getCLogger(MD5Bean.class); + } + + /* (non-Javadoc) + * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext) + */ + public void setSessionContext(SessionContext ctx) + throws EJBException, + RemoteException { + // TODO Raccord de méthode auto-généré + + } + + /* (non-Javadoc) + * @see javax.ejb.SessionBean#ejbRemove() + */ + public void ejbRemove() throws EJBException, RemoteException { + // TODO Raccord de méthode auto-généré + + } + + /* (non-Javadoc) + * @see javax.ejb.SessionBean#ejbActivate() + */ + public void ejbActivate() throws EJBException, RemoteException { + // TODO Raccord de méthode auto-généré + + } + + /* (non-Javadoc) + * @see javax.ejb.SessionBean#ejbPassivate() + */ + public void ejbPassivate() throws EJBException, RemoteException { + // TODO Raccord de méthode auto-généré + + } + + /** + * Default create method + * + * @throws CreateException + * @ejb.create-method + */ + public void ejbCreate() throws CreateException { + // TODO Auto-generated method stub + } + + /** + * Business method + * @ejb.interface-method view-type = "remote" + * @param FileName + * @return hash base64 encoded + */ + public String getFileMD5(String FileName) { + String hash = null; + String absoluteFilename = null; + String filepartOnly = null; + try + { + //Thread.currentThread().getContextClassLoader().getResource(""); + if ( FileName.startsWith("http://") ) + { + //extract absolute path by requesting jboss/tomcat + String[] filePathParts = FileName.split("/"); + filepartOnly = filePathParts[filePathParts.length-1]; + URL currentFile = Thread.currentThread().getContextClassLoader().getResource(filepartOnly); + System.out.println(filepartOnly); + absoluteFilename = currentFile.getFile(); + log.info("decoded absolute path name for "+filepartOnly +" is "+absoluteFilename); + } + else + { + absoluteFilename = FileName; + } + + if (absoluteFilename != null) + { + DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); + hash = md5DigestAgent.digestAsBase64(new java.io.File(absoluteFilename)); + } + + } + catch(Exception e) + { + log.severe(e.getMessage()); + return null; + } + + return hash; + } + + /** + * Business method + * @ejb.interface-method view-type = "remote" + * @param Filename + * @return AbsolutePath on server + */ + public String getFileAsolutePath(String Filename) + { + java.net.URL currentFile = Thread.currentThread().getContextClassLoader().getResource(Filename); + return currentFile.toString(); + } +} \ No newline at end of file diff --git a/JasperReportsWebApp/src/org/compiere/interfaces/MD5.java b/JasperReportsWebApp/src/org/compiere/interfaces/MD5.java new file mode 100644 index 0000000000..c1307f2849 --- /dev/null +++ b/JasperReportsWebApp/src/org/compiere/interfaces/MD5.java @@ -0,0 +1,35 @@ +/* + * Generated file - Do not edit! + */ +package org.compiere.interfaces; + +import java.lang.*; +import java.net.URL; +import java.rmi.RemoteException; +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +import org.compiere.util.CLogger; +import org.compiere.utils.DigestOfFile; + +/** + * Remote interface for compiere/MD5. + * @xdoclet-generated at Feb 27, 2006 1:18:49 PM + */ +public interface MD5 + extends javax.ejb.EJBObject +{ + /** + * Business method + * @param Filename + * @return AbsolutePath on server */ + public java.lang.String getFileAsolutePath( java.lang.String Filename ) throws java.rmi.RemoteException; + + /** + * Business method + * @param FileName + * @return hash base64 encoded */ + public java.lang.String getFileMD5( java.lang.String FileName ) throws java.rmi.RemoteException; + +} diff --git a/JasperReportsWebApp/src/org/compiere/interfaces/MD5Home.java b/JasperReportsWebApp/src/org/compiere/interfaces/MD5Home.java new file mode 100644 index 0000000000..ba6bd22aba --- /dev/null +++ b/JasperReportsWebApp/src/org/compiere/interfaces/MD5Home.java @@ -0,0 +1,28 @@ +/* + * Generated file - Do not edit! + */ +package org.compiere.interfaces; + +import java.lang.*; +import java.net.URL; +import java.rmi.RemoteException; +import javax.ejb.CreateException; +import javax.ejb.EJBException; +import javax.ejb.SessionBean; +import javax.ejb.SessionContext; +import org.compiere.util.CLogger; +import org.compiere.utils.DigestOfFile; + +/** + * Home interface for compiere/MD5. Lookup using {1} + * @xdoclet-generated at Feb 27, 2006 1:18:49 PM + */ +public interface MD5Home + extends javax.ejb.EJBHome +{ + public static final String COMP_NAME="java:comp/env/ejb/compiere/MD5"; + public static final String JNDI_NAME="ejb/compiere/MD5"; + + public org.compiere.interfaces.MD5 create() throws javax.ejb.CreateException, java.rmi.RemoteException; + +} diff --git a/JasperReportsWebApp/src/org/compiere/utils/DigestOfFile.java b/JasperReportsWebApp/src/org/compiere/utils/DigestOfFile.java new file mode 100644 index 0000000000..ecf2547c17 --- /dev/null +++ b/JasperReportsWebApp/src/org/compiere/utils/DigestOfFile.java @@ -0,0 +1,130 @@ +package org.compiere.utils; + +import java.security.*; +import sun.security.provider.Sun; +import java.io.*; + +import sun.misc.*; + + +/** + * @author rlemeill + * + */ +public class DigestOfFile +{ + /** + * @param mode ie MD5 + * @throws Exception + */ + public DigestOfFile(String mode) throws Exception + { + digestAgent = MessageDigest.getInstance(mode, "SUN"); + } + + /** + * @param file to hash + * @return hash + * @throws Exception + */ + synchronized public byte[] digestAsByteArray(File file) throws Exception + { + digestAgent.reset(); + InputStream is = new BufferedInputStream(new FileInputStream(file)); + for (int bytesRead = 0; (bytesRead = is.read(buffer)) >= 0;) + { + digestAgent.update(buffer, 0, bytesRead); + } + is.close(); + byte[] digest = digestAgent.digest(); + return digest; + } + + /** + * @author rlemeill + * @param file + * @return hash (base64 encoded) + * @throws Exception + */ + synchronized public String digestAsBase64(File file) throws Exception + { + byte[] digest = digestAsByteArray(file); + String digestAsBase64 = base64Encoder.encode(digest); + return digestAsBase64; + } + + + + //private static final char[] HEX_CHARS = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + + private MessageDigest digestAgent; + private BASE64Encoder base64Encoder = new BASE64Encoder(); + private byte[] buffer = new byte[4096]; + + /** + * @author rlemeill + * @param args file + */ + public static void main(String[] args) + { + try + { + java.security.Security.addProvider(new Sun()); + + DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); + + for (int argIndex = 0; argIndex < args.length; argIndex++) + { + { + String base64Digest = md5DigestAgent.digestAsBase64(new File(args[argIndex])); + System.out.println("Base64 MD5 of " + args[argIndex] + " = [" + base64Digest + "]"); + } + } + } + catch (Exception e) + { + e.printStackTrace(System.out); + } + } + + + /** + * @param file1 first file to compare + * @param file2 second file to compare + * @return true if files are identic false otherwise + */ + public static boolean md5localHashCompare(File file1,File file2) + { + //compute Hash of exisiting and downloaded + String hashFile1; + String hashFile2; + java.security.Security.addProvider(new Sun()); + try{ + DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); + hashFile1 = md5DigestAgent.digestAsBase64(file1); + hashFile2 = md5DigestAgent.digestAsBase64(file2); + return hashFile1.equals(hashFile2) ; } + catch (Exception e) + { + return false; //if there is an error during comparison return files are difs + } + } + + /** + * @param file + * @return md5 hash null if file is not found or other error + */ + public static String GetLocalMD5Hash(File file) + { + String hash; + java.security.Security.addProvider(new Sun()); + try{ + DigestOfFile md5DigestAgent = new DigestOfFile("MD5"); + hash = md5DigestAgent.digestAsBase64(file); + return hash; } + catch (Exception e) + { + return null; //if there is an error during comparison return files are difs + } + } +} diff --git a/JasperReportsWebApp/src/org/compiere/utils/MD5EjbTest.java b/JasperReportsWebApp/src/org/compiere/utils/MD5EjbTest.java new file mode 100644 index 0000000000..99514f9d08 --- /dev/null +++ b/JasperReportsWebApp/src/org/compiere/utils/MD5EjbTest.java @@ -0,0 +1,98 @@ +/* + * Créé le 26 mars 2005 + * + * TODO Pour changer le modèle de ce fichier généré, allez à : + * Fenêtre - Préférences - Java - Style de code - Modèles de code + */ +package org.compiere.utils; + +import java.net.InetAddress; +import java.util.Hashtable; + +import javax.naming.InitialContext; + +import org.compiere.interfaces.MD5; +import org.compiere.interfaces.MD5Home; +/** + * @author rlemeill + */ + +public class MD5EjbTest { + + /************************************************************************** + * constructor + * @param serverName + * @param context + * @param Filename + */ + public MD5EjbTest (String serverName,String Filename) + { + Hashtable env = new Hashtable(); + env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); + env.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); + env.put(InitialContext.PROVIDER_URL, serverName); + System.out.println ("Creating context ..."); + System.out.println (" " + env); + InitialContext context = null; + try + { + context = new InitialContext(env); + } + catch (Exception e) + { + System.err.println("ERROR: Could not create context: " + e); + return; + } + testEjb(serverName,context,Filename); + } + + + /************************************************************************** + * testing entry point + * @param serverName + * @param context + * @param Filename + */ + public static void testEjb(String serverName, InitialContext context, String Filename) + { + try{ + System.out.println("MD5Home Creation at: "+MD5Home.JNDI_NAME); + MD5Home home = (MD5Home)context.lookup(MD5Home.JNDI_NAME); + MD5 md5 = home.create(); + System.out.println("Creation OK"); + System.out.println("MD5 for " + Filename + " is " +md5.getFileMD5(Filename)); + md5.remove(); + } + catch(Exception e) + { + + } + } + + /************************************************************************** + * Start Method + * @param args serverName Filename + */ + public static void main(String[] args) + { + String serverName = null; + String Filename = null; + if (args.length > 0) + serverName = args[0]; + if (args.length > 1) + Filename = args[1]; + if (serverName == null || serverName.length() == 0) + { + try + { + serverName = InetAddress.getLocalHost().getHostName(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + MD5EjbTest myMD5EjbTest = new MD5EjbTest(serverName,Filename); + + } +} diff --git a/JasperReportsWebApp/src/org/compiere/web/GetMD5FileServlet.java b/JasperReportsWebApp/src/org/compiere/web/GetMD5FileServlet.java new file mode 100644 index 0000000000..59f763a3c5 --- /dev/null +++ b/JasperReportsWebApp/src/org/compiere/web/GetMD5FileServlet.java @@ -0,0 +1,91 @@ +/* + * Créé le 22 mars 2005 + * + * TODO Pour changer le modèle de ce fichier généré, allez à : + * Fenêtre - Préférences - Java - Style de code - Modèles de code + */ +package org.compiere.web; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.servlet.http.HttpServlet; + +import javax.servlet.ServletException; +import javax.servlet.ServletConfig; +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.compiere.interfaces.MD5; +import org.compiere.interfaces.MD5Home; + + +/** + * Servlet Class + * + * @web.servlet name="GetMD5File" + * display-name="Name for GetMD5File" + * description="Description for GetMD5File" + * @web.servlet-mapping url-pattern="/GetMD5File" + * @web.servlet-init-param name="A parameter" + * value="A value" + * @web.ejb-ref name="ejb/compiere/MD5" + * type="Session" + * home = "org.compiere.interfaces.MD5Home" + * remote = "org.compiere.interfaces.MD5" + * + * @jboss.ejb-ref-jndi ref-name="ejb/compiere/MD5" + * jndi-name = "ejb/compiere/MD5" + */ +public class GetMD5FileServlet extends HttpServlet { + + /** + * + */ + private MD5Home home; + + public GetMD5FileServlet() { + super(); + // TODO Raccord de constructeur auto-généré + } + + public void init(ServletConfig config) throws ServletException { + super.init(config); + try + { + Context context = new InitialContext(); + Object ref = context.lookup("java:/comp/env/ejb/compiere/MD5"); + home = (MD5Home)javax.rmi.PortableRemoteObject.narrow(ref,MD5Home.class); + } + catch(Exception e) + { + throw new ServletException("Error getting EJB: java:/comp/env/ejb/compiere/MD5"); + } + } + + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, + IOException { + // TODO Auto-generated method stub + MD5 md5=null; + String file = req.getParameter("File"); + PrintWriter out = resp.getWriter(); + out.println("MD5 Hash"); + try + { + md5 = home.create(); + } + catch(javax.ejb.CreateException e) + { + out.println("

Error javax.ejb.CreateException home.create();

"); + out.println(""); + throw new ServletException("Error CreateException"); + } + out.println("File is: "+ file + "
MD5 : "+ md5.getFileMD5(file)+"
"); + //out.println(md5.getFileAsolutePath(file)); + out.println(""); + } + +} \ No newline at end of file diff --git a/JasperReportsWebApp/xdoclet-build.xml b/JasperReportsWebApp/xdoclet-build.xml new file mode 100644 index 0000000000..8b40e4696f --- /dev/null +++ b/JasperReportsWebApp/xdoclet-build.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-------------------- +ATTENTION It needs xdoclet 1.2.3 in tools/lib$ +you can download it at http://xdoclet.sourceforge.net +-------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +