// get the character encoding map
CharacterEncodingMap characterEncodingMap = siteContext.getCharacterEncodingManager().getMap(path);
// put standard servlet stuff into the context
JPublishContext context = new JPublishContext(this);
context.put("request", request);
context.put("response", response);
context.put("session", session);
context.put("application", servletContext);
// add the character encoding map to the context
context.put("characterEncodingMap", characterEncodingMap);
// add the URLUtilities to the context
URLUtilities urlUtilities = new URLUtilities(request, response);
context.put("urlUtilities", urlUtilities);
// add the DateUtilities to the context
context.put("dateUtilities", DateUtilities.getInstance());
// add the NumberUtilities to the context
context.put("numberUtilities", NumberUtilities.getInstance());
// add the messages log to the context
context.put("syslog", SiteContext.syslog);
// expose the SiteContext
context.put("site", siteContext);
if (siteContext.isProtectReservedNames()) {
context.enableCheckReservedNames(this);
}
// add the repositories to the context
Iterator repositories = siteContext.getRepositories().iterator();
while (repositories.hasNext()) {
Repository repository = (Repository) repositories.next();
context.put(repository.getName(), new RepositoryWrapper(repository, context));
// add the fs_repository also as the name 'pages' so we can use existing logic in pages
// note this is a hack and we should look at doing this a different way; but first need
// to investigate how to get content from different repositories
if (repository.getName().equals("fs_repository")) {
context.put("pages", new RepositoryWrapper(repository, context));
}
}
try {
if (executePreEvaluationActions(request, response, context, path))
return;
// if the page is static
StaticResourceManager staticResourceManager = siteContext.getStaticResourceManager();
if (staticResourceManager.resourceExists(path)) {
if (outputStream != null) {
// execute the global actions
if (executeGlobalActions(request, response, context, path, allowRedirect))
return;
// execute path actions
if (executePathActions(request, response, context, path, allowRedirect))
return;
// execute parameter actions
if (executeParameterActions(request, response, context, path, allowRedirect))
return;
// load and return the static resource
staticResourceManager.load(path, outputStream);
outputStream.flush();
return;
} else {
throw new GeneralException("Cannot load static resource with a null OutputStream");
}
}
// check and make sure we have a writer
if (writer == null)
throw new GeneralException("Cannot load dynamic content with a null Writer");
// load the page
PageInstance pageInstance = siteContext.getPageManager().getPage(path);
Page page = new Page(pageInstance);
context.disableCheckReservedNames(this);
// expose the page in the context
context.put("page", page);
// expose components in the context
context.put("components", new ComponentMap(context));
if (siteContext.isProtectReservedNames()) {
context.enableCheckReservedNames(this);
}
// execute the global actions
if (executeGlobalActions(request, response, context, path, allowRedirect))
return;