Fixed bug in findResource and Dispatcher.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2577 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2014-03-21 00:15:30 +00:00
parent 65b48943e4
commit 9c63398588
11 changed files with 209 additions and 89 deletions

View File

@ -55,7 +55,7 @@ import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.StringTokenizer;
import org.apache.log4j.Level;
// import org.apache.log4j.Level;
import org.apache.log4j.Logger;
/**
@ -126,15 +126,7 @@ public class ContentSection extends Application {
private final static String SECTION_ID = "sectionId";
private static final CMSConfig s_config = CMSConfig.getInstanceOf();
/* DO NOT use CMSConfig constructor to instantiate !
private static final CMSConfig s_config = new CMSConfig();
static {
s_log.debug("Static initializer starting...");
s_config.load();
s_log.debug("Static initializer finished...");
}
*/
// Cached properties
PageResolver m_pageResolver = null;
ItemResolver m_itemResolver = null;
@ -159,7 +151,7 @@ public class ContentSection extends Application {
/**
* Constructor re-creating a content section object from its data object.
*
* @param oid
* @param obj
* @throws DataObjectNotFoundException
*/
public ContentSection(DataObject obj) {
@ -170,7 +162,7 @@ public class ContentSection extends Application {
* Constructor re-creating a content section object by retrieving its data
* Object by ID
*
* @param oid
* @param id
* @throws DataObjectNotFoundException
*/
public ContentSection(BigDecimal id) throws DataObjectNotFoundException {
@ -264,8 +256,8 @@ public class ContentSection extends Application {
* This URL includes the webapp context path.
*/
public String getURL() {
String sURL = null;
String sURL;
//see if there is a request
final HttpServletRequest sreq = Web.getRequest();
if (sreq != null) {
@ -1092,9 +1084,11 @@ public class ContentSection extends Application {
* returns it.
*
* @param name Name of the content section
* @param rootCategory
* @return ContentSection
*/
public static ContentSection create(final String name, final Category rootCategory) {
public static ContentSection create(final String name,
final Category rootCategory) {
Folder folder = createRootFolder(name);
//Category category = createRootCategory(name);

View File

@ -88,6 +88,7 @@ import org.apache.log4j.Logger;
* - Refactor content item UI bebop ApplicationPage or PageFactory instead of
* legacy infected sitenode / package dispatchers.
*/
/**
* Content Section's Application Servlet according CCM core web application
* structure {@see com.arsdigita.web.Application} implements the content
@ -106,9 +107,9 @@ public class ContentSectionServlet extends BaseApplicationServlet {
private static final Logger s_log =
Logger.getLogger(ContentSectionServlet.class);
/** Stringarray of file name patterns for index files. */
private static final String[] WELCOME_FILES = new String[]{
"index.jsp", "index.html"
};
// private static final String[] WELCOME_FILES = new String[]{
// "index.jsp", "index.html"
// };
/** The context (in url) for previewing items */
public static final String PREVIEW = "/preview";
/** Template files */
@ -122,34 +123,40 @@ public class ContentSectionServlet extends BaseApplicationServlet {
public static final String XML_MODE = "xmlMode";
public static final String MEDIA_TYPE = "templateContext";
private static final String CACHE_KEY_DELIMITER = "%";
private ContentItemDispatcher m_disp = new ContentItemDispatcher();
private final ContentItemDispatcher m_disp = new ContentItemDispatcher();
public static Map s_itemResolverCache = Collections
.synchronizedMap(new HashMap());
/** cache the content items */
private static Map s_itemURLCacheMap = null;
private static boolean s_cacheItems = true;
/** Whether to cache the content items */
private static final boolean s_cacheItems = true;
// NEW STUFF here used to process the pages in this servlet
/** URL (pathinfo) -> Page object mapping. Based on it (and the http
* request url) the doService method selects a page to display */
private final Map m_pages = new HashMap();
/** Path to directory containg ccm-cms template (jsp) files */
private String m_templatePath;
// Probably compatibility stuff, based on dispatcher
/** Resolvers to find templages (JSP) and other stuff stored in file system.*/
/** Resolver to actually use to find templates (JSP). JSP may be stored in
* file system or otherwise, depends on resolver. Resolver is retrieved
* from configuration.
* (probably used for other stuff as JSP's as well) */
private ApplicationFileResolver m_resolver;
/**
* Init method overwrites parents init to pass in optional parameters
* {@link com.arsdigita.web.BaseServlet}.
* If not specified system wide defaults are used.
* @param config
* @throws javax.servlet.ServletException
*/
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
// optional init-param named template-path from ~/WEB-INF/web.xml
// may overwrite configuration parameters
String templatePath = config.getInitParameter("template-path");
if (templatePath == null) {
m_templatePath = ContentSection.getConfig().getTemplateRoot();
@ -172,11 +179,13 @@ public class ContentSectionServlet extends BaseApplicationServlet {
m_resolver = (ApplicationFileResolver) Classes.newInstance(resolverName);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Template path is " + m_templatePath + " with resolver " + m_resolver.
s_log.debug("Template path is " + m_templatePath +
" with resolver " + m_resolver.
getClass().getName());
}
// NEW STUFF here used to process the pages in this servlet
// NEW STUFF here will be used to process the pages in this servlet
// Currently NOT working
// addPage("/admin", new MainPage()); // index page at address ~/cs
// addPage("/admin/index.jsp", new MainPage());
// addPage("/admin/item.jsp", new MainPage());
@ -187,10 +196,16 @@ public class ContentSectionServlet extends BaseApplicationServlet {
* Implementation of parent's (abstract) doService method checks HTTP request
* to determine whether to handle a content item or other stuff which is
* delegated to jsp templates.
*
* {@see com.arsdigita.web.BaseApplicationServlet#doService
* (HttpServletRequest, HttpServletResponse, Application)}
*
* @param sreq
* @param sresp
* @param app
* @throws javax.servlet.ServletException
* @throws java.io.IOException
*/
@Override
protected void doService(HttpServletRequest sreq,
HttpServletResponse sresp,
Application app)
@ -203,20 +218,20 @@ public class ContentSectionServlet extends BaseApplicationServlet {
// ////////////////////////////////////////////////////////////////////
/*
* NOTE:
* Resolves currently to SiteNodeRequestContext which will be removed.
* NOTE 2:
* SiteNodeRequestContext removed, resolves currently to
* Used to resolve to SiteNodeRequestContext (old style applications)
* which has been removed.
* Resolves currently to
* KernelRequestContext which will be removed as well.
*/
RequestContext ctx = DispatcherHelper.getRequestContext();
String url = ctx.getRemainingURLPart(); // here KernelRequestContext now
if (s_log.isInfoEnabled()) {
s_log.info("Resolving item URL " + url);
s_log.info("Resolving URL " + url + " and trying as item first.");
}
final ItemResolver itemResolver = getItemResolver(section);
// ////////////////////////////////////////////////////////////////////
// Prepare NEW style servlet based bebpo page service
// Prepare NEW style servlet based bebob page service
// ////////////////////////////////////////////////////////////////////
String pathInfo = sreq.getPathInfo();
@ -287,13 +302,13 @@ public class ContentSectionServlet extends BaseApplicationServlet {
/* OTHERWISE delegate to a JSP in file system */
} else {
/* We have to deal with a content-section, folder or an other bit*/
/* We have to deal with a content-section, folder or another bit */
if (s_log.isInfoEnabled()) {
s_log.info("NOT serving content item");
}
/* Store content section in http request to make it available
* for admin index,jsp */
* for admin/index.jsp */
sreq.setAttribute(CONTENT_SECTION, section);
RequestDispatcher rd = m_resolver.resolve(m_templatePath,
@ -447,6 +462,10 @@ public class ContentSectionServlet extends BaseApplicationServlet {
/**
*
* @param section
* @param url
* @param itemResolver
* @return
*/
public ContentItem getItem(ContentSection section, String url,
ItemResolver itemResolver) {
@ -510,6 +529,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
// Get the negotiated locale
String lang = GlobalizationHelper.getNegotiatedLocale().getLanguage();
// XXX why assign a value and afterwards null??
item = itemURLCacheGet(section, url, lang);
item = null;
@ -598,6 +618,7 @@ public class ContentSectionServlet extends BaseApplicationServlet {
* Maps the content item to the URL in a cache
* @param section the content section in which the content item is published
* @param sURL the URL at which the content item s published
* @param lang
* @param item the content item at the URL
*/
public static synchronized void itemURLCachePut(ContentSection section,
@ -608,7 +629,8 @@ public class ContentSectionServlet extends BaseApplicationServlet {
return;
}
if (s_log.isDebugEnabled()) {
s_log.debug("adding cached entry for url " + sURL + " and language " + lang);
s_log.debug("adding cached entry for url " + sURL +
" and language " + lang);
}
itemURLCachePut(section, sURL, lang, item.getID());
@ -618,20 +640,24 @@ public class ContentSectionServlet extends BaseApplicationServlet {
* Removes the cache entry for the URL, sURL
* @param section the content section in which to remove the key
* @param sURL the cache entry key to remove
* @param lang
*/
public static synchronized void itemURLCacheRemove(ContentSection section,
String sURL,
String lang) {
if (s_log.isDebugEnabled()) {
s_log.debug("removing cached entry for url " + sURL + "and language " + lang);
s_log.debug("removing cached entry for url " + sURL +
"and language " + lang);
}
getItemURLCache(section).remove(sURL + CACHE_KEY_DELIMITER + lang);
}
/**
* Fetches the ContentItem published at that URL from the cache
* Fetches the ContentItem published at that URL from the cache.
*
* @param section the content section in which the content item is published
* @param sURL the URL for the item to fetch
* @param lang
* @return the ContentItem in the cache, or null
*/
public static ContentItem itemURLCacheGet(ContentSection section,
@ -683,6 +709,9 @@ public class ContentSectionServlet extends BaseApplicationServlet {
/**
* Checks that the current user has permission to access the admin pages.
* @param request
* @param section
* @return
**/
public static boolean checkAdminAccess(HttpServletRequest request,
ContentSection section) {

View File

@ -470,6 +470,7 @@ public final class LoaderConfig extends AbstractConfig {
/**
* Retrieve whether the content-section is publicly viewable (i.e. without
* registration and login)
* @return
*/
public Boolean isPubliclyViewable() {
return ((Boolean) get(m_isPublic)).booleanValue();
@ -477,6 +478,7 @@ public final class LoaderConfig extends AbstractConfig {
/**
* Retrieve the item resolver class
* @return
*/
public String getItemResolverClass() {
return (String) get(m_itemResolverClass);
@ -484,6 +486,7 @@ public final class LoaderConfig extends AbstractConfig {
/**
* Retrieve the template resolver class
* @return
*/
public String getTemplateResolverClass() {
return (String) get(m_templateResolverClass);
@ -506,6 +509,7 @@ public final class LoaderConfig extends AbstractConfig {
* Retrieve the list of files containing categories to load. In old
* Initialiser: Parameter name: CATEGORIES Deskr. "XML file containing the
* category tree"
* @return
*/
public List getCategoryFileList() {
String[] catFiles = (String[]) get(m_categoryFileList);

View File

@ -310,7 +310,9 @@ public final class ContentSectionConfig extends AbstractConfig {
// //////////////////////////////////////////////////////////
/**
* Retrieve the list of workflow tasks and events for each tasks which should receive overdue
* notification alerts
* notification alerts.
*
* @return
*/
public final String[] getTaskAlerts() {
return (String[]) get(m_taskAlerts);
@ -318,28 +320,38 @@ public final class ContentSectionConfig extends AbstractConfig {
/**
* Retrieve whether to send overdue information for unfinished tasks.
*
* @return
*/
public Boolean getSendOverdueAlerts() {
return ((Boolean) get(m_sendOverdueAlerts)).booleanValue();
}
/**
* Retrieve time between when a task is enabled and when it is considered overdue.
* Retrieve time between when a task is enabled and when it is considered
* overdue.
*
* @return
*/
public Integer getTaskDuration() {
return ((Integer) get(m_taskDuration)).intValue();
}
/**
* Retrieve the time to wait between sending successive alerts on the same overdue task (in
* HOURS).
* Retrieve the time to wait between sending successive alerts on the
* same overdue task (in HOURS).
*
* @return
*/
public Integer getAlertInterval() {
return (Integer) get(m_alertInterval);
}
/**
* Retrieve the maximum number of alerts to send that a single task is overdue
* Retrieve the maximum number of alerts to send that a single task is
* overdue.
*
* @return
*/
public Integer getMaxAlerts() {
return (Integer) get(m_maxAlerts);
@ -381,8 +393,9 @@ public final class ContentSectionConfig extends AbstractConfig {
* solution.
*/
/**
* Changed: The forth field is not used anymore
* Changed: The forth field is not used anymore.
*
* @return
*/
public List getDefaultRoles() {
@ -651,6 +664,7 @@ public final class ContentSectionConfig extends AbstractConfig {
/**
* Retrieve whether the content-section is publicly viewable (i.e. without registration and
* login)
* @return
*/
public Boolean isPubliclyViewable() {
return ((Boolean) get(m_isPublic)).booleanValue();
@ -658,13 +672,15 @@ public final class ContentSectionConfig extends AbstractConfig {
/**
* Retrieve the item resolver class
* @return
*/
public String getItemResolverClass() {
return (String) get(m_itemResolverClass);
}
/**
* Retrieve the template resolver class
* Retrieve the template resolver class.
* @return
*/
public String getTemplateResolverClass() {
return (String) get(m_templateResolverClass);
@ -684,8 +700,10 @@ public final class ContentSectionConfig extends AbstractConfig {
}
/**
* Retrieve the list of files containing categories to load. In old Initialiser: Parameter name:
* Retrieve the list of files containing categories to load.
* In old Initialiser: Parameter name:
* CATEGORIES Deskr. "XML file containing the category tree"
* @return
*/
public List getCategoryFileList() {
String[] catFiles = (String[]) get(m_categoryFileList);
@ -693,7 +711,8 @@ public final class ContentSectionConfig extends AbstractConfig {
}
/**
* Retrieve the
* Retrieve the.
* @return
*/
public List getContentSectionsContentTypes() {
String[] taskAlerts = (String[]) get(m_contentTypeList);

View File

@ -21,7 +21,7 @@ import com.arsdigita.kernel.NoValidURLException;
import com.arsdigita.kernel.URLFinder;
import com.arsdigita.persistence.OID;
import com.arsdigita.web.Web;
import com.arsdigita.web.WebConfig;
//import com.arsdigita.web.WebConfig;
/**
* Implementation of URLFinder for Assets.
@ -37,6 +37,7 @@ public class AssetURLFinder implements URLFinder {
* @param context the context of the lookup (live/draft)
* @return
*/
@Override
public String find(OID oid, String context) throws NoValidURLException {
if( !"live".equals( context ) )
throw new NoValidURLException("No draft URL for assets");
@ -57,6 +58,7 @@ public class AssetURLFinder implements URLFinder {
* @param oid the OID of the asset
* @return
*/
@Override
public String find(OID oid) throws NoValidURLException {
return find(oid, "live");
}

View File

@ -60,6 +60,10 @@ import org.apache.log4j.Logger;
*/
public final class DispatcherHelper implements DispatcherConstants {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.dispatcher.DispatcherHelper=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(DispatcherHelper.class);
private static String s_webappCtx;
private static String s_staticURL;
@ -89,7 +93,7 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* The current HttpServletRequest.
*/
private static ThreadLocal s_request = new ThreadLocal();
private static final ThreadLocal s_request = new ThreadLocal();
/** null constructor, private so no one can instantiate! */
private DispatcherHelper() {
@ -128,6 +132,7 @@ public final class DispatcherHelper implements DispatcherConstants {
* if servlet A includes servlet B, calling getRequestURI() in B
* returns "A" and not "B".
*
* @param req
* @return the URL path (relative to the webapp root) for the currently
* executing resource.
*/
@ -153,6 +158,7 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* Gets the application context from the request attributes.
* @param req
* @return the application context from the request attributes.
*/
public static RequestContext getRequestContext(HttpServletRequest req) {
@ -242,6 +248,11 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* Equivalent to <code>forwardRequestByPath(path, req, resp,
* DispatcherHelper.getRequestContext(req).getServletContext())</code>.
* @param path
* @param req
* @param resp
* @throws java.io.IOException
* @throws javax.servlet.ServletException
*/
public static void forwardRequestByPath(String path,
HttpServletRequest req,
@ -316,6 +327,12 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* Equivalent to <code>forwardRequestByName(name, req, resp,
* DispatcherHelper.getRequestContext(req).getServletContext())</code>.
*
* @param name
* @param req
* @param resp
* @throws java.io.IOException
* @throws javax.servlet.ServletException
*/
public static void forwardRequestByName(String name,
HttpServletRequest req,
@ -345,6 +362,7 @@ public final class DispatcherHelper implements DispatcherConstants {
* not end with a trailing slash.
* @exception java.io.FileNotFoundException if no matching
* file exists.
* @throws com.arsdigita.dispatcher.DirectoryListingException
* @deprecated abstract URLs are no longer supported. Use
* extensions when your file on disk has an extension.
*/
@ -382,17 +400,13 @@ public final class DispatcherHelper implements DispatcherConstants {
final String extensionSearchList[] = {".jsp"};
if (filesInDir != null) {
// look for .jsp files first
for (int j = 0; j < extensionSearchList.length; j++) {
File possibleFile =
new File(dirToSearch,
filenameStub + extensionSearchList[j]);
for (String searchExtension : extensionSearchList) { //1.5 enhanced loop
File possibleFile = new File(dirToSearch,
filenameStub + searchExtension);
for (int i = 0; i < filesInDir.length; i++) {
if (filesInDir[i].equals(possibleFile)) {
return (indexPage ? File.separator + "index" : "")
+ extensionSearchList[j];
+ searchExtension;
}
}
}
@ -474,6 +488,11 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* This method will optionally wrap the request if it is a multipart POST,
* or restore the original wrapper if it was already wrapped.
*
* @param sreq
* @return
* @throws java.io.IOException
* @throws javax.servlet.ServletException
*/
public static HttpServletRequest maybeWrapRequest(HttpServletRequest sreq)
throws IOException, ServletException {
@ -533,6 +552,7 @@ public final class DispatcherHelper implements DispatcherConstants {
* Redirects the client to the given URL without rewriting it. Delegates
* to the sendExternalRedirect method.
*
* @throws java.io.IOException
* @deprecated This method does not rewrite URLs. Use
* sendRedirect(HttpServletRequest, HttpServletResponse, String) for
* redirects within this ACS or
@ -556,6 +576,7 @@ public final class DispatcherHelper implements DispatcherConstants {
* for URL rewriting
* @param resp the current response
* @param url the destination URL for redirect
* @throws java.io.IOException
**/
public static void sendRedirect(HttpServletRequest req,
HttpServletResponse resp,
@ -570,6 +591,7 @@ public final class DispatcherHelper implements DispatcherConstants {
*
* @param resp the current response
* @param url the destination URL for redirect
* @throws java.io.IOException
**/
public static void sendExternalRedirect(HttpServletResponse resp,
String url)
@ -782,6 +804,8 @@ public final class DispatcherHelper implements DispatcherConstants {
* 3. If there is no request or previous request, use the value
* specified by the enterprise.init webappContext parameter.
* 4. Lastly, return null.
*
* @return
*/
public static String getWebappContext() {
init();
@ -832,6 +856,8 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* Stores the HttpServletRequest in a ThreadLocal so that it can be
* accessed globally.
*
* @param r
*/
public static void setRequest(HttpServletRequest r) {
init();
@ -1070,6 +1096,7 @@ public final class DispatcherHelper implements DispatcherConstants {
/**
* This returns a reference to the dispatcher configuration file
* @return
*/
public static DispatcherConfig getConfig() {
if (s_config == null) {
@ -1080,9 +1107,9 @@ public final class DispatcherHelper implements DispatcherConstants {
}
/**
* This method returns the best matching locate for the request. In contrast to
* the other methods available this one will also respect the supported_languages
* config entry.
* This method returns the best matching locale for the request. In contrast
* to the other methods available this one will also respect the
* supported_languages config entry.
*
* @return The negotiated locale
*/
@ -1113,8 +1140,8 @@ public final class DispatcherHelper implements DispatcherConstants {
}
} catch (NullPointerException ex) {
// Don't have to do anything because I want to fall back to default language anyway
// This case should only appear during setup
// Don't have to do anything because I want to fall back to default
// language anyway. This case should only appear during setup
} finally {
return preferedLocale;

View File

@ -149,6 +149,7 @@ public abstract class BaseServlet extends HttpServlet {
final IOException[] ioException = { null };
new KernelExcursion() {
@Override
protected final void excurse() {
setLocale(sreq.getLocale());
setSessionID(sreq.getSession().getId());
@ -266,6 +267,10 @@ public abstract class BaseServlet extends HttpServlet {
/**
* <p>Processes HTTP GET requests.</p>
*
* @param sreq
* @param sresp
* @throws javax.servlet.ServletException
* @throws java.io.IOException
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest,HttpServletResponse)
*/
@Override
@ -284,6 +289,11 @@ public abstract class BaseServlet extends HttpServlet {
/**
* <p>Processes HTTP POST requests.</p>
*
* @param sreq
* @param sresp
* @throws javax.servlet.ServletException
* @throws java.io.IOException
*
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest,HttpServletResponse)
*/
@Override

View File

@ -318,6 +318,9 @@ public class CCMDispatcherServlet extends BaseServlet {
s_log.debug("Checking if this request needs to be forwarded or " +
"included " + sreq);
// Just in case sreq is wrapped in one of our own classes (spec.
// MultipartHttpServletRequest), return unwrapped request, otherwise
// do nothing (doesn't modify anything). Mostly does nothing!
sreq = DispatcherHelper.restoreOriginalRequest(sreq);
if (sreq.getAttribute("javax.servlet.include.request_uri") == null) {
@ -499,7 +502,7 @@ public class CCMDispatcherServlet extends BaseServlet {
@Override
public String toString() {
final String sep = ", ";
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("[");
sb.append("appID=").append(m_id).append(sep);
sb.append("instanceURI=").append(m_instanceURI).append(sep);
@ -516,6 +519,7 @@ public class CCMDispatcherServlet extends BaseServlet {
*/
private static class Cache extends PathMapCache {
/** */
private static final ThreadLocal s_handleHere = new ThreadLocal() {
@Override
protected Object initialValue() {
@ -523,6 +527,9 @@ public class CCMDispatcherServlet extends BaseServlet {
}
};
/**
* Constructor, just delegates to Super class
*/
public Cache() {
super("BaseDispatcherCache");
}

View File

@ -31,14 +31,16 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver {
* 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 Logger s_log = Logger.getLogger
(DefaultApplicationFileResolver.class);
private static final String[] WELCOME_FILES = new String[] {
"index.jsp", "index.html"
};
/**
* Determines from the passsed in information a suitable RequestDispatcher.
* Implementation of the interface' single method.
*
* @param templatePath
* @param sreq
@ -52,7 +54,7 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver {
HttpServletResponse sresp,
Application app) {
String contextPath = app.getContextPath();
String contextPath = app.getContextPath(); // constant from Application!
String pathInfo = sreq.getPathInfo();
if (s_log.isDebugEnabled()) {
@ -65,15 +67,13 @@ public class DefaultApplicationFileResolver implements ApplicationFileResolver {
if (path.endsWith("/")) {
for (int i = 0 ; i < WELCOME_FILES.length ; i++) {
for (String welcomeFile : WELCOME_FILES) { //1.5 enhanced for-loop
if (s_log.isDebugEnabled()) {
s_log.debug("Trying welcome resource " +
path + WELCOME_FILES[i]);
path + welcomeFile);
}
RequestDispatcher rd = Web.findResourceDispatcher(
contextPath + path
+ WELCOME_FILES[i]);
contextPath + path + welcomeFile);
if (rd != null) {
if (s_log.isDebugEnabled()) {
s_log.debug("Got dispatcher " + rd);

View File

@ -22,13 +22,14 @@ package com.arsdigita.web;
import com.arsdigita.kernel.security.UserContext;
import com.arsdigita.util.Assert;
import com.arsdigita.util.StringUtils;
import com.arsdigita.util.UncheckedWrapperException;
//import com.arsdigita.util.UncheckedWrapperException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
//import java.util.HashMap;
//import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
@ -51,7 +52,7 @@ public class Web {
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(Web.class);
private static WebConfig s_config = WebConfig.getInstanceOf();
private static final WebConfig s_config = WebConfig.getInstanceOf();
private static final ThreadLocal s_request =
new InternalRequestLocal();
@ -237,7 +238,7 @@ public class Web {
}
return url; // Return adjusted resourcePath url
}
} catch (IOException ex) {
} catch (MalformedURLException ex) {
if (s_log.isDebugEnabled()) {
s_log.debug("Cannot get resource for " + resourcePath);
}
@ -272,7 +273,7 @@ public class Web {
s_log.debug("No URL present for " + path);
}
}
} catch(IOException exc) {
} catch(MalformedURLException exc) {
if (s_log.isDebugEnabled()) {
s_log.debug("cannot get resource for " + path);
}
@ -324,7 +325,7 @@ public class Web {
s_log.debug("No URL present for " + path);
}
}
} catch(IOException ex) {
} catch(MalformedURLException ex) {
if (s_log.isDebugEnabled()) {
s_log.debug("cannot get resource for " + path);
}
@ -404,15 +405,36 @@ public class Web {
return null;
}
ServletContext ctx = getServletContext();
URL url = null;
// Check for old style resource format including a comma seoarated list
// of webapps
if(resourcePath.indexOf(",") <= 0 ) {
// no comma separated list found, process as normal
return ctx == null ? null : ctx.getRequestDispatcher(resourcePath);
try {
url = ctx.getResource(resourcePath);
} catch (MalformedURLException ex) {
if (s_log.isDebugEnabled()) {
s_log.debug("Resource for " + resourcePath + " not found.");
}
// throw new UncheckedWrapperException(
// "No resource at " + resourcePath, ex);
return null;
}
if (url == null) {
return null;
} else {
RequestDispatcher rd = (ctx == null) ?
null : ctx.getRequestDispatcher(resourcePath);
return rd;
}
} else {
// old style format not implemented yet here
return null;
}
}

View File

@ -248,6 +248,7 @@ public final class WebConfig extends AbstractConfig {
* per-user caching, <code>world</code> for globally enabled
* caching, <code>disable</code> to prevent HTTP header caching, and
* <code>none</code>to always prevent caching in any case.
* @return
*/
public final CachePolicy getCachePolicy() {
return (CachePolicy) get(m_policy);
@ -259,6 +260,7 @@ public final class WebConfig extends AbstractConfig {
super(name);
}
@Override
protected void doValidate(final Object value, final ErrorList errors) {
final String string = (String) value;
@ -322,6 +324,7 @@ public final class WebConfig extends AbstractConfig {
//
/**
* @return
* @deprecated Use <code>getServer().getName()</code> instead.
*/
public final String getServerName() {
@ -329,6 +332,7 @@ public final class WebConfig extends AbstractConfig {
}
/**
* @return
* @deprecated Use <code>getServer().getPort()</code> instead.
*/
public final int getServerPort() {
@ -336,6 +340,7 @@ public final class WebConfig extends AbstractConfig {
}
/**
* @return
* @deprecated Use
* <code>Host.retrieve(Web.getConfig().getHost())</code> instead.
*/
@ -344,6 +349,7 @@ public final class WebConfig extends AbstractConfig {
}
/**
* @return
* @deprecated Use <code>Host.retrieveAll()</code> instead.
*/
public final Host[] getHosts() {