"Another part of cleaning up dispatcher code and enable installation of CCM into any arbitrary application context."
git-svn-id: https://svn.libreccm.org/ccm/trunk@2560 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b396010920
commit
cfc3064fc6
|
|
@ -31,6 +31,7 @@ import com.arsdigita.categorization.Category;
|
|||
*/
|
||||
public class DublinCoreRelatedItemsQueryFactoryImpl extends RelatedItemsQueryFactory {
|
||||
|
||||
@Override
|
||||
public RelatedItemsQuery getRelatedItems(ContentPage page,
|
||||
Category current) {
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,10 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class Application extends Resource {
|
||||
|
||||
/** Logger instance for debugging. */
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.web.Application=DEBUG by uncommenting
|
||||
* or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(Application.class);
|
||||
/** PDL property, basic object type for all applications of this type */
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
|
|
@ -488,8 +491,8 @@ public class Application extends Resource {
|
|||
* @return Path string including w/o static prefix (if configured)
|
||||
*/
|
||||
public final String getPath() {
|
||||
final String path = (String) get(PRIMARY_URL);
|
||||
|
||||
final String path = (String) get(PRIMARY_URL);
|
||||
Assert.exists(path, String.class);
|
||||
|
||||
if (path.endsWith(SLASH)) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ public class CCMDispatcherServlet extends BaseServlet {
|
|||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.web.CCMDispatcherServlet=DEBUG by uncommenting
|
||||
* or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(CCMDispatcherServlet.class);
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
CCMDispatcherServlet.class);
|
||||
|
||||
static final String DISPATCHED_ATTRIBUTE =
|
||||
CCMDispatcherServlet.class.getName() + ".dispatched";
|
||||
|
|
@ -123,8 +124,8 @@ public class CCMDispatcherServlet extends BaseServlet {
|
|||
s_contextPath = servletContext.getContextPath();
|
||||
// For backwords compatibility reasons register the web application
|
||||
// context of the Core (root) application als "/"
|
||||
Web.registerServletContext("/",
|
||||
servletContext);
|
||||
// Web.registerServletContext("/",
|
||||
// servletContext);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -279,14 +280,16 @@ public class CCMDispatcherServlet extends BaseServlet {
|
|||
s_log.debug("Forwarding by path to target '" + target + "'");
|
||||
}
|
||||
s_log.debug("The context path is: " + contextPath);
|
||||
if (StringUtils.emptyString(contextPath)) {
|
||||
contextPath = "/";
|
||||
}
|
||||
if (!contextPath.endsWith("/")) {
|
||||
contextPath = contextPath + "/";
|
||||
if (StringUtils.emptyString(contextPath)) { // not compliant with JEE
|
||||
contextPath = "/"; // Empty context has to be
|
||||
} // "" !
|
||||
if (!contextPath.endsWith("/")) { // No trailing slash
|
||||
contextPath = contextPath + "/"; // according to JEE
|
||||
}
|
||||
// XXX We should pass servlet context down
|
||||
final ServletContext context = Web.getServletContext(contextPath);
|
||||
// final ServletContext context = Web.getServletContext(contextPath);
|
||||
final ServletContext context = Web.getServletContext()
|
||||
.getContext(contextPath);
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("From context " + Web.getServletContext() +
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
|
||||
// This class uses a non-standard way to construct a kind of repository of
|
||||
// webapp contexts various applications of CCM used to be installed up to
|
||||
// version 1.0.4
|
||||
// With version 2.0 all modules of CCM are installed into one directory
|
||||
// (context) and this servlet is nolonger used (and will be removed soon).
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
Every application running in its own webapp should
|
||||
|
|
@ -77,12 +85,12 @@ public class ContextRegistrationServlet extends HttpServlet {
|
|||
* getServletContext is retrieved by the ContextRegistrationServlet
|
||||
* loaded first it is not affected by the bug.
|
||||
*/
|
||||
Web.registerServletContext(m_uri,
|
||||
sconfig.getServletContext());
|
||||
// Web.registerServletContext(m_uri,
|
||||
// sconfig.getServletContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Web.unregisterServletContext(m_uri);
|
||||
// Web.unregisterServletContext(m_uri);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,17 @@ import org.apache.log4j.Logger;
|
|||
|
||||
public class DefaultApplicationFileResolver implements ApplicationFileResolver {
|
||||
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.web.DefaultApplicationFileResolver=DEBUG by
|
||||
* uncommenting or adding the line. */
|
||||
private static Logger s_log =
|
||||
Logger.getLogger(DefaultApplicationFileResolver.class);
|
||||
|
||||
private static final String[] WELCOME_FILES = new String[] {
|
||||
"index.jsp", "index.html"
|
||||
};
|
||||
|
||||
private static Logger s_log =
|
||||
Logger.getLogger(DefaultApplicationFileResolver.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param templatePath
|
||||
|
|
@ -47,10 +51,8 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver {
|
|||
HttpServletRequest sreq,
|
||||
HttpServletResponse sresp,
|
||||
Application app) {
|
||||
// XXX proper list of dependent & customization webapps to search
|
||||
String[] webapps = new String[] {
|
||||
app.getContextPath(), "ROOT"
|
||||
};
|
||||
|
||||
String contextPath = app.getContextPath();
|
||||
String pathInfo = sreq.getPathInfo();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
|
|
@ -70,8 +72,8 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver {
|
|||
}
|
||||
|
||||
RequestDispatcher rd = Web.findResourceDispatcher(
|
||||
webapps,
|
||||
path + WELCOME_FILES[i]);
|
||||
contextPath + path
|
||||
+ WELCOME_FILES[i]);
|
||||
if (rd != null) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got dispatcher " + rd);
|
||||
|
|
@ -85,8 +87,7 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver {
|
|||
}
|
||||
|
||||
RequestDispatcher rd = Web.findResourceDispatcher(
|
||||
webapps,
|
||||
path);
|
||||
contextPath + path);
|
||||
if (rd != null) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got dispatcher " + rd);
|
||||
|
|
|
|||
|
|
@ -63,13 +63,20 @@ public class Web {
|
|||
|
||||
static final WebContext s_initialContext = new WebContext();
|
||||
|
||||
/** Internal service property to temporarly save the ServletContext as
|
||||
* determined by findResource(resource) method to make it available to
|
||||
* those methods of this class which use findResource to lookup a
|
||||
* resource as a base for determining additional information, e.g.
|
||||
* provide a dispatcher (findResourceDispatcher) */
|
||||
static private ServletContext s_urlContext;
|
||||
|
||||
/** String containing the webapp context path portion of the WEB application
|
||||
* where this CCM instance is executed. (I.e. where the WEB-INF directory
|
||||
* is located in the servlet container webapps directory. */
|
||||
* is located in the servlet container webapps directory). */
|
||||
private static String s_contextPath;
|
||||
|
||||
/**
|
||||
*
|
||||
* Static Initializer block.
|
||||
*/
|
||||
static void init(final HttpServletRequest sreq,
|
||||
final ServletContext sc,
|
||||
|
|
@ -160,7 +167,7 @@ public class Web {
|
|||
* @return The current <code>UserContext</code> object; it can be
|
||||
* null
|
||||
*/
|
||||
public static final UserContext getUserContext() {
|
||||
public static UserContext getUserContext() {
|
||||
return (UserContext) s_userContext.get();
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +181,7 @@ public class Web {
|
|||
* @param resource Path to the resource as String. It may include the
|
||||
* web context in its first part or may be relative to the
|
||||
* current webapp document root (i.e. its context).
|
||||
* Additionally, it the web application component (if any)
|
||||
* Additionally, the web application component (if any)
|
||||
* may be a comma separate list of webapps to search for the
|
||||
* rest of the path String.
|
||||
* So, if the 'resource' is:
|
||||
|
|
@ -230,6 +237,8 @@ public class Web {
|
|||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Cannot get resource for " + resource);
|
||||
}
|
||||
// Try the first part of resource as a webapp context path and
|
||||
// check far a resource there
|
||||
int offset = resource.indexOf("/", 1); // search for second "/"
|
||||
String testPath = resource.substring(1, offset);
|
||||
String path = resource.substring(offset);
|
||||
|
|
@ -237,12 +246,15 @@ public class Web {
|
|||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Try to find a context at " + testPath);
|
||||
}
|
||||
// Try to achieve a context
|
||||
ServletContext ctx = myctx.getContext(testPath);
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Servlet context for " + testPath +
|
||||
" is " + ctx);
|
||||
}
|
||||
if (ctx != null) {
|
||||
// successs, try to finf a resource for the remaining
|
||||
// string as path
|
||||
try {
|
||||
URL url = ctx.getResource(path);
|
||||
if (url != null) {
|
||||
|
|
@ -351,22 +363,53 @@ public class Web {
|
|||
}
|
||||
|
||||
/**
|
||||
* Follows the same rules as findResource(String), but
|
||||
* instead returns a request dispatcher for serving
|
||||
* the resource
|
||||
* Follows the same rules as findResource(String), but instead returns a
|
||||
* request dispatcher for serving the resource
|
||||
*
|
||||
* @param resource Path to the resource as String. It may include the
|
||||
* web context in its first part or may be relative to the
|
||||
* current webapp document root (i.e. its context).
|
||||
* Additionally, it the web application component (if any)
|
||||
* may be a comma separate list of webapps to search for the
|
||||
* rest of the path String.
|
||||
* So, if the 'resource' is:
|
||||
* <pre>
|
||||
* /myproj,ccm-cms/themes/heirloom/admin/index.xsl
|
||||
* </pre>
|
||||
* then this method will look for resources at
|
||||
* <pre>
|
||||
* /myproj/themes/heirloom/admin/index.xsl
|
||||
* /ccm-cms/themes/heirloom/admin/index.xsl
|
||||
* </pre>
|
||||
*
|
||||
* @param resource the resource name
|
||||
* @return the request dispatcher for the resource, or null
|
||||
*/
|
||||
public static RequestDispatcher findResourceDispatcher(String resource) {
|
||||
|
||||
ResourceSpec spec = parseResource(resource);
|
||||
URL url = findResource(resource);
|
||||
ServletContext ctx = s_urlContext;
|
||||
String path = url.toString();
|
||||
|
||||
return findResourceDispatcher(spec.getWebapps(),
|
||||
spec.getPath());
|
||||
return ctx == null ? null : ctx.getRequestDispatcher(path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static class WebContextLocal extends InternalRequestLocal {
|
||||
|
||||
@Override
|
||||
protected Object initialValue() {
|
||||
return Web.s_initialContext.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearValue() {
|
||||
((WebContext) get()).clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
|
@ -392,7 +435,7 @@ public class Web {
|
|||
*
|
||||
* @deprecated without direct replacement. See above
|
||||
*/
|
||||
private static final String ROOT_WEBAPP = "ROOT";
|
||||
// private static final String ROOT_WEBAPP = "ROOT";
|
||||
|
||||
|
||||
/** Map containing a list of registered ccm webapps and corresponding
|
||||
|
|
@ -400,7 +443,7 @@ public class Web {
|
|||
*
|
||||
* @deprecated without direct replacement, see above.
|
||||
*/
|
||||
private static final Map s_contexts = new HashMap();
|
||||
// private static final Map s_contexts = new HashMap();
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -428,36 +471,36 @@ public class Web {
|
|||
* web application context.
|
||||
*
|
||||
*/
|
||||
public static ServletContext getServletContext(String uri) {
|
||||
Assert.isTrue(uri.startsWith("/"), "uri must start with /");
|
||||
Assert.isTrue(uri.endsWith("/"), "uri must end with /");
|
||||
return (ServletContext)s_contexts.get(uri);
|
||||
}
|
||||
// public static ServletContext getServletContext(String uri) {
|
||||
// Assert.isTrue(uri.startsWith("/"), "uri must start with /");
|
||||
// Assert.isTrue(uri.endsWith("/"), "uri must end with /");
|
||||
// return (ServletContext)s_contexts.get(uri);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Registers a servlet context against a URI. Only intended
|
||||
* to be used by ContextRegistrationServlet
|
||||
* @deprecated without direct replacement. See getServletContext
|
||||
*/
|
||||
static final void registerServletContext(String uri,
|
||||
ServletContext ctx) {
|
||||
s_log.debug("Mapping " + ctx + " to " + uri);
|
||||
Assert.isTrue(s_contexts.get(uri) == null,
|
||||
"a context mapping exists at " + uri);
|
||||
// Save the web context as manually configured in web.xml
|
||||
// along with the context as provided by ServletContext.
|
||||
s_contexts.put(uri, ctx);
|
||||
}
|
||||
// static final void registerServletContext(String uri,
|
||||
// ServletContext ctx) {
|
||||
// s_log.debug("Mapping " + ctx + " to " + uri);
|
||||
// Assert.isTrue(s_contexts.get(uri) == null,
|
||||
// "a context mapping exists at " + uri);
|
||||
// // Save the web context as manually configured in web.xml
|
||||
// // along with the context as provided by ServletContext.
|
||||
// s_contexts.put(uri, ctx);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Unregisters the servlet context against a URI. Only intended
|
||||
* to be used by ContextRegistrationServlet
|
||||
* @deprecated without direct replacement. See getServletContext
|
||||
*/
|
||||
static final void unregisterServletContext(String uri) {
|
||||
s_log.debug("Unmapping " + uri);
|
||||
s_contexts.remove(uri);
|
||||
}
|
||||
// static final void unregisterServletContext(String uri) {
|
||||
// s_log.debug("Unmapping " + uri);
|
||||
// s_contexts.remove(uri);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -476,24 +519,24 @@ public class Web {
|
|||
* @return the URL for the resource, or null
|
||||
* @deprecated without direct replacement at the moment.
|
||||
*/
|
||||
public static URL findResource(String[] webapps,
|
||||
String path) {
|
||||
|
||||
ServletContext ctx = findResourceContext(webapps,
|
||||
path);
|
||||
|
||||
URL url = null;
|
||||
try {
|
||||
url = (ctx == null ? null :
|
||||
ctx.getResource(path));
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException("cannot get URL for " + path, ex);
|
||||
}
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("URL for " + path + " is " + url);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
// public static URL findResource(String[] webapps,
|
||||
// String path) {
|
||||
//
|
||||
// ServletContext ctx = findResourceContext(webapps,
|
||||
// path);
|
||||
//
|
||||
// URL url = null;
|
||||
// try {
|
||||
// url = (ctx == null ? null :
|
||||
// ctx.getResource(path));
|
||||
// } catch (IOException ex) {
|
||||
// throw new UncheckedWrapperException("cannot get URL for " + path, ex);
|
||||
// }
|
||||
// if (s_log.isDebugEnabled()) {
|
||||
// s_log.debug("URL for " + path + " is " + url);
|
||||
// }
|
||||
// return url;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -548,23 +591,23 @@ public class Web {
|
|||
// spec.getPath());
|
||||
// }
|
||||
|
||||
/**
|
||||
* Follows the same rules as findResource(String[], String), but
|
||||
* instead returns a request dispatcher for serving
|
||||
* the resource
|
||||
*
|
||||
* @param webapps the list of webapps
|
||||
* @param path the resource path
|
||||
* @return the request dispatcher for the resource, or null
|
||||
* @deprecated without direct replacement at the moment.
|
||||
*/
|
||||
public static RequestDispatcher findResourceDispatcher(String[] webapps,
|
||||
String path) {
|
||||
ServletContext ctx = findResourceContext(webapps,
|
||||
path);
|
||||
|
||||
return ctx == null ? null : ctx.getRequestDispatcher(path);
|
||||
}
|
||||
// /**
|
||||
// * Follows the same rules as findResource(String[], String), but
|
||||
// * instead returns a request dispatcher for serving
|
||||
// * the resource
|
||||
// *
|
||||
// * @param webapps the list of webapps
|
||||
// * @param path the resource path
|
||||
// * @return the request dispatcher for the resource, or null
|
||||
// * @deprecated without direct replacement at the moment.
|
||||
// */
|
||||
// public static RequestDispatcher findResourceDispatcher(String[] webapps,
|
||||
// String path) {
|
||||
// ServletContext ctx = findResourceContext(webapps,
|
||||
// path);
|
||||
//
|
||||
// return ctx == null ? null : ctx.getRequestDispatcher(path);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -577,50 +620,49 @@ public class Web {
|
|||
* @return
|
||||
* @deprecated without direct replacement at the moment.
|
||||
*/
|
||||
private static ServletContext findResourceContext(String[] webapps,
|
||||
String path) {
|
||||
for (int i = (webapps.length - 1) ; i >= 0 ; i--) {
|
||||
|
||||
// trash here, depends of a kind of "home made" list of
|
||||
// webapps/webcontexts (or ServletContexts) which are part of CCM
|
||||
// but installed in its own context (it is the structure of APLAWS
|
||||
// until 1.0.4.
|
||||
String ctxPath = ROOT_WEBAPP.equals(webapps[i]) ?
|
||||
"" : webapps[i];
|
||||
|
||||
if (!ctxPath.startsWith("/")) {
|
||||
ctxPath = "/" + ctxPath;
|
||||
}
|
||||
if (!ctxPath.endsWith("/")) {
|
||||
ctxPath = ctxPath + "/";
|
||||
}
|
||||
|
||||
ServletContext ctx = getServletContext(ctxPath);
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Servlet context for " + ctxPath + " is " + ctx);
|
||||
}
|
||||
|
||||
if (ctx != null) {
|
||||
try {
|
||||
URL url = ctx.getResource(path);
|
||||
if (url != null) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got URL " + url + " for " + path);
|
||||
}
|
||||
return ctx;
|
||||
} else {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("No URL present for " + path);
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
"cannot get resource " + path, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// private static ServletContext findResourceContext(String[] webapps,
|
||||
// String path) {
|
||||
// for (int i = (webapps.length - 1) ; i >= 0 ; i--) {
|
||||
// // trash here, depends of a kind of "home made" list of
|
||||
// // webapps/webcontexts (or ServletContexts) which are part of CCM
|
||||
// // but installed in its own context (it is the structure of APLAWS
|
||||
// // until 1.0.4.
|
||||
// String ctxPath = ROOT_WEBAPP.equals(webapps[i]) ?
|
||||
// "" : webapps[i];
|
||||
//
|
||||
// if (!ctxPath.startsWith("/")) {
|
||||
// ctxPath = "/" + ctxPath;
|
||||
// }
|
||||
// if (!ctxPath.endsWith("/")) {
|
||||
// ctxPath = ctxPath + "/";
|
||||
// }
|
||||
//
|
||||
// ServletContext ctx = getServletContext(ctxPath);
|
||||
// if (s_log.isDebugEnabled()) {
|
||||
// s_log.debug("Servlet context for " + ctxPath + " is " + ctx);
|
||||
// }
|
||||
//
|
||||
// if (ctx != null) {
|
||||
// try {
|
||||
// URL url = ctx.getResource(path);
|
||||
// if (url != null) {
|
||||
// if (s_log.isDebugEnabled()) {
|
||||
// s_log.debug("Got URL " + url + " for " + path);
|
||||
// }
|
||||
// return ctx;
|
||||
// } else {
|
||||
// if (s_log.isDebugEnabled()) {
|
||||
// s_log.debug("No URL present for " + path);
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException ex) {
|
||||
// throw new UncheckedWrapperException(
|
||||
// "cannot get resource " + path, ex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -648,76 +690,59 @@ public class Web {
|
|||
* @return
|
||||
* @deprecated without direct replacement.
|
||||
*/
|
||||
private static ResourceSpec parseResource(String resource) {
|
||||
|
||||
if (resource == null || resource.length() < 2) {
|
||||
throw new IllegalArgumentException(
|
||||
"Resource spec is too short: " + resource);
|
||||
}
|
||||
|
||||
int offset = resource.indexOf("/", 1);
|
||||
if (offset == -1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot find second '/' in resource spec : " + resource);
|
||||
}
|
||||
|
||||
String webappList = resource.substring(1, offset);
|
||||
String path = resource.substring(offset);
|
||||
|
||||
String[] webapps = StringUtils.split(webappList, ',');
|
||||
|
||||
if (s_log.isInfoEnabled()) {
|
||||
s_log.info("Web app list " + webappList + " path " + path);
|
||||
}
|
||||
|
||||
return new ResourceSpec(webapps, path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Container to hold a pointer to a resource. The pointer specifically
|
||||
* consists of an array of webapps probably containing the requested
|
||||
* resource and a path to that resource that has to be equal for each
|
||||
* webapp.
|
||||
* @deprecated without direct replacement at the moment.
|
||||
*/
|
||||
private static class ResourceSpec {
|
||||
private final String[] m_webapps;
|
||||
private final String m_path;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param webapps
|
||||
* @param path
|
||||
*/
|
||||
public ResourceSpec(String[] webapps,
|
||||
String path) {
|
||||
m_webapps = webapps;
|
||||
m_path = path;
|
||||
}
|
||||
|
||||
public String[] getWebapps() {
|
||||
return m_webapps;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return m_path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static class WebContextLocal extends InternalRequestLocal {
|
||||
|
||||
@Override
|
||||
protected Object initialValue() {
|
||||
return Web.s_initialContext.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearValue() {
|
||||
((WebContext) get()).clear();
|
||||
}
|
||||
}
|
||||
// private static ResourceSpec parseResource(String resource) {
|
||||
// if (resource == null || resource.length() < 2) {
|
||||
// throw new IllegalArgumentException(
|
||||
// "Resource spec is too short: " + resource);
|
||||
// }
|
||||
//
|
||||
// int offset = resource.indexOf("/", 1);
|
||||
// if (offset == -1) {
|
||||
// throw new IllegalArgumentException(
|
||||
// "Cannot find second '/' in resource spec : " + resource);
|
||||
// }
|
||||
//
|
||||
// String webappList = resource.substring(1, offset);
|
||||
// String path = resource.substring(offset);
|
||||
//
|
||||
// String[] webapps = StringUtils.split(webappList, ',');
|
||||
//
|
||||
// if (s_log.isInfoEnabled()) {
|
||||
// s_log.info("Web app list " + webappList + " path " + path);
|
||||
// }
|
||||
//
|
||||
// return new ResourceSpec(webapps, path);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Container to hold a pointer to a resource. The pointer specifically
|
||||
// * consists of an array of webapps probably containing the requested
|
||||
// * resource and a path to that resource that has to be equal for each
|
||||
// * webapp.
|
||||
// * @deprecated without direct replacement at the moment.
|
||||
// */
|
||||
// private static class ResourceSpec {
|
||||
// private final String[] m_webapps;
|
||||
// private final String m_path;
|
||||
//
|
||||
// /**
|
||||
// * Constructor.
|
||||
// * @param webapps
|
||||
// * @param path
|
||||
// */
|
||||
// public ResourceSpec(String[] webapps,
|
||||
// String path) {
|
||||
// m_webapps = webapps;
|
||||
// m_path = path;
|
||||
// }
|
||||
//
|
||||
// public String[] getWebapps() {
|
||||
// return m_webapps;
|
||||
// }
|
||||
//
|
||||
// public String getPath() {
|
||||
// return m_path;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ public class Navigation extends Application {
|
|||
});
|
||||
|
||||
/* Create Instance beyond root (4. parameter null) */
|
||||
final Application application = Application.createApplication(Navigation.BASE_DATA_OBJECT_TYPE,
|
||||
final Application application = Application.createApplication(
|
||||
Navigation.BASE_DATA_OBJECT_TYPE,
|
||||
navUrl,
|
||||
navTitle,
|
||||
null);
|
||||
|
|
@ -134,7 +135,8 @@ public class Navigation extends Application {
|
|||
|
||||
}
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.navigation.Navigation";
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.navigation.Navigation";
|
||||
|
||||
public Navigation(final DataObject obj) {
|
||||
super(obj);
|
||||
|
|
@ -144,6 +146,9 @@ public class Navigation extends Application {
|
|||
super(oid);
|
||||
}
|
||||
|
||||
|
||||
// All modules are now installed into one context (may be ROOT or any other
|
||||
// one
|
||||
/*
|
||||
public String getContextPath() {
|
||||
return "ccm-navigation";
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
HttpServletRequest sreq,
|
||||
HttpServletResponse sresp,
|
||||
Application app) {
|
||||
|
||||
String path = sreq.getPathInfo();
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Resolving " + path);
|
||||
|
|
@ -194,17 +195,20 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
*/
|
||||
private void setPathCookie(HttpServletResponse resp, Category[] catsArray) {
|
||||
|
||||
// 1st part of cookie value is website - if cookie domain covers several Aplaws sites,
|
||||
// and the navigation model retains the cookie for more than one request,
|
||||
// we could potentially link to one site with a path relating to another site. A check on this part
|
||||
// of the cookie will prevent problems
|
||||
// 1st part of cookie value is website - if cookie domain covers several
|
||||
// Aplaws sites, and the navigation model retains the cookie for more
|
||||
// than one request, we could potentially link to one site with a path
|
||||
// relating to another site. A check on this part of the cookie will
|
||||
// prevent problems
|
||||
StringBuffer path = new StringBuffer(Web.getConfig().getSiteName());
|
||||
|
||||
// 2nd part of cookie value is the application that set it. Again may be used if a navigation model
|
||||
// retains the cookie. If we link to another application, it's navigation model may
|
||||
// use this when deciding whether to trust the given path
|
||||
// 2nd part of cookie value is the application that set it. Again may
|
||||
// be used if a navigation model retains the cookie. If we link to
|
||||
// another application, it's navigation model may use this when
|
||||
// deciding whether to trust the given path.
|
||||
|
||||
path.append(PATH_COOKIE_SEPARATOR + Kernel.getContext().getResource().getID().toString());
|
||||
path.append(PATH_COOKIE_SEPARATOR +
|
||||
Kernel.getContext().getResource().getID().toString());
|
||||
for (int i = 0; i < catsArray.length; i++) {
|
||||
Category cat = catsArray[i];
|
||||
path.append(PATH_COOKIE_SEPARATOR + cat.getID().toString());
|
||||
|
|
@ -235,6 +239,12 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cat
|
||||
* @param useContext
|
||||
* @return
|
||||
*/
|
||||
private RequestDispatcher resolveTemplate(Category cat, String useContext) {
|
||||
Template template = null;
|
||||
if (Navigation.getConfig().inheritTemplates()) {
|
||||
|
|
@ -248,7 +258,8 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
}
|
||||
// If there's an explicit use context which doesn't exist, give a 404
|
||||
if (!Template.DEFAULT_USE_CONTEXT.equals(useContext) && null == template) {
|
||||
s_log.debug("No template found in context " + getTemplateContext() + " for category " + cat.getID()
|
||||
s_log.debug("No template found in context " + getTemplateContext() +
|
||||
" for category " + cat.getID()
|
||||
+ " with use context " + useContext);
|
||||
return null;
|
||||
}
|
||||
|
|
@ -262,9 +273,14 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
} else {
|
||||
path = template.getURL();
|
||||
}
|
||||
RequestDispatcher rd = Web.findResourceDispatcher(
|
||||
new String[]{"ROOT"},
|
||||
path);
|
||||
// Old style, no longer valid. App may be installed into any arbitrary
|
||||
// context and by default all modules are installed into one context.
|
||||
// RequestDispatcher rd = Web.findResourceDispatcher(
|
||||
// new String[]{"ROOT"},
|
||||
// path);
|
||||
// new style, will lookup path in the current context (formerly used to
|
||||
// be ROOT)
|
||||
RequestDispatcher rd = Web.findResourceDispatcher(path);
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got dispatcher " + rd);
|
||||
|
|
@ -300,8 +316,9 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
|
||||
/**
|
||||
*
|
||||
* category resolution retained as an instance method to allow it to be overridden. Default functionality contained
|
||||
* in static resolveCategory method
|
||||
* category resolution retained as an instance method to allow it to be
|
||||
* overridden. Default functionality contained in static resolveCategory
|
||||
* method.
|
||||
*
|
||||
* @param root
|
||||
* @param path
|
||||
|
|
@ -312,11 +329,13 @@ public class NavigationFileResolver extends DefaultApplicationFileResolver {
|
|||
}
|
||||
|
||||
/**
|
||||
* Match a URL with the category tree and return the requested category if exists.
|
||||
* Match a URL with the category tree and return the requested category
|
||||
* if exists.
|
||||
*
|
||||
* Quasimodo: Originally addEqualsFilter has been used to filter the appropriate category directly inside the SQL
|
||||
* query. This is possible anymore due to the localised URLs of the new localised categories (or at least: not found
|
||||
* it). Therefore we do the filtering in Java now.
|
||||
* Quasimodo: Originally addEqualsFilter has been used to filter the
|
||||
* appropriate category directly inside the SQL query. This isn't possible
|
||||
* anymore due to the localised URLs of the new localised categories
|
||||
* (or at least: not found it). Therefore we do the filtering in Java now.
|
||||
*
|
||||
*/
|
||||
public static Category[] resolveCategory(Category root,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ public class Template extends DomainObject {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ import org.apache.log4j.Logger;
|
|||
|
||||
public class RSSFileResolver extends DefaultApplicationFileResolver {
|
||||
|
||||
/** Internal logger instance to faciliate debugging. Enable logging output
|
||||
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
|
||||
* and set com.arsdigita.rssfeed.RSSFileResolver=DEBUG by
|
||||
* uncommenting or adding the line. */
|
||||
private static final Logger s_log = Logger.getLogger(RSSFileResolver.class);
|
||||
|
||||
/**
|
||||
|
|
@ -71,9 +75,15 @@ public class RSSFileResolver extends DefaultApplicationFileResolver {
|
|||
s_log.debug("Trying resource " + path);
|
||||
}
|
||||
|
||||
RequestDispatcher rd = Web.findResourceDispatcher(
|
||||
webapps,
|
||||
path);
|
||||
// Old style, no longer valid. All CCM modules are nox installed
|
||||
// into one context, treating CCM as one web application in a
|
||||
// servlet conainer
|
||||
//RequestDispatcher rd = Web.findResourceDispatcher(
|
||||
// webapps,
|
||||
// path);
|
||||
// Looks now for a esource at path in the current context
|
||||
RequestDispatcher rd = Web.findResourceDispatcher(path);
|
||||
|
||||
if (rd != null) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got dispatcher " + rd);
|
||||
|
|
|
|||
Loading…
Reference in New Issue