Package org.apache.jetspeed.request

Examples of org.apache.jetspeed.request.RequestContext


   
    @Override
    protected void doHeaders(RenderRequest request, RenderResponse response)
    {
        super.doHeaders(request, response);
        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
        Element headElem = response.createElement("script");
        headElem.setAttribute("language", "javascript");
        String scriptPath = rc.getRequest().getContextPath() + yuiScriptPath;
        headElem.setAttribute("id", HeaderPhaseSupportConstants.HEAD_ELEMENT_CONTRIBUTION_ELEMENT_ID_YUI_LIBRARY_INCLUDE);
        headElem.setAttribute("src", scriptPath);
        headElem.setAttribute("type", "text/javascript");
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, headElem);
    }
View Full Code Here


  }

  @Override
  protected void doHeaders(RenderRequest request, RenderResponse response) {
    super.doHeaders(request, response);
    RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
    addJavaScript(response, rc.getRequest().getContextPath() + yuiScriptPath,
        HeaderPhaseSupportConstants.HEAD_ELEMENT_CONTRIBUTION_ELEMENT_ID_YUI_LIBRARY_INCLUDE);

   
    addJavaScript(response, request.getContextPath() + "/javascript/yui2/yui2-jetspeed.js", null);
    addStyleLink(response, request.getContextPath() + "/css/yui2/yui2-jetspeed.css", null);
View Full Code Here

  public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {

    boolean hasEditAccess = false;

    try {
      RequestContext requestContext = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
      ContentPage contentPage = requestContext.getPage();
      contentPage.checkAccess(JetspeedActions.EDIT);
      hasEditAccess = true;
    } catch (Exception ignore) {
    }
View Full Code Here

        return false;
    }

    public static String getAbsoluteUrl(RenderRequest renderRequest, String relativePath)
    {
        RequestContext requestContext = (RequestContext) renderRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
        HttpServletRequest request = requestContext.getRequest();
        StringBuffer path = new StringBuffer();
        if ( !requestContext.getPortalURL().isRelativeOnly() )
        {
            path.append(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getServerPort());
        }
        return requestContext.getResponse().encodeURL(path.append(request.getContextPath()).append(request.getServletPath()).append(
                relativePath).toString());
    }
View Full Code Here

   
    @Override
    protected void doHeaders(RenderRequest request, RenderResponse response)
    {
        super.doHeaders(request, response);
        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
        Element headElem = response.createElement("script");
        headElem.setAttribute("language", "javascript");
        String scriptPath = rc.getRequest().getContextPath() + yuiScriptPath;
        headElem.setAttribute("id", HeaderPhaseSupportConstants.HEAD_ELEMENT_CONTRIBUTION_ELEMENT_ID_YUI_LIBRARY_INCLUDE);
        headElem.setAttribute("src", scriptPath);
        headElem.setAttribute("type", "text/javascript");
        response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, headElem);
    }
View Full Code Here

            }
        }
       
        try
        {
            RequestContext requestContext = (RequestContext) actionRequest.getAttribute(RequestContext.REQUEST_PORTALENV);
            ContentPage contentPage = requestContext.getPage();
           
            String spacePath = space.getPath();
            String contentPagePath = contentPage.getPath();
            String contentFolderPath = StringUtils.defaultIfEmpty(StringUtils.substringBeforeLast(contentPagePath, "/"), "/");
            String nodeName = name.replace(' ', '_');
            String nodePath = null;
           
            if (contentFolderPath.startsWith(spacePath))
            {
                nodePath = StringUtils.removeEnd(contentFolderPath, "/") + "/" + StringUtils.removeStart(nodeName, "/");
            }
            else
            {
                nodePath = StringUtils.removeEnd(spacePath, "/") + "/" + StringUtils.removeStart(nodeName, "/");
            }
           
            if (Page.DOCUMENT_TYPE.equals(type))
            {
                String path = nodePath + Page.DOCUMENT_TYPE;
                Page source = pageManager.getPage(templatePage);
                Page newPage = pageManager.copyPage(source, path, false);
                newPage.setTitle(name);
                pageManager.updatePage(newPage);
               
                requestContext.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, null);
               
                String redirect = admin.getPortalURL(actionRequest, actionResponse, path);
                actionResponse.sendRedirect(redirect);
            }
            else if (Folder.FOLDER_TYPE.equals(type))
            {
                String path = nodePath;
                Folder folder = pageManager.newFolder(path);
                folder.setTitle(name);
                pageManager.updateFolder(folder);
               
                String defaultPagePath = folder.getPath() + "/" + Folder.FALLBACK_DEFAULT_PAGE;
                Page source = pageManager.getPage(templatePage);
                Page newPage = pageManager.copyPage(source, defaultPagePath, false);
                pageManager.updatePage(newPage);
               
                requestContext.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, null);
            }
            else if (Link.DOCUMENT_TYPE.equals(type))
            {
                String path = nodePath + Link.DOCUMENT_TYPE;
                Link link = pageManager.newLink(path);
                link.setTitle(name);
                pageManager.updateLink(link);
               
                requestContext.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, null);
            }
        }
        catch (Exception e)
        {
            log.error("Failed to update page.", e);
View Full Code Here

    {
        List<MenuElement> spaceMenuElements = null;
       
        try
        {
            RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
            PortalSiteRequestContext psrc = (PortalSiteRequestContext) rc.getAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);

            Menu spaceMenu = null;
           
            String menuName = request.getPreferences().getValue("Menu", defaultMenu);
           
View Full Code Here

    {
        List<MenuElement> spaceLinkMenuElements = null;
       
        try
        {
            RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
            PortalSiteRequestContext psrc = (PortalSiteRequestContext) rc.getAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);

            Menu spaceLinksMenu = null;
           
            String linksMenuName = request.getPreferences().getValue("LinkMenu", defaultLinksMenu);
           
View Full Code Here

        if (templateLocator == null)
        {
            return templateLocation + PATH_SEPARATOR + templateName;
        }

        RequestContext requestContext = (RequestContext) request
                .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
        Locale locale = request.getLocale();

        try
        {
            LocatorDescriptor locator = templateLocator.createLocatorDescriptor("email");
            locator.setName(templateName);
            locator.setMediaType(requestContext.getMediaType());
            locator.setLanguage(locale.getLanguage());
            locator.setCountry(locale.getCountry());
            TemplateDescriptor template = templateLocator.locateTemplate(locator);

            return template.getAppRelativePath();
View Full Code Here

     * @see org.apache.portals.applications.webcontent.portlet.WebContentPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
     */
    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
    {
        // portal request context
        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);

        // default page view rendering
        String viewPage = (String)request.getAttribute(PARAM_VIEW_PAGE);
        if (viewPage != null)
        {
            super.doView(request, response);
            return;
        }

        // get source web content URL, parameters, and method to view
        String sourceURL = null;
        Map sourceParams = null;
        boolean sourcePostMethod = false;
        WebContentHistoryPage webContentPage = (WebContentHistoryPage)PortletMessaging.receive(request, getClass().getName());
        if (webContentPage != null)
        {
            // view rewritten action URL page
            sourceURL = webContentPage.getUrl();
            sourceParams = webContentPage.getParams();
            sourcePostMethod = webContentPage.isPost();           
        }
        else
        {
            // load and validate preferences, (base url and portal base path
            // should both end in a "/" path separator to ensure that relative
            // urls in the content resolve predictably)
            String baseURL = request.getPreferences().getValue("SRC", null);
            String portalBasePath = request.getPreferences().getValue("PORTALPATH", null);
            if ((baseURL == null) || (portalBasePath == null))
            {
                throw new PortletException("Required SRC and PORTALPATH preferences not set");
            }
            if (!baseURL.endsWith("/"))
            {
                baseURL += "/";
            }
            if (!portalBasePath.startsWith("/"))
            {
                portalBasePath = "/"+portalBasePath;
            }       
            if (!portalBasePath.endsWith("/"))
            {
                portalBasePath += "/";
            }       
            // view content page based on portal request URL
            String portalRequestPath = rc.getPath();
            if (!portalRequestPath.startsWith(portalBasePath))
            {
                throw new PortletException("Unable to map portal request path: "+portalRequestPath+" onto portal base path: "+portalBasePath);
            }
            sourceURL = baseURL+portalRequestPath.substring(portalBasePath.length());           
        }

        // get web content
        byte[] content = null;
        try
        {
            // initialize and lock stateful rewriter
            String basePortalPath = rc.getPortalURL().getPageBasePath();
            initializeRewriter(DynamicWebContentRewriter.class);
            ((DynamicWebContentRewriter)getRewriter()).setBasePortalPath(basePortalPath);
       
            // get and rewrite web content
            if (log.isDebugEnabled())
            {
                log.debug("Portal request: "+rc.getPath()+", Web content: "+sourceURL);
            }
            try
            {
                content = doWebContent(sourceURL, sourceParams, sourcePostMethod, request, response);
            }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.request.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.