Adempiere 3.1.2
This commit is contained in:
parent
64eca30fca
commit
43c7859095
|
@ -3,59 +3,67 @@
|
|||
* 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
|
||||
* 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
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
*/
|
||||
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...");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
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
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
doGet(request, response);
|
||||
} // doPost
|
||||
}
|
||||
{
|
||||
doGet(request, response);
|
||||
} // doPost
|
||||
}
|
||||
|
|
|
@ -3,154 +3,152 @@
|
|||
* 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
|
||||
* 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);
|
||||
// We will reset the Media URL for each request. Should be moved in the session.
|
||||
resetInternalMediaURL (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 ("<H1>Fatal Error:" + ErrorMessage + "</H1>");
|
||||
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
|
||||
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 ("<H1>Fatal Error:" + ErrorMessage + "</H1>");
|
||||
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
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* 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.
|
||||
* 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.
|
||||
|
@ -22,84 +22,84 @@ 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
|
||||
{
|
||||
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();
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* 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.
|
||||
* 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.
|
||||
|
@ -15,104 +15,105 @@
|
|||
*****************************************************************************/
|
||||
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;
|
||||
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
|
||||
* Extend
|
||||
* @param request
|
||||
* @param t_ctx
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,377 +3,374 @@
|
|||
* 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
|
||||
* 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;
|
||||
protected 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
|
||||
*/
|
||||
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)
|
||||
public void resetInternalMediaURL (HttpServletRequest request)
|
||||
{
|
||||
if (internalMediaURL == null)
|
||||
{
|
||||
internalMediaURL = request.getRequestURL ().toString ().substring (
|
||||
0,
|
||||
request.getRequestURL ().toString ().indexOf (
|
||||
request.getServerName ())
|
||||
+ request.getServerName ().length ())
|
||||
+ request.getContextPath () + "/media/";
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,124 +1,132 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Compiere 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
|
||||
* 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
|
||||
* @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);
|
||||
|
||||
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
|
||||
{
|
||||
// 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
|
||||
* Process the HTTP Post request
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
doGet(request, response);
|
||||
} // doPost
|
||||
|
||||
} // Broadcast
|
||||
{
|
||||
doGet(request, response);
|
||||
} // doPost
|
||||
|
||||
} // Broadcast
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
* 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.
|
||||
* 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.
|
||||
|
@ -15,78 +15,77 @@
|
|||
*****************************************************************************/
|
||||
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 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
|
||||
|
||||
/**
|
||||
* 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());
|
||||
/** serialVersionUID */
|
||||
private static final long serialVersionUID = 6979583935052312291L;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
* @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();
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
|
|
@ -3,118 +3,118 @@
|
|||
* 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 *
|
||||
*****************************************************************************/
|
||||
* 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$
|
||||
*/
|
||||
/**
|
||||
* Broadcast Servlet
|
||||
*
|
||||
* @author $Author$
|
||||
* @version $Id$
|
||||
*/
|
||||
public class StageBroadcast extends HttpServletCM
|
||||
{
|
||||
|
||||
/** serialVersionUID */
|
||||
private static final long serialVersionUID = 7348394433516908807L;
|
||||
|
||||
/**
|
||||
* 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 ("<H1>Fatal Error:" + ErrorMessage + "</H1>");
|
||||
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
|
||||
* @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 ("<H1>Fatal Error:" + ErrorMessage + "</H1>");
|
||||
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
|
||||
|
|
|
@ -3,64 +3,66 @@
|
|||
* 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$
|
||||
* 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
|
||||
{
|
||||
/** serialVersionUID */
|
||||
private static final long serialVersionUID = -1280320974132533949L;
|
||||
|
||||
/**
|
||||
* Get
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void doGet (HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
* @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);
|
||||
resetInternalMediaURL (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
|
||||
.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
|
||||
|
|
|
@ -3,130 +3,177 @@
|
|||
* 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;
|
||||
* 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;
|
||||
|
||||
* 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());
|
||||
|
||||
/**
|
||||
* Cache Object
|
||||
*/
|
||||
public CO () {
|
||||
}
|
||||
|
||||
/**
|
||||
* set Context
|
||||
* @param thisCtx
|
||||
*/
|
||||
public void setCtx(Properties thisCtx) {
|
||||
ctx = thisCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Context
|
||||
* @return Context
|
||||
*/
|
||||
public Properties getCtx() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* put
|
||||
* @param ID
|
||||
* @param thisObject
|
||||
*/
|
||||
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();
|
||||
cacheUsage.put(ID, thisLong);
|
||||
if (cacheUsage.size()>cacheSize-1) {
|
||||
cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove
|
||||
* @param ID
|
||||
*/
|
||||
public void remove(String ID) {
|
||||
cache.remove(ID);
|
||||
cacheUsage.remove(ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* getSize of current cache
|
||||
* @return number of cache entries
|
||||
*/
|
||||
public int getSize() {
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* get key enumeration
|
||||
* @return key enumeration
|
||||
*/
|
||||
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;i<vecKeys.size();i++)
|
||||
{
|
||||
String value = vecKeys.get(i).toString();
|
||||
String key = "";
|
||||
Enumeration keys = cacheUsage.keys();
|
||||
while (keys.hasMoreElements() && key.equals("")) {
|
||||
String thisKey = keys.nextElement().toString();
|
||||
String tempValue = cacheUsage.get(thisKey).toString();
|
||||
if (tempValue.equals(value)) {
|
||||
key = thisKey;
|
||||
}
|
||||
}
|
||||
// Use Maxelements -1 since i starts with 0
|
||||
if (i>cacheSize-1) {
|
||||
cache.remove(key);
|
||||
cacheUsage.remove(key);
|
||||
log.fine("Item: " + key + " from cache: " + this.getClass().getName() + " was removed.");
|
||||
}
|
||||
|
||||
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;i<vecKeys.size();i++)
|
||||
{
|
||||
String value = vecKeys.get(i).toString();
|
||||
String key = "";
|
||||
Enumeration keys = cacheUsage.keys();
|
||||
while (keys.hasMoreElements() && key.equals("")) {
|
||||
String thisKey = keys.nextElement().toString();
|
||||
String tempValue = cacheUsage.get(thisKey).toString();
|
||||
if (tempValue.equals(value)) {
|
||||
key = thisKey;
|
||||
}
|
||||
}
|
||||
// Use Maxelements -1 since i starts with 0
|
||||
if (i>cacheSize-1) {
|
||||
cache.remove(key);
|
||||
cacheUsage.remove(key);
|
||||
log.fine("Item: " + key + " from cache: " + this.getClass().getName() + " was removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Usage value for cache optimization
|
||||
* @param ID
|
||||
*/
|
||||
public void use(int ID) {
|
||||
Long thisLong = new Long(new java.util.Date().getTime());
|
||||
cacheUsage.put("" + ID, thisLong);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Usage value for cache optimization
|
||||
* @param ID
|
||||
*/
|
||||
public void use(String ID) {
|
||||
Long thisLong = new Long(new java.util.Date().getTime());
|
||||
cacheUsage.put(ID, thisLong);
|
||||
}
|
||||
|
||||
/**
|
||||
* empty complete Cache
|
||||
*/
|
||||
public void empty() {
|
||||
cache = new Hashtable(cacheSize);
|
||||
cacheUsage = new Hashtable(cacheSize);
|
||||
log.fine("Cache: " + this.getClass().getName() + " was cleared.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Cache Content
|
||||
* @return XML String with CacheContent
|
||||
*/
|
||||
public String show() {
|
||||
StringBuffer tStrHTML = new StringBuffer();
|
||||
Enumeration thisEnum = null;
|
||||
tStrHTML.append(" <size>" + this.getSize() + "</size>\n");
|
||||
thisEnum = this.getKeys();
|
||||
while (thisEnum.hasMoreElements()) {
|
||||
tStrHTML.append(" <item>" + thisEnum.nextElement() + "</item>\n");
|
||||
}
|
||||
return tStrHTML.toString();
|
||||
}
|
||||
}
|
||||
tStrHTML.append(" <size>" + this.getSize() + "</size>\n");
|
||||
thisEnum = this.getKeys();
|
||||
while (thisEnum.hasMoreElements()) {
|
||||
tStrHTML.append(" <item>" + thisEnum.nextElement() + "</item>\n");
|
||||
}
|
||||
return tStrHTML.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,47 +3,63 @@
|
|||
* 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 *
|
||||
*****************************************************************************/
|
||||
* 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;
|
||||
import org.compiere.model.MChat;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Chat Cache Object
|
||||
*
|
||||
* @author Yves Sandfort
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Chat extends CO {
|
||||
|
||||
protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
|
||||
|
||||
/**
|
||||
* getCM_Chat
|
||||
* @param ID
|
||||
* @return Chat
|
||||
*/
|
||||
public MChat getCM_Chat(int ID) {
|
||||
return getCM_Chat(""+ ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* getCM_Chat
|
||||
* @param ID
|
||||
* @return Chat
|
||||
*/
|
||||
public MChat getCM_Chat(String ID) {
|
||||
if (cache.containsKey(ID)) {
|
||||
use(ID);
|
||||
return (MChat) cache.get(ID);
|
||||
} else {
|
||||
int[] tableKeys = MChat.getAllIDs("CM_Chat", "CM_Chat_ID=" + ID, "WebCM");
|
||||
if (tableKeys.length==0) {
|
||||
// No Chat entry
|
||||
return null;
|
||||
} else if (tableKeys.length==1) {
|
||||
MChat thisChat = new MChat(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public class Container extends CO {
|
|||
* @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);
|
||||
public MContainer getCM_Container(String ID, int CM_WebProject_ID) {
|
||||
return getCM_Container(Integer.parseInt(ID), CM_WebProject_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,22 +45,21 @@ public class Container extends CO {
|
|||
* @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;
|
||||
public MContainer getCM_Container(int ID, int CM_WebProject_ID) {
|
||||
if (cache.containsKey(ID)) {
|
||||
use(ID);
|
||||
return (MContainer) cache.get(ID);
|
||||
} else {
|
||||
MContainer thisContainer = MContainer.get(ctx, ID, CM_WebProject_ID, "WebCM");
|
||||
if (thisContainer==null)
|
||||
{
|
||||
return getCM_ContainerByURL("/error404.html", CM_WebProject_ID, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
put ("" + thisContainer.getCM_Container_ID(),thisContainer);
|
||||
cacheContainerURL.put (CM_WebProject_ID + "-" + thisContainer.getRelativeURL(),"" + thisContainer.getCM_Container_ID());
|
||||
return thisContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +68,7 @@ public class Container extends CO {
|
|||
* Get Container from cache by URL
|
||||
* @param URL URL to look for
|
||||
* @param CM_WebProject_ID Web Project
|
||||
* @param resolveURLErrors
|
||||
* @return Container
|
||||
*/
|
||||
public MContainer getCM_ContainerByURL(String URL, int CM_WebProject_ID, boolean resolveURLErrors) {
|
||||
|
@ -82,8 +82,8 @@ public class Container extends CO {
|
|||
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) {
|
||||
MContainer thisContainer = MContainer.get (ctx, URL, CM_WebProject_ID, "WebCM");
|
||||
if (thisContainer==null) {
|
||||
if (resolveURLErrors) {
|
||||
if (URL.equals("/error404.html")) {
|
||||
// Okay we are already been requested as the error message, so we try the index.html
|
||||
|
@ -98,17 +98,13 @@ public class Container extends CO {
|
|||
} 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;
|
||||
} else {
|
||||
// Found exactly one record, so we return it
|
||||
if (thisContainer.isSummary ()) {
|
||||
thisContainer = getCM_ContainerByURL(URL + "/index.html", CM_WebProject_ID, resolveURLErrors);
|
||||
}
|
||||
return thisContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,31 +16,45 @@
|
|||
*****************************************************************************/
|
||||
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;
|
||||
import org.compiere.model.MContainerElement;
|
||||
|
||||
/**
|
||||
* Container Element Cache
|
||||
*
|
||||
* @author Yves Sandfort
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ContainerElement extends CO {
|
||||
/**
|
||||
* getCM_Container_Element
|
||||
* @param ID
|
||||
* @param CM_WebProject_ID
|
||||
* @return Container Element
|
||||
*/
|
||||
public MContainerElement getCM_Container_Element(String ID, int CM_WebProject_ID) {
|
||||
return getCM_Container_Element(Integer.parseInt(ID), CM_WebProject_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* getCM_Container_Element
|
||||
* @param ID
|
||||
* @param CM_WebProject_ID
|
||||
* @return Container Element
|
||||
*/
|
||||
public MContainerElement getCM_Container_Element(int ID, int CM_WebProject_ID) {
|
||||
if (cache.containsKey(ID)) {
|
||||
use(ID);
|
||||
return (MContainerElement) cache.get(ID);
|
||||
} else {
|
||||
MContainerElement thisContainerElement = MContainerElement.get(ctx, ID, "WebCM");
|
||||
if (thisContainerElement==null) {
|
||||
// No Elements in DB found, needs to get handled
|
||||
return null;
|
||||
} else {
|
||||
put ("" + thisContainerElement.get_ID(),thisContainerElement);
|
||||
return thisContainerElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,11 +21,23 @@ 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) {
|
||||
/**
|
||||
* Container Tree Cache
|
||||
*
|
||||
* @author Yves Sandfort
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ContainerTree extends CO {
|
||||
|
||||
protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
|
||||
|
||||
/**
|
||||
* getContainerTree
|
||||
* @param ID
|
||||
* @param trxName
|
||||
* @return XML StringBuffer
|
||||
*/
|
||||
public StringBuffer getContainerTree(int ID, String trxName) {
|
||||
StringBuffer xmlCode = new StringBuffer();
|
||||
if (cache.containsKey("" + ID)) {
|
||||
use("" + ID);
|
||||
|
|
|
@ -38,47 +38,17 @@ public class Domain extends CO
|
|||
}
|
||||
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<tableKeys.length;i++) {
|
||||
if (tableKeys[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;i<tableKeys.length;i++) {
|
||||
MWebProjectDomain thisDomain = new MWebProjectDomain (
|
||||
ctx, tableKeys[0], "WebCM");
|
||||
put (thisDomain.getFQDN (), thisDomain);
|
||||
return thisDomain;
|
||||
}
|
||||
// As even this doesn't work we return null
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} // getWebProjectDomain
|
||||
|
||||
} // Domain
|
||||
MWebProjectDomain thisWebProjectDomain = MWebProjectDomain.get(ctx, serverName, "WebCM");
|
||||
if (thisWebProjectDomain==null)
|
||||
{
|
||||
// HardCoded to deliver the GardenWorld Site as default
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
put (thisWebProjectDomain.getFQDN (), thisWebProjectDomain);
|
||||
return thisWebProjectDomain;
|
||||
}
|
||||
}
|
||||
} // getWebProjectDomain
|
||||
} // Domain
|
||||
|
|
|
@ -25,7 +25,24 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.compiere.cm.*;
|
||||
|
||||
public class Service extends HttpServletCM {
|
||||
/**
|
||||
* Cache Object Service classes
|
||||
*
|
||||
* @author Yves Sandfort
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Service extends HttpServletCM {
|
||||
/** serialVersionUID */
|
||||
private static final long serialVersionUID = 167843885331587478L;
|
||||
|
||||
/**
|
||||
* doGet
|
||||
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws ServletException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
|
|
|
@ -22,13 +22,9 @@ 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;
|
||||
|
@ -111,7 +107,7 @@ public class Generator
|
|||
private void generateSystemHeader (HttpServletCM thisServlet)
|
||||
{
|
||||
xmlCode.append ("<system>\n");
|
||||
xmlCode.append ("<adempiere>\n");
|
||||
xmlCode.append ("<compiere>\n");
|
||||
xmlCode.append ("<mainversion>" + Adempiere.MAIN_VERSION
|
||||
+ "</mainversion>\n");
|
||||
xmlCode.append ("<dateversion>" + Adempiere.DATE_VERSION
|
||||
|
@ -238,7 +234,7 @@ public class Generator
|
|||
//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_Product", "M_Product.IsActive='Y' AND M_Product.AD_Client_ID=" + l_nClientID + " AND M_Product.Value like 'cd_%' 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);
|
||||
|
@ -465,8 +461,10 @@ public class Generator
|
|||
|
||||
private void generateContainerTree (ContainerTree containerTreeCache)
|
||||
{
|
||||
xmlCode.append (containerTreeCache.getContainerTree (containerTreeCache
|
||||
.getCtx (), thisRequest.getWebProject ().get_ID (), null));
|
||||
/* xmlCode.append (containerTreeCache.getContainerTree (containerTreeCache
|
||||
.getCtx (), thisRequest.getWebProject ().get_ID (), null));*/
|
||||
xmlCode.append (containerTreeCache.getContainerTree (
|
||||
thisRequest.getWebProject ().get_ID (), null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue