boolean websiteOk;
try {
websiteOk = verifyContentToWebSite(delegator, webSiteId, contentId);
} catch (GeneralException e) {
Debug.logError(e, module);
throw new GeneralRuntimeException(e.getMessage(), e);
}
if (websiteOk) {
// create the template map
MapStack<String> templateMap = MapStack.create();
ScreenRenderer.populateContextForRequest(templateMap, null, request, response, servletContext);
templateMap.put("formStringRenderer", new HtmlFormRenderer(request, response));
// make the link prefix
ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
templateMap.put("_REQUEST_HANDLER_", rh);
// NOTE DEJ20080817: this is done in the ContentMapFacade class now to avoid problems with the jsessionid being in the middle of the URL and such
//String contextLinkPrefix = rh.makeLink(request, response, "", true, false, true);
//templateMap.put("_CONTEXT_LINK_PREFIX_", contextLinkPrefix);
Writer writer;
try {
// use UtilJ2eeCompat to get this setup properly
boolean useOutputStreamNotWriter = false;
if (servletContext != null) {
useOutputStreamNotWriter = UtilJ2eeCompat.useOutputStreamNotWriter(servletContext);
}
if (useOutputStreamNotWriter) {
ServletOutputStream ros = response.getOutputStream();
writer = new OutputStreamWriter(ros, "UTF-8");
} else {
writer = response.getWriter();
}
// render
if (UtilValidate.isEmpty(mapKey)) {
ContentWorker.renderContentAsText(dispatcher, delegator, contentId, writer, templateMap, locale, "text/html", true);
} else {
ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, writer, mapKey, templateMap, locale, "text/html", true);
}
} catch (IOException e) {
throw new GeneralRuntimeException("Error in the response writer/output stream: " + e.toString(), e);
} catch (GeneralException e) {
throw new GeneralRuntimeException("Error rendering content: " + e.toString(), e);
}
return "success";
} else {
String contentName = null;