if (count == 0 || "true".equals(config.getString(CRConfig.ADVPLR_HOST_FORCE))) {
//not permitted or forced, build link
ret = getAlternateUrl(contentid);
} else {
Resolvable plinkObject;
try {
plinkObject = PortalConnectorFactory.getContentObject(contentid, ds);
//TODO: make this more beautiful and
//compatible with portlets
String filenameattribute = (String) config.get(CRConfig.ADVPLR_FN_KEY);
String pubdirattribute = (String) config.get(CRConfig.ADVPLR_PB_KEY);
String filename = (String) plinkObject.get(filenameattribute);
String pubdir = (String) plinkObject.get(pubdirattribute);
HttpServletRequest servletRequest = (HttpServletRequest) request.get("request");
String contextPath = servletRequest.getContextPath();
String servletPath = servletRequest.getServletPath();
ret = contextPath + servletPath + pubdir + filename;
} catch (DatasourceNotAvailableException e) {