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

Commit f780576

Browse files
nscavellppalaga
authored andcommittedJul 26, 2013
GTNPORTAL-3200 Non-Ascii node names are not routed properly.
1 parent 6d76cd9 commit f780576

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed
 

Diff for: ‎webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java

+31
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
import org.exoplatform.container.PortalContainer;
4646
import org.exoplatform.portal.config.UserPortalConfig;
4747
import org.exoplatform.portal.config.UserPortalConfigService;
48+
import org.exoplatform.portal.config.model.PortalConfig;
4849
import org.exoplatform.portal.mop.SiteKey;
4950
import org.exoplatform.portal.mop.SiteType;
51+
import org.exoplatform.portal.mop.navigation.NavigationService;
5052
import org.exoplatform.portal.mop.page.PageContext;
5153
import org.exoplatform.portal.mop.page.PageKey;
5254
import org.exoplatform.portal.mop.user.UserNavigation;
@@ -110,6 +112,8 @@ public class PortalRequestContext extends WebuiRequestContext {
110112
/** The path decoded from the request. */
111113
private final String nodePath_;
112114

115+
private String resolvedNodePath;
116+
113117
/** . */
114118
private final String requestURI_;
115119

@@ -444,6 +448,33 @@ public String getNodePath() {
444448
return nodePath_;
445449
}
446450

451+
/**
452+
* Returns the resolvable node path. For example if nodePath was /home/foo/bar and /foo/bar did not
453+
* exist, /home would be returned.
454+
*
455+
* @return the resolved node path
456+
*/
457+
public String getResolvedNodePath() {
458+
if (resolvedNodePath == null) {
459+
UserNode node = null;
460+
UserPortal userPortal = getUserPortal();
461+
String nodePath = getNodePath();
462+
UserNavigation userNavigation = userPortal.getNavigation(siteKey);
463+
if (userNavigation == null) {
464+
nodePath = ""; // Unknown site was requested, default to no node path
465+
} else {
466+
node = userPortal.resolvePath(userNavigation, null, nodePath);
467+
if (node == null) {
468+
node = userPortal.getDefaultPath(userNavigation, null);
469+
}
470+
}
471+
472+
resolvedNodePath = (node == null) ? nodePath : node.getURI();
473+
}
474+
475+
return resolvedNodePath;
476+
}
477+
447478
public String getRequestURI() {
448479
return requestURI_;
449480
}

Diff for: ‎webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public boolean execute(ControllerContext controllerContext) throws Exception {
124124

125125
//
126126
String requestPath = controllerContext.getParameter(REQUEST_PATH);
127-
requestPath = EntityEncoder.FULL.encode(requestPath);
128127
String requestSiteType = controllerContext.getParameter(REQUEST_SITE_TYPE);
129128
String requestSiteName = controllerContext.getParameter(REQUEST_SITE_NAME);
130129

Diff for: ‎webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.UnsupportedEncodingException;
2323
import java.io.Writer;
2424
import java.net.URLDecoder;
25+
import java.net.URLEncoder;
2526
import java.util.ArrayList;
2627
import java.util.Collection;
2728
import java.util.Collections;
@@ -778,16 +779,16 @@ public String getPortalURLTemplate() throws UnsupportedEncodingException {
778779
PortalRequestContext pcontext = Util.getPortalRequestContext();
779780
ComponentURL urlTemplate = pcontext.createURL(ComponentURL.TYPE);
780781
urlTemplate.setMimeType(MimeType.PLAIN);
781-
urlTemplate.setPath(pcontext.getNodePath());
782+
urlTemplate.setPath(pcontext.getResolvedNodePath());
782783
urlTemplate.setResource(EMPTY_COMPONENT);
783784
urlTemplate.setAction("{portal:action}");
784785

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

788-
public String getBaseURL() {
789+
public String getBaseURL() throws UnsupportedEncodingException {
789790
PortalRequestContext pcontext = Util.getPortalRequestContext();
790-
NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE, new NavigationResource(pcontext.getSiteKey(), pcontext.getNodePath()));
791-
return nodeURL.toString();
791+
NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE, new NavigationResource(pcontext.getSiteKey(), pcontext.getResolvedNodePath()));
792+
return URLDecoder.decode(nodeURL.toString(), "UTF-8");
792793
}
793794
}

0 commit comments

Comments
 (0)
This repository has been archived.