Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
GTNPORTAL-3200 Non-Ascii node names are not routed properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
nscavell authored and ppalaga committed Jul 26, 2013
1 parent 6d76cd9 commit f780576
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
Expand Up @@ -45,8 +45,10 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.SiteKey;
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.navigation.NavigationService;
import org.exoplatform.portal.mop.page.PageContext;
import org.exoplatform.portal.mop.page.PageKey;
import org.exoplatform.portal.mop.user.UserNavigation;
Expand Down Expand Up @@ -110,6 +112,8 @@ public class PortalRequestContext extends WebuiRequestContext {
/** The path decoded from the request. */
private final String nodePath_;

private String resolvedNodePath;

/** . */
private final String requestURI_;

Expand Down Expand Up @@ -444,6 +448,33 @@ public String getNodePath() {
return nodePath_;
}

/**
* Returns the resolvable node path. For example if nodePath was /home/foo/bar and /foo/bar did not
* exist, /home would be returned.
*
* @return the resolved node path
*/
public String getResolvedNodePath() {
if (resolvedNodePath == null) {
UserNode node = null;
UserPortal userPortal = getUserPortal();
String nodePath = getNodePath();
UserNavigation userNavigation = userPortal.getNavigation(siteKey);
if (userNavigation == null) {
nodePath = ""; // Unknown site was requested, default to no node path
} else {
node = userPortal.resolvePath(userNavigation, null, nodePath);
if (node == null) {
node = userPortal.getDefaultPath(userNavigation, null);
}
}

resolvedNodePath = (node == null) ? nodePath : node.getURI();
}

return resolvedNodePath;
}

public String getRequestURI() {
return requestURI_;
}
Expand Down
Expand Up @@ -124,7 +124,6 @@ public boolean execute(ControllerContext controllerContext) throws Exception {

//
String requestPath = controllerContext.getParameter(REQUEST_PATH);
requestPath = EntityEncoder.FULL.encode(requestPath);
String requestSiteType = controllerContext.getParameter(REQUEST_SITE_TYPE);
String requestSiteName = controllerContext.getParameter(REQUEST_SITE_NAME);

Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -778,16 +779,16 @@ public String getPortalURLTemplate() throws UnsupportedEncodingException {
PortalRequestContext pcontext = Util.getPortalRequestContext();
ComponentURL urlTemplate = pcontext.createURL(ComponentURL.TYPE);
urlTemplate.setMimeType(MimeType.PLAIN);
urlTemplate.setPath(pcontext.getNodePath());
urlTemplate.setPath(pcontext.getResolvedNodePath());
urlTemplate.setResource(EMPTY_COMPONENT);
urlTemplate.setAction("{portal:action}");

return URLDecoder.decode(urlTemplate.toString(), "UTF-8");
}

public String getBaseURL() {
public String getBaseURL() throws UnsupportedEncodingException {
PortalRequestContext pcontext = Util.getPortalRequestContext();
NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE, new NavigationResource(pcontext.getSiteKey(), pcontext.getNodePath()));
return nodeURL.toString();
NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE, new NavigationResource(pcontext.getSiteKey(), pcontext.getResolvedNodePath()));
return URLDecoder.decode(nodeURL.toString(), "UTF-8");
}
}

0 comments on commit f780576

Please sign in to comment.