use of org.exoplatform.web.url.navigation.NodeURL in project ecms by exoplatform.
the class EmailNotifyCloudDocumentListener method getViewableLink.
/**
* Used in
* {@link WatchCloudDocumentServiceImpl#watchDocument(Node, String, int)}.
*
* @return the viewable link
* @throws Exception the exception
*/
String getViewableLink() throws Exception {
PortalRequestContext pContext = Util.getPortalRequestContext();
NodeURL nodeURL = pContext.createURL(NodeURL.TYPE);
String nodePath = NodeLocation.getNodeByLocation(observedNode_).getPath();
ManageDriveService manageDriveService = WCMCoreUtils.getService(ManageDriveService.class);
List<DriveData> driveList = manageDriveService.getDriveByUserRoles(pContext.getRemoteUser(), getMemberships());
DriveData drive = getDrive(driveList, WCMCoreUtils.getRepository().getConfiguration().getDefaultWorkspaceName(), nodePath);
String driverName = drive.getName();
String nodePathInDrive = "/".equals(drive.getHomePath()) ? nodePath : nodePath.substring(drive.getHomePath().length());
UserNode siteExNode = getUserNodeByURI(SITE_EXPLORER);
nodeURL.setNode(siteExNode);
nodeURL.setQueryParameterValue(PATH_PARAM, "/" + driverName + nodePathInDrive);
PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
PortletRequest portletRequest = portletRequestContext.getRequest();
String baseURI = portletRequest.getScheme() + "://" + portletRequest.getServerName() + ":" + String.format("%s", portletRequest.getServerPort());
return baseURI + nodeURL.toString();
}
use of org.exoplatform.web.url.navigation.NodeURL in project gatein-portal by Meeds-io.
the class UISitemapPortlet method toJSON.
private JSONObject toJSON(TreeNode tnode, MimeResponse res) throws Exception {
UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);
JSONObject json = new JSONObject();
UserNode node = tnode.getNode();
String nodeId = node.getId();
json.put("label", node.getEncodedResolvedLabel());
json.put("hasChild", tnode.hasChild());
json.put("isExpanded", tnode.isExpanded());
json.put("collapseURL", uiPortalNavigation.url("CollapseNode", nodeId));
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(nodeId);
json.put("getNodeURL", rsURL.toString());
if (node.getPageRef() != null) {
NavigationResource resource = new NavigationResource(node);
NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
url.setAjax(isUseAjax());
json.put("actionLink", url.toString());
}
JSONArray childs = new JSONArray();
for (TreeNode child : tnode.getChildren()) {
childs.put(toJSON(child, res));
}
json.put("childs", childs);
return json;
}
use of org.exoplatform.web.url.navigation.NodeURL in project gatein-portal by Meeds-io.
the class BasePartialUpdateToolbar method toJSON.
protected JSONObject toJSON(UserNode node, String navId, MimeResponse res) throws Exception {
JSONObject json = new JSONObject();
String nodeId = node.getId();
json.put("label", node.getEncodedResolvedLabel());
json.put("hasChild", node.getChildrenCount() > 0);
json.put("isSelected", nodeId.equals(getSelectedNode().getId()));
json.put("icon", node.getIcon());
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(getResourceIdFromNode(node, navId));
json.put("getNodeURL", rsURL.toString());
if (node.getPageRef() != null) {
NavigationResource resource = new NavigationResource(node);
NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
json.put("actionLink", url.setAjax(false).toString());
}
JSONArray childs = new JSONArray();
for (UserNode child : node.getChildren()) {
childs.put(toJSON(child, navId, res));
}
json.put("childs", childs);
return json;
}
use of org.exoplatform.web.url.navigation.NodeURL in project gatein-portal by Meeds-io.
the class UIPortalApplication method 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();
}
use of org.exoplatform.web.url.navigation.NodeURL in project gatein-portal by Meeds-io.
the class UIPortalApplication method processAction.
/**
* The processAction() method is doing 3 actions: <br>
* 1) if this is a non ajax request and the last is an ajax one, then we check if the requested nodePath is equal to last
* non ajax nodePath and is not equal to the last nodePath, the server performs a 302 redirect on the last nodePath.<br>
* 2) if the nodePath exist but is equals to the current one then we also call super and stops here.<br>
* 3) if the requested nodePath is not equals to the current one or current page no longer exists, then an event of type
* PageNodeEvent.CHANGE_NODE is sent to the associated EventListener; a call to super is then done.
*/
@Override
public void processAction(WebuiRequestContext context) throws Exception {
PortalRequestContext pcontext = (PortalRequestContext) context;
RequestNavigationData requestNavData = pcontext.getNavigationData();
boolean isAjax = pcontext.useAjax();
if (!isAjax) {
if (isAjaxInLastRequest) {
isAjaxInLastRequest = false;
if (requestNavData.equals(lastNonAjaxRequestNavData) && !requestNavData.equals(lastRequestNavData) && pcontext.getPortletParameters().isEmpty()) {
NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE).setNode(getCurrentSite().getSelectedUserNode());
pcontext.sendRedirect(nodeURL.toString());
return;
}
}
lastNonAjaxRequestNavData = requestNavData;
}
isAjaxInLastRequest = isAjax;
if (!requestNavData.equals(lastRequestNavData)) {
lastRequestNavData = requestNavData;
StringBuilder js = new StringBuilder("eXo.env.server.portalBaseURL=\"");
js.append(getBaseURL()).append("\";\n");
String url = getPortalURLTemplate();
js.append("eXo.env.server.portalURLTemplate=\"");
js.append(url).append("\";");
pcontext.getJavascriptManager().require("SHARED/base").addScripts(js.toString());
SiteKey siteKey = pcontext.getSiteKey();
PageNodeEvent<UIPortalApplication> pnevent = new PageNodeEvent<UIPortalApplication>(this, PageNodeEvent.CHANGE_NODE, siteKey, pcontext.getNodePath());
broadcast(pnevent, Event.Phase.PROCESS);
}
if (!isAjax) {
lastNonAjaxRequestNavData = requestNavData;
}
if (pcontext.isResponseComplete()) {
return;
}
if (currentSite == null || currentSite.getSelectedUserNode() == null) {
pcontext.sendError(HttpServletResponse.SC_NOT_FOUND);
}
super.processAction(pcontext);
}
Aggregations