Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Config.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Config.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Config.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Config.java Mon Sep 8 06:04:39 2014 @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -34,58 +35,198 @@ import java.util.TimeZone; public class Config { - private static String getConfigFileName(String command) { - // default command is "start" - if (command == null || command.trim().length() == 0) { - command = "start"; - } - return "org/ofbiz/base/start/" + command + ".properties"; - } + public final InetAddress adminAddress; + public final String adminKey; + public final int adminPort; + public final String awtHeadless; + public final String baseConfig; + public final String baseDtd; + public final String baseJar; + public final String baseLib; + public final String commJar; + public final String containerConfig; + public final String instrumenterClassName; + public final String instrumenterFile; + public final List<Map<String, String>> loaders; + public final String logDir; + public final String ofbizHome; + public final boolean requireCommJar; + public final boolean requireToolsJar; + public final boolean shutdownAfterLoad; + public final String splashLogo; + public final String toolsJar; + public final boolean useShutdownHook; - public static Config getInstance(String[] args) throws IOException { + Config(String[] args) throws IOException { String firstArg = args.length > 0 ? args[0] : ""; // Needed when portoffset is used with these commands, start.properties fits for all of them - if ("start-batch".equalsIgnoreCase(firstArg) - || "start-debug".equalsIgnoreCase(firstArg) - || "stop".equalsIgnoreCase(firstArg) - || "-shutdown".equalsIgnoreCase(firstArg) // shutdown & status hack (was pre-existing to portoffset introduction, also useful with it) + if ("start-batch".equalsIgnoreCase(firstArg) + || "start-debug".equalsIgnoreCase(firstArg) + || "stop".equalsIgnoreCase(firstArg) + || "-shutdown".equalsIgnoreCase(firstArg) // shutdown & status hack (was pre-existing to portoffset introduction, also useful with it) || "-status".equalsIgnoreCase(firstArg)) { firstArg = "start"; } - String configFileName = getConfigFileName(firstArg); - Config result = new Config(); - result.readConfig(configFileName, args); - return result; - } + // default command is "start" + if (firstArg == null || firstArg.trim().length() == 0) { + firstArg = "start"; + } + String config = "org/ofbiz/base/start/" + firstArg + ".properties"; + + // check the java_version + String javaVersion = System.getProperty("java.version"); + String javaVendor = System.getProperty("java.vendor"); - public InetAddress adminAddress; - public String adminKey; - public int adminPort; - public String awtHeadless; - public String baseConfig; - public String baseDtd; - public String baseJar; - public String baseLib; - public String commJar; - public String containerConfig; - public String instrumenterClassName; - public String instrumenterFile; - public List<Map<String, String>> loaders; - public String logDir; - public String ofbizHome; - public boolean requireCommJar = false; - public boolean requireToolsJar = false; - public boolean shutdownAfterLoad = false; - public String splashLogo; - public String testConfig; - public String toolsJar; - public boolean useShutdownHook = true; + Properties props = this.getPropertiesFile(config); + System.out.println("Start.java using configuration file " + config); + + // set the ofbiz.home + String ofbizHomeTmp = props.getProperty("ofbiz.home", "."); + // get a full path + if (ofbizHomeTmp.equals(".")) { + ofbizHomeTmp = System.getProperty("user.dir"); + ofbizHomeTmp = ofbizHomeTmp.replace('\\', '/'); + } + ofbizHome = ofbizHomeTmp; + System.setProperty("ofbiz.home", ofbizHome); + System.out.println("Set OFBIZ_HOME to - " + ofbizHome); + + // base config directory + baseConfig = getOfbizHomeProp(props, "ofbiz.base.config", "framework/base/config"); + + // base schema directory + baseDtd = getOfbizHomeProp(props, "ofbiz.base.schema", "framework/base/dtd"); + + // base lib directory + baseLib = getOfbizHomeProp(props, "ofbiz.base.lib", "framework/base/lib"); + + // base jar file + baseJar = getOfbizHomeProp(props, "ofbiz.base.jar", "framework/base/build/lib/ofbiz-base.jar"); + + // tools jar + String reqTJ = getProp(props, "java.tools.jar.required", "false"); + requireToolsJar = "true".equalsIgnoreCase(reqTJ); + toolsJar = this.findSystemJar(props, javaVendor, javaVersion, "tools.jar", requireToolsJar); + + // comm jar + String reqCJ = getProp(props, "java.comm.jar.required", "false"); + requireCommJar = "true".equalsIgnoreCase(reqCJ); + commJar = this.findSystemJar(props, javaVendor, javaVersion, "comm.jar", requireCommJar); + + // log directory + logDir = getOfbizHomeProp(props, "ofbiz.log.dir", "runtime/logs"); + + // container configuration + containerConfig = getOfbizHomeProp(props, "ofbiz.container.config", "framework/base/config/ofbiz-containers.xml"); + + // get the admin server info + String serverHost = getProp(props, "ofbiz.admin.host", "127.0.0.1"); + + String adminPortStr = getProp(props, "ofbiz.admin.port", "0"); + // set the admin key + adminKey = getProp(props, "ofbiz.admin.key", "NA"); + + // create the host InetAddress + adminAddress = InetAddress.getByName(serverHost); + + // parse the port number + int adminPortTmp; + try { + adminPortTmp = Integer.parseInt(adminPortStr); + if (args.length > 0) { + for (String arg : args) { + if (arg.toLowerCase().contains("portoffset=") && !arg.toLowerCase().contains("${portoffset}")) { + adminPortTmp = adminPortTmp != 0 ? adminPortTmp : 10523; // This is necessary because the ASF machines don't allow ports 1 to 3, see INFRA-6790 + adminPortTmp += Integer.parseInt(arg.split("=")[1]); + } + } + } + } catch (Exception e) { + System.out.println("Error while parsing admin port number (so default to 10523) = " + e); + adminPortTmp = 10523; + } + adminPort = adminPortTmp; + + // set the Derby system home + String derbyPath = getProp(props, "derby.system.home", "runtime/data/derby"); + System.setProperty("derby.system.home", derbyPath); + + // check for shutdown hook + if (System.getProperty("ofbiz.enable.hook") != null && System.getProperty("ofbiz.enable.hook").length() > 0) { + useShutdownHook = "true".equalsIgnoreCase(System.getProperty("ofbiz.enable.hook")); + } else if (props.getProperty("ofbiz.enable.hook") != null && props.getProperty("ofbiz.enable.hook").length() > 0) { + useShutdownHook = "true".equalsIgnoreCase(props.getProperty("ofbiz.enable.hook")); + } else { + useShutdownHook = true; + } + + // check for auto-shutdown + if (System.getProperty("ofbiz.auto.shutdown") != null && System.getProperty("ofbiz.auto.shutdown").length() > 0) { + shutdownAfterLoad = "true".equalsIgnoreCase(System.getProperty("ofbiz.auto.shutdown")); + } else if (props.getProperty("ofbiz.auto.shutdown") != null && props.getProperty("ofbiz.auto.shutdown").length() > 0) { + shutdownAfterLoad = "true".equalsIgnoreCase(props.getProperty("ofbiz.auto.shutdown")); + } else { + shutdownAfterLoad = false; + } + + // set AWT headless mode + awtHeadless = getProp(props, "java.awt.headless", null); + if (awtHeadless != null) { + System.setProperty("java.awt.headless", awtHeadless); + } + + // get the splash logo + splashLogo = props.getProperty("ofbiz.start.splash.logo", null); + + // set the default locale + String localeString = props.getProperty("ofbiz.locale.default"); + if (localeString != null && localeString.length() > 0) { + String locales[] = localeString.split("_"); + switch (locales.length) { + case 1: + Locale.setDefault(new Locale(locales[0])); + break; + case 2: + Locale.setDefault(new Locale(locales[0], locales[1])); + break; + case 3: + Locale.setDefault(new Locale(locales[0], locales[1], locales[2])); + } + System.setProperty("user.language", localeString); + } + + // set the default time zone + String tzString = props.getProperty("ofbiz.timeZone.default"); + if (tzString != null && tzString.length() > 0) { + TimeZone.setDefault(TimeZone.getTimeZone(tzString)); + } + + instrumenterClassName = getProp(props, "ofbiz.instrumenterClassName", null); + instrumenterFile = getProp(props, "ofbiz.instrumenterFile", null); + + // loader classes + List loadersTmp = new ArrayList<Map<String, String>>(); + int currentPosition = 1; + Map<String, String> loader = null; + while (true) { + loader = new HashMap<String, String>(); + String loaderClass = props.getProperty("ofbiz.start.loader" + currentPosition); + if (loaderClass == null || loaderClass.length() == 0) { + break; + } else { + loader.put("class", loaderClass); + loader.put("profiles", props.getProperty("ofbiz.start.loader" + currentPosition + ".loaders")); + loadersTmp.add(Collections.unmodifiableMap(loader)); + currentPosition++; + } + } + loaders = Collections.unmodifiableList(loadersTmp); + } private String findSystemJar(Properties props, String javaVendor, String javaVersion, String jarName, boolean required) { String fileSep = System.getProperty("file.separator"); String javaHome = System.getProperty("java.home"); String errorMsg = "Unable to locate " + jarName + " - "; - // String foundMsg = "Found " + jarName + " - "; String jarLoc = "lib" + fileSep + jarName; File tj = null; @@ -278,160 +419,4 @@ public class Config { } } } - - public void readConfig(String config, String[] args) throws IOException { - // check the java_version - String javaVersion = System.getProperty("java.version"); - String javaVendor = System.getProperty("java.vendor"); - - Properties props = this.getPropertiesFile(config); - System.out.println("Start.java using configuration file " + config); - - // set the ofbiz.home - if (ofbizHome == null) { - ofbizHome = props.getProperty("ofbiz.home", "."); - // get a full path - if (ofbizHome.equals(".")) { - ofbizHome = System.getProperty("user.dir"); - ofbizHome = ofbizHome.replace('\\', '/'); - System.out.println("Set OFBIZ_HOME to - " + ofbizHome); - } - } - System.setProperty("ofbiz.home", ofbizHome); - - // base config directory - baseConfig = getOfbizHomeProp(props, "ofbiz.base.config", "framework/base/config"); - - // base schema directory - baseDtd = getOfbizHomeProp(props, "ofbiz.base.schema", "framework/base/dtd"); - - // base lib directory - baseLib = getOfbizHomeProp(props, "ofbiz.base.lib", "framework/base/lib"); - - // base jar file - baseJar = getOfbizHomeProp(props, "ofbiz.base.jar", "framework/base/build/lib/ofbiz-base.jar"); - - // tools jar - String reqTJ = getProp(props, "java.tools.jar.required", "false"); - requireToolsJar = "true".equalsIgnoreCase(reqTJ); - toolsJar = this.findSystemJar(props, javaVendor, javaVersion, "tools.jar", requireToolsJar); - - // comm jar - String reqCJ = getProp(props, "java.comm.jar.required", "false"); - requireCommJar = "true".equalsIgnoreCase(reqCJ); - commJar = this.findSystemJar(props, javaVendor, javaVersion, "comm.jar", requireCommJar); - - // log directory - logDir = getOfbizHomeProp(props, "ofbiz.log.dir", "runtime/logs"); - - // container configuration - containerConfig = getOfbizHomeProp(props, "ofbiz.container.config", "framework/base/config/ofbiz-containers.xml"); - - // get the admin server info - String serverHost = getProp(props, "ofbiz.admin.host", "127.0.0.1"); - - String adminPortStr = getProp(props, "ofbiz.admin.port", "0"); - // set the admin key - adminKey = getProp(props, "ofbiz.admin.key", "NA"); - - // create the host InetAddress - adminAddress = InetAddress.getByName(serverHost); - - // parse the port number - try { - adminPort = Integer.parseInt(adminPortStr); - if (args.length > 0) { - for (String arg : args) { - if (arg.toLowerCase().contains("portoffset=") && !arg.toLowerCase().contains("${portoffset}")) { - adminPort = adminPort != 0 ? adminPort : 10523; // This is necessary because the ASF machines don't allow ports 1 to 3, see INFRA-6790 - adminPort += Integer.parseInt(arg.split("=")[1]); - } - } - } - } catch (Exception e) { - System.out.println("Error while parsing admin port number (so default to 10523) = " + e); - adminPort = 10523; - } - - // set the Derby system home - String derbyPath = getProp(props, "derby.system.home", "runtime/data/derby"); - System.setProperty("derby.system.home", derbyPath); - - // set the property to tell Log4J to use log4j.xml - String log4jConfig = getProp(props, "log4j.configuration", "log4j.xml"); - - // set the log4j configuration property so we don't pick up one inside jars by - // mistake - System.setProperty("log4j.configuration", log4jConfig); - - // check for shutdown hook - if (System.getProperty("ofbiz.enable.hook") != null && System.getProperty("ofbiz.enable.hook").length() > 0) { - useShutdownHook = "true".equalsIgnoreCase(System.getProperty("ofbiz.enable.hook")); - } else if (props.getProperty("ofbiz.enable.hook") != null && props.getProperty("ofbiz.enable.hook").length() > 0) { - useShutdownHook = "true".equalsIgnoreCase(props.getProperty("ofbiz.enable.hook")); - } - - // check for auto-shutdown - if (System.getProperty("ofbiz.auto.shutdown") != null && System.getProperty("ofbiz.auto.shutdown").length() > 0) { - shutdownAfterLoad = "true".equalsIgnoreCase(System.getProperty("ofbiz.auto.shutdown")); - } else if (props.getProperty("ofbiz.auto.shutdown") != null && props.getProperty("ofbiz.auto.shutdown").length() > 0) { - shutdownAfterLoad = "true".equalsIgnoreCase(props.getProperty("ofbiz.auto.shutdown")); - } - - // set AWT headless mode - awtHeadless = getProp(props, "java.awt.headless", null); - if (awtHeadless != null) { - System.setProperty("java.awt.headless", awtHeadless); - } - - // get the splash logo - splashLogo = props.getProperty("ofbiz.start.splash.logo", null); - - // set the property to tell Jetty to use 2.4 SessionListeners - System.setProperty("org.mortbay.jetty.servlet.AbstractSessionManager.24SessionDestroyed", "true"); - - // set the default locale - String localeString = props.getProperty("ofbiz.locale.default"); - if (localeString != null && localeString.length() > 0) { - String locales[] = localeString.split("_"); - switch (locales.length) { - case 1: - Locale.setDefault(new Locale(locales[0])); - break; - case 2: - Locale.setDefault(new Locale(locales[0], locales[1])); - break; - case 3: - Locale.setDefault(new Locale(locales[0], locales[1], locales[2])); - } - System.setProperty("user.language", localeString); - } - - // set the default time zone - String tzString = props.getProperty("ofbiz.timeZone.default"); - if (tzString != null && tzString.length() > 0) { - TimeZone.setDefault(TimeZone.getTimeZone(tzString)); - } - - instrumenterClassName = getProp(props, "ofbiz.instrumenterClassName", null); - instrumenterFile = getProp(props, "ofbiz.instrumenterFile", null); - - // loader classes - loaders = new ArrayList<Map<String, String>>(); - int currentPosition = 1; - Map<String, String> loader = null; - while (true) { - loader = new HashMap<String, String>(); - String loaderClass = props.getProperty("ofbiz.start.loader" + currentPosition); - if (loaderClass == null || loaderClass.length() == 0) { - break; - } else { - loader.put("class", loaderClass); - loader.put("profiles", props.getProperty("ofbiz.start.loader" + currentPosition + ".loaders")); - loaders.add(loader); - currentPosition++; - } - } - } - } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Start.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Start.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Start.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/Start.java Mon Sep 8 06:04:39 2014 @@ -197,7 +197,7 @@ public final class Start { } } try { - this.config = Config.getInstance(args); + this.config = new Config(args); } catch (IOException e) { throw (StartupException) new StartupException("Couldn't not fetch config instance").initCause(e); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/both.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/both.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/both.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/both.properties Mon Sep 8 06:04:39 2014 @@ -60,8 +60,5 @@ ofbiz.auto.shutdown=false # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=false Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/install.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/install.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/install.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/install.properties Mon Sep 8 06:04:39 2014 @@ -54,9 +54,6 @@ ofbiz.auto.shutdown=true # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=true Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/jetty.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/jetty.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/jetty.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/jetty.properties Mon Sep 8 06:04:39 2014 @@ -63,8 +63,5 @@ ofbiz.auto.shutdown=false # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=true Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/pos.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/pos.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/pos.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/pos.properties Mon Sep 8 06:04:39 2014 @@ -60,8 +60,5 @@ ofbiz.auto.shutdown=false # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=false Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/rmi.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/rmi.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/rmi.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/rmi.properties Mon Sep 8 06:04:39 2014 @@ -54,8 +54,5 @@ ofbiz.start.loader1.loaders=rmi # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=true Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/setup.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/setup.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/setup.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/setup.properties Mon Sep 8 06:04:39 2014 @@ -54,8 +54,5 @@ ofbiz.start.loader1.loaders=setup # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=true Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/start.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/start.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/start.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/start.properties Mon Sep 8 06:04:39 2014 @@ -63,9 +63,6 @@ ofbiz.start.loader1.loaders=main,rmi # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=true Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/test.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/test.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/test.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/test.properties Mon Sep 8 06:04:39 2014 @@ -57,9 +57,6 @@ ofbiz.instrumenterFile=runtime/logs/cobe # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # -- The default locale for this OFBiz instance. ofbiz.locale.default=en Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/testlist.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/testlist.properties?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/testlist.properties (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/start/src/org/ofbiz/base/start/testlist.properties Mon Sep 8 06:04:39 2014 @@ -54,8 +54,5 @@ ofbiz.auto.shutdown=true # --- Default Derby system home directory #derby.system.home=runtime/data/derby -# --- By default we will find base/config/debug.properties and point to there -#log4j.configuration=log4j.xml - # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11) java.awt.headless=true Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/testtools/src/org/ofbiz/testtools/ModelTestSuite.java Mon Sep 8 06:04:39 2014 @@ -18,10 +18,10 @@ *******************************************************************************/ package org.ofbiz.testtools; +import java.util.ArrayList; import java.util.Enumeration; import java.util.List; -import javolution.util.FastList; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -57,7 +57,7 @@ public class ModelTestSuite { protected Delegator delegator; protected LocalDispatcher dispatcher; - protected List<Test> testList = FastList.newInstance(); + protected List<Test> testList = new ArrayList<Test>(); public ModelTestSuite(Element mainElement, String testCase) { this.suiteName = mainElement.getAttribute("suite-name"); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/build.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/build.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/build.xml Mon Sep 8 06:04:39 2014 @@ -52,13 +52,6 @@ under the License. <exclude name="org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java"/> <exclude name="org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java"/> <exclude name="org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java"/> - <!-- JPublish/EdenLib dependent files --> - <exclude name="org/ofbiz/webapp/view/GenericViewRenderer.java"/> - <exclude name="org/ofbiz/webapp/view/JPublishViewHandler.java"/> - <exclude name="org/ofbiz/webapp/view/JPublishWrapper.java"/> - <exclude name="org/ofbiz/webapp/view/FopPdfViewHandler.java"/> - <exclude name="org/ofbiz/webapp/ftl/FreeMarkerViewRenderer.java"/> - <exclude name="org/ofbiz/webapp/ftl/JpCacheIncludeTransform.java"/> </patternset> <target name="jar" depends="classes"> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/dtd/webapp-catalog.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/dtd/webapp-catalog.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/dtd/webapp-catalog.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/dtd/webapp-catalog.xml Mon Sep 8 06:04:39 2014 @@ -27,6 +27,5 @@ under the License. <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <!-- <public publicId="-//W3C//DTD SVG 1.0//EN" uri="svg10.dtd"/> --> - <system systemId="http://ofbiz.apache.org/dtds/regions.xsd" uri="regions.xsd"/> <system systemId="http://ofbiz.apache.org/dtds/site-conf.xsd" uri="site-conf.xsd"/> </catalog> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Mon Sep 8 06:04:39 2014 @@ -35,10 +35,8 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilHttp; -import org.ofbiz.base.util.UtilJ2eeCompat; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericDelegator; @@ -50,8 +48,6 @@ import org.ofbiz.service.LocalDispatcher import org.ofbiz.webapp.stats.ServerHitBin; import org.ofbiz.webapp.stats.VisitHandler; -import freemarker.ext.servlet.ServletContextHashModel; - /** * ControlServlet.java - Master servlet for the web application. */ @@ -190,9 +186,6 @@ public class ControlServlet extends Http request.setAttribute("_REQUEST_HANDLER_", requestHandler); - ServletContextHashModel ftlServletContext = new ServletContextHashModel(this, FreeMarkerWorker.getDefaultOfbizWrapper()); - request.setAttribute("ftlServletContext", ftlServletContext); - // setup some things that should always be there UtilHttp.setInitialRequestInfo(request); VisitHandler.getVisitor(request, response); @@ -260,11 +253,7 @@ public class ControlServlet extends Http String errorMessage = "ERROR rendering error page [" + errorPage + "], but here is the error text: " + request.getAttribute("_ERROR_MESSAGE_"); try { - if (UtilJ2eeCompat.useOutputStreamNotWriter(getServletContext())) { - response.getOutputStream().print(errorMessage); - } else { - response.getWriter().print(errorMessage); - } + response.getWriter().print(errorMessage); } catch (Throwable t2) { try { int errorToSend = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; @@ -283,11 +272,7 @@ public class ControlServlet extends Http } String errorMessage = "<html><body>ERROR in error page, (infinite loop or error page not found with name [" + errorPage + "]), but here is the text just in case it helps you: " + request.getAttribute("_ERROR_MESSAGE_") + "</body></html>"; - if (UtilJ2eeCompat.useOutputStreamNotWriter(getServletContext())) { - response.getOutputStream().print(errorMessage); - } else { - response.getWriter().print(errorMessage); - } + response.getWriter().print(errorMessage); } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Mon Sep 8 06:04:39 2014 @@ -69,29 +69,29 @@ import org.owasp.esapi.errors.EncodingEx public class RequestHandler { public static final String module = RequestHandler.class.getName(); - private boolean throwRequestHandlerExceptionOnMissingLocalRequest = UtilProperties.propertyValueEqualsIgnoreCase( + private static final boolean throwRequestHandlerExceptionOnMissingLocalRequest = UtilProperties.propertyValueEqualsIgnoreCase( "requestHandler.properties", "throwRequestHandlerExceptionOnMissingLocalRequest", "Y"); - private String statusCodeString = UtilProperties.getPropertyValue("requestHandler.properties", "status-code", "302"); + private final String defaultStatusCodeString = UtilProperties.getPropertyValue("requestHandler.properties", "status-code", "302"); + private final ViewFactory viewFactory; + private final EventFactory eventFactory; + private final URL controllerConfigURL; + private final boolean forceHttpSession; + private final boolean trackServerHit; + private final boolean trackVisit; + private final boolean cookies; + private final String charset; + public static RequestHandler getRequestHandler(ServletContext servletContext) { RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); if (rh == null) { - rh = new RequestHandler(); + rh = new RequestHandler(servletContext); servletContext.setAttribute("_REQUEST_HANDLER_", rh); - rh.init(servletContext); } return rh; } - protected ServletContext context = null; - protected ViewFactory viewFactory = null; - protected EventFactory eventFactory = null; - protected URL controllerConfigURL = null; - - public void init(ServletContext context) { - if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler Loading...]", module); - this.context = context; - - // init the ControllerConfig, but don't save it anywhere + private RequestHandler(ServletContext context) { + // init the ControllerConfig, but don't save it anywhere, just load it into the cache this.controllerConfigURL = ConfigXMLReader.getControllerConfigURL(context); try { ConfigXMLReader.getControllerConfig(this.controllerConfigURL); @@ -99,8 +99,14 @@ public class RequestHandler { // FIXME: controller.xml errors should throw an exception. Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); } - this.viewFactory = new ViewFactory(this); - this.eventFactory = new EventFactory(this); + this.viewFactory = new ViewFactory(context, this.controllerConfigURL); + this.eventFactory = new EventFactory(context, this.controllerConfigURL); + + this.forceHttpSession = "true".equalsIgnoreCase(context.getInitParameter("forceHttpSession")); + this.trackServerHit = !"false".equalsIgnoreCase(context.getInitParameter("track-serverhit")); + this.trackVisit = !"false".equalsIgnoreCase(context.getInitParameter("track-visit")); + this.cookies = !"false".equalsIgnoreCase(context.getInitParameter("cookies")); + this.charset = context.getInitParameter("charset"); } public ConfigXMLReader.ControllerConfig getControllerConfig() { @@ -129,16 +135,17 @@ public class RequestHandler { // get the controllerConfig once for this method so we don't have to get it over and over inside the method ConfigXMLReader.ControllerConfig controllerConfig = this.getControllerConfig(); Map<String, ConfigXMLReader.RequestMap> requestMapMap = null; - String controllerStatusCodeString = null; + String statusCodeString = null; try { requestMapMap = controllerConfig.getRequestMapMap(); - controllerStatusCodeString = controllerConfig.getStatusCode(); + statusCodeString = controllerConfig.getStatusCode(); } catch (WebAppConfigurationException e) { Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); throw new RequestHandlerException(e); } - if(UtilValidate.isNotEmpty(controllerStatusCodeString != null)) - statusCodeString = controllerStatusCodeString; + if (UtilValidate.isEmpty(statusCodeString)) { + statusCodeString = defaultStatusCodeString; + } // workaround if we are in the root webapp String cname = UtilHttp.getApplicationName(request); @@ -248,7 +255,6 @@ public class RequestHandler { requestMap = requestMapMap.get(defaultRequest); } } - boolean forceHttpSession = "true".equals(context.getInitParameter("forceHttpSession")); // Check if we SHOULD be secure and are not. String forwardedProto = request.getHeader("X-Forwarded-Proto"); boolean isForwardedSecure = UtilValidate.isNotEmpty(forwardedProto) && "HTTPS".equals(forwardedProto.toUpperCase()); @@ -775,11 +781,6 @@ public class RequestHandler { return null; } - /** Returns the ServletContext Object. */ - public ServletContext getServletContext() { - return context; - } - /** Returns the ViewFactory Object. */ public ViewFactory getViewFactory() { return viewFactory; @@ -941,7 +942,7 @@ public class RequestHandler { long viewStartTime = System.currentTimeMillis(); // setup character encoding and content type - String charset = UtilFormatOut.checkEmpty(getServletContext().getInitParameter("charset"), req.getCharacterEncoding(), "UTF-8"); + String charset = UtilFormatOut.checkEmpty(this.charset, req.getCharacterEncoding(), "UTF-8"); String viewCharset = viewMap.encoding; //NOTE: if the viewCharset is "none" then no charset will be used @@ -1197,7 +1198,7 @@ public class RequestHandler { String encodedUrl; if (encode) { - boolean forceManualJsessionid = "false".equals(getServletContext().getInitParameter("cookies")) ? true : false; + boolean forceManualJsessionid = !cookies; boolean isSpider = false; // if the current request comes from a spider, we will not add the jsessionid to the link @@ -1292,7 +1293,7 @@ public class RequestHandler { } public boolean trackStats(HttpServletRequest request) { - if (!"false".equalsIgnoreCase(context.getInitParameter("track-serverhit"))) { + if (trackServerHit) { String uriString = RequestHandler.getRequestUri(request.getPathInfo()); if (uriString == null) { uriString=""; @@ -1311,7 +1312,7 @@ public class RequestHandler { } public boolean trackVisit(HttpServletRequest request) { - if (!"false".equalsIgnoreCase(context.getInitParameter("track-visit"))) { + if (trackVisit) { String uriString = RequestHandler.getRequestUri(request.getPathInfo()); if (uriString == null) { uriString=""; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java Mon Sep 8 06:04:39 2014 @@ -18,21 +18,17 @@ *******************************************************************************/ package org.ofbiz.webapp.event; +import java.net.URL; +import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.ObjectType; import org.ofbiz.webapp.control.ConfigXMLReader; -import org.ofbiz.webapp.control.RequestHandler; -import org.ofbiz.webapp.control.WebAppConfigurationException; /** * EventFactory - Event Handler Factory @@ -41,104 +37,30 @@ public class EventFactory { public static final String module = EventFactory.class.getName(); - protected RequestHandler requestHandler = null; - protected ServletContext context = null; - protected Map<String, EventHandler> handlers = null; - - public EventFactory(RequestHandler requestHandler) { - handlers = FastMap.newInstance(); - this.requestHandler = requestHandler; - this.context = requestHandler.getServletContext(); + private final Map<String, EventHandler> handlers = new HashMap<String, EventHandler>(); - // pre-load all event handlers + public EventFactory(ServletContext context, URL controllerConfigURL) { + // load all the event handlers try { - this.preLoadAll(); - } catch (EventHandlerException e) { + Set<Map.Entry<String,String>> handlerEntries = ConfigXMLReader.getControllerConfig(controllerConfigURL).getEventHandlerMap().entrySet(); + if (handlerEntries != null) { + for (Map.Entry<String,String> handlerEntry: handlerEntries) { + EventHandler handler = (EventHandler) ObjectType.getInstance(handlerEntry.getValue()); + handler.init(context); + this.handlers.put(handlerEntry.getKey(), handler); + } + } + } catch (Exception e) { Debug.logError(e, module); throw new GeneralRuntimeException(e); } } - private void preLoadAll() throws EventHandlerException { - Set<String> handlers = null; - try { - handlers = this.requestHandler.getControllerConfig().getEventHandlerMap().keySet(); - } catch (WebAppConfigurationException e) { - Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); - } - if (handlers != null) { - for (String type: handlers) { - this.handlers.put(type, this.loadEventHandler(type)); - } - } - } - public EventHandler getEventHandler(String type) throws EventHandlerException { - // check if we are new / empty and add the default handler in - if (handlers.size() == 0) { - this.preLoadAll(); - } - - // attempt to get a pre-loaded handler EventHandler handler = handlers.get(type); - if (handler == null) { - synchronized (EventHandler.class) { - handler = handlers.get(type); - if (handler == null) { - handler = this.loadEventHandler(type); - handlers.put(type, handler); - } - } - if (handler == null) - throw new EventHandlerException("No handler found for type: " + type); + throw new EventHandlerException("No handler found for type: " + type); } return handler; } - - public void clear() { - handlers.clear(); - } - - private EventHandler loadEventHandler(String type) throws EventHandlerException { - EventHandler handler = null; - String handlerClass = null; - try { - handlerClass = this.requestHandler.getControllerConfig().getEventHandlerMap().get(type); - } catch (WebAppConfigurationException e) { - Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); - } - if (handlerClass == null) { - throw new EventHandlerException("Unknown handler type: " + type); - } - - try { - handler = (EventHandler) ObjectType.getInstance(handlerClass); - handler.init(context); - } catch (NoClassDefFoundError e) { - throw new EventHandlerException("No class def found for handler [" + handlerClass + "]", e); - } catch (ClassNotFoundException cnf) { - throw new EventHandlerException("Cannot load handler class [" + handlerClass + "]", cnf); - } catch (InstantiationException ie) { - throw new EventHandlerException("Cannot get instance of the handler [" + handlerClass + "]", ie); - } catch (IllegalAccessException iae) { - throw new EventHandlerException(iae.getMessage(), iae); - } - return handler; - } - - public static String runRequestEvent(HttpServletRequest request, HttpServletResponse response, String requestUri) - throws EventHandlerException { - ServletContext application = ((ServletContext) request.getAttribute("servletContext")); - RequestHandler handler = (RequestHandler) application.getAttribute("_REQUEST_HANDLER_"); - ConfigXMLReader.ControllerConfig controllerConfig = handler.getControllerConfig(); - ConfigXMLReader.RequestMap requestMap; - try { - requestMap = controllerConfig.getRequestMapMap().get(requestUri); - } catch (WebAppConfigurationException e) { - Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); - throw new EventHandlerException(e); - } - return handler.runEvent(request, response, requestMap.event, requestMap, "unknown"); - } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/RomeEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/RomeEventHandler.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/RomeEventHandler.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/event/RomeEventHandler.java Mon Sep 8 06:04:39 2014 @@ -43,18 +43,10 @@ public class RomeEventHandler implements public static final String mime = "application/xml; charset=UTF-8"; public static final String defaultFeedType = "rss_2.0"; - protected RequestHandler handler; - protected ServletContext context; protected EventHandler service; protected WireFeedOutput out; public void init(ServletContext context) throws EventHandlerException { - this.context = context; - this.handler = (RequestHandler) context.getAttribute("_REQUEST_HANDLER_"); - if (this.handler == null) { - throw new EventHandlerException("No request handler found in servlet context!"); - } - // get the service event handler this.service = new ServiceEventHandler(); this.service.init(context); @@ -65,6 +57,10 @@ public class RomeEventHandler implements * @see org.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLReader.Event, ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException { + RequestHandler handler = (RequestHandler) request.getSession().getServletContext().getAttribute("_REQUEST_HANDLER_"); + if (handler == null) { + throw new EventHandlerException("No request handler found in servlet context!"); + } // generate the main and entry links String entryLinkReq = request.getParameter("entryLinkReq"); String mainLinkReq = request.getParameter("mainLinkReq"); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java Mon Sep 8 06:04:39 2014 @@ -45,11 +45,9 @@ import freemarker.template.TemplateExcep public class FreeMarkerViewHandler extends AbstractViewHandler { public static final String module = FreeMarkerViewHandler.class.getName(); - protected ServletContext servletContext = null; protected Configuration config = (Configuration) FreeMarkerWorker.getDefaultOfbizConfig().clone(); public void init(ServletContext context) throws ViewHandlerException { - this.servletContext = context; config.setCacheStorage(new OfbizCacheStorage("unknown")); config.setServletContextForTemplateLoading(context, "/"); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/taglib/ContentUrlTag.java Mon Sep 8 06:04:39 2014 @@ -20,12 +20,8 @@ package org.ofbiz.webapp.taglib; import java.io.IOException; import javax.servlet.http.HttpServletRequest; -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.BodyContent; -import javax.servlet.jsp.tagext.BodyTagSupport; import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilJ2eeCompat; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -35,19 +31,9 @@ import org.ofbiz.entity.GenericValue; /** * ContentUrlTag - Creates a URL string prepending the content prefix from url.properties */ -@SuppressWarnings("serial") -public class ContentUrlTag extends BodyTagSupport { +public class ContentUrlTag { - public static final String module = UrlTag.class.getName(); - - @Deprecated - public static void appendContentPrefix(HttpServletRequest request, StringBuffer urlBuffer) { - try { - appendContentPrefix(request, (Appendable) urlBuffer); - } catch (IOException e) { - throw UtilMisc.initCause(new InternalError(e.getMessage()), e); - } - } + public static final String module = ContentUrlTag.class.getName(); public static void appendContentPrefix(HttpServletRequest request, StringBuilder urlBuffer) { try { @@ -100,30 +86,4 @@ public class ContentUrlTag extends BodyT ContentUrlTag.appendContentPrefix(request, buf); return buf.toString(); } - - @Override - public int doEndTag() throws JspException { - HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); - - BodyContent body = getBodyContent(); - String bodyString = body.getString(); - - StringBuilder newURL = new StringBuilder(); - - appendContentPrefix(request, newURL); - newURL.append(bodyString); - body.clearBody(); - - try { - getPreviousOut().print(newURL.toString()); - } catch (IOException e) { - if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) { - throw new JspException(e.getMessage(), e); - } else { - Debug.logError(e, "Server does not support nested exceptions, here is the exception", module); - throw new JspException(e.toString()); - } - } - return SKIP_BODY; - } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/HttpViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/HttpViewHandler.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/HttpViewHandler.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/HttpViewHandler.java Mon Sep 8 06:04:39 2014 @@ -35,10 +35,7 @@ public class HttpViewHandler extends Abs public static final String module = HttpViewHandler.class.getName(); - protected ServletContext context; - public void init(ServletContext context) throws ViewHandlerException { - this.context = context; } public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java Mon Sep 8 06:04:39 2014 @@ -18,20 +18,18 @@ *******************************************************************************/ package org.ofbiz.webapp.view; +import java.net.URL; +import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.servlet.ServletContext; -import javolution.util.FastMap; - import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.webapp.control.RequestHandler; -import org.ofbiz.webapp.control.RequestHandlerException; -import org.ofbiz.webapp.control.WebAppConfigurationException; +import org.ofbiz.webapp.control.ConfigXMLReader; /** * ViewFactory - View Handler Factory @@ -40,46 +38,29 @@ public class ViewFactory { public static final String module = ViewFactory.class.getName(); - protected RequestHandler requestHandler = null; - protected ServletContext context = null; - protected Map<String, ViewHandler> handlers = null; - - public ViewFactory(RequestHandler requestHandler) { - this.handlers = FastMap.newInstance(); - this.requestHandler = requestHandler; - this.context = requestHandler.getServletContext(); - - // pre-load all the view handlers - try { - this.preLoadAll(); - } catch (ViewHandlerException e) { - Debug.logError(e, module); - throw new GeneralRuntimeException(e); - } - } + private final Map<String, ViewHandler> handlers = new HashMap<String, ViewHandler>(); - private void preLoadAll() throws ViewHandlerException { - Set<String> handlers = null; + public ViewFactory(ServletContext context, URL controllerConfigURL) { + // load all the view handlers try { - handlers = this.requestHandler.getControllerConfig().getViewHandlerMap().keySet(); - } catch (WebAppConfigurationException e) { - Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); - } - if (handlers != null) { - for (String type: handlers) { - this.handlers.put(type, this.loadViewHandler(type)); + Set<Map.Entry<String,String>> handlerEntries = ConfigXMLReader.getControllerConfig(controllerConfigURL).getViewHandlerMap().entrySet(); + if (handlerEntries != null) { + for (Map.Entry<String,String> handlerEntry: handlerEntries) { + ViewHandler handler = (ViewHandler) ObjectType.getInstance(handlerEntry.getValue()); + handler.setName(handlerEntry.getKey()); + handler.init(context); + this.handlers.put(handlerEntry.getKey(), handler); + } } - } - - // load the "default" type - if (!this.handlers.containsKey("default")) { - try { - ViewHandler h = (ViewHandler) ObjectType.getInstance("org.ofbiz.webapp.view.JspViewHandler"); - h.init(context); - this. handlers.put("default", h); - } catch (Exception e) { - throw new ViewHandlerException(e); + // load the "default" type + if (!this.handlers.containsKey("default")) { + ViewHandler defaultHandler = (ViewHandler) ObjectType.getInstance("org.ofbiz.webapp.view.JspViewHandler"); + defaultHandler.init(context); + this. handlers.put("default", defaultHandler); } + } catch (Exception e) { + Debug.logError(e, module); + throw new GeneralRuntimeException(e); } } @@ -87,60 +68,11 @@ public class ViewFactory { if (UtilValidate.isEmpty(type)) { type = "default"; } - - // check if we are new / empty and add the default handler in - if (handlers.size() == 0) { - this.preLoadAll(); - } - // get the view handler by type from the contextHandlers ViewHandler handler = handlers.get(type); - - // if none found lets create it and add it in if (handler == null) { - synchronized (ViewFactory.class) { - handler = handlers.get(type); - if (handler == null) { - handler = this.loadViewHandler(type); - handlers.put(type, handler); - } - } - if (handler == null) { - throw new ViewHandlerException("No handler found for type: " + type); - } - } - return handler; - } - - public void clear() { - handlers.clear(); - } - - private ViewHandler loadViewHandler(String type) throws ViewHandlerException { - ViewHandler handler = null; - String handlerClass = null; - try { - handlerClass = this.requestHandler.getControllerConfig().getViewHandlerMap().get(type); - } catch (WebAppConfigurationException e) { - Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); - } - if (handlerClass == null) { - throw new ViewHandlerException("Unknown handler type: " + type); + throw new ViewHandlerException("No handler found for type: " + type); } - - try { - handler = (ViewHandler) ObjectType.getInstance(handlerClass); - handler.setName(type); - handler.init(context); - } catch (ClassNotFoundException cnf) { - //throw new ViewHandlerException("Cannot load handler class", cnf); - Debug.logWarning("Warning: could not load view handler class because it was not found; note that some views may not work: " + cnf.toString(), module); - } catch (InstantiationException ie) { - throw new ViewHandlerException("Cannot get instance of the handler", ie); - } catch (IllegalAccessException iae) { - throw new ViewHandlerException(iae.getMessage(), iae); - } - return handler; } } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Mon Sep 8 06:04:39 2014 @@ -47,9 +47,12 @@ import org.ofbiz.entity.config.model.Del import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.entity.*; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; +import org.ofbiz.service.ServiceContainer; import org.ofbiz.service.eca.ServiceEcaRule; import org.ofbiz.webapp.control.ConfigXMLReader; import org.ofbiz.webapp.control.ConfigXMLReader.ControllerConfig; @@ -129,16 +132,13 @@ public class ArtifactInfoFactory { this.delegatorName = delegatorName; this.entityModelReader = ModelReader.getModelReader(delegatorName); DelegatorElement delegatorInfo = EntityConfig.getInstance().getDelegator(delegatorName); - String modelName; + String modelName = "main"; if (delegatorInfo != null) { modelName = delegatorInfo.getEntityModelReader(); - } else { - modelName = "main"; } - // since we do not associate a dispatcher to this DispatchContext, it is important to set a name of an existing entity model reader: - // in this way it will be possible to retrieve the service models from the cache - this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader(), null); - + Delegator delegator = DelegatorFactory.getDelegator(delegatorName); + LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(modelName, delegator); + this.dispatchContext = dispatcher.getDispatchContext(); this.prepareAll(); } Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java Mon Sep 8 06:04:39 2014 @@ -47,8 +47,10 @@ import org.ofbiz.entity.model.ModelEntit import org.ofbiz.entity.model.ModelField; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; +import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelParam; import org.ofbiz.service.ModelService; +import org.ofbiz.service.ServiceContainer; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; @@ -77,15 +79,12 @@ public class LabelReferences { } catch (GenericEntityConfException e) { Debug.logWarning(e, "Exception thrown while getting delegator config: ", module); } - String modelName; + String modelName = "main"; if (delegatorInfo != null) { modelName = delegatorInfo.getEntityModelReader(); - } else { - modelName = "main"; } - // since we do not associate a dispatcher to this DispatchContext, it is important to set a name of an existing entity model reader: - // in this way it will be possible to retrieve the service models from the cache - this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader(), null); + LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(modelName, delegator); + this.dispatchContext = dispatcher.getDispatchContext(); Collection<LabelInfo> infoList = this.labels.values(); for (LabelInfo labelInfo : infoList) { this.labelSet.add(labelInfo.getLabelKey()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/actions/entity/XmlDsDump.groovy Mon Sep 8 06:04:39 2014 @@ -19,12 +19,7 @@ import java.util.*; import java.io.*; -import java.net.*; -import org.w3c.dom.*; -import org.ofbiz.security.*; -import org.ofbiz.entity.*; import org.ofbiz.base.util.*; -import org.ofbiz.webapp.pseudotag.*; import org.ofbiz.entity.model.*; import org.ofbiz.entity.util.*; import org.ofbiz.entity.transaction.*; Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/controller.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/controller.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/controller.xml Mon Sep 8 06:04:39 2014 @@ -27,7 +27,6 @@ under the License. <description>WebTools Site Configuration File</description> <handler name="ftl" type="view" class="org.ofbiz.webapp.ftl.FreeMarkerViewHandler"/> - <handler name="datavision" type="view" class="org.ofbiz.webapp.view.DataVisionViewHandler"/> <!-- Events to run on every request before security (chains exempt) --> <!-- @@ -675,8 +674,6 @@ under the License. <view-map name="printStart" type="screen" page="component://webtools/widget/CommonScreens.xml#printStart"/> <view-map name="printDone" type="screen" page="component://webtools/widget/CommonScreens.xml#printDone"/> - <view-map name="UomReport" page="/UomReport.xml" type="datavision" info="Uom"/> - <view-map name="EntitySyncStatus" page="component://webtools/widget/EntitySyncScreens.xml#EntitySyncStatus" type="screen"/> <view-map name="EntitySQLProcessor" page="component://webtools/widget/EntityScreens.xml#EntitySQLProcessor" type="screen"/> <view-map name="ConnectionPoolStatus" page="component://webtools/widget/EntityScreens.xml#ConnectionPoolStatus" type="screen"/> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/web.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/web.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/WEB-INF/web.xml Mon Sep 8 06:04:39 2014 @@ -105,11 +105,6 @@ under the License. <welcome-file>index.jsp</welcome-file> </welcome-file-list> - <taglib> - <taglib-uri>ofbizTags</taglib-uri> - <taglib-location>/WEB-INF/ofbiz.tld</taglib-location> - </taglib> - <!-- HTTP Response Code definitions: | "400" ; Bad Request | "401" ; Unauthorized Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp Mon Sep 8 06:04:39 2014 @@ -15,7 +15,7 @@ software distributed under the License i KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---%><%@ page import="java.io.*, java.util.*, java.net.*, org.w3c.dom.*, org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.entity.condition.*, org.ofbiz.entity.util.*, org.ofbiz.base.util.*, org.ofbiz.entity.model.*, org.ofbiz.entity.transaction.*" %><%@ taglib uri="ofbizTags" prefix="ofbiz" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><% +--%><%@ page import="java.io.*, java.util.*, java.net.*, org.w3c.dom.*, org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.entity.condition.*, org.ofbiz.entity.util.*, org.ofbiz.base.util.*, org.ofbiz.entity.model.*, org.ofbiz.entity.transaction.*" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><% if(security.hasPermission("ENTITY_MAINT", session)) { TreeSet passedEntityNames = (TreeSet) session.getAttribute("xmlrawdump_entitylist"); session.removeAttribute("xmlrawdump_entitylist"); @@ -38,11 +38,7 @@ under the License. PrintWriter writer = null; ServletContext context = pageContext.getServletContext(); - if (UtilJ2eeCompat.useOutputStreamNotWriter(context)) { - writer = new PrintWriter(response.getOutputStream(), true); - } else { - writer = response.getWriter(); - } + writer = response.getWriter(); writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); writer.println("<entity-engine-xml>"); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java Mon Sep 8 06:04:39 2014 @@ -70,10 +70,6 @@ public class HtmlWidget extends ModelScr @SuppressWarnings("unchecked") @Override public TemplateModel wrap(Object object) throws TemplateModelException { - /* NOTE: don't use this and the StringHtmlWrapperForFtl or things will be double-encoded - if (object instanceof GenericValue) { - return new GenericValueHtmlWrapperForFtl((GenericValue) object, this); - }*/ // This StringHtmlWrapperForFtl option seems to be the best option // and handles most things without causing too many problems if (object instanceof String) { @@ -153,64 +149,6 @@ public class HtmlWidget extends ModelScr throw new IllegalArgumentException("Template location is empty"); } - - /* - // ======================================================================= - // Go through the context and find GenericValue objects and wrap them - - // NOTE PROBLEM: there are still problems with this as it gets some things - // but does not get non-entity data including lots of strings - // directly in the context or things prepared or derived right in - // the FTL file, like the results of service calls, etc; we could - // do something more aggressive to encode and wrap EVERYTHING in - // the context, but I've been thinking that even this is too much - // overhead and that would be crazy - - // NOTE ALTERNATIVE1: considering instead to use the FTL features to wrap - // everything in an <#escape x as x?html>...</#escape>, but that could - // cause problems with ${} expansions that have HTML in them, including: - // included screens (using ${screens.render(...)}), content that should - // have HTML in it (lots of general, product, category, etc content), etc - - // NOTE ALTERNATIVE2: kind of like the "#escape X as x?html" option, - // implement an FTL *Model class and load it through a ObjectWrapper - // FINAL NOTE: after testing all of these alternatives, this one seems - // to behave the best, so going with that for now. - - // isolate the scope so these wrapper objects go away after rendering is done - MapStack<String> contextMs; - if (!(context instanceof MapStack)) { - contextMs = MapStack.create(context); - context = contextMs; - } else { - contextMs = UtilGenerics.cast(context); - } - - contextMs.push(); - for (Map.Entry<String, Object> mapEntry: contextMs.entrySet()) { - Object value = mapEntry.getValue(); - if (value instanceof GenericValue) { - contextMs.put(mapEntry.getKey(), GenericValueHtmlWrapper.create((GenericValue) value)); - } else if (value instanceof List) { - if (((List) value).size() > 0 && ((List) value).get(0) instanceof GenericValue) { - List<GenericValue> theList = (List<GenericValue>) value; - List<GenericValueHtmlWrapper> newList = FastList.newInstance(); - for (GenericValue gv: theList) { - newList.add(GenericValueHtmlWrapper.create(gv)); - } - contextMs.put(mapEntry.getKey(), newList); - } - } - // TODO and NOTE: should get most stuff, but we could support Maps - // and Lists in Maps and such; that's tricky because we have to go - // through the entire Map and not just one entry, and we would - // have to shallow copy the whole Map too - - } - // this line goes at the end of the method, but moved up here to be part of the big comment about this - contextMs.pop(); - */ - if (location.endsWith(".ftl")) { try { Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters")); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java Mon Sep 8 06:04:39 2014 @@ -19,11 +19,9 @@ package org.ofbiz.widget.screen; import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.Writer; import javax.servlet.ServletContext; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.ParserConfigurationException; @@ -31,7 +29,6 @@ import javax.xml.parsers.ParserConfigura import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.StringUtil; -import org.ofbiz.base.util.UtilJ2eeCompat; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.webapp.view.AbstractViewHandler; @@ -58,19 +55,8 @@ public class MacroScreenViewHandler exte } public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException { - Writer writer = null; try { - // use UtilJ2eeCompat to get this setup properly - boolean useOutputStreamNotWriter = false; - if (this.servletContext != null) { - useOutputStreamNotWriter = UtilJ2eeCompat.useOutputStreamNotWriter(this.servletContext); - } - if (useOutputStreamNotWriter) { - ServletOutputStream ros = response.getOutputStream(); - writer = new OutputStreamWriter(ros, UtilProperties.getPropertyValue("widget", getName() + ".default.contenttype", "UTF-8")); - } else { - writer = response.getWriter(); - } + Writer writer = response.getWriter(); // compress output if configured to do so if (UtilValidate.isEmpty(encoding)) { Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Mon Sep 8 06:04:39 2014 @@ -62,7 +62,6 @@ import org.xml.sax.SAXException; import freemarker.ext.jsp.TaglibFactory; import freemarker.ext.servlet.HttpRequestHashModel; import freemarker.ext.servlet.HttpSessionHashModel; -import freemarker.ext.servlet.ServletContextHashModel; /** * Widget Library - Screen model class @@ -246,10 +245,6 @@ public class ScreenRenderer { context.put("JspTaglibs", JspTaglibs); context.put("requestParameters", UtilHttp.getParameterMap(request)); - ServletContextHashModel ftlServletContext = (ServletContextHashModel) request.getAttribute("ftlServletContext"); - context.put("Application", ftlServletContext); - context.put("Request", context.get("requestAttributes")); - // this is a dummy object to stand-in for the JPublish page object for backward compatibility context.put("page", FastMap.newInstance()); Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/ivy.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/ivy.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/ivy.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/ivy.xml Mon Sep 8 06:04:39 2014 @@ -43,7 +43,6 @@ <exclude module="log4j" conf="cobertura"/> <exclude module="ant" conf="cobertura"/> <exclude module="asm" conf="cobertura"/> - <exclude module="asm-tree" conf="cobertura"/> <exclude module="oro" conf="cobertura"/> </dependencies> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/macros.xml Mon Sep 8 06:04:39 2014 @@ -64,7 +64,6 @@ under the License. <pathelement location="${ofbiz.home.dir}/framework/base/lib/cobertura-1.9.4.1.jar" /> <pathelement location="${ofbiz.home.dir}/framework/base/lib/log4j-1.2.17.jar" /> <pathelement location="${ofbiz.home.dir}/framework/base/lib/scripting/asm-3.2.jar" /> - <pathelement location="${ofbiz.home.dir}/framework/base/lib/scripting/asm-tree-3.2.jar" /> <pathelement location="${ofbiz.home.dir}/framework/base/lib/scripting/jakarta-oro-2.0.8.jar" /> </path> <path id="local.class.path"/> @@ -110,12 +109,6 @@ under the License. <exclude name="**/JasperReportsXmlViewHandler.java"/> <exclude name="**/JasperReportsJXlsViewHandler.java"/> <exclude name="**/JasperReportsPoiXlsViewHandler.java"/> - <exclude name="**/GenericViewRenderer.java"/> - <exclude name="**/JPublishViewHandler.java"/> - <exclude name="**/JPublishWrapper.java"/> - <exclude name="**/FopPdfViewHandler.java"/> - <exclude name="**/FreeMarkerViewRenderer.java"/> - <exclude name="**/JpCacheIncludeTransform.java"/> </fileset> <link href="http://java.sun.com/javase/7/docs/api/" offline="true" packagelistLoc="${ofbiz.home.dir}/tools/api-java17"/> </javadoc> Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/birt/webapp/birt/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/birt/webapp/birt/WEB-INF/controller.xml?rev=1623295&r1=1623294&r2=1623295&view=diff ============================================================================== --- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/birt/webapp/birt/WEB-INF/controller.xml (original) +++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/specialpurpose/birt/webapp/birt/WEB-INF/controller.xml Mon Sep 8 06:04:39 2014 @@ -28,12 +28,6 @@ under the License. <description>BIRT Component Site Configuration File</description> <handler name="birt" type="view" class="org.ofbiz.birt.webapp.view.BirtViewHandler"/> - <!-- - These can be used to return the reports as views; make sure the classes are compiled and available - <handler name="datavision" type="view" class="org.ofbiz.webapp.view.DataVisionViewHandler"/> - <handler name="jasperreportspdf" type="view" class="org.ofbiz.webapp.view.JasperReportsPdfViewHandler"/> - <handler name="jasperreportsxml" type="view" class="org.ofbiz.webapp.view.JasperReportsXmlViewHandler"/> - --> <!-- Events to run on every request before security (chains exempt) --> <!-- |
Free forum by Nabble | Edit this page |