Package org.apache.ecs

Examples of org.apache.ecs.ConcreteElement


     * @param id The portlet id
     * @return the rendered content of the portlet
     */
    public ConcreteElement getPortalElement(String id)
    {
        ConcreteElement result = null;
       
        if (null != rundata)
        {
            Profile profile = rundata.getProfile();
            try
View Full Code Here


     * @param peid the peid of the portlet to render
     * @return the rendered content of the portlet
     */
    public ConcreteElement getPortletById(String peid)
    {
        ConcreteElement result = null;
        Portlet found = null;
        Stack sets = new Stack();
        sets.push(rundata.getProfile().getRootSet());
       
        while ((sets.size() > 0) && (found==null))
        {
            PortletSet set = (PortletSet)sets.pop();
           
            if (set.getID().equals(peid))
            {
                found = set;
            }
            else
            {
                Enumeration en = set.getPortlets();
                while((found==null) && en.hasMoreElements())
                {
                    Portlet p = (Portlet)en.nextElement();
                       
                    // unstack the controls to find the real PortletSets
                    Portlet real = p;
                    while (real instanceof PortletControl)
                    {
                        real = ((PortletControl)p).getPortlet();
                    }
                       
                    if (real instanceof PortletSet)
                    {
                        // we'll explore this set afterwards
                        sets.push(real);
                    }
                    else if (p.getID().equals(peid))
                    {                       
                        found = p;
                    }
                }
            }
        }
       
        if (found!=null)
        {
            // Return portlet's content checking the security first
            result = PortletWrapper.wrap(found).getContent(rundata);
        }
       
        if (result==null)
        {
            //the customizer already streamed its content, return a stub
            result = new ConcreteElement();
        }

        return result;
    }
View Full Code Here

     * @return the rendered content of the portlet
     */
    public ConcreteElement getPortletFromRegistry(RunData data)
    {

        ConcreteElement result = null;
        Portlet p = null;
        String portletName = data.getParameters().getString("p");
        String controlName = data.getParameters().getString("c");
       
        try
        {

            // Retrieve registry entry
            PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, portletName);

            // Verify security for the parameter
            boolean canAccess = JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(),
                                                                 new PortalResource(entry),
                                                                 JetspeedSecurity.PERMISSION_CUSTOMIZE);

            if (canAccess)
            {
                // Always set portlet id to "preview" so each preview request gets it from the cache.
                // At least, I think that's how it works.
                p = PortletFactory.getPortlet(portletName, "preview");
                PortletControl control = controlName == null ? PortalToolkit.getControl((String) null)
                                                             : PortalToolkit.getControl(controlName);
                if (control != null)
                {
                    JetspeedRunData jdata = (JetspeedRunData) rundata;
                    // Use the profile's skin
                    p.getPortletConfig().setPortletSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
                    control.setPortlet(p);
                    control.init();
                    result = control.getContent(rundata);
                }
                else if (p != null)
                {
                    result = p.getContent(rundata);
                }
            }
            else
            {
                result = new JetspeedClearElement(Localization.getString(data, "SECURITY_NO_ACCESS_TO_PORTLET"));
            }
        }
        catch (Exception e)
        {
            logger.error("Exception",  e);
            result = new ConcreteElement();
        }
               
        if (result == null)
        {
            //the customizer already streamed its content, return a stub
            result = new ConcreteElement();
        }

        return result;
    }
View Full Code Here

     * @deprecated Do not use this method because it's not secure. It will be removed after Beta 5.
     */
    public ConcreteElement getPortletFromRegistry(String portletName, String controlName)
    {

        ConcreteElement result = null;
        Portlet p = null;
       
        try
        {
            // Always set portlet id to "preview" so each preview request gets it from the cache.
            // At least, I think that's how it works.
            p = PortletFactory.getPortlet(portletName, "preview");
            PortletControl control = controlName == null ? PortalToolkit.getControl((String) null)
                                                         : PortalToolkit.getControl(controlName);
            if (control != null)
            {
                JetspeedRunData jdata = (JetspeedRunData) rundata;
                // Use the profile's skin
                p.getPortletConfig().setPortletSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
                control.setPortlet(p);
                control.init();
                result = control.getContent(rundata);
            }
            else if (p != null)
            {
                result = p.getContent(rundata);
            }
        }
        catch (Exception e)
        {
            logger.error("Exception",  e);
            result = new ConcreteElement();
        }
               
        if (result == null)
        {
            //the customizer already streamed its content, return a stub
            result = new ConcreteElement();
        }

        return result;
    }
View Full Code Here

    */
    public ConcreteElement getContent( RunData rundata )
    {

        CapabilityMap map = ((JetspeedRunData)rundata).getCapability();
        ConcreteElement content = null;

        if ( MimeType.WML.equals( map.getPreferredType() ) )
        {
            content = getWMLContent( portlets, rundata );
        }
View Full Code Here

        Context context = TurbineVelocity.getContext(rundata);
        context.put( "data", rundata);
        TurbineVelocity.getContext(rundata).put("jetspeed", new org.apache.jetspeed.util.template.JetspeedTool(rundata));

        ConcreteElement result = null;
        String controlName = rundata.getParameters().getString("previewedControlName");
        String portletName = rundata.getParameters().getString("previewedPortletName");
        if ( portletName == null )
        {
            JetspeedLink jsLink = null;

            try
            {
                jsLink = JetspeedLinkFactory.getInstance(rundata);
                rundata.setRedirectURI(
                    jsLink.setUser(
                        rundata.getUser().getUserName(), "default.psml")
                    .addPathInfo("template", "Customize")
                    .addPathInfo("media-type", "html")
                    .toString()
                    );
                JetspeedLinkFactory.putInstance(jsLink);
                jsLink = null;
                return new JetspeedClearElement("");
            } catch (Exception e)
            {
                logger.error("Exception",  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);
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

                                       boolean allowRecurse ) {

        CapabilityMap mymap = map;
        if ( mymap == null ) mymap = CapabilityMapFactory.getCapabilityMap( rundata );

        ConcreteElement element = (ConcreteElement)content.get( mymap.toString() );

        if ( element == null ) {
            if ( allowRecurse ) {
                try {
                    // init will put content under default cmap
View Full Code Here

    /**
    */
    public void init() throws PortletException
    {
        PortletConfig pc = getPortletConfig();
        ConcreteElement myContent = null;
        try
        {
            screen = ( String ) pc.getInitParameter( SCREEN );
            //if it is null here it should be in the parameters
            if ( screen == null )
View Full Code Here

    {
        JetspeedRunData data = (JetspeedRunData) pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
       
        try
        {
            ConcreteElement result = null;
            Profile baseProfile = null;
            ProfileLocator baseLocator = Profiler.createLocator();
            int rootType = JetspeedLink.DEFAULT;
            String rootValue = null;
            int elementType = JetspeedLink.DEFAULT;
View Full Code Here

TOP

Related Classes of org.apache.ecs.ConcreteElement

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.