Package org.apache.jetspeed.util

Examples of org.apache.jetspeed.util.JetspeedClearElement


                    .addPathInfo("media-type", "html")
                    .toString()
                    );
                JetspeedLinkFactory.putInstance(jsLink);
                jsLink = null;
                return new JetspeedClearElement("");
            } catch (Exception e)
            {
                Log.error(e);
                rundata.setScreenTemplate("Home");
                return new JetspeedClearElement("");
            }
            //return new JetspeedClearElement("You must specify portlet to preview using [previewedPortletName] parameter");
        }
        Portlet portlet = null;

        try
        {
            portlet = PortletFactory.getPortlet(portletName, "PreviewPortlet");
            PortletControl control = controlName == null ? PortalToolkit.getControl((String)null) :
                                     PortalToolkit.getControl(controlName);
            control = null;
            if ( control != null )
            {
                JetspeedRunData jdata = (JetspeedRunData)rundata;
                // Use the profile's skin
                //portlet.getPortletConfig().setSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
                control.setPortlet(portlet);
                control.init();
                result = control.getContent(rundata);
            }
            else if ( portlet != null )
            {
                result = portlet.getContent(rundata);
            }

            if ( result != null && !result.toString().equals("") )
            {
                /*String html =  result.toString();
                String currentURL = rundata.getRequest().getRequestURI();
                Log.debug("PreviewPortlet: currentURL = " + currentURL + " reader value = " + html);
                PreviewRewriter rewriter = new PreviewRewriter(currentURL, currentURL , currentURL, portletName);
                result = new JetspeedClearElement(rewriter.rewrite(new StringReader(html)));*/
            }
            else
            {
                // The portlet already streamed its content - return a stub
                result = new JetspeedClearElement("");
            }

        }
        catch ( Exception e )
        {
            Log.error(e);
            result = new JetspeedClearElement("This resource is temporarily unavailable");
        }

        rundata.setLayout("preview");
        return result;
    }
View Full Code Here


            path = this.getPortletConfig().getInitParameter("path");
        }

        if (null == path)
        {
            return new JetspeedClearElement("Path parameter not set");
        }

        ProfileLocator locator = Profiler.createLocator();
        locator.createFromPath(path);
        String id = locator.getId();

        try
        {
            Profile profile = Profiler.getProfile(locator);
            PSMLDocument doc = profile.getDocument();
            if (doc == null)
            {
                return null;
            }
            Portlets portlets = doc.getPortlets();
            //PortletContainer.aggregate(portlets);
            return new JetspeedClearElement("XXX Under Construction :)");
        }
        catch (Exception e)
        {
            Log.error( e );
            return new JetspeedClearElement("Error in aggregation portlet: " + e.toString());
        }
    }
View Full Code Here

            url = getPortletConfig().getURL();
            String content = JetspeedDiskCache.getInstance().getEntry( url ).getData();
           CapabilityMap xmap =
               CapabilityMapFactory.getCapabilityMap(CapabilityMapFactory.AGENT_XML);
            setContent( new JetspeedClearElement(content), xmap );
            InputSource isrc = new InputSource( this.cleanse( content ) );
            isrc.setSystemId( url );
            isrc.setEncoding("UTF-8");
            this.document = parser.parse( isrc );
View Full Code Here

    @return the content to be displayed to the user-agent
    */
    public ConcreteElement getContent( RunData data ) {
        CapabilityMap map = ((JetspeedRunData)data).getCapability();
        String type = map.getPreferredType().toString();
        ConcreteElement content = new JetspeedClearElement(INVALID_TYPE);
        String stylesheet = (String)stylesheets.get(type);

        if (stylesheet != null) {
            content = getContent( data, map );
            if ( content == null ) {
                try {
                    content = new JetspeedClearElement(
                        SimpleTransform.transform( this.document,
                                                   stylesheet,
                                                   this.params ) );
                    setContent( content, map );
                } catch ( SAXException e ) {
                    Log.error( e );
                    content = new JetspeedClearElement(e.getMessage());
                }
            }
        }
        else
        {
View Full Code Here

     */
    public Object processView(GenericMVCContext context)
      {

        // generate the content
        JetspeedClearElement element = null;
        String template = (String) context.get("template");
        Log.info("VelocityViewProcessor - processing " + template);

        try
          {

            if (-1 == template.indexOf(".vm"))
              {
                template = template + ".vm";
              }

            Log.info("VelocityViewProcessor - locating template - " +
                     ((RunData) context.get("data")).toString() + template);

            String templatePath = TemplateLocator.locatePortletTemplate(
                                          (RunData) context.get("data"),
                                          template);

            // need to add cache support
            Portlet portlet = (Portlet) context.get("portlet");
            RunData rundata = (RunData) context.get("data");
            long cachePeriod = -1;
            AbstractPortlet abstractPortlet = null;
            // STW: Safety net ;)
            if(portlet instanceof AbstractPortlet)
            {
              abstractPortlet =(AbstractPortlet) portlet;
              if(abstractPortlet.getExpirationMillis() != null)
              {
                cachePeriod = abstractPortlet.getExpirationMillis().longValue();
              }
            }
          
      if (cachePeriod > 0 && abstractPortlet != null)
      {
        String s = TurbineVelocity.handleRequest(context, templatePath);
        abstractPortlet.setExpirationMillis(
          cachePeriod + System.currentTimeMillis());
        element = new JetspeedClearElement(s);

      }
      else
      {
        TurbineVelocity.handleRequest(
          context, templatePath, rundata.getOut());
      }
           
           
          }
        catch (Exception e)
          {
            element = new JetspeedClearElement(e.toString());
            Log.error("VelocityViewProcessor - had problems handling request - " + e);
            e.printStackTrace();
          }

        TurbineVelocity.requestFinished(context);

        if (element == null)
          {
            element = new JetspeedClearElement("");
          }

        return element;
      }
View Full Code Here

        {
            if (PortletStats.isEnabled())
            {
                PortletStats.logAccess(rundata, this, PortletStats.ACCESS_DENIED);
            }
            return new JetspeedClearElement(Localization.getString("SECURITY_NO_ACCESS_TO_PORTLET"));
        }
    }
View Full Code Here

    }

    /**
    */
    protected void setContent( String content ) {
        this.setContent( new JetspeedClearElement( content ),
                         CapabilityMapFactory.getDefaultCapabilityMap() );
    }
View Full Code Here

        CapabilityMap mymap = map;
        if ( mymap == null ) {
            mymap = CapabilityMapFactory.getDefaultCapabilityMap();
        }

        ConcreteElement buffer = new JetspeedClearElement( content.toString( ) );
        this.content.put( mymap.toString(), buffer );
    }
View Full Code Here

                    if( element != null ) {
                        // now we put it under our cmap
                        this.setContent( element, mymap );
                    }
                } catch (Exception e) {
                    element = new JetspeedClearElement("Error when retrieving Portlet contents");
                }
            } else {
                if( element == null ) {
                    //FIXME: Let's asume that the contents under "default" map are good
                    mymap = CapabilityMapFactory.getDefaultCapabilityMap();
                    element = (ConcreteElement)content.get( mymap.toString() );
                    if( element == null ) {
                        element = new JetspeedClearElement("Unknown Problem getting Contents");
                    }
                }
            }
        }
View Full Code Here

                //Set encoding for the document to utf-8...
                String content = SimpleTransform.transform( document,
                                                            stylesheet,
                                                            this.getPortletConfig().getInitParameters() );

                this.setContent( new JetspeedClearElement( content ) );


            } catch ( SAXException e ) {
                Log.error( e );
                throw new PortletException( e.getMessage() );
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.util.JetspeedClearElement

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.