Adempiere 3.1.2

This commit is contained in:
vpj-cd 2006-12-07 03:26:50 +00:00
parent 64eca30fca
commit 43c7859095
17 changed files with 1355 additions and 1272 deletions

View File

@ -31,6 +31,10 @@ 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
@ -52,6 +56,10 @@ public class AdRedirector extends HttpServletCM
/**
* 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

View File

@ -48,10 +48,8 @@ public class Broadcast extends HttpServletCM
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");

View File

@ -51,7 +51,7 @@ public class Community extends HttpServletCM
HttpSession sess = request.getSession (true);
sess.setMaxInactiveInterval (WebEnv.TIMEOUT);
Properties ctx = getCtx();
ctx = getCtx();
if (sess.getAttribute ("ctx")!=null)
ctx = (Properties) sess.getAttribute ("ctx");

View File

@ -36,8 +36,9 @@ public abstract class Extend implements Serializable
private String e_redirectURL;
/**
* Extend
* @param request
* Extend
* @param request
* @param t_ctx
*/
public Extend (HttpServletRequest request, Properties t_ctx) {
ctx = t_ctx;

View File

@ -126,7 +126,7 @@ public class HttpServletCM extends HttpServlet
* 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
@ -307,17 +307,14 @@ public class HttpServletCM extends HttpServlet
*
* @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/";
}
/**

View File

@ -1,5 +1,5 @@
/******************************************************************************
* 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 *
@ -39,6 +39,10 @@ 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
@ -113,7 +117,11 @@ public class MediaBroadcast extends HttpServletCM
/**
* 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

View File

@ -24,7 +24,6 @@ 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;
@ -36,8 +35,8 @@ import org.compiere.util.WebUtil;
* @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
@ -53,7 +52,7 @@ public class RequestServlet extends HttpServletCM {
HttpSession sess = request.getSession (true);
sess.setMaxInactiveInterval (WebEnv.TIMEOUT);
Properties ctx = getCtx();
ctx = getCtx();
if (sess.getAttribute ("ctx")!=null)
ctx = (Properties) sess.getAttribute ("ctx");

View File

@ -17,12 +17,9 @@
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.*;
@ -35,6 +32,9 @@ import org.compiere.cm.xml.*;
public class StageBroadcast extends HttpServletCM
{
/** serialVersionUID */
private static final long serialVersionUID = 7348394433516908807L;
/**
* Handle Get Request
*

View File

@ -30,6 +30,9 @@ import org.compiere.cm.xml.Generator;
*/
public class XMLBroadcast extends HttpServletCM
{
/** serialVersionUID */
private static final long serialVersionUID = -1280320974132533949L;
/**
* Get
* @param request
@ -43,8 +46,7 @@ public class XMLBroadcast extends HttpServletCM
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

View File

@ -18,7 +18,6 @@ package org.compiere.cm.cache;
import java.util.*;
import org.compiere.model.*;
import org.compiere.util.CLogger;
/**
@ -38,17 +37,33 @@ public class CO {
/** 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());
@ -58,15 +73,27 @@ public class CO {
}
}
/**
* 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();
}
@ -108,17 +135,37 @@ public class CO {
}
}
/**
* 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;

View File

@ -17,27 +17,43 @@
package org.compiere.cm.cache;
import java.util.*;
import org.compiere.model.X_CM_Chat;
import org.compiere.model.MChat;
/**
* Chat Cache Object
*
* @author Yves Sandfort
* @version $Id$
*/
public class Chat extends CO {
protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
public X_CM_Chat getCM_Chat(int ID) {
/**
* getCM_Chat
* @param ID
* @return Chat
*/
public MChat getCM_Chat(int ID) {
return getCM_Chat(""+ ID);
}
public X_CM_Chat getCM_Chat(String ID) {
/**
* getCM_Chat
* @param ID
* @return Chat
*/
public MChat getCM_Chat(String ID) {
if (cache.containsKey(ID)) {
use(ID);
return (X_CM_Chat) cache.get(ID);
return (MChat) cache.get(ID);
} else {
int[] tableKeys = X_CM_Chat.getAllIDs("CM_Chat", "CM_Chat_ID=" + ID, "WebCM");
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) {
X_CM_Chat thisChat = new X_CM_Chat(ctx, tableKeys[0], "WebCM");
MChat thisChat = new MChat(ctx, tableKeys[0], "WebCM");
put ("" + thisChat.get_ID(),thisChat);
return thisChat;
} else {

View File

@ -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) {
public MContainer getCM_Container(int 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) {
MContainer thisContainer = MContainer.get(ctx, ID, CM_WebProject_ID, "WebCM");
if (thisContainer==null)
{
return getCM_ContainerByURL("/error404.html", CM_WebProject_ID, true);
} else if (tableKeys.length==1) {
MContainer thisContainer = new MContainer(ctx, tableKeys[0], "WebCM");
}
else
{
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;
}
}
}
@ -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,16 +98,12 @@ public class Container extends CO {
} else {
return null;
}
} else if (tableKeys.length==1) {
} else {
// 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;
}
}
}

View File

@ -16,29 +16,43 @@
*****************************************************************************/
package org.compiere.cm.cache;
import org.compiere.model.X_CM_Container_Element;
import org.compiere.model.MContainerElement;
/**
* Container Element Cache
*
* @author Yves Sandfort
* @version $Id$
*/
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);
/**
* 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);
}
public X_CM_Container_Element getCM_Container_Element(String ID, int 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 (X_CM_Container_Element) cache.get(ID);
return (MContainerElement) 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) {
MContainerElement thisContainerElement = MContainerElement.get(ctx, ID, "WebCM");
if (thisContainerElement==null) {
// 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");
} else {
put ("" + thisContainerElement.get_ID(),thisContainerElement);
return thisContainerElement;
} else {
// More than one result, this is funny, normally this is not possible :-/
return null;
}
}
}

View File

@ -21,11 +21,23 @@ import java.util.*;
import org.compiere.cm.utils.TreeXML;
import org.compiere.model.MWebProject;
/**
* Container Tree Cache
*
* @author Yves Sandfort
* @version $Id$
*/
public class ContainerTree extends CO {
protected Hashtable cacheContainerURL = new Hashtable(cacheSize);
public StringBuffer getContainerTree(Properties ctx, int ID, String trxName) {
/**
* 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);

View File

@ -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)
MWebProjectDomain thisWebProjectDomain = MWebProjectDomain.get(ctx, serverName, "WebCM");
if (thisWebProjectDomain==null)
{
// 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;
put (thisWebProjectDomain.getFQDN (), thisWebProjectDomain);
return thisWebProjectDomain;
}
}
} // getWebProjectDomain
} // Domain

View File

@ -25,7 +25,24 @@ import javax.servlet.http.HttpServletResponse;
import org.compiere.cm.*;
/**
* 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
{

View File

@ -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));
}
/**