<%@ page language="java" extends="com.polopoly.cm.jsp.ThreadSafePolopolyJspPage" import="com.polopoly.cm.core.Dynamic, com.polopoly.cm.core.Variant, com.polopoly.cm.jsp.CMUtil, com.polopoly.util.logging.impl.Level, com.polopoly.util.logging.impl.Logger" session="false" %><%! protected static final String CLASS = "Crosslink"; protected static Logger logger = Logger.getLogger(CLASS); %><% /** * Implementation hint: if all content on the site is access protected you * probably want to this page to extend ThreadSafeLoggedInPolopolyJspPage * instead of ThreadSafePolopolyJspPage. Then the user will be redirected * to a login page if not logged in. * * ----------------------------------------------------------------------------- * * Top dispatcher for all roads within a publication. * Will read variant data from object and switch accordingly. * Variants will be handled by separate dyn pages (stored in road dir). * * Requestdata: * d departmentId, default is 10 * a articleId, default is department.getTopArticle() if existing, else -1 (none) * f startFile, default is "index.html" * t level: * 0 toplevel, all frames etc (default) * <>0 other levels * p production and publication name concatenated. * Default is "prod.publ.PublicationExternal". * r roadId, default is 0 * v departmentVariantId, to override department setting, default is from dep * * * Road and variant selection algorithm: * * Rules (first rule apply if conflicting): * any specified param is used as is * article = department.getTopArticle() * article = set from HTTP_REFERER * department = article.getFirstDepartment() * department = 10 * road = first road that has a variant for both the article and department * road = 0 * variant = department.getVariant(road) * variant = standardVariant * * * Evaluation order for department and article * article department result * ----------------------------------------------------------------------------- * set not set eval department (see above) * not set set normal dep: eval article (see above) * static dep: use f as path within department dir * handled by 0/Render * not set not set if f is set, get article id from HTTP_REFERER * else, eval department (see above) * static dep: use f as path within department dir * handled by 0/Render * * road and variant are used to branch to correct render. */ try { CMUtil cmUtil = initPage(pageContext); // CMUtil is saved in REQUEST_SCOPE // get params Integer articleId = cmUtil.findArticleId(); Integer departmentId = cmUtil.findDepartmentId(); Integer departmentVariantId = cmUtil.findDepartmentVariantId(); Variant departmentVariant = cmUtil.findDepartmentVariant(); logger.finest(CLASS, "jspService", "departmentId=" + departmentId + ", articleId=" + articleId); // Are we dealing with a dynamo template? boolean useDynTemplate = false; if (departmentVariant != null) { useDynTemplate = (departmentVariant.getFlags() & Variant.FLAG_DYNOVERIDE) != 0; } // Send message to log server (if it is running) boolean log = !"true".equalsIgnoreCase(request.getParameter("nolog")); if (log && !useDynTemplate) { cmUtil.sendUrlRequestToLogServer("Crosslink"); } // do the actual page if (useDynTemplate) { String startFile = cmUtil.findStartFile(); Integer level = cmUtil.findLevel(); String includeUrlStr = cmUtil.getPublication().getDynamoWebPath() + "/Crosslink.dyn"; includeUrlStr += "?d=" + departmentId.intValue(); if (articleId != null && articleId.intValue() >= 0) includeUrlStr += "&a=" + articleId.intValue(); if (departmentVariantId != null && departmentVariantId.intValue() >= 0) includeUrlStr += "&v=" + departmentVariantId.intValue(); if (level != null && level.intValue() >= 0) includeUrlStr += "&t=" + level.intValue(); if (startFile != null && startFile.length() > 0) includeUrlStr += "&f=" + startFile; logger.fine(CLASS, "jspService", "forward: " + includeUrlStr); response.sendRedirect(includeUrlStr); return; } else { // NOTE: This does not work with STATIC departments. // Should we support them? Then the check should be here. String includeUrlStr = cmUtil.getContentRenderWebAppPath(departmentVariant); if (response.isCommitted()) { // In case someone includes polopoly.jsp logger.fine(CLASS, "jspService", "include: " + includeUrlStr); pageContext.include(includeUrlStr); } else { if (request.getQueryString() != null) includeUrlStr += "?" + request.getQueryString(); logger.fine(CLASS, "jspService", "forward: " + includeUrlStr); pageContext.forward(includeUrlStr); } return; } } catch (Exception e) { logger.logp(Level.WARNING, CLASS, "jspService", "exception", e); } %>