use of javax.portlet.ResourceURL in project core by wicketstuff.
the class PortletRequestMapper method encodeResourceUrl.
private Url encodeResourceUrl(Url url) {
if (url != null) {
String qualifiedPath = getQualifiedPath(url.toString());
PortletResponse portletResponse = ThreadPortletContext.getPortletResponse();
if ((portletResponse != null) && (portletResponse instanceof MimeResponse)) {
try {
ResourceURL resourceUrl = ((MimeResponse) portletResponse).createResourceURL();
resourceUrl.setResourceID(qualifiedPath);
qualifiedPath = resourceUrl.toString();
// resource URLs preserve all request render parameters (at
// least for Liferay even all POST parameters), so we have
// to remove all Wicket parameters (that have the portlet
// namespace), otherwise we would have all submited values
// in the URL
int queryStringSeparator = qualifiedPath.indexOf('?');
if (queryStringSeparator > 0) {
Map<String, String[]> parameterMap = Utils.parseQueryString(qualifiedPath.substring(queryStringSeparator + 1));
boolean changed = false;
Iterator<Map.Entry<String, String[]>> it = parameterMap.entrySet().iterator();
String namespace = ThreadPortletContext.getNamespace();
while (it.hasNext()) {
if (it.next().getKey().startsWith(namespace)) {
changed = true;
it.remove();
}
}
if (changed) {
qualifiedPath = qualifiedPath.substring(0, queryStringSeparator) + '?' + Utils.buildQueryString(parameterMap);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
url = parseUrl(qualifiedPath);
}
return markAsPortletUrl(url);
}
use of javax.portlet.ResourceURL in project ecms by exoplatform.
the class UISingleContentViewerPortlet method toJSON.
private JSONObject toJSON(UserNode node, MimeResponse res) throws Exception {
JSONObject json = new JSONObject();
String nodeId = node.getId();
json.put("label", node.getEncodedResolvedLabel());
json.put("hasChild", node.getChildrenCount() > 0);
UserNode selectedNode = Util.getUIPortal().getNavPath();
json.put("isSelected", nodeId.equals(selectedNode.getId()));
json.put("icon", node.getIcon());
String nodeURI = "";
if (node.getPageRef() != null) {
nodeURI = node.getURI();
}
json.put("uri", nodeURI);
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(res.encodeURL(node.getURI()));
json.put("getNodeURL", rsURL.toString());
JSONArray jsonChildren = new JSONArray();
for (UserNode child : node.getChildren()) {
jsonChildren.put(toJSON(child, res));
}
json.put("childs", jsonChildren);
return json;
}
Aggregations