// Get the renderer id that has been registered with the url. For this,
// we first have to load the page data, then get the associated renderer
// bundle.
try {
Page page = null;
ResourceURI pageURI = null;
Site site = request.getSite();
// Check if a page was passed as an attribute
if (request.getAttribute(WebloungeRequest.PAGE) != null) {
page = (Page) request.getAttribute(WebloungeRequest.PAGE);
pageURI = page.getURI();
}
// Load the page from the content repository
else {
ContentRepository contentRepository = site.getContentRepository();
if (contentRepository == null) {
logger.debug("No content repository found for site '{}'", site);
return false;
} else if (contentRepository.isIndexing()) {
logger.debug("Content repository of site '{}' is currently being indexed", site);
DispatchUtils.sendServiceUnavailable(request, response);
return true;
}
ResourceURI requestURI = null;
ResourceURI requestedURI = null;
// Load the page. Note that we are taking care of the special case where
// a user may have created a page with a url that matches a valid
// language identifier, in which case it would have been stripped from
// request.getUrl().
try {
if (action != null) {
pageURI = getPageURIForAction(action, request);
requestURI = pageURI;
} else if (path.startsWith(URI_PREFIX)) {
String uriSuffix = StringUtils.substringBefore(path.substring(URI_PREFIX.length()), "/");
uriSuffix = URLDecoder.decode(uriSuffix, "utf-8");
ResourceURI uri = new PageURIImpl(site, null, uriSuffix, request.getVersion());
requestURI = uri;
WebUrl requestedUrl = request.getRequestedUrl();
if (requestedUrl.hasLanguagePathSegment()) {
String requestedPath = UrlUtils.concat(path, request.getLanguage().getIdentifier());
String requestedUriSuffix = StringUtils.substringBefore(requestedPath.substring(URI_PREFIX.length()), "/");
requestedUriSuffix = URLDecoder.decode(requestedUriSuffix, "utf-8");
requestedURI = new PageURIImpl(site, requestedUriSuffix, null, request.getVersion());
}
} else {
long version = isEditing ? Resource.WORK : Resource.LIVE;
ResourceURI uri = new PageURIImpl(request);
uri.setVersion(version);
requestURI = uri;
WebUrl requestedUrl = request.getRequestedUrl();
if (requestedUrl.hasLanguagePathSegment()) {
String requestedPath = UrlUtils.concat(path, request.getLanguage().getIdentifier());
requestedPath = URLDecoder.decode(requestedPath, "utf-8");