Activated user accessible log4j configuration file. In addition, file location is now configurable using a new web.xml context parameter.
git-svn-id: https://svn.libreccm.org/ccm/trunk@183 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e2b5a3d64e
commit
0dce2ee598
|
|
@ -24,6 +24,7 @@ import com.arsdigita.util.JavaPropertyReader;
|
||||||
import com.arsdigita.util.parameter.ErrorList;
|
import com.arsdigita.util.parameter.ErrorList;
|
||||||
import com.arsdigita.util.parameter.Parameter;
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
import com.arsdigita.util.parameter.StringParameter;
|
import com.arsdigita.util.parameter.StringParameter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
@ -35,6 +36,7 @@ import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,7 +52,8 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Dan Berrange
|
* @author Dan Berrange
|
||||||
* @see <a href="http://www.tuxedo.org/~esr/jargon/html/entry/guru-meditation.html">http://www.tuxedo.org/~esr/jargon/html/entry/guru-meditation.html</a>
|
* @see <a href="http://www.tuxedo.org/~esr/jargon/html/entry/guru-meditation.html">
|
||||||
|
* http://www.tuxedo.org/~esr/jargon/html/entry/guru-meditation.html</a>
|
||||||
*/
|
*/
|
||||||
public class ErrorReport {
|
public class ErrorReport {
|
||||||
public static final String versionId =
|
public static final String versionId =
|
||||||
|
|
@ -79,7 +82,7 @@ public class ErrorReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initializeAppender(String directory) {
|
public static void initializeAppender(String directory) {
|
||||||
Assert.assertNotNull(directory, "directory is null");
|
Assert.exists(directory, "directory is null");
|
||||||
|
|
||||||
File file = new File(directory);
|
File file = new File(directory);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ import org.apache.log4j.RollingFileAppender;
|
||||||
* @version $Revision: #9 $ $Date: 2004/08/16 $
|
* @version $Revision: #9 $ $Date: 2004/08/16 $
|
||||||
*/
|
*/
|
||||||
public class LogExample {
|
public class LogExample {
|
||||||
public final static String versionId = "$Id: LogExample.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
public final static String versionId =
|
||||||
|
"$Id: LogExample.java 287 2005-02-22 00:29:02Z sskracic $" +
|
||||||
|
" by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
||||||
|
|
||||||
// get the logger named the same as this class
|
// get the logger named the same as this class
|
||||||
static final Logger cat = Logger.getLogger(LogExample.class);
|
static final Logger cat = Logger.getLogger(LogExample.class);
|
||||||
|
|
@ -45,10 +47,10 @@ public class LogExample {
|
||||||
try {
|
try {
|
||||||
// create a rolling file appender with standard layout
|
// create a rolling file appender with standard layout
|
||||||
RollingFileAppender rfa = new RollingFileAppender(
|
RollingFileAppender rfa = new RollingFileAppender(
|
||||||
new PatternLayout(
|
new PatternLayout(
|
||||||
PatternLayout.TTCC_CONVERSION_PATTERN
|
PatternLayout.TTCC_CONVERSION_PATTERN
|
||||||
), filename
|
), filename
|
||||||
);
|
);
|
||||||
|
|
||||||
// add our secure log filter to this appender so that it
|
// add our secure log filter to this appender so that it
|
||||||
// won't get any of the secure log messages
|
// won't get any of the secure log messages
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,9 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Revision: #10 $ $Date: 2004/08/16 $
|
* @version $Revision: #10 $ $Date: 2004/08/16 $
|
||||||
*/
|
*/
|
||||||
public class LogExampleThread extends Thread {
|
public class LogExampleThread extends Thread {
|
||||||
public final static String versionId = "$Id: LogExampleThread.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
public final static String
|
||||||
|
versionId = "$Id: LogExampleThread.java 287 2005-02-22 00:29:02Z sskracic $" +
|
||||||
|
" by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
||||||
|
|
||||||
// get the category named the same as this class
|
// get the category named the same as this class
|
||||||
private static final Logger cat = Logger.getLogger(LogExampleThread.class);
|
private static final Logger cat = Logger.getLogger(LogExampleThread.class);
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
|
|
||||||
<p>
|
<p>Contains example code to demonstrate proper usage of
|
||||||
|
the ACS Logging system.</p>
|
||||||
|
|
||||||
<b>Example</b> Contains example code to demonstrate proper usage of
|
|
||||||
the ACS Logging system.
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,14 @@
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
Extends the <a href="http://jakarta.apache.org/log4j/">Log4j</a>
|
Extends the <a href="http://jakarta.apache.org/log4j/">Log4j</a>
|
||||||
framework to support secure logging.
|
framework to support secure logging. In case of an error it generates an
|
||||||
|
error page for the user which contains a unique reference code. Is is meant to
|
||||||
|
be used to search for the error message in the log files. In addition is
|
||||||
|
generates a formated log entry with a lot of additional information about the
|
||||||
|
system's state.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@ public class MasterTool {
|
||||||
final PrintStream out = System.out;
|
final PrintStream out = System.out;
|
||||||
final PrintStream err = System.err;
|
final PrintStream err = System.err;
|
||||||
|
|
||||||
com.arsdigita.runtime.Startup.startup();
|
// nolonger needed
|
||||||
|
// com.arsdigita.runtime.Startup.startup();
|
||||||
|
|
||||||
Commands cmds = new Commands();
|
Commands cmds = new Commands();
|
||||||
Command help = new Help();
|
Command help = new Help();
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,16 @@
|
||||||
package com.arsdigita.runtime;
|
package com.arsdigita.runtime;
|
||||||
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>CCMResourceManager Runtime environment repository object, stores essential
|
* <p>CCMResourceManager Runtime environment repository object, stores essential
|
||||||
* properties of the runtime environment.</p>
|
* properties of the runtime environment and provides them on request.</p>
|
||||||
*
|
*
|
||||||
* <p>Currently, is is limited to the </p>
|
* <p>Currently, is is limited to the </p>
|
||||||
* <ul>
|
* <ul>
|
||||||
|
|
@ -37,10 +39,11 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* <p>The singleton is initialised</p>
|
* <p>The singleton is initialised</p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>either during startup of the container (called by BaseServlet, in future
|
* <li>either during startup of the container (called by
|
||||||
* by a specialised ApplicationContextListener) </li>
|
* @see com.arsdigita.web.CCMApplicationContextListener (must be configured in
|
||||||
|
* web.xml)</li>
|
||||||
* <li>or by the command line system at the beginning of the processing (esp.
|
* <li>or by the command line system at the beginning of the processing (esp.
|
||||||
* package c.ad.packaging).</li>
|
* package @see com.arsdigita.packaging.Mastertool).</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>Currently as a fall back mechanism the environmant Variable CCM_HOME is
|
* <p>Currently as a fall back mechanism the environmant Variable CCM_HOME is
|
||||||
* evaluated and used a last resort, if no initialisation has been done when
|
* evaluated and used a last resort, if no initialisation has been done when
|
||||||
|
|
@ -49,7 +52,7 @@ import org.apache.log4j.Logger;
|
||||||
* <p>It is essential for the proper working of CCM that CCMResourceManager is
|
* <p>It is essential for the proper working of CCM that CCMResourceManager is
|
||||||
* initialised before any operation starts, as it is the case with the Startup
|
* initialised before any operation starts, as it is the case with the Startup
|
||||||
* class of the runtime package, which is responsible for organising database
|
* class of the runtime package, which is responsible for organising database
|
||||||
* assess.</p>
|
* access.</p>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* <p><b>Subject to change!</b></p>
|
* <p><b>Subject to change!</b></p>
|
||||||
|
|
@ -60,10 +63,8 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Id: CCMResourceManager.java 751 2005-09-02 12:52:23Z sskracic $
|
* @version $Id: CCMResourceManager.java 751 2005-09-02 12:52:23Z sskracic $
|
||||||
*/
|
*/
|
||||||
public final class CCMResourceManager {
|
public final class CCMResourceManager {
|
||||||
public final static String versionId =
|
public final static String versionId =
|
||||||
"$Id: CCMResourceManager.java 1393 2006-11-28 09:12:32Z sskracic $" +
|
"$Id: CCMResourceManager.java 1393 2006-11-28 09:12:32Z sskracic $" ;
|
||||||
"$Author: pboy $" +
|
|
||||||
"$DateTime: 2009/01/10 18:10:38 $";
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(CCMResourceManager.class);
|
private static final Logger s_log = Logger.getLogger(CCMResourceManager.class);
|
||||||
|
|
||||||
|
|
@ -169,7 +170,7 @@ public final class CCMResourceManager {
|
||||||
* The dependency from a system wide environment variable prevents a servlet
|
* The dependency from a system wide environment variable prevents a servlet
|
||||||
* container to run multiple instances of CCM. In addition to it CCM will
|
* container to run multiple instances of CCM. In addition to it CCM will
|
||||||
* be migrated to be installable in a standard way to a standard container.
|
* be migrated to be installable in a standard way to a standard container.
|
||||||
* Therefore all file locations will be given to the applications
|
* Therefore all file locations will be given relative to the applications
|
||||||
* directory (the baseDirectory @see m_baseDir).
|
* directory (the baseDirectory @see m_baseDir).
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|
@ -192,7 +193,7 @@ public final class CCMResourceManager {
|
||||||
("The ccm.home system property is null or not defined");
|
("The ccm.home system property is null or not defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
// make a guess, weather ist is old style (i.e. referring to the containers
|
// make a guess, wether it is old style (i.e. referring to the containers
|
||||||
// base directory and therefor does not contain the webapps part) or
|
// base directory and therefor does not contain the webapps part) or
|
||||||
// new style referring to the apps base directory (and therefor containing
|
// new style referring to the apps base directory (and therefor containing
|
||||||
// the webapps part)
|
// the webapps part)
|
||||||
|
|
@ -303,23 +304,13 @@ public final class CCMResourceManager {
|
||||||
/**
|
/**
|
||||||
* Stores the passed in String as File object.
|
* Stores the passed in String as File object.
|
||||||
*
|
*
|
||||||
* XXX contemporary Hack: checks if the last part of the dir is ROOT,
|
|
||||||
* otherwise replaces the ccm-<module> part. Must be removed as soon as all
|
|
||||||
* CCMResourceManager modules are relocated in one single context (app directory)
|
|
||||||
* instead of spreaded as separate applications.
|
|
||||||
* @param baseDirName String containing the path, must not be null
|
* @param baseDirName String containing the path, must not be null
|
||||||
*/
|
*/
|
||||||
private final void storeBaseDir(String baseDirName) {
|
private final void storeBaseDir(String baseDirName) {
|
||||||
|
|
||||||
s_log.info("storeBaseDir: BaseDir name is given as " + baseDirName );
|
s_log.debug("storeBaseDir: BaseDir name is given as " + baseDirName );
|
||||||
m_baseDir = new File(baseDirName);
|
m_baseDir = new File(baseDirName);
|
||||||
|
|
||||||
|
|
||||||
// temporary: enforce that BaseDir is ROOT!
|
|
||||||
// removed, all modules are now installed into one context and
|
|
||||||
// its name is specified in project.xml
|
|
||||||
// m_baseDir.renameTo(new File(m_baseDir.getParent(),"ROOT"));
|
|
||||||
|
|
||||||
// eventually: check if dir exists, create it if not.
|
// eventually: check if dir exists, create it if not.
|
||||||
if (!m_baseDir.exists()) {
|
if (!m_baseDir.exists()) {
|
||||||
if (!m_baseDir.mkdirs()) {
|
if (!m_baseDir.mkdirs()) {
|
||||||
|
|
@ -332,8 +323,6 @@ public final class CCMResourceManager {
|
||||||
("Base directory value is not a directory: " + m_baseDir);
|
("Base directory value is not a directory: " + m_baseDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_log.info("storeBaseDir: BaseDir is stored as " + m_baseDir );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import com.arsdigita.util.Classes;
|
||||||
import com.arsdigita.util.SystemProperties;
|
import com.arsdigita.util.SystemProperties;
|
||||||
import com.arsdigita.util.parameter.Parameter;
|
import com.arsdigita.util.parameter.Parameter;
|
||||||
import com.arsdigita.util.parameter.StringParameter;
|
import com.arsdigita.util.parameter.StringParameter;
|
||||||
|
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
@ -48,6 +49,7 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -81,34 +83,6 @@ public class Startup extends CompoundInitializer {
|
||||||
|
|
||||||
private static boolean s_hasRun = false;
|
private static boolean s_hasRun = false;
|
||||||
|
|
||||||
private static boolean s_hasStartup = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method must be called before any CCM resources are loaded.
|
|
||||||
*/
|
|
||||||
public static void startup() {
|
|
||||||
if (s_hasStartup) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register custom protocol handlers
|
|
||||||
String handlerPackages =
|
|
||||||
System.getProperty("java.protocol.handler.pkgs");
|
|
||||||
if (handlerPackages == null)
|
|
||||||
handlerPackages = "com.arsdigita.util.protocol";
|
|
||||||
else
|
|
||||||
handlerPackages = "com.arsdigita.util.protocol|" + handlerPackages;
|
|
||||||
System.setProperty("java.protocol.handler.pkgs", handlerPackages);
|
|
||||||
|
|
||||||
s_hasStartup = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new startup by defaulting the connection source to
|
|
||||||
* a dedicated connection source that uses the JDBC URL specified
|
|
||||||
* by the waf.runtime.jdbc_url parameter.
|
|
||||||
**/
|
|
||||||
|
|
||||||
public Startup() {
|
public Startup() {
|
||||||
this(new PooledConnectionSource
|
this(new PooledConnectionSource
|
||||||
(RuntimeConfig.getConfig().getJDBCURL(),
|
(RuntimeConfig.getConfig().getJDBCURL(),
|
||||||
|
|
@ -254,7 +228,8 @@ public class Startup extends CompoundInitializer {
|
||||||
public final void run() {
|
public final void run() {
|
||||||
s_log.info("Initializing WAF runtime");
|
s_log.info("Initializing WAF runtime");
|
||||||
|
|
||||||
startup();
|
// Deprecated, no longer needed.
|
||||||
|
// startup();
|
||||||
|
|
||||||
DbHelper.setDatabase
|
DbHelper.setDatabase
|
||||||
(DbHelper.getDatabaseFromURL(RuntimeConfig.
|
(DbHelper.getDatabaseFromURL(RuntimeConfig.
|
||||||
|
|
|
||||||
|
|
@ -409,7 +409,7 @@ public class Assert {
|
||||||
*
|
*
|
||||||
* pboy Jan.09: not used by any package in trunk
|
* pboy Jan.09: not used by any package in trunk
|
||||||
*/
|
*/
|
||||||
public static final boolean ASSERT_ON = true;
|
// public static final boolean ASSERT_ON = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates state of the ASSERT_ON flag.
|
* Indicates state of the ASSERT_ON flag.
|
||||||
|
|
@ -418,9 +418,9 @@ public class Assert {
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link #isEnabled()} instead
|
* @deprecated Use {@link #isEnabled()} instead
|
||||||
*/
|
*/
|
||||||
public static final boolean isAssertOn() {
|
// public static final boolean isAssertOn() {
|
||||||
return isEnabled();
|
// return isEnabled();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells whether asserts are turned on. Use this to wrap code
|
* Tells whether asserts are turned on. Use this to wrap code
|
||||||
|
|
|
||||||
|
|
@ -18,25 +18,26 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.web;
|
package com.arsdigita.web;
|
||||||
|
|
||||||
import com.arsdigita.util.Assert;
|
|
||||||
import com.arsdigita.dispatcher.InitialRequestContext;
|
import com.arsdigita.dispatcher.InitialRequestContext;
|
||||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.dispatcher.RequestContext;
|
import com.arsdigita.dispatcher.RequestContext;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.util.Assert;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
|
||||||
import com.arsdigita.web.Application;
|
|
||||||
import com.arsdigita.kernel.SiteNode;
|
import com.arsdigita.kernel.SiteNode;
|
||||||
import com.arsdigita.kernel.KernelExcursion;
|
import com.arsdigita.kernel.KernelExcursion;
|
||||||
import com.arsdigita.kernel.KernelRequestContext;
|
import com.arsdigita.kernel.KernelRequestContext;
|
||||||
import com.arsdigita.kernel.security.SessionContext;
|
import com.arsdigita.kernel.security.SessionContext;
|
||||||
import com.arsdigita.kernel.security.UserContext;
|
import com.arsdigita.kernel.security.UserContext;
|
||||||
import com.arsdigita.sitenode.SiteNodeRequestContext;
|
import com.arsdigita.sitenode.SiteNodeRequestContext;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import com.arsdigita.web.Application;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -165,7 +166,7 @@ public abstract class BaseApplicationServlet extends BaseServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertNotNull(id, "BigDecimal id");
|
Assert.exists(id, "BigDecimal id");
|
||||||
|
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Retrieving application " + id + " from the " +
|
s_log.debug("Retrieving application " + id + " from the " +
|
||||||
|
|
@ -175,6 +176,13 @@ public abstract class BaseApplicationServlet extends BaseServlet {
|
||||||
return Application.retrieveApplication(id);
|
return Application.retrieveApplication(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sreq
|
||||||
|
* @param app
|
||||||
|
* @param uc
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private RequestContext makeLegacyContext(HttpServletRequest sreq,
|
private RequestContext makeLegacyContext(HttpServletRequest sreq,
|
||||||
final Application app,
|
final Application app,
|
||||||
final UserContext uc) {
|
final UserContext uc) {
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.arsdigita.runtime.Startup;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,30 +40,43 @@ import org.apache.log4j.Logger;
|
||||||
* method to open up a default persistence session, and
|
* method to open up a default persistence session, and
|
||||||
* then hand off to the doService method. Subclasses
|
* then hand off to the doService method. Subclasses
|
||||||
* should override this doService method to provide the
|
* should override this doService method to provide the
|
||||||
* processing they require.
|
* processing they require.
|
||||||
|
*
|
||||||
|
* Assumes a initialized database connection and domain
|
||||||
|
* coupling machinery (provided by CCMApplicationListener
|
||||||
|
* during container startup).
|
||||||
|
*
|
||||||
|
* Actually, the class does nothing at all!
|
||||||
*/
|
*/
|
||||||
public class BaseFilter implements Filter {
|
public class BaseFilter implements Filter {
|
||||||
|
|
||||||
private static Logger s_log = Logger.getLogger(BaseFilter.class);
|
private static Logger s_log = Logger.getLogger(BaseFilter.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sconfig
|
||||||
|
* @throws javax.servlet.ServletException
|
||||||
|
*/
|
||||||
public final void init(final FilterConfig sconfig) throws ServletException {
|
public final void init(final FilterConfig sconfig) throws ServletException {
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info("Initializing filter " + sconfig.getFilterName() +
|
s_log.info("Initializing filter " + sconfig.getFilterName() +
|
||||||
" (class: " + getClass().getName() + ")");
|
" (class: " + getClass().getName() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
Startup startup = new Startup();
|
|
||||||
if ( !startup.hasRun() ) {
|
|
||||||
startup.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
doInit();
|
doInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @throws javax.servlet.ServletException
|
||||||
|
*/
|
||||||
protected void doInit() throws ServletException {
|
protected void doInit() throws ServletException {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public final void destroy() {
|
public final void destroy() {
|
||||||
if (s_log.isInfoEnabled()) {
|
if (s_log.isInfoEnabled()) {
|
||||||
s_log.info
|
s_log.info
|
||||||
|
|
@ -75,10 +86,21 @@ public class BaseFilter implements Filter {
|
||||||
doDestroy();
|
doDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected void doDestroy() {
|
protected void doDestroy() {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sreq
|
||||||
|
* @param sresp
|
||||||
|
* @param chain
|
||||||
|
* @throws java.io.IOException
|
||||||
|
* @throws javax.servlet.ServletException
|
||||||
|
*/
|
||||||
public void doFilter(ServletRequest sreq,
|
public void doFilter(ServletRequest sreq,
|
||||||
ServletResponse sresp,
|
ServletResponse sresp,
|
||||||
FilterChain chain)
|
FilterChain chain)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.jsp.HttpJspPage;
|
import javax.servlet.jsp.HttpJspPage;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -27,16 +27,16 @@ import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.kernel.KernelExcursion;
|
import com.arsdigita.kernel.KernelExcursion;
|
||||||
import com.arsdigita.kernel.security.UserContext;
|
import com.arsdigita.kernel.security.UserContext;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.runtime.CCMResourceManager;
|
|
||||||
import com.arsdigita.runtime.Startup;
|
|
||||||
import com.arsdigita.sitenode.ServletErrorReport;
|
import com.arsdigita.sitenode.ServletErrorReport;
|
||||||
import com.arsdigita.util.ResourceManager;
|
import com.arsdigita.util.ResourceManager;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.ServletConfig;
|
import javax.servlet.ServletConfig;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,8 +46,8 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* <b>Subject zu change!</b>
|
* <b>Subject zu change!</b>
|
||||||
*
|
*
|
||||||
* Note: In the future the database related tasks may be moved to a
|
* Note: Database initialization (Startup() ) has been moved to
|
||||||
* ContextListener object (CCMAplicationContextListener).
|
* CCMAplicationContextListener).
|
||||||
*
|
*
|
||||||
* <p>Users of this class may implement {@link
|
* <p>Users of this class may implement {@link
|
||||||
* #doService(HttpServletRequest,HttpServletResponse)} to service a
|
* #doService(HttpServletRequest,HttpServletResponse)} to service a
|
||||||
|
|
@ -88,12 +88,6 @@ public abstract class BaseServlet extends HttpServlet {
|
||||||
// ToDo: integrate both into a single class, e.g. CCMResourceManager
|
// ToDo: integrate both into a single class, e.g. CCMResourceManager
|
||||||
// to simplify and clean-up of the code!
|
// to simplify and clean-up of the code!
|
||||||
ResourceManager.getInstance().setServletContext(getServletContext());
|
ResourceManager.getInstance().setServletContext(getServletContext());
|
||||||
CCMResourceManager.setBaseDirectory(getServletContext().getRealPath("/"));
|
|
||||||
|
|
||||||
Startup startup = new Startup();
|
|
||||||
if ( !startup.hasRun() ) {
|
|
||||||
startup.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
doInit();
|
doInit();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,16 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.web;
|
package com.arsdigita.web;
|
||||||
|
|
||||||
// import com.arsdigita.runtime.CCMResourceManager;
|
import com.arsdigita.runtime.CCMResourceManager;
|
||||||
import com.arsdigita.runtime.*;
|
import com.arsdigita.runtime.Startup;
|
||||||
|
// import com.arsdigita.util.ResourceManager;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.apache.log4j.PropertyConfigurator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web application lifecycle listener, used to perform central initialization
|
* Web application lifecycle listener, used to perform central initialization
|
||||||
|
|
@ -72,18 +75,48 @@ public class CCMApplicationContextListener implements ServletContextListener {
|
||||||
public void contextInitialized(ServletContextEvent applicationStartEvent) {
|
public void contextInitialized(ServletContextEvent applicationStartEvent) {
|
||||||
// throw new UnsupportedOperationException("Not supported yet.");
|
// throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fully qualified path name to application base in the servers file system
|
||||||
|
*/
|
||||||
String m_appBase ;
|
String m_appBase ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log4J config file name including path relative to application base
|
||||||
|
*/
|
||||||
|
String m_log4j ;
|
||||||
|
|
||||||
// s_log.setLevel( INFO );
|
// s_log.setLevel( INFO );
|
||||||
|
s_log.info("Starting CCM Application.");
|
||||||
|
|
||||||
|
|
||||||
ServletContext sc = applicationStartEvent.getServletContext();
|
ServletContext sc = applicationStartEvent.getServletContext();
|
||||||
m_appBase = sc.getRealPath("/");
|
m_appBase = sc.getRealPath("/");
|
||||||
|
|
||||||
CCMResourceManager.setBaseDirectory(sc.getRealPath("/"));
|
//Configure log4j configuration file
|
||||||
|
m_log4j = sc.getInitParameter("log4j-conf-file");
|
||||||
|
s_log.info("Logging context parameeter is: " + m_log4j);
|
||||||
|
// if the log4j-init-file is not set, then no point in trying
|
||||||
|
if(m_log4j != null) {
|
||||||
|
PropertyConfigurator.configure(m_appBase+m_log4j);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PropertyConfigurator.configure(m_appBase+
|
||||||
|
"WEB-INF/conf/log4j.properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
// The classes ResourceManager and CCMResourceManager handle a
|
||||||
|
// very similiar scope of tasks.
|
||||||
|
// ToDo: integrate both into a single class, e.g. CCMResourceManager
|
||||||
|
// to simplify and clean-up of the code!
|
||||||
|
CCMResourceManager.setBaseDirectory(m_appBase);
|
||||||
s_log.info("CCMApplicationContextListener: BaseDir set to: " + m_appBase );
|
s_log.info("CCMApplicationContextListener: BaseDir set to: " + m_appBase );
|
||||||
s_log.debug("CCMApplicationContextListener done." );
|
|
||||||
s_log.fatal("CCMApplicationContextListener: BaseDir set to: " + m_appBase );
|
// Central startup procedure, initialize the database and
|
||||||
|
// domain coupling machinary
|
||||||
|
Startup startup = new Startup();
|
||||||
|
if ( !startup.hasRun() ) {
|
||||||
|
startup.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -96,7 +129,11 @@ public class CCMApplicationContextListener implements ServletContextListener {
|
||||||
*/
|
*/
|
||||||
public void contextDestroyed(ServletContextEvent applicationEndEvent) {
|
public void contextDestroyed(ServletContextEvent applicationEndEvent) {
|
||||||
// throw new UnsupportedOperationException("Not supported yet.");
|
// throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
s_log.info("Shutdown procedure started.");
|
||||||
|
|
||||||
// do nothing at the moment
|
// do nothing at the moment
|
||||||
|
|
||||||
|
s_log.info("CCM Application shutdown.");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# To customize logging, copy this file to
|
# To customize logging, copy this file to
|
||||||
# $CCM_HOME/conf/log4j.properties and edit it appropriately.
|
# $CCM_HOME/WEB-INF/conf/log4j.properties and edit it appropriately.
|
||||||
|
|
||||||
# Choose one of the following lines, or make up your own...
|
# Choose one of the following lines, or make up your own...
|
||||||
#log4j.rootCategory=WARN, console, file
|
#log4j.rootCategory=WARN, console, file
|
||||||
|
|
@ -28,7 +28,11 @@ log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||||
|
|
||||||
# Change logger priorities below here:
|
# Change logger priorities below here:
|
||||||
|
|
||||||
# For seeing progress of main initialization process
|
# For seeing progress of container startup process
|
||||||
|
log4j.logger.com.arsdigita.web.CCMApplicationContextListener=INFO
|
||||||
|
|
||||||
|
# For seeing progress of main runtime initialization process
|
||||||
|
log4j.logger.com.arsdigita.runtime.CCMResourceManager=INFO
|
||||||
log4j.logger.com.arsdigita.runtime.Startup=INFO
|
log4j.logger.com.arsdigita.runtime.Startup=INFO
|
||||||
|
|
||||||
# For seeing progress of the 'ccm load' command
|
# For seeing progress of the 'ccm load' command
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,13 @@
|
||||||
<display-name>CCM</display-name>
|
<display-name>CCM</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
Context Listener
|
Context Listener
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
<display-name>CCM</display-name>
|
<display-name>CCM</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>shortcuts</filter-name>
|
<filter-name>shortcuts</filter-name>
|
||||||
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
<display-name>CCM</display-name>
|
<display-name>CCM</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>shortcuts</filter-name>
|
<filter-name>shortcuts</filter-name>
|
||||||
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
<display-name>CCM</display-name>
|
<display-name>CCM</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>shortcuts</filter-name>
|
<filter-name>shortcuts</filter-name>
|
||||||
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
<display-name>CCM</display-name>
|
<display-name>CCM</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>shortcuts</filter-name>
|
<filter-name>shortcuts</filter-name>
|
||||||
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
<filter-class>com.arsdigita.london.shortcuts.ShortcutFilter</filter-class>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
<display-name>CCM SHP</display-name>
|
<display-name>CCM SHP</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<!-- Require secure connection by redirect to host-port part
|
<!-- Require secure connection by redirect to host-port part
|
||||||
of parameter waf.web.secure_server
|
of parameter waf.web.secure_server
|
||||||
NOT USED with SHP
|
NOT USED with SHP
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
<display-name>CCM ZeS</display-name>
|
<display-name>CCM ZeS</display-name>
|
||||||
<description>Content and Collaboration Management</description>
|
<description>Content and Collaboration Management</description>
|
||||||
|
|
||||||
|
<!-- path and filename of the log4j user accessible config file
|
||||||
|
WEB-INF/conf/log4j.properties is the built-in default value -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>log4j-conf-file</param-name>
|
||||||
|
<param-value>WEB-INF/conf/log4j.properties</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
|
||||||
<!-- Require secure connection by redirect to host-port part
|
<!-- Require secure connection by redirect to host-port part
|
||||||
of parameter waf.web.secure_server
|
of parameter waf.web.secure_server
|
||||||
NOT USED with ZeS
|
NOT USED with ZeS
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue