WebUrl url = request.getUrl();
long version = request.getVersion();
Action action = (Action) request.getAttribute(WebloungeRequest.ACTION);
PageletRenderer renderer = null;
try {
String moduleId = pagelet.getModule();
String rendererId = pagelet.getIdentifier();
// Check access rights
// Permission p = SystemPermission.READ;
// if (!pagelet.checkOne(p, user.getRoleClosure()) &&
// !pagelet.check(p, user)) {
// logger.debug("Skipping pagelet " + i + " in composer " + composer
// + " due to insufficient rights");
// continue p;
// }
// Check publishing dates
// TODO: Fix this. pagelet.isPublished() currently returns false,
// as both from and to dates are null (see PublishingCtx)
// if (!(request.getVersion() == Resource.WORK) && !pagelet.isPublished())
// {
// logger.debug("Skipping pagelet " + position + " in composer " + id +
// " since it is not yet published");
// return;
// }
// Select the actual renderer by method and have it render the
// request. Since renderers are being pooled by the bundle, we
// have to return it after the request has finished.
Module m = site.getModule(moduleId);
if (m == null) {
logger.warn("Unable to render '{}' on {}://{}: module '{}' not installed", new Object[] {
rendererId,
site,
request.getRequestedUrl(),
moduleId });
return;
}
// Load renderer
renderer = m.getRenderer(rendererId);
if (renderer == null) {
logger.warn("No suitable renderer '" + moduleId + "/" + rendererId + "' found to handle " + url);
return;
}
// Flush all data that has been created previously
writer.flush();
response.addTag(CacheTag.Position, Integer.toString(position));
// Pass control to callback
int beforePageletResult = beforePagelet(pagelet, position, writer, isGhostContent);
// Do we need to process this pagelet?
if (beforePageletResult == SKIP_PAGELET) {
// At least close pagelet properly before returning
try {
afterPagelet(pagelet, position, writer);
} catch (ContentRepositoryException e) {
logger.warn("Failed to close pagelet: {}", e.getMessage());
response.invalidate();
} catch (ContentRepositoryUnavailableException e) {
logger.warn("Failed to close pagelet due to missing content repository");
response.invalidate();
}
return;
}
renderingState = RenderingState.InsidePagelet;
writer.flush();
// Check whether this request is being controlled by an action. If
// so, we have to call the action on composer and pagelet start
if (action != null && action instanceof HTMLAction) {
HTMLAction htmlAction = (HTMLAction) action;
try {
if (htmlAction.startPagelet(request, response, pagelet) == HTMLAction.SKIP_PAGELET) {
return;
}
} catch (Exception e) {
logger.warn("Exception while rendering pagelet through action " + action + " on " + url, e);
response.invalidate();
}
}
// Add the pagelet's includes to the request's head section
for (HTMLHeadElement header : renderer.getHTMLHeaders()) {
if (!HTMLInclude.Use.Editor.equals(header.getUse()))
response.addHTMLHeader(header);
}
logger.debug("Rendering pagelet " + renderer);
// Render pagelet
try {
renderer.render(request, response);
// if (orientation_ == ORIENTATION_VERTICAL) {
// writer.println("<br class=\"weblounge\"/>");
// }
writer.flush();