diff --git a/webCM/.classpath b/webCM/.classpath
new file mode 100644
index 0000000000..31fda05130
--- /dev/null
+++ b/webCM/.classpath
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/webCM/.packaging b/webCM/.packaging
new file mode 100644
index 0000000000..a336b0bb42
--- /dev/null
+++ b/webCM/.packaging
@@ -0,0 +1,2 @@
+
+
diff --git a/webCM/.project b/webCM/.project
new file mode 100644
index 0000000000..640dfd7c51
--- /dev/null
+++ b/webCM/.project
@@ -0,0 +1,17 @@
+
+
+ webCM
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/webCM/.settings/com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs b/webCM/.settings/com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs
new file mode 100644
index 0000000000..214fea8850
--- /dev/null
+++ b/webCM/.settings/com.genuitec.jboss.ide.eclipse.xdoclet.run.prefs
@@ -0,0 +1,4 @@
+#Sun Jun 11 17:51:42 PDT 2006
+eclipse.preferences.version=1
+xdoclet.build.policy=automatic
+xdoclet.jdk.support=jdk5
diff --git a/webCM/.settings/org.eclipse.ltk.core.refactoring.prefs b/webCM/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 0000000000..1562767b46
--- /dev/null
+++ b/webCM/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,3 @@
+#Sat Sep 16 18:27:05 CEST 2006
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/webCM/.settings/org.eclipse.wst.validation.prefs b/webCM/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 0000000000..79ab30f281
--- /dev/null
+++ b/webCM/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,6 @@
+#Sat Sep 16 18:27:05 CEST 2006
+DELEGATES_PREFERENCE=delegateValidatorList
+USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator;org.eclipse.jst.jsp.core.internal.validation.JSPELValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;
+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator;org.eclipse.jst.jsp.core.internal.validation.JSPELValidator;org.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;
+USER_PREFERENCE=overrideGlobalPreferencesfalse
+eclipse.preferences.version=1
diff --git a/webCM/.settings/org.hibernate.eclipse.console.prefs b/webCM/.settings/org.hibernate.eclipse.console.prefs
new file mode 100644
index 0000000000..cf74dec012
--- /dev/null
+++ b/webCM/.settings/org.hibernate.eclipse.console.prefs
@@ -0,0 +1,4 @@
+#Thu Mar 02 17:55:23 CET 2006
+default.configuration=
+eclipse.preferences.version=1
+hibernate3.enabled=false
diff --git a/webCM/.xdoclet b/webCM/.xdoclet
new file mode 100644
index 0000000000..a336b0bb42
--- /dev/null
+++ b/webCM/.xdoclet
@@ -0,0 +1,2 @@
+
+
diff --git a/webCM/RUN_build.bat b/webCM/RUN_build.bat
new file mode 100644
index 0000000000..70faed51ef
--- /dev/null
+++ b/webCM/RUN_build.bat
@@ -0,0 +1,19 @@
+@Title Build Adempiere Root
+@Rem $Header: /cvs/adempiere/webCM/RUN_build.bat,v 1.1 2006/05/10 04:43:52 jjanke Exp $
+
+@CALL ..\utils_dev\myDevEnv.bat
+@IF NOT %ADEMPIERE_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
+
+@Echo Done ...
+@sleep 60
+@exit
+
+:NOBUILD
+@Echo Check myDevEnv.bat (copy from myDevEnvTemplate.bat)
+@Pause
diff --git a/webCM/RUN_build.sh b/webCM/RUN_build.sh
new file mode 100644
index 0000000000..5f80633c60
--- /dev/null
+++ b/webCM/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 adempiere source
+cd $SAVED_DIR #back to the saved directory
+
+. $UTILS_DEV/myDevEnv.sh #call environment
+echo done
+if [ ! $ADEMPIERE_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/webCM/build.xml b/webCM/build.xml
new file mode 100644
index 0000000000..79647eb54b
--- /dev/null
+++ b/webCM/build.xml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/webCM/documentation.bat b/webCM/documentation.bat
new file mode 100644
index 0000000000..182c3fd299
--- /dev/null
+++ b/webCM/documentation.bat
@@ -0,0 +1,5 @@
+@Rem API Documentation for Server
+
+call ..\doc\documentation.bat "src\main\client;src\main\ejb;src\main\server;src\main\servlet" doc -private
+
+@pause
diff --git a/webCM/src/ear/application.xml b/webCM/src/ear/application.xml
new file mode 100644
index 0000000000..f84b6d0050
--- /dev/null
+++ b/webCM/src/ear/application.xml
@@ -0,0 +1,15 @@
+
+
+
+ webCM
+ Adempiere Web CM
+
+
+ adempiereWebCM.war
+ /
+
+
+
diff --git a/webCM/src/main/servlet/org/compiere/cm/AdRedirector.java b/webCM/src/main/servlet/org/compiere/cm/AdRedirector.java
new file mode 100644
index 0000000000..0c142773f0
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/AdRedirector.java
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.compiere.model.*;
+
+/**
+ * AdRedirector will forward the Ad Request to the destination URL and log the request
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+@SuppressWarnings("serial")
+public class AdRedirector extends HttpServletCM
+{
+ /**
+ * Process the HTTP Get request
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ if (request.getParameter("CM_Ad_ID")!=null) {
+ try {
+ String CM_Ad_ID = request.getParameter("CM_Ad_ID");
+ MAd thisAd = new MAd(ctx, Integer.parseInt(CM_Ad_ID), "webCM");
+ thisAd.addClick(request);
+ response.sendRedirect(thisAd.getTargetURL());
+ } catch (Exception E) {
+ response.sendError(500, "Internal Error while processing Ad Redirect...");
+ }
+ } else {
+ response.sendError(500,"Unknown or illegal Ad set, can't handle request...");
+ }
+ }
+
+ /**
+ * Process the HTTP Post request
+ * to simplify we reuse the doGet functionality
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ doGet(request, response);
+ } // doPost
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/Broadcast.java b/webCM/src/main/servlet/org/compiere/cm/Broadcast.java
new file mode 100644
index 0000000000..025858885b
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/Broadcast.java
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.compiere.util.*;
+import org.compiere.cm.utils.*;
+import org.compiere.cm.xml.*;
+
+/**
+ * Broadcast Servlet This servlet normally does Page processing for all pages,
+ * so it creates context etc.
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+@SuppressWarnings("serial")
+public class Broadcast extends HttpServletCM
+{
+
+ /**
+ * Process Get Request
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doGet (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ // Create New Session
+ HttpSession sess = request.getSession (true);
+ sess.setMaxInactiveInterval (WebEnv.TIMEOUT);
+ StringBuffer output = new StringBuffer ();
+ // Check whether internalMediaURL is build up, otherwise create it. (can
+ // be started only from a servlet!)
+ if (getInternalMediaURL () == null)
+ setInternalMediaURL (request);
+ if (configLoaded && !fatalError)
+ {
+ String acceptLanguage = request.getHeader ("Accept-Language");
+ String acceptCharset = request.getHeader ("Accept-Charset");
+ LocaleHandler lhandler = new LocaleHandler (acceptLanguage,
+ acceptCharset);
+ RequestAnalyzer thisRequest = new RequestAnalyzer (this, request,
+ false, "");
+ StringBuffer xmlCode = new StringBuffer();
+ StringBuffer xmlAppend = new StringBuffer();
+
+ // Fill up ExternalMediaURL
+ //if (externalMediaURL == null) {
+ if (thisRequest.getWebProject()!=null)
+ externalMediaURL = getExternalMediaURL (thisRequest
+ .getWebProject ().get_ID ());
+ else
+ externalMediaURL = getInternalMediaURL();
+ //}
+ sess.setAttribute ("ctx", getCtx());
+ // This Request has a Processor Class Name, so we should process it!
+ if (thisRequest.getProcClassName ()!=null) {
+ try {
+ org.compiere.cm.Extend thisProcessor = thisRequest.getProcClass();
+ thisProcessor.doIt ();
+ xmlAppend.append(thisProcessor.getXML());
+ if (thisProcessor.getRedirectURL()!=null)
+ thisRequest.setRedirectURL(thisProcessor.getRedirectURL());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace ();
+ }
+
+ }
+ if (thisRequest.getIsRedirect ())
+ {
+ // If we need to redirect as the URL is different do it beofre
+ // we transmit to client
+ response.sendRedirect (thisRequest.getRedirectURL ());
+ }
+ else
+ {
+ // No need to redirect so we will display the content
+ // Generate the needed XMLCode
+ Generator thisXMLGen = new Generator (this, request,
+ thisRequest, xmlAppend);
+ xmlCode.append(thisXMLGen.get ());
+ // Get or generate Template needed
+ String xslCode = templateCache.getCM_Template (
+ thisRequest.getCM_Container ().getCM_Template_ID (),
+ thisRequest.getWebProject ().get_ID ())
+ .getPreBuildTemplate ().toString ();
+ // Put it all together
+ try
+ {
+ output.append (XSLTProcessor.run (request, xslCode, xmlCode.toString()));
+ }
+ catch (Exception E)
+ {
+ response.sendError (500);
+ }
+ // response.setContentType("text/html; charset=" +
+ // lhandler.getCharset());
+ response.setContentType ("text/html; charset=UTF-8");
+ response.setHeader ("CMBuild", buildDate);
+ PrintWriter out;
+ out = response.getWriter ();
+ out.print (output.toString ());
+ out.close ();
+
+ if (thisRequest.getWebProject()!=null) {
+ // We will log the request in a seperate task to speed up page display
+ AccessLogger thisAccessLogger = new AccessLogger(request, this, thisRequest);
+ thisAccessLogger.setFileSize(new java.math.BigDecimal(output.length()));
+ thisAccessLogger.start();
+ }
+ }
+ }
+ else if (fatalError)
+ {
+ PrintWriter out;
+ out = response.getWriter ();
+ out.print ("Fatal Error:" + ErrorMessage + "
");
+ out.close ();
+ }
+ } // doGet
+
+ /**
+ * Process Post Request (handled by get)
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doPost (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ doGet (request, response);
+ } // doPost
+} // Broadcast
diff --git a/webCM/src/main/servlet/org/compiere/cm/Community.java b/webCM/src/main/servlet/org/compiere/cm/Community.java
new file mode 100644
index 0000000000..c2bd5e4ba8
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/Community.java
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms version 2 of the GNU General Public License as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 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.
+ * You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
+ * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Properties;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.compiere.util.*;
+import org.compiere.model.*;
+import org.compiere.cm.utils.*;
+
+/**
+ * Community Servlet to handle login, BPartner create & Update etc.
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class Community extends HttpServletCM
+{
+ /** Logging */
+ private CLogger log = CLogger.getCLogger(getClass());
+
+ /**
+ * Process Get Request
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doGet (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ HttpSession sess = request.getSession (true);
+ sess.setMaxInactiveInterval (WebEnv.TIMEOUT);
+
+ Properties ctx = getCtx();
+
+ if (sess.getAttribute ("ctx")!=null)
+ ctx = (Properties) sess.getAttribute ("ctx");
+
+ if (ctx.get ("#AD_Client_ID")!=null) {
+ RequestAnalyzer thisRequest = new RequestAnalyzer(this, request, false, null);
+ }
+
+
+ WebSessionCtx wsc = (WebSessionCtx)sess.getAttribute(WebSessionCtx.NAME);
+ // Create New
+ if (wsc == null)
+ {
+ int [] allIDs = X_W_Store.getAllIDs ("W_Store", "AD_Client_ID=" + ctx.get ("#AD_Client_ID"), "");
+ if (allIDs!=null && allIDs.length>0)
+ {
+ wsc = WebSessionCtx.get(request, allIDs[0]);
+ wsc.setWStore (allIDs[0]);
+ sess.setAttribute(WebSessionCtx.NAME, wsc);
+ }
+ }
+
+ WebLogin thisLogin = new WebLogin(request, response, ctx);
+ thisLogin.init ();
+ if (!thisLogin.action ())
+ {
+ WebUtil.reload(thisLogin.getMessage(), thisLogin.getUpdate_page (), sess, request, response, getServletContext());
+ return;
+ }
+ String url = thisLogin.getForward ();
+ if (!url.startsWith("/"))
+ url = "/" + url;
+ log.info("doPost - Forward to " + url);
+ response.sendRedirect (url);
+ }
+
+ /**
+ * Process Post Request (handled by get)
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doPost (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ doGet (request, response);
+ } // doPost
+
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/Extend.java b/webCM/src/main/servlet/org/compiere/cm/Extend.java
new file mode 100644
index 0000000000..f4519251b8
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/Extend.java
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms version 2 of the GNU General Public License as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 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.
+ * You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
+ * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.Serializable;
+import org.compiere.util.*;
+import java.util.*;
+import javax.servlet.http.*;
+
+/**
+ *
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public abstract class Extend implements Serializable
+{
+ protected HttpServletRequest e_request;
+ protected HttpSession e_session;
+ protected Properties ctx;
+ protected WebInfo wi = null;
+ private StringBuffer e_xmlCode;
+ private String e_redirectURL;
+
+ /**
+ * Extend
+ * @param request
+ */
+ public Extend (HttpServletRequest request, Properties t_ctx) {
+ ctx = t_ctx;
+ e_request = request;
+ e_session = request.getSession();
+ if (e_session.getAttribute (WebInfo.NAME)!=null)
+ {
+ wi = (WebInfo) e_session.getAttribute (WebInfo.NAME);
+ }
+ e_xmlCode = new StringBuffer();
+ }
+
+ /**
+ * set XML Code
+ * @param xmlCode
+ */
+ protected void setXML(StringBuffer xmlCode)
+ {
+ e_xmlCode = xmlCode;
+ }
+
+ /**
+ * append XML Code
+ * @param xmlCode String containing XMLCode
+ */
+ public void appendXML(String xmlCode)
+ {
+ e_xmlCode.append(xmlCode);
+ }
+
+ /**
+ * append XML Code
+ * @param xmlCode Stringbuffer containing XMLCode
+ */
+ public void appendXML(StringBuffer xmlCode)
+ {
+ e_xmlCode.append(xmlCode);
+ }
+
+ /**
+ * get XML Code
+ * @returns xmlCode
+ */
+ protected StringBuffer getXML()
+ {
+ if (e_xmlCode==null)
+ return new StringBuffer("");
+ return e_xmlCode;
+ }
+
+ /**
+ * get Redirect URL
+ * @param redirectURL
+ */
+ protected String getRedirectURL()
+ {
+ return e_redirectURL;
+ }
+
+ /**
+ * set Redirect URL
+ * @param redirectURL
+ */
+ protected void setRedirectURL(String redirectURL)
+ {
+ e_redirectURL = redirectURL;
+ }
+
+ protected Properties getCtx()
+ {
+ return ctx;
+ }
+
+ protected boolean doIt()
+ {
+ return true;
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/HttpServletCM.java b/webCM/src/main/servlet/org/compiere/cm/HttpServletCM.java
new file mode 100644
index 0000000000..eb6479ce46
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/HttpServletCM.java
@@ -0,0 +1,379 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.util.*;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.*;
+import org.compiere.cm.cache.*;
+import org.compiere.util.*;
+
+/**
+ * HttpServletCM we extended the normal HttpServlet to store some global
+ * environment and cache here
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class HttpServletCM extends HttpServlet
+{
+
+ /**
+ * serialVersionUID for serializable HttpServlet
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * status if config is loaded... true if loaded false is default after
+ * startup
+ */
+ protected static boolean configLoaded = false;
+
+ /**
+ * fatalError stores a shared variable which will be set to yes whenever a
+ * global Server Error from which we can not recover occurs. You should not
+ * set it manually as will stop all servlet's and will not rerun them unless
+ * set back to false true if there is a global error false if there is no
+ * global error
+ */
+ protected static boolean fatalError = false;
+
+ /**
+ * belongs to fatalError, should get a corresponding error message to
+ * display in the web frontend. null if no error
+ */
+ protected static String ErrorMessage = null;
+
+ /**
+ * special application templates ssometimes depend on a special version,
+ * this is to give them an idea. Is included in the XML Code.
+ */
+ protected static String buildDate = "200606062343";
+
+ /**
+ * DomainCache is storing the domains of the system, to reduce DB lookups
+ */
+ protected static Domain domainCache = new Domain ();
+
+ /**
+ * WebProject is storing the projects often used by the system, to reduce DB
+ * lookups
+ */
+ protected static WebProject webProjectCache = new WebProject ();
+
+ /**
+ * ChatCache is storing the chat's often used by the system, to reduce DB
+ * lookups
+ */
+ protected static Chat chatCache = new Chat ();
+
+ /**
+ * ContainerCache is storing the containers's often used by the system, to
+ * reduce DB lookups
+ */
+ protected static Container containerCache = new Container ();
+
+ /**
+ * ContainerElementCache is storing the container's elements often used by
+ * the system, to reduce DB lookups
+ */
+ protected static ContainerElement containerElementCache = new ContainerElement ();
+
+ /**
+ * ContainerTreeCache is storing the container's tree often used by the
+ * system, to reduce DB lookups
+ */
+ protected static ContainerTree containerTreeCache = new ContainerTree ();
+
+ /**
+ * MediaServerCache is storing the project's media server in combination
+ * with Request Info
+ */
+ protected static MediaServer mediaServerCache = new MediaServer ();
+
+ /**
+ * TemplateCache stores the oftens used templates
+ */
+ protected static Template templateCache = new Template ();
+
+ /**
+ * XMLCache stores the oftens used templates
+ */
+ protected static XML xmlCache = new XML ();
+
+ /**
+ * Context of this Servlet
+ */
+ protected Properties ctx = null;
+
+ /**
+ * String containing the internal media path (should not be used for real
+ * page deployment) the normal broadcaster will replace this URL with the
+ * correct media server for this client
+ */
+ protected static String internalMediaURL = null;
+
+ /**
+ * String containing the external media URL
+ */
+ protected String externalMediaURL = null;
+
+ /** Logger */
+ protected CLogger log = CLogger.getCLogger (this.getClass ());
+
+ /**
+ * Init
+ *
+ * @param config
+ * @throws ServletException
+ */
+ public void init (ServletConfig config)
+ throws ServletException
+ {
+ super.init (config);
+ if (!WebEnv.initWeb (config))
+ throw new ServletException ("Broadcast.init");
+ if (!DB.isConnected ())
+ {
+ fatalError = true;
+ ErrorMessage = "Connection to DB dropped!";
+ log.severe ("No Database Connection!");
+ }
+ org.compiere.cm.utils.CMEnv cmEnv = new org.compiere.cm.utils.CMEnv ();
+ ctx = cmEnv.getDefaults ();
+ chatCache.setCtx (ctx);
+ containerCache.setCtx (ctx);
+ containerElementCache.setCtx (ctx);
+ containerTreeCache.setCtx (ctx);
+ domainCache.setCtx (ctx);
+ mediaServerCache.setCtx (ctx);
+ templateCache.setCtx (ctx);
+ webProjectCache.setCtx (ctx);
+ xmlCache.setCtx(ctx);
+ if (!fatalError)
+ configLoaded = true;
+ }
+
+ /**
+ * Returns the current build version/date of the servlet engine, this is
+ * used by special application templates which depend on certain
+ * functionality to check for their availability.
+ *
+ * @return the Build Date as a string in format YYYYMMDDHHMM
+ */
+ public String getBuildDate ()
+ {
+ return buildDate;
+ }
+
+ /**
+ * Returns the ContainerCache Object
+ *
+ * @return CO Object Container
+ */
+ public org.compiere.cm.cache.Container getContainerCache ()
+ {
+ return containerCache;
+ }
+
+ /**
+ * Returns the ChatCache Object
+ *
+ * @return CO Object Chat
+ */
+ public org.compiere.cm.cache.Chat getChatCache ()
+ {
+ return chatCache;
+ }
+
+ /**
+ * Returns the ContainerElementCache Object
+ *
+ * @return CO Object ContainerElement
+ */
+ public org.compiere.cm.cache.ContainerElement getContainerElementCache ()
+ {
+ return containerElementCache;
+ }
+
+ /**
+ * Returns the ContainerTreeCache Object
+ *
+ * @return CO Object ContainerElement
+ */
+ public org.compiere.cm.cache.ContainerTree getContainerTreeCache ()
+ {
+ return containerTreeCache;
+ }
+
+ /**
+ * Returns the DomainCache Object
+ *
+ * @return CO Object Domain
+ */
+ public org.compiere.cm.cache.Domain getDomainCache ()
+ {
+ return domainCache;
+ }
+
+ /**
+ * Returns the MediaServerCache Object
+ *
+ * @return CO Object MediaServer
+ */
+ public org.compiere.cm.cache.MediaServer getMediaServerCache ()
+ {
+ return mediaServerCache;
+ }
+
+ /**
+ * Returns the WebProjectCache Object
+ *
+ * @return CO Object WebProject
+ */
+ public org.compiere.cm.cache.WebProject getWebProjectCache ()
+ {
+ return webProjectCache;
+ }
+
+ /**
+ * Returns the Template Object
+ *
+ * @return CO Object Template
+ */
+ public org.compiere.cm.cache.Template getTemplateCache ()
+ {
+ return templateCache;
+ }
+
+ /**
+ * Returns the Template Object
+ *
+ * @return CO Object Template
+ */
+ public org.compiere.cm.cache.XML getXMLCache ()
+ {
+ return xmlCache;
+ }
+
+ /**
+ * Returns the internalMediaURL for replacement
+ *
+ * @return String with internal MediaURL normally context + "/" + media +
+ * "/"
+ */
+ public String getInternalMediaURL ()
+ {
+ return internalMediaURL;
+ }
+
+ /**
+ * Returns the sessionMediaURL, this is the ideal Media URL for this Request
+ *
+ * @param request
+ * the Request for this
+ * @param CM_WebProject_ID
+ * Returns the WebProject ID
+ * @return String with session MediaURL, if none found we return the
+ * internal one
+ */
+ public String getSessionMediaURL (HttpServletRequest request,
+ int CM_WebProject_ID)
+ {
+ String sessionMediaURL = getMediaServerCache ().getMediaServer (
+ getCtx (), CM_WebProject_ID, null);
+ if (sessionMediaURL == null)
+ sessionMediaURL = getInternalMediaURL ();
+ return internalMediaURL;
+ }
+
+ /**
+ * Sets internal Media URL
+ *
+ * @param request
+ */
+ public void setInternalMediaURL (HttpServletRequest request)
+ {
+ if (internalMediaURL == null)
+ {
+ internalMediaURL = request.getRequestURL ().toString ().substring (
+ 0,
+ request.getRequestURL ().toString ().indexOf (
+ request.getServerName ())
+ + request.getServerName ().length ())
+ + request.getContextPath () + "/media/";
+ }
+ }
+
+ /**
+ * Returns the Context of the current session. This is a very sensitive
+ * function as we will take care of all parameters here!
+ *
+ * @return Context
+ */
+ public Properties getCtx ()
+ {
+ return ctx;
+ }
+
+ /**
+ * Returns the current External Media URL for the Project
+ *
+ * @param CM_WebProject_ID
+ * WebProject
+ * @return ExternalMediaURL as String
+ */
+ public String getExternalMediaURL (int CM_WebProject_ID)
+ {
+ externalMediaURL = getMediaServerCache ().getMediaServer (getCtx (),
+ CM_WebProject_ID, null);
+ if (externalMediaURL != null
+ && externalMediaURL.charAt (externalMediaURL.length () - 1) != '/')
+ externalMediaURL = externalMediaURL + "/";
+ return externalMediaURL;
+ }
+
+ /**
+ * Returns the current External Media URL be carefull this Function needs to
+ * be called after the URL is set!
+ *
+ * @return ExternalMediaURL as String
+ */
+ public String getExternalMediaURL ()
+ {
+ return externalMediaURL;
+ }
+
+ /**
+ * setAD_Client_ID to update AD_Client as soon System has recognized the Client
+ * @param newVal
+ */
+ public void setAD_Client_ID(int newVal)
+ {
+ ctx.put ("#AD_Client_ID", (String) (""+newVal));
+ }
+
+ /**
+ * get Servlet Logger
+ * @return CLooger log
+ */
+ public CLogger getLogger()
+ {
+ return log;
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java b/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java
new file mode 100644
index 0000000000..fae98fd01c
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java
@@ -0,0 +1,124 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import org.compiere.model.MImage;
+import org.compiere.model.MMedia;
+import org.compiere.util.WebEnv;
+
+/**
+ * Broadcast Servlet
+ *
+ * @author $Author$
+ * @version $Id$
+ */
+@SuppressWarnings("serial")
+public class MediaBroadcast extends HttpServletCM
+{
+ /**
+ * Process the HTTP Get request
+ */
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ // Create New Session
+ HttpSession sess = request.getSession(true);
+ sess.setMaxInactiveInterval(WebEnv.TIMEOUT);
+
+ if (configLoaded && !fatalError) {
+ String requestURL = request.getRequestURL().toString();
+ String serverName = request.getServerName();
+ String baseURL = requestURL.substring(0,requestURL.indexOf(serverName)+serverName.length()+6)+request.getContextPath();
+ String relativeURL = requestURL.substring(baseURL.length());
+ // If the relativeURL still contains / we will simply strip them off...
+ if (relativeURL.indexOf("/")>=0)
+ relativeURL = relativeURL.substring(relativeURL.lastIndexOf("/")+1);
+
+ // We should have only an ID before the first dot.
+ Integer mediaID = null;
+ try {
+ if (relativeURL.indexOf(".")>=0) {
+ mediaID = Integer.parseInt(relativeURL.substring(0,relativeURL.indexOf(".")));
+ } else {
+ mediaID = Integer.parseInt(relativeURL);
+ }
+ } catch (NumberFormatException ne) {
+
+ }
+
+ if (mediaID!=null && mediaID.intValue()>0) {
+
+ MMedia thisMedia = new org.compiere.model.MMedia(webProjectCache.getCtx(),mediaID,null);
+ if (thisMedia!=null && thisMedia.get_ID()>0) {
+ if (thisMedia.getMediaType ().equals ("CSS")) {
+ response.setContentType("text/css");
+ // Text Content will get handled via direct Stream
+ response.setContentLength (thisMedia.getContentText ().length ());
+ PrintWriter out;
+ out = response.getWriter ();
+ out.print (thisMedia.getContentText ());
+ out.close ();
+ } else {
+ response.setContentType(thisMedia.getMediaType());
+ // Binary / Image content will get handled here
+ MImage thisImage = thisMedia.getImage();
+ response.setContentLength(thisImage.getData().length);
+
+ // Open the file and output streams
+ byte[] buffer = thisImage.getData();
+ ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ OutputStream out = response.getOutputStream();
+
+ // Copy the contents of the file to the output stream
+ byte[] buf = new byte[1024];
+ int count = 0;
+ while ((count = in.read(buf)) >= 0) {
+ out.write(buf, 0, count);
+ }
+ in.close();
+ out.close();
+ }
+ } else {
+ response.sendError(404);
+ }
+ } else {
+ response.sendError(404);
+ }
+ } else if (fatalError) {
+ response.sendError(500, ErrorMessage);
+ }
+ } // doGet
+
+
+ /**
+ * Process the HTTP Post request
+ */
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ doGet(request, response);
+ } // doPost
+
+} // Broadcast
diff --git a/webCM/src/main/servlet/org/compiere/cm/RequestServlet.java b/webCM/src/main/servlet/org/compiere/cm/RequestServlet.java
new file mode 100644
index 0000000000..03274d5103
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/RequestServlet.java
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms version 2 of the GNU General Public License as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 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.
+ * You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
+ * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.compiere.cm.request.Request;
+import org.compiere.util.CLogger;
+import org.compiere.util.WebEnv;
+import org.compiere.util.WebSessionCtx;
+import org.compiere.util.WebUtil;
+
+/**
+ * Request Servlet to handle Request create & Update etc.
+ *
+ * @author Kai Viiksaar
+ * @version $Id: RequestServlet.java,v 1.1 2006/10/11 06:30:11 comdivision Exp $
+ */
+public class RequestServlet extends HttpServletCM {
+ /** Logging */
+ private CLogger log = CLogger.getCLogger(getClass());
+
+ /**
+ * Process Get Request
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doGet (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ String l_szRequestID = null;
+ HttpSession sess = request.getSession (true);
+ sess.setMaxInactiveInterval (WebEnv.TIMEOUT);
+
+ Properties ctx = getCtx();
+
+ if (sess.getAttribute ("ctx")!=null)
+ ctx = (Properties) sess.getAttribute ("ctx");
+
+ WebSessionCtx wsc = (WebSessionCtx)sess.getAttribute(WebSessionCtx.NAME);
+
+ // Create New Request
+ if (wsc != null) {
+ String mode = WebUtil.getParameter(request, "Mode");
+ if (mode != null && mode.equals("RequestNew")) {
+ l_szRequestID = Request.createRequest(request, ctx);
+ } else if (mode != null && mode.equals("RequestChange")) {
+ l_szRequestID = Request.changeRequest(request, ctx);
+ }
+ }
+ String url = request.getParameter("ForwardTo") + l_szRequestID;
+ if (!url.startsWith("/"))
+ url = "/" + url;
+ response.sendRedirect(url);
+ }
+
+ /**
+ * Process Post Request (handled by get)
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doPost (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ doGet (request, response);
+ } // doPost
+
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/StageBroadcast.java b/webCM/src/main/servlet/org/compiere/cm/StageBroadcast.java
new file mode 100644
index 0000000000..a7f61856fb
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/StageBroadcast.java
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.*;
+import java.util.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import org.compiere.Adempiere;
+import org.compiere.util.*;
+import org.compiere.model.*;
+import org.compiere.cm.utils.*;
+import org.compiere.cm.xml.*;
+
+/**
+ * Broadcast Servlet
+ *
+ * @author $Author$
+ * @version $Id$
+ */
+public class StageBroadcast extends HttpServletCM
+{
+
+ /**
+ * Handle Get Request
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doGet (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ // Create New Session
+ HttpSession sess = request.getSession (true);
+ sess.setMaxInactiveInterval (WebEnv.TIMEOUT);
+ StringBuffer output = new StringBuffer ();
+ if (configLoaded && !fatalError)
+ {
+ String acceptLanguage = request.getHeader ("Accept-Language");
+ String acceptCharset = request.getHeader ("Accept-Charset");
+ LocaleHandler lhandler = new LocaleHandler (acceptLanguage,
+ acceptCharset);
+ RequestAnalyzer thisRequest = new RequestAnalyzer (this, request,
+ true, "");
+ if (thisRequest.getIsRedirect ())
+ {
+ // If we need to redirect as the URL is different do it beofre
+ // we transmit to client
+ response.sendRedirect (thisRequest.getRedirectURL ());
+ }
+ else
+ {
+ // No need to redirect so we will display the content
+ // Generate the needed XMLCode
+ Generator thisXMLGen = new Generator (this, request,
+ thisRequest, new StringBuffer(""));
+ // thisXMLGen.addPObject(thisRequest.getCM_Container());
+ String xmlCode = thisXMLGen.get ();
+ // Get or generate Template needed
+ String xslCode = templateCache.getCM_Template (
+ thisRequest.getCM_Container ().getCM_Template_ID (),
+ thisRequest.getWebProject ().get_ID ())
+ .getTemplateXST ();
+ // Put it all together
+ try
+ {
+ output.append (XSLTProcessor.run (request, xslCode, xmlCode));
+ }
+ catch (Exception E)
+ {
+ response.sendError (500);
+ }
+ response.setContentType ("text/html; charset="
+ + lhandler.getCharset ());
+ response.setHeader ("CMBuild", buildDate);
+ PrintWriter out;
+ out = response.getWriter ();
+ out.print (output.toString ());
+ out.close ();
+ }
+ }
+ else if (fatalError)
+ {
+ PrintWriter out;
+ out = response.getWriter ();
+ out.print ("Fatal Error:" + ErrorMessage + "
");
+ out.close ();
+ }
+ } // doGet
+
+ /**
+ * Process Post Request - handled by Get
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doPost (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ doGet (request, response);
+ } // doPost
+} // Broadcast
diff --git a/webCM/src/main/servlet/org/compiere/cm/XMLBroadcast.java b/webCM/src/main/servlet/org/compiere/cm/XMLBroadcast.java
new file mode 100644
index 0000000000..dfc0b70e78
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/XMLBroadcast.java
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.compiere.cm.utils.RequestAnalyzer;
+import org.compiere.cm.xml.Generator;
+
+/**
+ * @author YS
+ * @version $Id$
+ */
+public class XMLBroadcast extends HttpServletCM
+{
+ /**
+ * Get
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public void doGet (HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ RequestAnalyzer thisRequest = new RequestAnalyzer (this, request,
+ false, "/xml");
+ // Even if we will only display the XML tree we are forced to build the Media URLs
+ if (getInternalMediaURL () == null)
+ setInternalMediaURL (request);
+ if (externalMediaURL == null) {
+ if (thisRequest.getWebProject()!=null)
+ externalMediaURL = getExternalMediaURL (thisRequest
+ .getWebProject ().get_ID ());
+ else
+ externalMediaURL = getInternalMediaURL();
+
+ }
+ // Generate the needed XMLCode
+ Generator thisXMLGen = new Generator (this, request, thisRequest, new StringBuffer(""));
+ String xmlCode = thisXMLGen.get ();
+ response.setContentType ("text/xml; charset=UTF8");
+ PrintWriter out;
+ out = response.getWriter ();
+ out.print (xmlCode);
+ out.close ();
+ } // doGet
+
+} // HttpServletCM
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/CO.java b/webCM/src/main/servlet/org/compiere/cm/cache/CO.java
new file mode 100644
index 0000000000..8bfa2ab802
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/CO.java
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import java.util.*;
+
+import org.compiere.model.*;
+import org.compiere.util.CLogger;
+
+/**
+ * CO CacheObject
+ * we store parts of the content in caches on the webservers to reduce DB load and speed up page deployment
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class CO {
+
+ protected static int cacheSize = 100;
+ protected Hashtable cache = new Hashtable(cacheSize);
+ protected Hashtable cacheUsage = new Hashtable(cacheSize);
+ protected Properties ctx;
+
+ /** Logger */
+ protected CLogger log = CLogger.getCLogger(this.getClass());
+
+ public CO () {
+ }
+
+ public void setCtx(Properties thisCtx) {
+ ctx = thisCtx;
+ }
+
+ public Properties getCtx() {
+ return ctx;
+ }
+
+ public void put(String ID, Object thisObject) {
+ cache.put(ID,thisObject);
+ Long thisLong = new Long(new Date().getTime());
+ cacheUsage.put(ID, thisLong);
+ if (cacheUsage.size()>cacheSize-1) {
+ cleanUp();
+ }
+ }
+
+ public void remove(String ID) {
+ cache.remove(ID);
+ cacheUsage.remove(ID);
+ }
+
+ public int getSize() {
+ return cache.size();
+ }
+
+ public Enumeration getKeys() {
+ return cache.keys();
+ }
+
+ private void cleanUp () {
+ Vector vecKeys = new Vector();
+ //Gets keys from hashtable
+
+ Enumeration myEnum = cacheUsage.elements();
+
+ while (myEnum.hasMoreElements())
+ {
+ vecKeys.add(myEnum.nextElement());
+ }
+
+ //Sorts vector in Ascending order
+ Collections.sort(vecKeys);
+ Collections.reverse(vecKeys);
+
+ //Displays values using Key
+ for(int i=0;icacheSize-1) {
+ cache.remove(key);
+ cacheUsage.remove(key);
+ log.fine("Item: " + key + " from cache: " + this.getClass().getName() + " was removed.");
+ }
+ }
+ }
+
+ public void use(String ID) {
+ Long thisLong = new Long(new java.util.Date().getTime());
+ cacheUsage.put(ID, thisLong);
+ }
+
+ public void empty() {
+ cache = new Hashtable(cacheSize);
+ cacheUsage = new Hashtable(cacheSize);
+ log.fine("Cache: " + this.getClass().getName() + " was cleared.");
+ }
+
+ public String show() {
+ StringBuffer tStrHTML = new StringBuffer();
+ Enumeration thisEnum = null;
+ tStrHTML.append(" " + this.getSize() + "\n");
+ thisEnum = this.getKeys();
+ while (thisEnum.hasMoreElements()) {
+ tStrHTML.append(" - " + thisEnum.nextElement() + "
\n");
+ }
+ return tStrHTML.toString();
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/Chat.java b/webCM/src/main/servlet/org/compiere/cm/cache/Chat.java
new file mode 100644
index 0000000000..ffb807737a
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/Chat.java
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import java.util.*;
+import org.compiere.model.X_CM_Chat;
+
+public class Chat extends CO {
+
+ protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
+
+ public X_CM_Chat getCM_Chat(int ID) {
+ return getCM_Chat(""+ ID);
+ }
+
+ public X_CM_Chat getCM_Chat(String ID) {
+ if (cache.containsKey(ID)) {
+ use(ID);
+ return (X_CM_Chat) cache.get(ID);
+ } else {
+ int[] tableKeys = X_CM_Chat.getAllIDs("CM_Chat", "CM_Chat_ID=" + ID, "WebCM");
+ if (tableKeys.length==0) {
+ // No Chat entry
+ return null;
+ } else if (tableKeys.length==1) {
+ X_CM_Chat thisChat = new X_CM_Chat(ctx, tableKeys[0], "WebCM");
+ put ("" + thisChat.get_ID(),thisChat);
+ return thisChat;
+ } else {
+ // More than one result, this is funny, normally this is not possible :-/
+ return null;
+ }
+ }
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/Container.java b/webCM/src/main/servlet/org/compiere/cm/cache/Container.java
new file mode 100644
index 0000000000..9f627e0d54
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/Container.java
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import java.util.*;
+import org.compiere.model.MContainer;
+
+/**
+ * Container Cache
+ *
+ * @author Yves Sandfort
+ * @version $ID$
+ */
+public class Container extends CO {
+
+ protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
+
+ /**
+ * Get Container from cache by ID
+ * @param ID Container ID
+ * @param CM_WebProject_ID Web Project
+ * @return Container
+ */
+ public MContainer getCM_Container(int ID, int CM_WebProject_ID) {
+ return getCM_Container(""+ ID, CM_WebProject_ID);
+ }
+
+ /**
+ * Get Container from cache by ID
+ * @param ID Container ID
+ * @param CM_WebProject_ID Web Project
+ * @return Container
+ */
+ public MContainer getCM_Container(String ID, int CM_WebProject_ID) {
+ if (cache.containsKey(ID)) {
+ use(ID);
+ return (MContainer) cache.get(ID);
+ } else {
+ int[] tableKeys = MContainer.getAllIDs("CM_Container", "CM_Container_ID=" + ID + " AND CM_WebProject_ID=" + CM_WebProject_ID, "WebCM");
+ if (tableKeys.length==0) {
+ return getCM_ContainerByURL("/error404.html", CM_WebProject_ID, true);
+ } else if (tableKeys.length==1) {
+ MContainer thisContainer = new MContainer(ctx, tableKeys[0], "WebCM");
+ put ("" + thisContainer.getCM_Container_ID(),thisContainer);
+ cacheContainerURL.put (CM_WebProject_ID + "-" + thisContainer.getRelativeURL(),"" + thisContainer.getCM_Container_ID());
+ return thisContainer;
+ } else {
+ // More than one result, this is funny, normally this is not possible :-/
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Get Container from cache by URL
+ * @param URL URL to look for
+ * @param CM_WebProject_ID Web Project
+ * @return Container
+ */
+ public MContainer getCM_ContainerByURL(String URL, int CM_WebProject_ID, boolean resolveURLErrors) {
+ if (cacheContainerURL.containsKey(CM_WebProject_ID + "-" + URL)) {
+ // Found a hit, so return it...
+ // Found exactly one record, so we return it
+ MContainer thisContainer = getCM_Container((String) cacheContainerURL.get(CM_WebProject_ID + "-" + URL), CM_WebProject_ID);
+ if (thisContainer.isSummary ()) {
+ thisContainer = getCM_ContainerByURL(URL + "/index.html", CM_WebProject_ID, resolveURLErrors);
+ }
+ return thisContainer;
+ } else {
+ // Let's try to find the URL...
+ int[] tableKeys = MContainer.getAllIDs("CM_Container", "(RelativeURL LIKE '" + URL + "' OR RelativeURL LIKE '" + URL + "/') AND CM_WebProject_ID=" + CM_WebProject_ID, "WebCM");
+ if (tableKeys==null || tableKeys.length==0) {
+ if (resolveURLErrors) {
+ if (URL.equals("/error404.html")) {
+ // Okay we are already been requested as the error message, so we try the index.html
+ MContainer tempContainer = getCM_ContainerByURL("/index.html", CM_WebProject_ID, false);
+ if (tempContainer!=null)
+ return tempContainer;
+ else
+ return null;
+ } else {
+ return getCM_ContainerByURL("/error404.html", CM_WebProject_ID, true);
+ }
+ } else {
+ return null;
+ }
+ } else if (tableKeys.length==1) {
+ // Found exactly one record, so we return it
+ MContainer thisContainer = getCM_Container("" + tableKeys[0], CM_WebProject_ID);
+ if (thisContainer.isSummary ()) {
+ thisContainer = getCM_ContainerByURL(URL + "/index.html", CM_WebProject_ID, resolveURLErrors);
+ }
+ return thisContainer;
+ } else {
+ // More than one result, this is funny, normally this is not possible :-/
+ return null;
+ }
+ }
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/ContainerElement.java b/webCM/src/main/servlet/org/compiere/cm/cache/ContainerElement.java
new file mode 100644
index 0000000000..77496b37b2
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/ContainerElement.java
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import org.compiere.model.X_CM_Container_Element;
+
+public class ContainerElement extends CO {
+ public X_CM_Container_Element getCM_Container_Element(int ID, int CM_WebProject_ID) {
+ return getCM_Container_Element(""+ ID, CM_WebProject_ID);
+ }
+
+ public X_CM_Container_Element getCM_Container_Element(String ID, int CM_WebProject_ID) {
+ if (cache.containsKey(ID)) {
+ use(ID);
+ return (X_CM_Container_Element) cache.get(ID);
+ } else {
+ int[] tableKeys = X_CM_Container_Element.getAllIDs("CM_Container_Element", "CM_Container_Element_ID=" + ID, "WebCM");
+ if (tableKeys==null || tableKeys.length==0) {
+ // No Elements in DB found, needs to get handled
+ return null;
+ } else if (tableKeys.length==1) {
+ X_CM_Container_Element thisContainerElement = new X_CM_Container_Element(ctx, tableKeys[0], "WebCM");
+ put ("" + thisContainerElement.get_ID(),thisContainerElement);
+ return thisContainerElement;
+ } else {
+ // More than one result, this is funny, normally this is not possible :-/
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/ContainerTree.java b/webCM/src/main/servlet/org/compiere/cm/cache/ContainerTree.java
new file mode 100644
index 0000000000..265749be41
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/ContainerTree.java
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import java.util.*;
+
+import org.compiere.cm.utils.TreeXML;
+import org.compiere.model.MWebProject;
+
+public class ContainerTree extends CO {
+
+ protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
+
+ public StringBuffer getContainerTree(Properties ctx, int ID, String trxName) {
+ StringBuffer xmlCode = new StringBuffer();
+ if (cache.containsKey("" + ID)) {
+ use("" + ID);
+ return (StringBuffer) cache.get("" + ID);
+ } else {
+ MWebProject thisProject = new MWebProject(ctx, ID, trxName);
+ TreeXML thisTree = new TreeXML(thisProject);
+ xmlCode.append(thisTree.getContainerXML());
+ xmlCode.append(thisTree.getTreeXML());
+ put ("" + ID, xmlCode);
+ return xmlCode;
+ }
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/Domain.java b/webCM/src/main/servlet/org/compiere/cm/cache/Domain.java
new file mode 100644
index 0000000000..2d845a5f80
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/Domain.java
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import org.compiere.model.*;
+
+/**
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class Domain extends CO
+{
+ /**
+ * Get Web Project Domain
+ * @param serverName
+ * @return web project domain
+ */
+ public MWebProjectDomain getWebProjectDomain (String serverName)
+ {
+ if (cache.containsKey (serverName))
+ {
+ use (serverName);
+ return (MWebProjectDomain)cache.get (serverName);
+ }
+ else
+ {
+ int[] tableKeys = MWebProjectDomain.getAllIDs (
+ "CM_WebProject_Domain",
+ "lower(FQDN) LIKE '" + serverName + "'", "WebCM");
+ if (tableKeys==null || tableKeys.length == 0)
+ {
+ // HardCoded to deliver the GardenWorld Site as default
+ return null;
+ }
+ else if (tableKeys.length == 1)
+ {
+ MWebProjectDomain thisDomain = new MWebProjectDomain (
+ ctx, tableKeys[0], "WebCM");
+ put (thisDomain.getFQDN (), thisDomain);
+ return thisDomain;
+ }
+ // We found more than one hit, this is bad, so we will try to use the first non system / gardenworld one
+ else if (tableKeys.length>1)
+ {
+ for (int i=0;i=1000000) {
+ MWebProjectDomain thisDomain = new MWebProjectDomain (
+ ctx, tableKeys[i], "WebCM");
+ put (thisDomain.getFQDN (), thisDomain);
+ return thisDomain;
+ }
+ }
+ // We can't find any non system/gardenworld hit, so we will try the first one
+ for (int i=0;iThis servlet only handles service requests!");
+ if (request.getParameter("Cache")!=null) {
+ if (request.getParameter("Cache").equals("Container")) {
+ if (request.getParameter("ID")!=null) {
+ containerCache.remove(request.getParameter("ID"));
+ }
+ if (request.getParameter("SHOW")!=null) {
+ out.print("" + containerCache.show() + "");
+ }
+ }
+ if (request.getParameter("Cache").equals("ContainerElement")) {
+ if (request.getParameter("ID")!=null) {
+ containerElementCache.remove(request.getParameter("ID"));
+ }
+ if (request.getParameter("SHOW")!=null) {
+ out.print("" + containerElementCache.show() + "");
+ }
+ }
+ if (request.getParameter("Cache").equals("ContainerTree")) {
+ if (request.getParameter("ID")!=null) {
+ containerTreeCache.remove(request.getParameter("ID"));
+ }
+ if (request.getParameter("SHOW")!=null) {
+ out.print("" + containerTreeCache.show() + "");
+ }
+ }
+ if (request.getParameter("Cache").equals("Template")) {
+ if (request.getParameter("ID")!=null) {
+ if (request.getParameter("ID").equals("0")) {
+ templateCache.empty();
+ } else {
+ templateCache.remove(request.getParameter("ID"));
+ }
+ }
+ if (request.getParameter("SHOW")!=null) {
+ out.print("" + templateCache.show() + "");
+ }
+ }
+ if (request.getParameter("Cache").equals("all")) {
+ chatCache.empty ();
+ containerCache.empty ();
+ containerElementCache.empty ();
+ containerTreeCache.empty ();
+ domainCache.empty ();
+ mediaServerCache.empty ();
+ templateCache.empty ();
+ webProjectCache.empty ();
+ xmlCache.empty ();
+ }
+ }
+ out.close();
+ }
+
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/Template.java b/webCM/src/main/servlet/org/compiere/cm/cache/Template.java
new file mode 100644
index 0000000000..ed1041185b
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/Template.java
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import org.compiere.model.MTemplate;
+
+/**
+ * Template
+ * we create a cacheObject for the template.
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class Template extends CO {
+ /**
+ * get Template by ID
+ * @param ID
+ * @param CM_WebProject_ID
+ * @return MTemplate
+ */
+ public MTemplate getCM_Template(int ID, int CM_WebProject_ID) {
+ return getCM_Template(""+ ID, CM_WebProject_ID);
+ }
+
+ /**
+ * get Template by ID
+ * @param ID
+ * @param CM_WebProject_ID
+ * @return MTemplate
+ */
+ public MTemplate getCM_Template(String ID, int CM_WebProject_ID) {
+ if (cache.containsKey(ID)) {
+ use(ID);
+ return (MTemplate) cache.get(ID);
+ } else {
+ int[] tableKeys = MTemplate.getAllIDs("CM_Template", "CM_Template_ID=" + ID + " AND CM_WebProject_ID=" + CM_WebProject_ID, "WebCM");
+ if (tableKeys.length==0) {
+ // TODO Throw Template Exception
+ return null;
+ } else if (tableKeys.length==1) {
+ MTemplate thisTemplate = new MTemplate(ctx, tableKeys[0], "WebCM");
+ // We must prebuild the Template here, as we will not have Access to it later!
+ thisTemplate.getPreBuildTemplate();
+ put ("" + thisTemplate.getCM_Template_ID(),thisTemplate);
+ return thisTemplate;
+ } else {
+ // More than one result, this is funny, normally this is not possible :-/
+ return null;
+ }
+ }
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/WebProject.java b/webCM/src/main/servlet/org/compiere/cm/cache/WebProject.java
new file mode 100644
index 0000000000..e7d01c00a3
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/WebProject.java
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import java.util.*;
+import org.compiere.model.*;
+
+/**
+ * Web Project Cache
+ * @author YS
+ * @version $Id$
+ */
+public class WebProject extends CO
+{
+ /**
+ * Get WebProject
+ * @param ID id
+ * @return web project
+ */
+ public MWebProject getWebProject (int ID)
+ {
+ return getWebProject ("" + ID);
+ } // getWebProject
+
+ /**
+ * Get WebProject
+ * @param ID id
+ * @return webProject
+ */
+ public MWebProject getWebProject (String ID)
+ {
+ if (cache.containsKey (ID))
+ {
+ use (ID);
+ return (MWebProject)cache.get (ID);
+ }
+ else
+ {
+ int[] tableKeys = MWebProject.getAllIDs ("CM_WebProject",
+ "CM_WebProject_ID=" + ID, "WebCM");
+ if (tableKeys.length == 0)
+ {
+ // Shouldn't happen, needs handler!
+ return null;
+ }
+ else if (tableKeys.length == 1)
+ {
+ MWebProject thisProject = new MWebProject (ctx,
+ tableKeys[0], "WebCM");
+ put ("" + thisProject.get_ID (), thisProject);
+ return thisProject;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ } // getWebProject
+
+} // WebProject
diff --git a/webCM/src/main/servlet/org/compiere/cm/cache/XML.java b/webCM/src/main/servlet/org/compiere/cm/cache/XML.java
new file mode 100644
index 0000000000..07938f8bdf
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/cache/XML.java
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.cache;
+
+import java.util.*;
+import org.compiere.model.*;
+
+public class XML extends CO {
+
+ protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
+
+ public String getXML(String ID) {
+ if (cache.containsKey(ID)) {
+ use(ID);
+ return (String) cache.get(ID).toString ();
+ } else {
+ // This Cache is special we do not base on records we provide common data, i.e. Countries etc.
+ StringBuffer result = new StringBuffer();
+ if (ID.equals ("C_Country"))
+ result = genCountryList(result);
+ if (result!=null) {
+ put (ID,result);
+ return result.toString ();
+ } else {
+ return null;
+ }
+ }
+ }
+
+ private StringBuffer genCountryList(StringBuffer result)
+ {
+ result.append("\n");
+ result.append(" \n");
+ MCountry defaultCountry = MCountry.getDefault (getCtx());
+ result = defaultCountry.get_xmlString (result);
+ result.append(" \n");
+ MCountry theseCountries[] = MCountry.getCountries(getCtx());
+ for (int i=0;i\n");
+ return result;
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/extend/indexSearch.java b/webCM/src/main/servlet/org/compiere/cm/extend/indexSearch.java
new file mode 100644
index 0000000000..8f458793ca
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/extend/indexSearch.java
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms version 2 of the GNU General Public License as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 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.
+ * You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
+ * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
+ *****************************************************************************/
+package org.compiere.cm.extend;
+
+import javax.servlet.http.*;
+import java.util.*;
+
+/**
+ * Search the index for results
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class indexSearch extends org.compiere.cm.Extend
+{
+ public indexSearch (HttpServletRequest request, Properties ctx)
+ {
+ super (request, ctx);
+ }
+
+ public boolean doIt()
+ {
+ return true;
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/request/Request.java b/webCM/src/main/servlet/org/compiere/cm/request/Request.java
new file mode 100644
index 0000000000..2627c9a2bc
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/request/Request.java
@@ -0,0 +1,419 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms version 2 of the GNU General Public License as published
+ * by the Free Software Foundation. This program is distributed in the hope
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 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.
+ * You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
+ * 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
+ *****************************************************************************/
+package org.compiere.cm.request;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.compiere.model.MColumn;
+import org.compiere.model.MRequest;
+import org.compiere.model.MTable;
+import org.compiere.model.PO;
+import org.compiere.model.X_AD_Reference;
+import org.compiere.util.DB;
+
+/**
+ * Request Class to create or update Requests.
+ *
+ * @author Kai Viiksaar
+ * @version $Id: Request.java,v 1.3 2006/10/16 11:34:47 comdivision Exp $
+ */
+public class Request {
+
+ //Integer values
+ private final static int i_integer = 11;
+ private final static int i_id = 13;
+ private final static int i_table = 18;
+ private final static int i_tableDirect = 19;
+ private final static int i_rowID = 26;
+ private final static int i_searchField = 30;
+
+ //BigDecimal values
+ private final static int bd_amount = 12;
+ private final static int bd_floatNumber = 22;
+ private final static int bd_quantity = 29;
+ private final static int bd_costsAndPrice = 37;
+
+ //Date values
+ private final static int d_date = 15;
+ private final static int d_dateTime = 16;
+ private final static int d_time = 24;
+
+ //String values
+ private final static int s_string = 10;
+ private final static int s_text = 14;
+ private final static int s_textLong = 36;
+ private final static int s_list = 17;
+ private final static int s_location = 21;
+ private final static int s_binary = 23;
+ private final static int s_account = 25;
+ private final static int s_color = 27;
+ private final static int s_button = 28;
+ private final static int s_warehousLocator = 31;
+ private final static int simage = 32;
+ private final static int s_assignment = 33;
+ private final static int s_memo = 34;
+ private final static int s_productAttribute = 35;
+
+ //Boolean values
+ private final static int b_bool = 20;
+
+
+ /**
+ * Creates a new Request.
+ *
+ * @param request
+ * @param ctx
+ * @return new Request ID
+ */
+ public static String createRequest(HttpServletRequest request, Properties ctx) {
+ String l_szTrxName = null;
+ String l_szReturn = null;
+
+ boolean l_bSuccess = true;
+
+ BigDecimal l_bdAmt = getParameterAsBD(request, "RequestAmt");
+
+ int l_nOrgID = getParameterAsInt(request, "AD_Org_ID");
+ //int l_nSalesRepID = getParameterAsInt(request, "SalesRep_ID");
+ int l_nRoleID = getParameterAsInt(request, "AD_Role_ID");
+ int l_nRReqTypeID = getParameterAsInt(request, "R_RequestType_ID");
+ int l_nRGroupID = getParameterAsInt(request, "R_Group_ID");
+ int l_nRCategoryID = getParameterAsInt(request, "R_Category_ID");
+ int l_nRReqRelID = getParameterAsInt(request, "R_RequestRelated_ID");
+ int l_nRStatusID = getParameterAsInt(request, "R_Status_ID");
+ int l_nRResolID = getParameterAsInt(request, "R_Resolution_ID");
+
+ int l_nBPartnerID = getParameterAsInt(request, "C_BPartner_ID");
+ int l_nUserID = getParameterAsInt(request, "AD_User_ID");
+ int l_nProjectID = getParameterAsInt(request, "C_Project_ID");
+ int l_nAssetID = getParameterAsInt(request, "A_Asset_ID");
+ int l_nOrderID = getParameterAsInt(request, "C_Order_ID");
+ int l_nInvoiceID = getParameterAsInt(request, "C_Invoice_ID");
+ int l_nProductID = getParameterAsInt(request, "M_Product_ID");
+ int l_nPaymentID = getParameterAsInt(request, "C_Payment_ID");
+ int l_nInOutID = getParameterAsInt(request, "M_InOut_ID");
+ int l_nRMAID = getParameterAsInt(request, "M_RMA_ID");
+ int l_nCampaignID = getParameterAsInt(request, "C_Campaign_ID");
+
+
+ /*
+ * Durchlauf der Parameter Werte. Dabei werden alle �bergebenen Parameter
+ * als Columns in der MColumn gesucht und bei einem Treffer diese Werte
+ * dann �ber set_ValueOfColumn gesetzt
+ */
+/* MRequest l_newRequest = new MRequest(ctx, 0, l_szTrxName);
+ Enumeration l_eParameterNames = request.getParameterNames();
+ MColumn curColumn = null;
+
+ int l_nColumnID = 0;
+ int l_nRefID = 0;
+
+ while (l_eParameterNames.hasMoreElements()) {
+ String name = l_eParameterNames.nextElement().toString();
+
+ l_nColumnID = l_newRequest.get_ColumnIndex(name);
+ if (l_nColumnID > -1) {
+ curColumn = new MColumn(ctx, l_nColumnID, l_szTrxName);
+ l_nRefID = curColumn.getAD_Reference_ID();
+
+ if (l_nRefID == b_bool) {
+ l_newRequest.set_ValueOfColumn(l_nColumnID, getParameterAsBool(request, name));
+ } else if (l_nRefID == bd_amount || l_nRefID == bd_costsAndPrice || l_nRefID == bd_floatNumber || l_nRefID == bd_quantity) {
+ l_newRequest.set_ValueOfColumn(l_nColumnID, getParameterAsBD(request, name));
+ } else if (l_nRefID == d_date || l_nRefID == d_dateTime || l_nRefID == d_time) {
+ l_newRequest.set_ValueOfColumn(l_nColumnID, getParameterAsDate(request, name));
+ } else if (l_nRefID == i_id || l_nRefID == i_integer || l_nRefID == i_rowID || l_nRefID == i_searchField || l_nRefID == i_table || l_nRefID == i_table) {
+ l_newRequest.set_ValueOfColumn(l_nColumnID, getParameterAsInt(request, name));
+ } else {
+ l_newRequest.set_ValueOfColumn(l_nColumnID, getParameterAsString(request, name));
+ }
+ }
+ }
+ l_bSuccess &= l_newRequest.save();
+*/
+
+ MRequest newRequest = new MRequest(ctx, 0, l_szTrxName);
+
+ // values for values no fieldgroup
+ newRequest.setAD_Org_ID(l_nOrgID);
+ newRequest.setDueType(getParameterAsString(request, "DueType"));
+ newRequest.setR_RequestType_ID(l_nRReqTypeID);
+ newRequest.setR_Group_ID(l_nRGroupID);
+ newRequest.setR_Category_ID(l_nRCategoryID);
+ newRequest.setR_RequestRelated_ID(l_nRReqRelID);
+ newRequest.setR_Status_ID(l_nRStatusID);
+ newRequest.setR_Resolution_ID(l_nRResolID);
+ newRequest.setPriority(getParameterAsString(request, "Priority"));
+ newRequest.setPriorityUser(getParameterAsString(request, "PriorityUser"));
+ newRequest.setSummary(getParameterAsString(request, "Summary"));
+ newRequest.setConfidentialType(getParameterAsString(request, "ConfidentialType"));
+ newRequest.setIsInvoiced(getParameterAsBool(request, "IsInvoiced"));
+
+ // Mandatory values for fieldgroup Action
+ newRequest.setConfidentialTypeEntry(getParameterAsString(request, "ConfidentialTypeEntry"));
+ newRequest.setAD_Role_ID(l_nRoleID);
+ //newRequest.setSalesRep_ID(l_nSalesRepID);
+
+ // values for fieldgroup Reference
+ newRequest.setC_BPartner_ID(l_nBPartnerID);
+ newRequest.setAD_User_ID(l_nUserID);
+ newRequest.setC_Project_ID(l_nProjectID);
+ newRequest.setA_Asset_ID(l_nAssetID);
+ newRequest.setC_Order_ID(l_nOrderID);
+ newRequest.setC_Invoice_ID(l_nInvoiceID);
+ newRequest.setM_Product_ID(l_nProductID);
+ newRequest.setC_Payment_ID(l_nPaymentID);
+ newRequest.setM_InOut_ID(l_nInOutID);
+ newRequest.setM_RMA_ID(l_nRMAID);
+ newRequest.setRequestAmt(l_bdAmt);
+ newRequest.setC_Campaign_ID(l_nCampaignID);
+
+ l_bSuccess &= newRequest.save();
+
+ if (l_bSuccess) {
+ try {
+ DB.commit(true, l_szTrxName);
+ l_szReturn = "" + newRequest.get_ID();
+ } catch (Exception e) {
+ l_szReturn = e.getMessage();
+ }
+ }
+ return l_szReturn;
+ }
+
+ /**
+ * Updates a Request.
+ *
+ * @param request
+ * @param ctx
+ * @return
+ */
+ public static String changeRequest(HttpServletRequest request, Properties ctx) {
+ String l_szTrxName = null;
+ String l_szReturn = null;
+
+ boolean l_bSuccess = true;
+
+ BigDecimal l_bdAmt = getParameterAsBD(request, "RequestAmt");
+
+ int l_nReqID = getParameterAsInt(request, "R_Request_ID");
+ int l_nOrgID = getParameterAsInt(request, "AD_Org_ID");
+ //int l_nSalesRepID = getParameterAsInt(request, "SalesRep_ID");
+ int l_nRReqTypeID = getParameterAsInt(request, "R_RequestType_ID");
+ int l_nRGroupID = getParameterAsInt(request, "R_Group_ID");
+ int l_nRCategoryID = getParameterAsInt(request, "R_Category_ID");
+ int l_nRReqRelID = getParameterAsInt(request, "R_RequestRelated_ID");
+ int l_nRStatusID = getParameterAsInt(request, "R_Status_ID");
+ int l_nRResolID = getParameterAsInt(request, "R_Resolution_ID");
+
+ int l_nBPartnerID = getParameterAsInt(request, "C_BPartner_ID");
+ int l_nUserID = getParameterAsInt(request, "AD_User_ID");
+ int l_nProjectID = getParameterAsInt(request, "C_Project_ID");
+ int l_nAssetID = getParameterAsInt(request, "A_Asset_ID");
+ int l_nOrderID = getParameterAsInt(request, "C_Order_ID");
+ int l_nInvoiceID = getParameterAsInt(request, "C_Invoice_ID");
+ int l_nProductID = getParameterAsInt(request, "M_Product_ID");
+ int l_nPaymentID = getParameterAsInt(request, "C_Payment_ID");
+ int l_nInOutID = getParameterAsInt(request, "M_InOut_ID");
+ int l_nRMAID = getParameterAsInt(request, "M_RMA_ID");
+ int l_nCampaignID = getParameterAsInt(request, "C_Campaign_ID");
+
+ int l_nResponseID = getParameterAsInt(request, "R_StandardResponse_ID");
+ int l_nMailTextID = getParameterAsInt(request, "R_MailText_ID");
+ int l_nActivityID = getParameterAsInt(request, "C_Activity_ID");
+ int l_nProdSpentID = getParameterAsInt(request, "M_ProductSpent_ID");
+
+ BigDecimal l_QtySpent = getParameterAsBD(request, "QtySpent");
+ BigDecimal l_QtyInvoiced = getParameterAsBD(request, "QtyInvoiced");
+ BigDecimal l_QtyPlan = getParameterAsBD(request, "QtyPlan");
+
+ Timestamp l_tsDateNextAction = getParameterAsDate(request, "DateNextAction");
+ Timestamp l_tsDateStartPlan = getParameterAsDate(request, "DateStartPlan");
+ Timestamp l_tsDateCompletePlan = getParameterAsDate(request, "DateCompletePlan");
+ Timestamp l_tsStartDate = getParameterAsDate(request, "StartDate");
+ Timestamp l_tsCloseDate = getParameterAsDate(request, "CloseDate");
+
+ MRequest newRequest = new MRequest(ctx, l_nReqID, l_szTrxName);
+
+ // values for values no fieldgroup
+ newRequest.setAD_Org_ID(l_nOrgID);
+ newRequest.setDueType(getParameterAsString(request, "DueType"));
+ newRequest.setR_RequestType_ID(l_nRReqTypeID);
+ newRequest.setR_Group_ID(l_nRGroupID);
+ newRequest.setR_Category_ID(l_nRCategoryID);
+ newRequest.setR_RequestRelated_ID(l_nRReqRelID);
+ newRequest.setR_Status_ID(l_nRStatusID);
+ newRequest.setR_Resolution_ID(l_nRResolID);
+ newRequest.setPriority(getParameterAsString(request, "Priority"));
+ newRequest.setPriorityUser(getParameterAsString(request, "PriorityUser"));
+ newRequest.setSummary(getParameterAsString(request, "Summary"));
+ newRequest.setConfidentialType(getParameterAsString(request, "ConfidentialType"));
+ newRequest.setIsInvoiced(getParameterAsBool(request, "IsInvoiced"));
+
+ // values for fieldgroup Action
+ newRequest.setDateNextAction(l_tsDateNextAction);
+ newRequest.setConfidentialTypeEntry(getParameterAsString(request, "ConfidentialTypeEntry"));
+ newRequest.setR_StandardResponse_ID(l_nResponseID);
+ newRequest.setR_MailText_ID(l_nMailTextID);
+ newRequest.setResult(getParameterAsString(request, "Result"));
+ newRequest.setC_Activity_ID(l_nActivityID);
+ newRequest.setQtyPlan(l_QtyPlan);
+ newRequest.setQtySpent(l_QtySpent);
+ newRequest.setM_ProductSpent_ID(l_nProdSpentID);
+ newRequest.setQtyInvoiced(l_QtyInvoiced);
+ newRequest.setDateStartPlan(l_tsDateStartPlan);
+ newRequest.setDateCompletePlan(l_tsDateCompletePlan);
+ newRequest.setStartDate(l_tsStartDate);
+ newRequest.setCloseDate(l_tsCloseDate);
+
+ // values for fieldgroup Reference
+ newRequest.setC_BPartner_ID(l_nBPartnerID);
+ newRequest.setAD_User_ID(l_nUserID);
+ newRequest.setC_Project_ID(l_nProjectID);
+ newRequest.setA_Asset_ID(l_nAssetID);
+ newRequest.setC_Order_ID(l_nOrderID);
+ newRequest.setC_Invoice_ID(l_nInvoiceID);
+ newRequest.setM_Product_ID(l_nProductID);
+ newRequest.setC_Payment_ID(l_nPaymentID);
+ newRequest.setM_InOut_ID(l_nInOutID);
+ newRequest.setM_RMA_ID(l_nRMAID);
+ newRequest.setRequestAmt(l_bdAmt);
+ newRequest.setC_Campaign_ID(l_nCampaignID);
+
+ l_bSuccess &= newRequest.save();
+
+ if (l_bSuccess) {
+ try {
+ DB.commit(true, l_szTrxName);
+ l_szReturn = "" + newRequest.get_ID();
+ } catch (Exception e) {
+ l_szReturn = e.getMessage();
+ }
+ }
+ return l_szReturn;
+ }
+
+ /**
+ * Returns a Request Parameter as String.
+ * Removes format characters.
+ *
+ * @param request
+ * @param parameterName
+ * @return
+ */
+ private static String getParameterAsString(HttpServletRequest request, String parameterName) {
+ String l_szReturn = new String("");
+
+ if (request.getParameter(parameterName) != null && request.getParameter(parameterName) != "") {
+ l_szReturn = request.getParameter(parameterName).toString();
+ l_szReturn = l_szReturn.replace("\r","");
+ l_szReturn = l_szReturn.replace("\n","");
+ }
+ return l_szReturn;
+ }
+
+ /**
+ * Returns a Request Parameter as Integer.
+ *
+ * @param request
+ * @param parameterName
+ * @return value, 0 if no parameter or parse error
+ */
+ private static int getParameterAsInt(HttpServletRequest request, String parameterName) {
+ int l_nID = 0;
+
+ if (request.getParameter(parameterName) != null && request.getParameter(parameterName) != "") {
+ try {
+ l_nID = Integer.parseInt(request.getParameter(parameterName));
+ } catch (Exception e) {
+ l_nID = 0;
+ }
+ }
+ return l_nID;
+ }
+
+ /**
+ * Returns a Request Parameter as BigDecimal.
+ *
+ * @param request
+ * @param parameterName
+ * @return value, 0 if no parameter or parse error
+ */
+ private static BigDecimal getParameterAsBD(HttpServletRequest request, String parameterName) {
+ BigDecimal l_bdValue = new BigDecimal(0);
+
+ if (request.getParameter(parameterName) != null && request.getParameter(parameterName) != "") {
+ try {
+ String l_szValue = request.getParameter(parameterName);
+ l_szValue = l_szValue.replace(",", ".");
+ l_bdValue = new BigDecimal(Float.parseFloat(l_szValue));
+ } catch (Exception e) {
+ l_bdValue = new BigDecimal(0);
+ }
+ }
+ l_bdValue = l_bdValue.setScale(2, BigDecimal.ROUND_CEILING);
+ return l_bdValue;
+ }
+
+ /**
+ * Returns a Parameter as boolean.
+ *
+ * @param request
+ * @param parameterName
+ * @return true if parameter != null
+ */
+ private static boolean getParameterAsBool(HttpServletRequest request, String parameterName) {
+ boolean l_bIs = false;
+
+ if (request.getParameter(parameterName) != null) {
+ l_bIs = true;
+ }
+ return l_bIs;
+ }
+
+ /**
+ * Returns a Parameter as Timestamp.
+ *
+ * @param request
+ * @param parameterName
+ * @return Timestamp or null
+ */
+ private static Timestamp getParameterAsDate(HttpServletRequest request, String parameterName) {
+ Date myDate = new Date();
+ SimpleDateFormat ger = new SimpleDateFormat("dd.MM.yyyy");
+ long time = 0;
+
+ if (request.getParameter(parameterName) != null && request.getParameter(parameterName) != "") {
+ try {
+ myDate = ger.parse(request.getParameter(parameterName).toString());
+ time = myDate.getTime();
+ } catch (ParseException e) {
+ return null;
+ }
+ return new Timestamp(time);
+ }
+ return null;
+ }
+}
+
\ No newline at end of file
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/AccessLogger.java b/webCM/src/main/servlet/org/compiere/cm/utils/AccessLogger.java
new file mode 100644
index 0000000000..e345043789
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/AccessLogger.java
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import javax.servlet.http.*;
+import java.math.BigDecimal;
+import java.util.Properties;
+import org.compiere.cm.*;
+import org.compiere.model.*;
+import org.compiere.util.Env;
+
+
+public class AccessLogger extends Thread
+{
+ private X_CM_WebAccessLog thisLog = null;
+
+ public AccessLogger(HttpServletRequest tRequest, HttpServletCM tServletCM, RequestAnalyzer tRequestAnalyzer)
+ {
+ Properties ctx = tServletCM.getCtx();
+ if (tRequestAnalyzer.getWebProject()!=null)
+ Env.setContext(ctx, "#AD_Client_ID", "" + tRequestAnalyzer.getWebProject().getAD_Client_ID());
+ //ctx.put()
+ thisLog = new X_CM_WebAccessLog(ctx, 0, null);
+ thisLog.setAD_Org_ID(0);
+ // Set Access Type
+ thisLog.setLogType("W");
+ // Set Web Project
+ if (tRequestAnalyzer.getWebProject()!=null)
+ thisLog.setCM_WebProject_ID(tRequestAnalyzer.getWebProject().get_ID());
+ // Set IP_Address
+ thisLog.setIP_Address("217.171.192.001");
+ // Set BroadcastServer
+
+ // Set the RequestType
+ if (tRequest.getMethod()!=null)
+ thisLog.setRequestType(tRequest.getMethod());
+ // Set Page URL
+ if (tRequest.getRequestURL()!=null)
+ thisLog.setPageURL(tRequest.getRequestURL().toString());
+ // Set Referrer
+ if (tRequest.getHeader("Referer")!=null)
+ thisLog.setReferrer(tRequest.getHeader("Referer"));
+ // Set RemoteHost
+ if (tRequest.getRemoteHost()!=null)
+ thisLog.setRemote_Host(tRequest.getRemoteHost());
+ // set RemoteAddr
+ if (tRequest.getRemoteAddr()!=null)
+ thisLog.setRemote_Addr(tRequest.getRemoteAddr());
+ // set Useragent / Browser
+ if (tRequest.getHeader("User-Agent")!=null)
+ thisLog.setUserAgent(tRequest.getHeader("User-Agent"));
+ // Set AcceptLanguage
+ if (tRequest.getHeader("Accept-Language")!=null)
+ thisLog.setAcceptLanguage(tRequest.getHeader("Accept-Language"));
+ // Set Websession ID
+ if (tRequest.getSession()!=null)
+ thisLog.setWebSession(tRequest.getSession().getId());
+ // Seth Hyphen
+
+ // Set Protocol
+ if (tRequest.getProtocol()!=null)
+ thisLog.setProtocol(tRequest.getProtocol());
+ else
+ // This is hardcoded we must fix this later!
+ thisLog.setProtocol("unknown");
+ // Statuscode
+ if (tRequestAnalyzer.getIsRedirect())
+ thisLog.setStatusCode(302);
+ else
+ thisLog.setStatusCode(200);
+ // Set Filesize
+ if (tRequest.getContentLength()>0) {
+ thisLog.setFileSize(new java.math.BigDecimal(tRequest.getContentLength()));
+ }
+ // Set AD_User
+
+ // Set CM_Media_ID
+
+ }
+
+ public void setFileSize(BigDecimal fileSize)
+ {
+ thisLog.setFileSize(fileSize);
+ }
+
+ public void run()
+ {
+ thisLog.save();
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/Attributes.java b/webCM/src/main/servlet/org/compiere/cm/utils/Attributes.java
new file mode 100644
index 0000000000..caf647765f
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/Attributes.java
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import java.util.Hashtable;
+
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+
+public class Attributes implements HttpSessionAttributeListener {
+ private static Hashtable projectSessions = new Hashtable();
+
+ public void attributeAdded(HttpSessionBindingEvent se) {
+ if (se.getName().equals("isy.user.project_id")) {
+ String project_id = se.getValue().toString();
+ int projectSessionCount = 0;
+ // Es gibt bereits einen Eintrag in der Hashtable
+ if (projectSessions.containsKey(project_id)) {
+ projectSessionCount= ((Integer)projectSessions.get(project_id)).intValue();
+ projectSessionCount++;
+ projectSessions.put(project_id,new Integer(projectSessionCount));
+ } else {
+ projectSessionCount = 1;
+ projectSessions.put(project_id,new Integer(projectSessionCount));
+ }
+ }
+ }
+
+ public void attributeRemoved(HttpSessionBindingEvent se) {
+ if (se.getName().equals("isy.user.project_id")) {
+ String project_id = se.getValue().toString();
+ int projectSessionCount = 0;
+ // Es gibt bereits einen Eintrag in der Hashtable
+ if (projectSessions.containsKey(project_id)) {
+ projectSessionCount= ((Integer)projectSessions.get(project_id)).intValue();
+ if (projectSessionCount>0) projectSessionCount--;
+ projectSessions.put(project_id,new Integer(projectSessionCount));
+ } else {
+ projectSessionCount = 0;
+ projectSessions.put(project_id,new Integer(projectSessionCount));
+ }
+ }
+ }
+
+ public void attributeReplaced(HttpSessionBindingEvent se) {
+ }
+
+ public static int getActiveSessions(String project_id) {
+ int projectSessionCount = 0;
+ if (projectSessions.containsKey(project_id)) {
+ projectSessionCount= ((Integer)projectSessions.get(project_id)).intValue();
+ }
+ return projectSessionCount;
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/CMEnv.java b/webCM/src/main/servlet/org/compiere/cm/utils/CMEnv.java
new file mode 100644
index 0000000000..a89ab9bb5a
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/CMEnv.java
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.compiere.model.MClient;
+import org.compiere.util.Env;
+
+public class CMEnv {
+
+ public Properties getDefaults() {
+ Properties ctx = new Properties();
+
+ Env.setContext(ctx, "#AD_Client_ID", "0");
+ Env.setContext(ctx, "#AD_Org_ID", "0");
+ Env.setContext(ctx, "#AD_User_ID", "0");
+ Env.setContext(ctx, "#AD_Role_ID", "0");
+ Env.setContext(ctx, "#AD_Language", "en_US");
+
+ return ctx;
+
+ }
+
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/Counter.java b/webCM/src/main/servlet/org/compiere/cm/utils/Counter.java
new file mode 100644
index 0000000000..57cc7e1190
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/Counter.java
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import javax.servlet.http.*;
+
+/**
+ * @author YS
+ * @version $Id$
+ */
+public class Counter
+ implements HttpSessionListener
+{
+
+ private static int m_activeSessions = 0;
+
+ /**
+ * SessionCreated
+ * @param se
+ */
+ public void sessionCreated (HttpSessionEvent se)
+ {
+ m_activeSessions++;
+ }
+
+ /**
+ * Session Destroyed
+ * @param se
+ */
+ public void sessionDestroyed (HttpSessionEvent se)
+ {
+ if (m_activeSessions > 0)
+ m_activeSessions--;
+ }
+
+ /**
+ * Get Active Sessions
+ * @return no of sessions
+ */
+ public static int getActiveSessions ()
+ {
+ return m_activeSessions;
+ }
+} //
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/LocaleHandler.java b/webCM/src/main/servlet/org/compiere/cm/utils/LocaleHandler.java
new file mode 100644
index 0000000000..08e4bfee60
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/LocaleHandler.java
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import java.util.*;
+
+/**
+ * @author YS
+ * @version $Id$
+ */
+public class LocaleHandler
+{
+ /** Locale */
+ private Locale m_chosenLocale;
+ /** Charset */
+ private String m_chosenCharset;
+
+ /** Locale - character set map */
+ private static Hashtable s_map;
+
+ /** Static Init */
+ static
+ {
+ s_map = new Hashtable ();
+ s_map.put ("ar", "ISO-8859-6");
+ s_map.put ("be", "ISO-8859-5");
+ s_map.put ("bg", "ISO-8859-5");
+ s_map.put ("ca", "ISO-8859-1");
+ s_map.put ("cs", "ISO-8859-2");
+ s_map.put ("da", "ISO-8859-1");
+ s_map.put ("de", "ISO-8859-1");
+ s_map.put ("el", "ISO-8859-7");
+ s_map.put ("en", "ISO-8859-1");
+ s_map.put ("es", "ISO-8859-1");
+ s_map.put ("et", "ISO-8859-1");
+ s_map.put ("fi", "ISO-8859-1");
+ s_map.put ("fr", "ISO-8859-1");
+ s_map.put ("hr", "ISO-8859-2");
+ s_map.put ("hu", "ISO-8859-2");
+ s_map.put ("is", "ISO-8859-1");
+ s_map.put ("it", "ISO-8859-1");
+ s_map.put ("iw", "ISO-8859-8");
+ s_map.put ("ja", "Shift_JIS");
+ s_map.put ("ko", "EUC-KR");
+ s_map.put ("lt", "ISO-8859-2");
+ s_map.put ("lv", "ISO-8859-2");
+ s_map.put ("mk", "ISO-8859-5");
+ s_map.put ("nl", "ISO-8859-1");
+ s_map.put ("no", "ISO-8859-1");
+ s_map.put ("pl", "ISO-8859-2");
+ s_map.put ("pt", "ISO-8859-1");
+ s_map.put ("ro", "ISO-8859-2");
+ s_map.put ("ru", "ISO-8859-5");
+ s_map.put ("sh", "ISO-8859-5");
+ s_map.put ("sk", "ISO-8859-2");
+ s_map.put ("sl", "ISO-8859-2");
+ s_map.put ("sq", "ISO-8859-2");
+ s_map.put ("sr", "ISO-8859-5");
+ s_map.put ("sv", "ISO-8859-1");
+ s_map.put ("tr", "ISO-8859-9");
+ s_map.put ("uk", "ISO-8859-5");
+ s_map.put ("zh", "GB2312");
+ s_map.put ("zh_TW", "Big5");
+ } // static
+
+ /**
+ * Constructs a new LocaleHandler language list, and charset list.
+ *
+ * @param languages
+ * the Accept-Language header
+ * @param charsets
+ * the Accept-Charset header
+ */
+ public LocaleHandler (String languages, String charsets)
+ {
+ Locale defaultLocale = new Locale ("en", "US");
+ String defaultCharset = "ISO-8859-1";
+ // If no specific language we will keep the default values
+ if (languages == null)
+ {
+ m_chosenLocale = defaultLocale;
+ m_chosenCharset = defaultCharset;
+ return; // quick exit
+ }
+ StringTokenizer langTokenizer = new StringTokenizer (languages, ",");
+ while (langTokenizer.hasMoreTokens ())
+ {
+ String lang = langTokenizer.nextToken ();
+ Locale loc = getLocaleForLanguage (lang);
+ String charset = getCharsetForLocale (loc, charsets);
+ if (charset == null)
+ continue;
+ // We can use the values if this point is reached
+ m_chosenLocale = loc;
+ m_chosenCharset = charset;
+ return;
+ }
+ // We didn't found anything, so we will use the defaults
+ m_chosenLocale = defaultLocale;
+ m_chosenCharset = defaultCharset;
+ } // LocaleHandler
+
+ /**
+ * Gets the chosen locale.
+ *
+ * @return the chosen locale
+ */
+ public Locale getLocale ()
+ {
+ return m_chosenLocale;
+ } // getLocale
+
+ /**
+ * Gets the chosen charset.
+ *
+ * @return the chosen charset
+ */
+ public String getCharset ()
+ {
+ return m_chosenCharset;
+ } // getCharset
+
+ /*
+ * Gets a Locale object for a given language string
+ */
+ private Locale getLocaleForLanguage (String lang)
+ {
+ Locale loc;
+ int semi, dash;
+ // Cut off any qvalue that might come after a semi-colon
+ if ((semi = lang.indexOf (';')) != -1)
+ {
+ lang = lang.substring (0, semi);
+ }
+ // Trim any whitespace
+ lang = lang.trim ();
+ // Create a Locale from the language. A dash may separate the
+ // language from the country.
+ if ((dash = lang.indexOf ('-')) == -1)
+ {
+ loc = new Locale (lang, ""); // No dash, no country
+ }
+ else
+ {
+ loc = new Locale (lang.substring (0, dash), lang
+ .substring (dash + 1));
+ }
+ return loc;
+ } // getLanguageForLanguage
+
+ /**
+ * Gets the best charset for a given locale, selecting from a charset list.
+ * Currently ignores the charset list. Subclasses can override this method
+ * to take the list into account.
+ *
+ * @param loc
+ * the locale
+ * @param charsets
+ * a comma-separated charset list
+ * @return the best charset for the given locale from the given list
+ */
+ protected String getCharsetForLocale (Locale loc, String charsets)
+ {
+ // Note: This method ignores the client-specified charsets
+ return getCharset (loc);
+ } // getCharsetForLocale
+
+ /**
+ * Gets the preferred charset for the given locale, or null if the locale is
+ * not recognized.
+ *
+ * @param loc
+ * the locale
+ * @return the preferred charset
+ */
+ public static String getCharset (Locale loc)
+ {
+ String charset;
+ // Try for an full name match (may include country)
+ charset = (String)s_map.get (loc.toString ());
+ if (charset != null)
+ return charset;
+ // If a full name didn't match, try just the language
+ charset = (String)s_map.get (loc.getLanguage ());
+ return charset; // may be null
+ } // getCharset
+
+} // LocaleHandler
+
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/RequestAnalyzer.java b/webCM/src/main/servlet/org/compiere/cm/utils/RequestAnalyzer.java
new file mode 100644
index 0000000000..301fa55ee3
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/RequestAnalyzer.java
@@ -0,0 +1,360 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.lang.reflect.Constructor;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.ResultSet;
+import java.util.Properties;
+import java.util.logging.Level;
+import org.compiere.model.*;
+import org.compiere.cm.cache.*;
+import org.compiere.cm.*;
+import org.compiere.util.*;
+
+/**
+ * RequestAnalyzer
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class RequestAnalyzer
+{
+
+ private String m_requestURL;
+
+ private String m_relativeURL;
+
+ private String m_serverName;
+
+ private String m_baseURL;
+
+ private String m_redirectURL;
+
+ private String m_procClassName = null;
+
+ private MWebProjectDomain m_WebProjectDomain;
+
+ private MWebProject m_WebProject;
+
+ private MContainer m_Container;
+
+ private boolean m_isValid = false;
+
+ private boolean m_isSecure = false;
+
+ private boolean m_isRedirect = false;
+
+ private int m_portNumber = 80;
+
+ private HttpServletRequest m_request;
+
+ private Properties m_ctx;
+
+ private HttpSession m_session;
+
+ /**
+ * RequestAnalyzer
+ * @param servlet servlet
+ * @param request request
+ * @param showStage show stage
+ * @param servletExtend servlet extend
+ */
+ public RequestAnalyzer (HttpServletCM servlet, HttpServletRequest request,
+ boolean showStage, String servletExtend)
+ {
+ Domain domainCache = servlet.getDomainCache ();
+ WebProject webProjectCache = servlet.getWebProjectCache ();
+ Container containerCache = servlet.getContainerCache ();
+ if (servletExtend==null) servletExtend="";
+ m_request = request;
+ m_ctx = servlet.getCtx ();
+ m_requestURL = m_request.getRequestURL ().toString ();
+ m_serverName = m_request.getServerName ();
+ m_baseURL = m_requestURL.substring (0, m_requestURL.indexOf (m_serverName)
+ + m_serverName.length () + servletExtend.length ())
+ + m_request.getContextPath ();
+ m_relativeURL = m_requestURL.substring (m_baseURL.length ());
+ // If RelativeURL is empty it should be /
+ if (m_relativeURL== null || m_relativeURL.equals("")) m_relativeURL="/";
+ // If URL ends with a / we should continue it with index.html
+ if (m_relativeURL.substring (m_relativeURL.length () - 1).equals ("/"))
+ m_relativeURL = m_relativeURL + "index.html";
+ m_isSecure = m_request.isSecure ();
+ m_portNumber = m_request.getServerPort ();
+ m_WebProjectDomain = domainCache.getWebProjectDomain (m_serverName);
+ if (m_WebProjectDomain != null)
+ {
+ // If we could identify the Domain we will have a project etc.
+ m_WebProject = webProjectCache.getWebProject
+ (m_WebProjectDomain.getCM_WebProject_ID ());
+ }
+ else
+ {
+ // Since we have not found a sufficient WebProject Domain we will
+ // fallback to the default
+ int[] defaultID = MWebProject.getAllIDs ("CM_WebProject",
+ "AD_Client_ID=0", null);
+ if (defaultID.length > 0)
+ m_WebProject = webProjectCache.getWebProject (defaultID[0]);
+ else {
+ m_isRedirect = true;
+ m_redirectURL = m_requestURL + "admin/";
+ }
+ // JJ
+ //throw new IllegalStateException("Unknown context - Set up Web Project"); // no known context
+ }
+ // Check for adempiere.jnlp
+ if (m_relativeURL!=null) {
+ if(m_relativeURL.equals("/adempiere.jnlp") || m_relativeURL.equals("/adempiereDirect.jnlp"))
+ {
+ m_isRedirect = true;
+ m_redirectURL = m_requestURL.substring(0,m_requestURL.indexOf(m_serverName)+m_serverName.length()) + "/admin" + m_relativeURL;
+ }
+ }
+ if (!m_isRedirect) {
+ if (m_relativeURL != null)
+ {
+ // We have a URL, so let's see whether we can handle it...
+ m_Container = containerCache.getCM_ContainerByURL (m_relativeURL,
+ m_WebProject.get_ID (), true);
+ if (m_Container == null)
+ m_isValid = false;
+ else
+ m_isValid = true;
+ if (m_isValid && !m_Container.getRelativeURL ().equals (m_relativeURL))
+ {
+ m_isRedirect = true;
+ m_redirectURL = m_Container.getRelativeURL ();
+ }
+ }
+ else
+ {
+ // We have no or an invalid relative URL found, so we need to
+ // fallback to Domain or Error handling
+ if (m_WebProjectDomain.getCM_Container_ID () > 0)
+ {
+ m_Container = containerCache.getCM_Container (
+ m_WebProjectDomain.getCM_Container_ID (),
+ m_WebProject.get_ID ());
+ }
+ if (m_Container == null)
+ {
+ m_Container = containerCache.getCM_ContainerByURL
+ ("/index.html", m_WebProject.get_ID (), true);
+ if (m_Container == null)
+ {
+ m_isValid = false;
+ }
+ else
+ {
+ m_isValid = true;
+ }
+ if (m_isValid
+ && !m_Container.getRelativeURL ().equals ("/index.html"))
+ {
+ m_isRedirect = true;
+ m_redirectURL = m_Container.getRelativeURL ();
+ }
+ }
+ }
+ if (m_isValid == false) {
+ // Try to solve invalid requests
+ if (m_WebProject==null || m_WebProject.getAD_Client_ID()==0)
+ {
+ // If we endup with an invalid request in NULL or System Project we redirect to /admin/
+ m_isRedirect = true;
+ m_redirectURL = m_requestURL.substring(0,m_requestURL.indexOf(m_serverName)+m_serverName.length()) + "/admin/";
+ }
+ }
+ if (m_isValid) {
+ if (m_Container.getContainerType ().equals ("L")) {
+ m_isRedirect = true;
+ MContainer linkedContainer = containerCache.getCM_Container (m_Container.getCM_ContainerLink_ID (), m_WebProject.get_ID());
+ if (linkedContainer!=null)
+ m_redirectURL = linkedContainer.getRelativeURL ();
+ }
+ servlet.setAD_Client_ID(m_WebProject.getAD_Client_ID());
+
+ }
+ }
+ if (m_request.getParameter ("cn")!=null) {
+ String className = m_request.getParameter("cn");
+ // First check adempiere.cm.
+ if (classChecker("adempiere.cm." + className,servlet.getLogger()))
+ m_procClassName = "adempiere.cm." + className;
+ if (classChecker("org.compiere.cm.extend." + className,servlet.getLogger()))
+ m_procClassName = "org.compiere.cm.extend." + className;
+ }
+ } // RequestAnalyzer
+
+ private boolean classChecker(String className, CLogger log) {
+ try
+ {
+ Class clazz = Class.forName(className);
+ // Make sure that it is a cm.Extend class
+ Class superClazz = clazz.getSuperclass();
+ while (superClazz != null)
+ {
+ if (superClazz == org.compiere.cm.Extend.class)
+ {
+ log.fine("Use: " + className);
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ log.finest("Not found: " + className);
+ return false;
+ }
+
+ public org.compiere.cm.Extend getProcClass()
+ {
+ if (m_procClassName==null)
+ return null;
+ try {
+ Class thisProcClass = Class.forName (m_procClassName);
+ boolean errorLogged = false;
+ try
+ {
+ Constructor constructor = thisProcClass.getDeclaredConstructor(new Class[]{HttpServletRequest.class, Properties.class});
+ Extend procClass = (Extend)constructor.newInstance(new Object[] {m_request, m_ctx});
+ return procClass;
+ }
+ catch (Exception e)
+ {
+ }
+ return null;
+ }
+ catch (Exception e)
+ {
+ }
+ return null;
+ }
+
+ /**
+ * Get Request URL
+ * @return request url
+ */
+ public String getRequestURL ()
+ {
+ return m_requestURL;
+ } // getRequestURL
+
+ /**
+ * Get ServerName
+ * @return server name
+ */
+ public String getServerName ()
+ {
+ return m_serverName;
+ } // getServerName
+
+ /**
+ * get WebProject_Domain
+ * @return web project domain
+ */
+ public MWebProjectDomain getWebProjectDomain()
+ {
+ return m_WebProjectDomain;
+ } // getWebProjectDomain
+
+ /**
+ * Get WebProject
+ * @return web project
+ */
+ public MWebProject getWebProject ()
+ {
+ return m_WebProject;
+ } // getWebProject
+
+ /**
+ * Get CM_Container
+ * @return container
+ */
+ public MContainer getCM_Container ()
+ {
+ return m_Container;
+ } // getCM_Container
+
+ /**
+ * Valid
+ * @return true if valid
+ */
+ public boolean getIsValid ()
+ {
+ return m_isValid;
+ } // getIsValid
+
+ /**
+ * Redirect
+ * @return true redirect
+ */
+ public boolean getIsRedirect ()
+ {
+ return m_isRedirect;
+ } // getIsRedirect
+
+ /**
+ * setRedirectURL
+ * @param redirectURL
+ */
+ public void setRedirectURL(String redirectURL)
+ {
+ m_redirectURL = redirectURL;
+ }
+
+ /**
+ * Get Redirect URL
+ * @return URL
+ */
+ public String getRedirectURL ()
+ {
+ try {
+ /* We will use the URL Object to check the validity of the URL
+ * this would not imply that the URL is reachable, it only
+ * checks the format.
+ */
+ URL testURL = new URL(m_redirectURL);
+ return m_redirectURL;
+ } catch (MalformedURLException E) {
+ if (m_redirectURL.equals ("/error404.html"))
+ {
+ return m_baseURL + m_redirectURL + "?errorURL=" + m_relativeURL;
+ }
+ else
+ {
+ return m_baseURL + m_redirectURL;
+ }
+ }
+ } // getRedirectURL
+
+ /**
+ * Get Processor Class Name
+ * @return ClassName for Processor
+ */
+ public String getProcClassName()
+ {
+ return m_procClassName;
+ }
+
+} // RequestAnalyzer
diff --git a/webCM/src/main/servlet/org/compiere/cm/utils/TreeXML.java b/webCM/src/main/servlet/org/compiere/cm/utils/TreeXML.java
new file mode 100644
index 0000000000..f723a0753d
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/utils/TreeXML.java
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.utils;
+
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.logging.Level;
+
+import org.compiere.Adempiere;
+import org.compiere.model.MCStage;
+import org.compiere.model.MContainer;
+import org.compiere.model.MTree;
+import org.compiere.model.MTreeNode;
+import org.compiere.model.MWebProject;
+import org.compiere.util.CLogger;
+
+public class TreeXML {
+ protected StringBuffer xmlContainer = new StringBuffer(" ");
+ protected StringBuffer xmlTree = new StringBuffer(" ");
+ protected Properties ctx;
+ protected String trxName;
+ private HashMap m_map = new HashMap();
+
+
+ public TreeXML(MWebProject m_project) {
+ ctx = m_project.getCtx();
+ trxName = m_project.get_TrxName();
+
+ // Containers
+ MContainer[] containers = MContainer.getContainers(m_project);
+ for (int i = 0; i < containers.length; i++)
+ m_map.put(new Integer(containers[i].getCM_Container_ID()), containers[i]);
+
+ MTree thisTree = new MTree (m_project.getCtx(), m_project.getAD_TreeCMC_ID(), true, true, m_project.get_TrxName());
+ generateTree(m_project, thisTree);
+ }
+
+ public void generateTree(MWebProject m_project, MTree thisTree) {
+ MTreeNode root = thisTree.getRoot();
+ xmlTree.append(appendNode(root));
+ }
+
+ private String appendNode(MTreeNode thisNode) {
+ StringBuffer tempTree = new StringBuffer();
+ Integer ID = new Integer(thisNode.getNode_ID());
+ MContainer container = m_map.get(ID);
+ //
+ int size = thisNode.getChildCount();
+ for (int i = 0; i < size; i++)
+ {
+ MTreeNode child = (MTreeNode)thisNode.getChildAt(i);
+ ID = new Integer(child.getNode_ID());
+ container = m_map.get(ID);
+ if (container == null)
+ {
+ continue;
+ }
+ if (!container.isActive())
+ continue;
+ //
+ tempTree.append("");
+ tempTree.append("" + container.get_ID() + "");
+ tempTree.append("" + container.getName() + "");
+ tempTree.append("" + container.getTitle() + "");
+ tempTree.append("" + container.getRelativeURL() + "");
+ tempTree.append("" + container.getDescription() + "");
+ tempTree.append("" + child.getChildCount() + "");
+ xmlContainer = container.get_xmlString(xmlContainer);
+ if (child.isSummary())
+ tempTree.append(appendNode(child));
+ tempTree.append("");
+ }
+ return tempTree.toString();
+ }
+
+ public String getTreeXML() {
+ return "\n\n" + xmlTree.toString() + "\n\n";
+ }
+
+ public String getContainerXML() {
+ return "\n\n" + xmlContainer.toString() + "\n\n";
+ }
+}
diff --git a/webCM/src/main/servlet/org/compiere/cm/xml/Generator.java b/webCM/src/main/servlet/org/compiere/cm/xml/Generator.java
new file mode 100644
index 0000000000..6002bdbe3e
--- /dev/null
+++ b/webCM/src/main/servlet/org/compiere/cm/xml/Generator.java
@@ -0,0 +1,565 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * 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. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.cm.xml;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.logging.Level;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.compiere.Adempiere;
+import org.compiere.cm.HttpServletCM;
+import org.compiere.cm.cache.Chat;
+import org.compiere.cm.cache.ContainerElement;
+import org.compiere.cm.cache.ContainerTree;
+import org.compiere.cm.utils.Counter;
+import org.compiere.cm.utils.RequestAnalyzer;
+import org.compiere.model.MAd;
+import org.compiere.model.MBPBankAccount;
+import org.compiere.model.MBPartner;
+import org.compiere.model.MBPartnerLocation;
+import org.compiere.model.MLocation;
+import org.compiere.model.MLookupFactory;
+import org.compiere.model.MNewsChannel;
+import org.compiere.model.MTable;
+import org.compiere.model.MTemplate;
+import org.compiere.model.MUser;
+import org.compiere.model.PO;
+import org.compiere.model.X_CM_Container_Element;
+import org.compiere.model.X_CM_NewsChannel;
+import org.compiere.model.X_CM_TemplateTable;
+import org.compiere.util.DB;
+import org.compiere.util.Language;
+import org.compiere.util.WebInfo;
+import org.w3c.dom.Document;
+
+/**
+ * This Generator builds up the XML for the XSLT Template Engine
+ *
+ * @author Yves Sandfort
+ * @version $Id$
+ */
+public class Generator
+{
+
+ protected StringBuffer xmlCode = new StringBuffer ();
+
+ protected RequestAnalyzer thisRequest;
+
+ /**
+ * Generator Object for the generation of XML Context
+ *
+ * @param thisServlet
+ * currentServletHandler
+ * @param httpRequest
+ * currentRequest
+ * @param tempRequest
+ * currentRequestAnalyzer
+ * @param xmlAppend
+ */
+ public Generator (HttpServletCM thisServlet,
+ HttpServletRequest httpRequest, RequestAnalyzer tempRequest, StringBuffer xmlAppend)
+ {
+ thisRequest = tempRequest;
+ xmlCode.append ("\n").append (
+ "\n").append ("\n").append ("").append (
+ thisServlet.getBuildDate ()).append ("\n");
+ generateSystemHeader (thisServlet);
+ generateProjectHeader ();
+ generateThisContainer (thisServlet.getContainerElementCache (),
+ thisServlet.getChatCache ());
+ generateExternalTables (thisServlet.getDomainCache ().getCtx (), httpRequest);
+ generateContainerTree (thisServlet.getContainerTreeCache ());
+ MTemplate thisTemplate = thisRequest.getCM_Container ().getTemplate ();
+ if (thisTemplate.isNews ())
+ generateNewsFeed (thisServlet.getDomainCache ().getCtx ());
+ if (thisTemplate.isUseAd ())
+ generateAdCode (httpRequest, thisTemplate);
+ // TODO change the decision via IsRequest boolean for Template
+ if (thisTemplate.getName().toUpperCase().indexOf("REQUEST") > -1)
+ generateRequest(httpRequest, thisServlet.getXMLCache(), thisServlet.getCtx ());
+ generateCommunity(thisServlet.getXMLCache ());
+ generateSessionEquiv(thisServlet, httpRequest, thisServlet.getCtx ());
+ queryStringToXML (httpRequest);
+ xmlCode.append(xmlAppend);
+ }
+
+ private void generateSystemHeader (HttpServletCM thisServlet)
+ {
+ xmlCode.append ("\n");
+ xmlCode.append ("\n");
+ xmlCode.append ("" + Adempiere.MAIN_VERSION
+ + "\n");
+ xmlCode.append ("" + Adempiere.DATE_VERSION
+ + "\n");
+ xmlCode.append ("" + Adempiere.DB_VERSION + "\n");
+ xmlCode.append ("\n");
+ xmlCode.append ("\n");
+ xmlCode.append (""
+ + thisServlet.getInternalMediaURL () + "\n");
+ xmlCode.append (""
+ + thisServlet.getExternalMediaURL () + "\n");
+ xmlCode.append ("\n");
+ Calendar cal = Calendar.getInstance ();
+ xmlCode.append ("" + cal.get (Calendar.DAY_OF_MONTH)
+ + "\n");
+ xmlCode.append ("" + cal.get (Calendar.MONTH)
+ + "\n");
+ xmlCode.append ("" + cal.get (Calendar.YEAR)
+ + "\n");
+ xmlCode.append ("" + cal.get (Calendar.HOUR_OF_DAY)
+ + "\n");
+ xmlCode.append ("" + cal.get (Calendar.MINUTE)
+ + "\n");
+ xmlCode.append ("" + cal.get (Calendar.SECOND)
+ + "\n");
+ xmlCode.append ("" + Counter.getActiveSessions ()
+ + "\n");
+ xmlCode.append ("\n");
+ }
+
+ private void generateSessionEquiv(HttpServletCM thisServlet, HttpServletRequest httpRequest, Properties ctx)
+ {
+ xmlCode.append("\n");
+ HttpSession thisSession = httpRequest.getSession (false);
+ if (thisSession!=null) {
+ if (thisSession.getAttribute (WebInfo.NAME)!=null)
+ {
+ WebInfo wi = (WebInfo) thisSession.getAttribute (WebInfo.NAME);
+ xmlCode.append ("\n");
+ xmlCode.append ("\n");
+ if (wi.getUser_ID ()>0)
+ {
+ MUser thisUser = MUser.get (ctx, wi.getAD_User_ID ());
+ xmlCode = thisUser.get_xmlString (xmlCode);
+ MBPartner thisBPartner = new MBPartner(ctx, wi.getC_BPartner_ID (), null);
+ if (thisBPartner!=null)
+ xmlCode = thisBPartner.get_xmlString (xmlCode);
+ MBPartnerLocation thisBPartnerLocation = thisBPartner.getPrimaryC_BPartner_Location ();
+ if (thisBPartnerLocation!=null)
+ xmlCode = thisBPartnerLocation.get_xmlString (xmlCode);
+ MLocation thisLocation = MLocation.getBPLocation (ctx, thisBPartnerLocation.get_ID (), null);
+ if (thisLocation!=null)
+ xmlCode = thisLocation.get_xmlString (xmlCode);
+ MBPBankAccount[] theseBPBankAccount = thisBPartner.getBankAccounts (true);
+ if (theseBPBankAccount!=null && theseBPBankAccount.length>0)
+ for (int i=0; i\n");
+ wi.getWebUser ().setPasswordMessage (null);
+ }
+ if (wi.getWebUser ().getSaveErrorMessage ()!=null)
+ {
+ xmlCode.append ("\n");
+ wi.getWebUser ().setSaveErrorMessage (null);
+ }
+ if (thisSession.getAttribute("hdrMessage")!=null) {
+ xmlCode.append ("\n");
+ thisSession.removeAttribute ("hdrMessage");
+ }
+ xmlCode.append ("\n");
+ xmlCode.append ("" + wi.getWebUser ().isLoggedIn () + "\n");
+ xmlCode.append ("\n");
+ xmlCode.append ("\n");
+ }
+ if (thisSession.getAttribute ("EMail")!=null)
+ xmlCode.append ("\n");
+ }
+ xmlCode.append("\n");
+ }
+
+ private void generateCommunity(org.compiere.cm.cache.XML thisXML)
+ {
+ xmlCode.append("\n");
+ xmlCode.append(thisXML.getXML ("C_Country"));
+ xmlCode.append("\n");
+ }
+
+ /**
+ * Creates the XML tree for request tables.
+ *
+ * @param httpRequest
+ * @param thisXML
+ * @param ctx
+ */
+ private void generateRequest(HttpServletRequest httpRequest, org.compiere.cm.cache.XML thisXML, Properties ctx)
+ {
+ HttpSession thisSession = httpRequest.getSession (false);
+ WebInfo wi = null;
+ if (thisSession!=null) {
+ if (thisSession.getAttribute (WebInfo.NAME)!=null)
+ wi = (WebInfo) thisSession.getAttribute (WebInfo.NAME);
+
+ xmlCode.append("\n");
+ int l_nClientID = Integer.parseInt(ctx.getProperty("#AD_Client_ID"));
+
+ if (wi != null) {
+ if (wi.getC_BPartner_ID() != -1) {
+ genTable("AD_User", "(AD_User.IsActive='Y' AND AD_User.AD_Client_ID=" + l_nClientID + " AND AD_User.C_BPartner_ID=@C_BPartner_ID@) ORDER BY AD_User.AD_User_ID", false, ctx, wi);
+ genTable("C_BPartner", "(C_BPartner.IsActive='Y' AND C_BPartner.AD_Client_ID=" + l_nClientID + " AND C_BPartner.C_BPartner_ID=@C_BPartner_ID@)ORDER BY C_BPartner.C_BPartner_ID", false, ctx, wi);
+ genTable("C_Invoice", "(C_Invoice.IsActive='Y' AND C_Invoice.AD_Client_ID=" + l_nClientID + " AND C_Invoice.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Invoice.C_Invoice_ID", false, ctx, wi);
+ genTable("C_Order", "(C_Order.IsActive='Y' AND C_Order.AD_Client_ID=" + l_nClientID + " AND C_Order.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Order.C_Order_ID", false, ctx, wi);
+ genTable("C_Payment", "(C_Payment.IsActive='Y' AND C_Payment.AD_Client_ID=" + l_nClientID + " AND C_Payment.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Payment.C_Payment_ID", false, ctx, wi);
+ genTable("C_Project", "(C_Project.IsActive='Y' AND C_Project.AD_Client_ID=" + l_nClientID + " AND C_Project.C_BPartner_ID=@C_BPartner_ID@) ORDER BY C_Project.C_Project_ID", false, ctx, wi);
+ genTable("M_InOut", "(M_InOut.IsActive='Y' AND M_InOut.AD_Client_ID=" + l_nClientID + " AND M_InOut.C_BPartner_ID=@C_BPartner_ID@) ORDER BY M_InOut.M_InOut_ID", false, ctx, wi);
+ genTable("R_Request", "(R_Request.IsActive='Y' AND R_Request.AD_Client_ID=" + l_nClientID + " AND R_Request.C_BPartner_ID=@C_BPartner_ID@) ORDER BY R_Request.R_Request_ID", true, ctx, wi);
+ genTable("R_RequestUpdate", "(R_RequestUpdate.IsActive='Y' AND R_RequestUpdate.AD_Client_ID=" + l_nClientID + " AND R_RequestUpdate.R_Request_ID IN (SELECT R_Request.R_Request_ID FROM R_Request WHERE R_Request.IsActive='Y' AND R_Request.AD_Client_ID=" + l_nClientID + " AND R_Request.C_BPartner_ID=@C_BPartner_ID@)) ORDER BY R_RequestUpdate.R_RequestUpdate_ID", true, ctx, wi);
+ }
+ genTable("A_Asset", "A_Asset.IsActive='Y' AND A_Asset.AD_Client_ID=" + l_nClientID + " ORDER BY A_Asset.A_Asset_ID", false, ctx, wi);
+ //genTable("AD_Role", "AD_Role.IsActive='Y' AND AD_Role.AD_Client_ID=" + l_nClientID + " ORDER BY AD_Role.AD_Role_ID", false, ctx, wi);
+ genTable("C_Activity", "C_Activity.IsActive='Y' AND C_Activity.AD_Client_ID=" + l_nClientID + " ORDER BY C_Activity.C_Activity_ID", false, ctx, wi);
+ genTable("C_Campaign", "C_Campaign.IsActive='Y' AND C_Campaign.AD_Client_ID=" + l_nClientID + " ORDER BY C_Campaign.C_Campaign_ID", false, ctx, wi);
+ genTable("M_Product", "M_Product.IsActive='Y' AND M_Product.AD_Client_ID=" + l_nClientID + " ORDER BY M_Product.M_Product_ID", false, ctx, wi);
+ genTable("M_RMA", "M_RMA.IsActive='Y' AND M_RMA.AD_Client_ID=" + l_nClientID + " ORDER BY M_RMA.M_RMA_ID", false, ctx, wi);
+ genTable("R_Category", "R_Category.IsActive='Y' AND R_Category.AD_Client_ID=" + l_nClientID + " ORDER BY R_Category.R_Category_ID", false, ctx, wi);
+ genTable("R_Group", "R_Group.IsActive='Y' AND R_Group.AD_Client_ID=" + l_nClientID + " ORDER BY R_Group.R_Group_ID", false, ctx, wi);
+ genTable("R_MailText", "R_MailText.IsActive='Y' AND R_MailText.AD_Client_ID=" + l_nClientID + " ORDER BY R_MailText.R_MailText_ID", true, ctx, wi);
+ genTable("R_RequestType", "R_RequestType.IsActive='Y' AND R_RequestType.AD_Client_ID=" + l_nClientID + " ORDER BY R_RequestType.R_RequestType_ID", false, ctx, wi);
+ genTable("R_Resolution", "R_Resolution.IsActive='Y' AND R_Resolution.AD_Client_ID=" + l_nClientID + " ORDER BY R_Resolution.R_Resolution_ID", false, ctx, wi);
+ genTable("R_StandardResponse", "R_StandardResponse.IsActive='Y' AND R_StandardResponse.AD_Client_ID=" + l_nClientID + " ORDER BY R_StandardResponse.R_StandardResponse_ID", false, ctx, wi);
+ genTable("R_Status", "R_Status.IsActive='Y' AND R_Status.AD_Client_ID=" + l_nClientID + " ORDER BY R_Status.R_Status_ID", false, ctx, wi);
+
+ genTable("_PriorityRule", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=154) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
+ genTable("R_Request_Confidential", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=340) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
+ genTable("R_Request_Due_Typ", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=222) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
+ genTable("R_Request_Next_Action", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=219) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
+ genTable("R_Request_TaskStatus", "(AD_Ref_List.IsActive='Y' AND AD_Ref_List.AD_Reference_ID=366) ORDER BY AD_Ref_List.AD_Ref_List_ID", false, ctx, wi);
+ }
+ xmlCode.append("\n");
+ }
+ }
+
+ private void generateProjectHeader ()
+ {
+ xmlCode.append ("\n");
+ xmlCode = thisRequest.getWebProject ().get_xmlString (xmlCode);
+ if (thisRequest.getWebProjectDomain () != null)
+ xmlCode = thisRequest.getWebProjectDomain ()
+ .get_xmlString (xmlCode);
+ xmlCode.append ("\n\n");
+ }
+
+ private void generateThisContainer (ContainerElement containerElementCache,
+ Chat chatCache)
+ {
+ xmlCode.append ("\n");
+ xmlCode = thisRequest.getCM_Container ().get_xmlString (xmlCode);
+ /*int[] tableKeys = X_CM_Chat.getAllIDs ("CM_Chat", "AD_Table_ID="
+ + thisRequest.getCM_Container ().get_Table_ID ()
+ + " AND Record_ID=" + thisRequest.getCM_Container ().get_ID (),
+ "WebCM");
+ if (tableKeys != null)
+ {
+ if (tableKeys.length > 0)
+ {
+ for (int i = 0; i < tableKeys.length; i++)
+ {
+ xmlCode = chatCache.getCM_Chat (tableKeys[i])
+ .get_xmlString (xmlCode);
+ }
+ }
+ }*/
+ int[] tableKeys = X_CM_Container_Element.getAllIDs ("CM_Container_Element",
+ "CM_Container_ID=" + thisRequest.getCM_Container ().get_ID (),
+ "WebCM");
+ if (tableKeys.length > 0)
+ {
+ // Found elements, so let's show them...
+ for (int i = 0; i < tableKeys.length; i++)
+ {
+ X_CM_Container_Element thisElement = containerElementCache
+ .getCM_Container_Element (tableKeys[i], thisRequest
+ .getCM_Container ().getCM_WebProject_ID ());
+ if (thisElement != null)
+ {
+ StringBuffer newCode = new StringBuffer ();
+ thisElement.get_xmlString (newCode);
+ if (newCode.indexOf ("") >= 0)
+ newCode.delete (newCode
+ .indexOf ("") + 6);
+ if (newCode.indexOf ("") >= 0)
+ newCode.delete (newCode.indexOf ("