Search in sources :

Example 1 with NodeURL

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();
}
Also used : ManageDriveService(org.exoplatform.services.cms.drives.ManageDriveService) PortletRequest(javax.portlet.PortletRequest) PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext) UserNode(org.exoplatform.portal.mop.user.UserNode) DriveData(org.exoplatform.services.cms.drives.DriveData) PortletRequestContext(org.exoplatform.webui.application.portlet.PortletRequestContext) NodeURL(org.exoplatform.web.url.navigation.NodeURL)

Example 2 with NodeURL

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;
}
Also used : JSONObject(org.json.JSONObject) TreeNode(org.exoplatform.portal.webui.navigation.TreeNode) UserNode(org.exoplatform.portal.mop.user.UserNode) JSONArray(org.json.JSONArray) UIPortalNavigation(org.exoplatform.portal.webui.navigation.UIPortalNavigation) NavigationResource(org.exoplatform.web.url.navigation.NavigationResource) NodeURL(org.exoplatform.web.url.navigation.NodeURL) ResourceURL(javax.portlet.ResourceURL)

Example 3 with NodeURL

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;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) UserNode(org.exoplatform.portal.mop.user.UserNode) NavigationResource(org.exoplatform.web.url.navigation.NavigationResource) NodeURL(org.exoplatform.web.url.navigation.NodeURL) ResourceURL(javax.portlet.ResourceURL)

Example 4 with NodeURL

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();
}
Also used : PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext) NavigationResource(org.exoplatform.web.url.navigation.NavigationResource) NodeURL(org.exoplatform.web.url.navigation.NodeURL)

Example 5 with NodeURL

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);
}
Also used : PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext) SiteKey(org.exoplatform.portal.mop.SiteKey) NodeURL(org.exoplatform.web.url.navigation.NodeURL) RequestNavigationData(org.exoplatform.portal.application.RequestNavigationData) PageNodeEvent(org.exoplatform.portal.webui.portal.PageNodeEvent)

Aggregations

NodeURL (org.exoplatform.web.url.navigation.NodeURL)36 NavigationResource (org.exoplatform.web.url.navigation.NavigationResource)29 PortalRequestContext (org.exoplatform.portal.application.PortalRequestContext)15 RequestContext (org.exoplatform.web.application.RequestContext)13 PortletRequestContext (org.exoplatform.webui.application.portlet.PortletRequestContext)8 UserNode (org.exoplatform.portal.mop.user.UserNode)7 WebuiRequestContext (org.exoplatform.webui.application.WebuiRequestContext)7 PortletRequest (javax.portlet.PortletRequest)6 Node (javax.jcr.Node)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 PortalURLContext (org.exoplatform.portal.url.PortalURLContext)4 FriendlyService (org.exoplatform.services.wcm.friendly.FriendlyService)4 ResourceURL (javax.portlet.ResourceURL)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 NodeLocation (org.exoplatform.services.wcm.core.NodeLocation)3 JSONArray (org.json.JSONArray)3 JSONObject (org.json.JSONObject)3 Test (org.junit.Test)3 PortletPreferences (javax.portlet.PortletPreferences)2 UserPortalConfigService (org.exoplatform.portal.config.UserPortalConfigService)2