Package org.apache.jetspeed.portlet.webcontent

Examples of org.apache.jetspeed.portlet.webcontent.WebContentHistoryList


        if (browserAction != null)
        {
            if (!browserAction.equalsIgnoreCase(BROWSER_ACTION_REFRESH_PAGE))
            {
                // for Refresh, there is nothing special to do - current history page will be re-displayed
                WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(actionRequest, HISTORY);
               
                if (browserAction.equalsIgnoreCase(BROWSER_ACTION_PREVIOUS_PAGE))
                {
                    if (history.hasPreviousPage())
                        history.getPreviousPage();
                }
                else if (browserAction.equalsIgnoreCase(BROWSER_ACTION_NEXT_PAGE))
                {
                    if (history.hasNextPage())
                        history.getNextPage();
                }
            }
           
            return ;   // proceed to doView() with adjusted history
        }
       
        // Check if an action parameter was defined       
        String webContentURL = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_URL);
        String webContentMethod = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_METHOD);
        Map webContentParams = new HashMap(actionRequest.getParameterMap()) ;
       
        // defaults
        if (webContentMethod == null) webContentMethod = "" ;   // default to GET
       
        // parameter map includes the URL (as ACTION_PARAMETER_URL), but all actual params as well
        webContentParams.remove(WebContentRewriter.ACTION_PARAMETER_URL);
        webContentParams.remove(WebContentRewriter.ACTION_PARAMETER_METHOD);
       
        if (webContentURL == null || actionRequest.getPortletMode() == PortletMode.EDIT)
        {
            processPreferencesAction(actionRequest, actionResponse);           
            webContentURL = actionRequest.getPreferences().getValue("SRC", "http://portals.apache.org");

            // parameters are for the EDIT mode form, and should not be propagated to the subsequent GET in doView
            webContentParams.clear();
        }

        /*
         * If the webContentParameter is not empty attach the URL to the session
         */
        if (webContentURL != null && webContentURL.length() > 0)
        {
            // new page visit - make it the current page in the history
            WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(actionRequest, HISTORY);
            if (history == null)
                history = new WebContentHistoryList();
            history.visitPage(new WebContentHistoryPage(webContentURL,webContentParams,webContentMethod));
            PortletMessaging.publish(actionRequest, HISTORY, history);
        }
    }
View Full Code Here


            super.doView(request, response);
            return;
        }
       
        // view the current page in the history
        WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(request, HISTORY);
        if (history == null)
            history = new WebContentHistoryList();
        WebContentHistoryPage currentPage = history.getCurrentPage();
        if (currentPage == null)
        {
            String sourceURL = request.getPreferences().getValue("SRC", "");
            if (sourceURL == null)
            {
                // BOZO - switch to edit mode automatically here, instead of throwing exception!
                throw new PortletException("WebContent source not specified. Go to edit mode and specify an URL.");
            }
            currentPage = new WebContentHistoryPage(sourceURL);
        }

        // Initialize the controller if it's not already done
        if (rewriteController == null)
        {
            PortletContext portletApplication = getPortletContext();
            String path = portletApplication.getRealPath("/WEB-INF");
            String contextPath = path + "/";
            try
            {
                // Create rewriter adaptor
                rewriteController = getController(contextPath);
            }
            catch (Exception e)
            {
                // Failed to create rewriter controller
                String msg = "WebContentPortlet failed to create rewriter controller.";
                log.error(msg,e);
                throw new PortletException(e.getMessage());
            }
        }

        // get content from current page
        response.setContentType("text/html");
        byte[] content = doWebContent(currentPage.getUrl(), currentPage.getParams(), currentPage.isPost(), request, response);
        // System.out.println("Rewritten content is\n..."+new String(content));
       
        // write the meta-control navigation header
        PrintWriter writer = response.getWriter();
        writer.print("<block>");
        if (history.hasPreviousPage())
        {
            PortletURL prevAction = response.createActionURL() ;
            prevAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_PREVIOUS_PAGE);
            writer.print(" [<a href=\"" + prevAction.toString() +"\">Previous Page</a>] ");
        }
        PortletURL refreshAction = response.createActionURL() ;
        refreshAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_REFRESH_PAGE);
        writer.print(" [<a href=\"" + refreshAction.toString() +"\">Refresh Page</a>] ");
        if (history.hasNextPage())
        {
            PortletURL nextAction = response.createActionURL() ;
            nextAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_NEXT_PAGE);
            writer.print(" [<a href=\"" + nextAction.toString() +"\">Next Page</a>] ");
        }
        writer.print("</block><hr/>");

        // drain the stream to the portlet window
        ByteArrayInputStream bais = new ByteArrayInputStream(content);
        drain(new InputStreamReader(bais, WebContentPortlet.defaultEncoding), writer);
        bais.close();
       
        // done, cache results in the history and save the history
        history.visitPage(currentPage);
        PortletMessaging.publish(request, HISTORY, history);
    }
View Full Code Here

        if (browserAction != null)
        {
            if (!browserAction.equalsIgnoreCase(BROWSER_ACTION_REFRESH_PAGE))
            {
                // for Refresh, there is nothing special to do - current history page will be re-displayed
                WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(actionRequest, HISTORY);
               
                if (browserAction.equalsIgnoreCase(BROWSER_ACTION_PREVIOUS_PAGE))
                {
                    if (history.hasPreviousPage())
                        history.getPreviousPage();
                }
                else if (browserAction.equalsIgnoreCase(BROWSER_ACTION_NEXT_PAGE))
                {
                    if (history.hasNextPage())
                        history.getNextPage();
                }
            }
           
            return ;   // proceed to doView() with adjusted history
        }
       
        // Check if an action parameter was defined       
        String webContentURL = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_URL);
        String webContentMethod = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_METHOD);
        Map webContentParams = new HashMap(actionRequest.getParameterMap()) ;
       
        // defaults
        if (webContentMethod == null) webContentMethod = "" ;   // default to GET
       
        // parameter map includes the URL (as ACTION_PARAMETER_URL), but all actual params as well
        webContentParams.remove(WebContentRewriter.ACTION_PARAMETER_URL);
        webContentParams.remove(WebContentRewriter.ACTION_PARAMETER_METHOD);
       
        if (webContentURL == null || actionRequest.getPortletMode() == PortletMode.EDIT)
        {
            processPreferencesAction(actionRequest, actionResponse);           
            webContentURL = actionRequest.getPreferences().getValue("SRC", "http://portals.apache.org");

            // parameters are for the EDIT mode form, and should not be propagated to the subsequent GET in doView
            webContentParams.clear();
        }

        /*
         * If the webContentParameter is not empty attach the URL to the session
         */
        if (webContentURL != null && webContentURL.length() > 0)
        {
            // new page visit - make it the current page in the history
            WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(actionRequest, HISTORY);
            if (history == null)
                history = new WebContentHistoryList();
            history.visitPage(new WebContentHistoryPage(webContentURL,webContentParams,webContentMethod));
            PortletMessaging.publish(actionRequest, HISTORY, history);
        }
    }
View Full Code Here

            super.doView(request, response);
            return;
        }
       
        // view the current page in the history
        WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(request, HISTORY);
        if (history == null)
            history = new WebContentHistoryList();
        WebContentHistoryPage currentPage = history.getCurrentPage();
        if (currentPage == null)
        {
            String sourceURL = request.getPreferences().getValue("SRC", "");
            if (sourceURL == null)
            {
                // BOZO - switch to edit mode automatically here, instead of throwing exception!
                throw new PortletException("WebContent source not specified. Go to edit mode and specify an URL.");
            }
            currentPage = new WebContentHistoryPage(sourceURL);
        }

        // Initialize the controller if it's not already done
        if (rewriteController == null)
        {
            PortletContext portletApplication = getPortletContext();
            String path = portletApplication.getRealPath("/WEB-INF");
            String contextPath = path + "/";
            try
            {
                // Create rewriter adaptor
                rewriteController = getController(contextPath);
            }
            catch (Exception e)
            {
                // Failed to create rewriter controller
                String msg = "WebContentPortlet failed to create rewriter controller.";
                log.error(msg,e);
                throw new PortletException(e.getMessage());
            }
        }

        // get content from current page
        response.setContentType("text/html");
        byte[] content = doWebContent(currentPage.getUrl(), currentPage.getParams(), currentPage.isPost(), request, response);
        // System.out.println("Rewritten content is\n..."+new String(content));
       
        // write the meta-control navigation header
        PrintWriter writer = response.getWriter();
        writer.print("<block>");
        if (history.hasPreviousPage())
        {
            PortletURL prevAction = response.createActionURL() ;
            prevAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_PREVIOUS_PAGE);
            writer.print(" [<a href=\"" + prevAction.toString() +"\">Previous Page</a>] ");
        }
        PortletURL refreshAction = response.createActionURL() ;
        refreshAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_REFRESH_PAGE);
        writer.print(" [<a href=\"" + refreshAction.toString() +"\">Refresh Page</a>] ");
        if (history.hasNextPage())
        {
            PortletURL nextAction = response.createActionURL() ;
            nextAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_NEXT_PAGE);
            writer.print(" [<a href=\"" + nextAction.toString() +"\">Next Page</a>] ");
        }
        writer.print("</block><hr/>");

        // drain the stream to the portlet window
        ByteArrayInputStream bais = new ByteArrayInputStream(content);
        drain(new InputStreamReader(bais, WebContentPortlet.defaultEncoding), writer);
        bais.close();
       
        // done, cache results in the history and save the history
        history.visitPage(currentPage);
        PortletMessaging.publish(request, HISTORY, history);
    }
View Full Code Here

        if (browserAction != null)
        {
            if (!browserAction.equalsIgnoreCase(BROWSER_ACTION_REFRESH_PAGE))
            {
                // for Refresh, there is nothing special to do - current history page will be re-displayed
                WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(actionRequest, HISTORY);
               
                if (browserAction.equalsIgnoreCase(BROWSER_ACTION_PREVIOUS_PAGE))
                {
                    if (history.hasPreviousPage())
                        history.getPreviousPage();
                }
                else if (browserAction.equalsIgnoreCase(BROWSER_ACTION_NEXT_PAGE))
                {
                    if (history.hasNextPage())
                        history.getNextPage();
                }
            }
           
            return ;   // proceed to doView() with adjusted history
        }
       
        // Check if an action parameter was defined       
        String webContentURL = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_URL);
        String webContentMethod = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_METHOD);
        Map webContentParams = new HashMap(actionRequest.getParameterMap()) ;
       
        // defaults
        if (webContentMethod == null) webContentMethod = "" ;   // default to GET
       
        // parameter map includes the URL (as ACTION_PARAMETER_URL), but all actual params as well
        webContentParams.remove(WebContentRewriter.ACTION_PARAMETER_URL);
        webContentParams.remove(WebContentRewriter.ACTION_PARAMETER_METHOD);
       
        if (webContentURL == null || actionRequest.getPortletMode() == PortletMode.EDIT)
        {
            processPreferencesAction(actionRequest, actionResponse);           
            webContentURL = actionRequest.getPreferences().getValue("SRC", "http://portals.apache.org");

            // parameters are for the EDIT mode form, and should not be propagated to the subsequent GET in doView
            webContentParams.clear();
        }

        /*
         * If the webContentParameter is not empty attach the URL to the session
         */
        if (webContentURL != null && webContentURL.length() > 0)
        {
            // new page visit - make it the current page in the history
            WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(actionRequest, HISTORY);
            if (history == null)
                history = new WebContentHistoryList();
            history.visitPage(new WebContentHistoryPage(webContentURL,webContentParams,webContentMethod));
            PortletMessaging.publish(actionRequest, HISTORY, history);
        }
    }
View Full Code Here

            super.doView(request, response);
            return;
        }
       
        // view the current page in the history
        WebContentHistoryList history = (WebContentHistoryList)PortletMessaging.receive(request, HISTORY);
        if (history == null)
            history = new WebContentHistoryList();
        WebContentHistoryPage currentPage = history.getCurrentPage();
        if (currentPage == null)
        {
            String sourceURL = request.getPreferences().getValue("SRC", "");
            if (sourceURL == null)
            {
                // BOZO - switch to edit mode automatically here, instead of throwing exception!
                throw new PortletException("WebContent source not specified. Go to edit mode and specify an URL.");
            }
            currentPage = new WebContentHistoryPage(sourceURL);
        }

        // Initialize the controller if it's not already done
        if (rewriteController == null)
        {
            PortletContext portletApplication = getPortletContext();
            String path = portletApplication.getRealPath("/WEB-INF");
            String contextPath = path + "/";
            try
            {
                // Create rewriter adaptor
                rewriteController = getController(contextPath);
            }
            catch (Exception e)
            {
                // Failed to create rewriter controller
                String msg = "WebContentPortlet failed to create rewriter controller.";
                log.error(msg,e);
                throw new PortletException(e.getMessage());
            }
        }

        // get content from current page
        response.setContentType("text/html");
        byte[] content = doWebContent(currentPage.getUrl(), currentPage.getParams(), currentPage.isPost(), request, response);
        // System.out.println("Rewritten content is\n..."+new String(content));
       
        // write the meta-control navigation header
        PrintWriter writer = response.getWriter();
        writer.print("<block>");
        if (history.hasPreviousPage())
        {
            PortletURL prevAction = response.createActionURL() ;
            prevAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_PREVIOUS_PAGE);
            writer.print(" [<a href=\"" + prevAction.toString() +"\">Previous Page</a>] ");
        }
        PortletURL refreshAction = response.createActionURL() ;
        refreshAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_REFRESH_PAGE);
        writer.print(" [<a href=\"" + refreshAction.toString() +"\">Refresh Page</a>] ");
        if (history.hasNextPage())
        {
            PortletURL nextAction = response.createActionURL() ;
            nextAction.setParameter(BROWSER_ACTION_PARAM, BROWSER_ACTION_NEXT_PAGE);
            writer.print(" [<a href=\"" + nextAction.toString() +"\">Next Page</a>] ");
        }
        writer.print("</block><hr/>");

        // drain the stream to the portlet window
        ByteArrayInputStream bais = new ByteArrayInputStream(content);
        drain(new InputStreamReader(bais, this.defaultEncoding), writer);
        bais.close();
       
        // done, cache results in the history and save the history
        history.visitPage(currentPage);
        PortletMessaging.publish(request, HISTORY, history);
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.portlet.webcontent.WebContentHistoryList

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.