Package org.apache.jetspeed.portal

Examples of org.apache.jetspeed.portal.Portlet


    {

        //record the begining of the portlet creation
        long begin = System.currentTimeMillis();

        Portlet portlet = null;
        Class portletClass = null;
        String handle = null;
       
        try
        {
            portletClass = Class.forName(classname);
        }
        catch (Exception e)
        {
            throw new PortletException( "PortletFactory: Unable to load class " + classname );
        }
       
        if (enableCache)
        {
            try
            {
                // try to invoke a static getHandle() for this class
                Class[] signatureParams = { Object.class };
                Object[] methodParams = { pc };
                handle = (String)portletClass.getMethod("getHandle",signatureParams)
                                             .invoke(null,methodParams);
                // make sure the handle is differenciated by class
                handle = String.valueOf(classname.hashCode())+handle;
            }
            catch (NoSuchMethodException e)
            {
                // ignore, this simply means the portlet is not cacheable
            }
            catch (Exception e)
            {
                // invocation failed or security exception, in both case
                // log the error and treat the class as non cacheable
                logger.error("PortletFactory: failed to get cache handle",e);
            }
        }
       
        try {

            if (enableCache && (handle != null))
            {
                portlet = (Portlet)PortletCache.getCacheable( handle );

                //portlet in cache but expired, remove it from cache
                if ((portlet!=null) && ((Cacheable)portlet).getExpire().isExpired() )
                {
                    logger.info( "The portlet (" + handle + ") is expired" );
                    PortletCache.removeCacheable(handle);
                    if ( logger.isDebugEnabled() )
                    {
                        logger.debug( "After removal of object(" + handle + ")." );
                    }
                    portlet = null;
                }
            }

            // we found a portlet in the cache
            if ( (portlet != null)
                 && ( portlet instanceof Cacheable )
                 && (! ((Cacheable)portlet).getExpire().isExpired()) )
            {
                // update the config for the portlet to the current one
                // Note: this is what was used to find the cached portlet.
                // Note: the init params may have changed in the psml since caching,
                //       this will update the portlet to use them.
                portlet.setPortletConfig( pc );
                portlet.setID( id );
                portlet.setName( pc.getName() );

                //FIXME: we now avoid to override metainfo when nothing is set
                //in the markup, so that cached portlets can keep their metainfo
                //This may lead to an incorrect metainfo retrieved if the first
                //instance of the portlet, which is put in the cache, has some
                //special metainfo defined in the markup

                MetaData meta = pc.getMetainfo();
               
                if ( meta != null)
                {

                    if (! MetaData.DEFAULT_TITLE.equals( meta.getTitle() ) )
                    {
                        portlet.setTitle( meta.getTitle() );
                    }
   
                    if (! MetaData.DEFAULT_DESCRIPTION.equals( meta.getDescription() ) )
                    {
                        portlet.setDescription( meta.getDescription() );
                    }
                }

                //FIXME: Notice here we are putting the portlet without wrapper
                //in the cache, and we must wrap it on return.
                //Security implications: the portletcache should not be
                //publicly accessible.
                //Alternative: we could wrap the portlet before putting
                //it in the cache.

                //now compute the time it took to instantate and log it...
                // time in millis, sugested by Thomas Schaeck (schaeck@de.ibm.com)
                long milliseconds = ( System.currentTimeMillis() - begin );
       
                if (logger.isDebugEnabled())
                    logger.debug( "PortletFactory.getPortlet(): found in cache in "
                        + milliseconds + " ms - handle: " + handle );

                return PortletWrapper.wrap( portlet );
            }

            // if not found in the cache, instanciate a new Portlet
            portlet = (Portlet)portletClass.newInstance();

        }
        catch ( Throwable t )
        {
            logger.error("Throwable", t);
            throw new PortletException( t.getMessage() );
        }

        // save the current meta-info
        String title = null;
        String description = null;
        MetaData metainfo = pc.getMetainfo();
       
        if ( metainfo != null ) {
            title=metainfo.getTitle();
            description=metainfo.getDescription();
        }
       
       
        // init the portlet, it may override its PSML defined markup if
        // it doesn't check for it
        portlet.setID( id );
        portlet.setName( pc.getName() );
        portlet.setPortletConfig( pc );
        portlet.setCreationTime( System.currentTimeMillis() );
        portlet.init();

        //force the title and description from markup metadata
        //in case the portlet overwrote some values

        if ( metainfo != null)
        {
            if (!MetaData.DEFAULT_TITLE.equals(title) )
            {
                portlet.setTitle( title );
            }

            if (!MetaData.DEFAULT_DESCRIPTION.equals(description) )
            {
                portlet.setDescription( description );
            }
        }

        if (enableCache && (portlet instanceof Cacheable))
        {
View Full Code Here


        PanedPortletController cont = (PanedPortletController)controller;
       
        PortletSet myPortlets = cont.getPortlets();
        PortletControllerConfig conf = cont.getConfig();

        Portlet portlet = null;
        String paneID = null;
        String paneName = rundata.getParameters().getString( JetspeedResources.PATH_PANENAME_KEY );

        if (null != paneName)       
        {
            portlet = myPortlets.getPortletByName(paneName);
            if (portlet != null)
            {
                paneID = portlet.getID();
                rundata.getParameters().setString(JetspeedResources.PATH_PANEID_KEY, paneID);
            }
        }

        if (null == portlet)
        {
            paneID = cont.retrievePaneID(rundata, true);
            portlet = myPortlets.getPortletByID(paneID);
            if (null == portlet)
            {
                paneID = cont.retrievePaneID(rundata, false);
                portlet = myPortlets.getPortletByID(paneID);
            }
        }

        if (portlet != null)
            context.put("pane", portlet);       
       
        if(!portlet.getAttribute("_menustate", "open", rundata).equals("closed"))
        {  
            cont.savePaneID(rundata, paneID);
        }
    }   
View Full Code Here

        Iterator eItr = portlets.getEntriesIterator();
        while(eItr.hasNext())
        {
            Object obj =  eItr.next();
            Entry entry = (Entry)obj;
            Portlet portlet = PortletFactory.getPortlet(entry);
            entries.add(new JetspeedPortletInstance(portlet, profile));
        }
       
        //Now if there are child levels, drill down recursively
        if(portlets.getPortletsCount() > 0)
View Full Code Here

                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();
View Full Code Here

     
        //see if any or the Portlets you want to add have a larger column or
        //row number than that defined in PSML
        while ( en.hasMoreElements() ) {

            Portlet portlet = (Portlet)en.nextElement();

            calculateControllerLayout( portlet );
           
        }

        setWidth( pc.getLayout( "width", getWidth() ) );

        int rows = getRow();
        int cols = getColumn();

        if (0 == rows || 0 == cols)
            return base; // empty container

        Table t = new Table()
                       .setWidth( this.getWidth() )
                       .setCellPadding( this.getPadding() )
                       .setAlign("center");

        base.addElement( t );

        ElementContainer[][] elements = new ElementContainer[rows][cols];

        for( int i = 0; i < rows; i++ )  {
            for ( int j = 0 ; j < cols; j++ ) {
                elements[i][j]=new ElementContainer();
            }
        }

        // populate the elements array
        en = portlets.getPortlets();
        while (en.hasMoreElements() ) {

            Portlet p = (Portlet)en.nextElement();
            PortletConfig pConf = p.getPortletConfig();

            Integer colObj = pConf.getConstraints().getColumn();
            Integer rowObj = pConf.getConstraints().getRow();
            int colnum = (colObj!=null)?colObj.intValue():0;
            int rownum = (rowObj!=null)?rowObj.intValue():0;

            elements[rownum % rows][colnum % cols]
                .addElement( p.getContent( rundata ) );

        }

        // build the table
View Full Code Here

        // Name of the button.
        String theButton = null;
       
        // Portlet whom this action is a target of
        Portlet portlet = (Portlet) context.get(GenericMVCPortlet.PORTLET);

        // ParameterParser.
        ParameterParser pp = data.getParameters();
        String button = pp.convert(BUTTON);
View Full Code Here

     */
    public void doUpdate(RunData rundata, Context context)
    {
        String pageSize = null;

        Portlet portlet = (Portlet) context.get("portlet");
        if (portlet != null)
        {
            String peid = portlet.getID();
            if ((peid != null)
                && peid.equals(rundata.getParameters().getString(PEID)))
            {
                pageSize = rundata.getParameters().getString(PAGE_SIZE);
            }
View Full Code Here

     * @param rundata
     * @param context The velocity context for this request.
     */
    public void doRefresh(RunData rundata, Context context)
    {
        Portlet portlet = (Portlet) context.get("portlet");
        PortletSessionState.clearAttribute(portlet, rundata, PROFILE_ITERATOR);
        PortletSessionState.clearAttribute(portlet, rundata, LAST_SEARCH_TYPE);
        PortletSessionState.clearAttribute(portlet, rundata, LAST_SEARCH_VALUE);
        rundata.getParameters().remove(FILTER_VALUE);
        buildNormalContext(portlet, context, rundata);
View Full Code Here

    {
        // Is filtering requested?
        int filterType = rundata.getParameters().getInt(FILTER_TYPE, QueryLocator.QUERY_ALL);
        String filterValue = rundata.getParameters().getString(FILTER_VALUE, null);

        Portlet portlet = (Portlet) context.get("portlet");

        performSearch(rundata, portlet, filterType, filterValue);

        buildNormalContext(portlet, context, rundata);
    }
View Full Code Here

        {
            logger.warn("Failed to get PEID (" + peid + ") entry for User ("
              + rundata.getUser().getName() + ")");
            return;
        }
        Portlet portlet = PortletFactory.getPortlet(entry);
       
        // Now unset the portlet to minimized
        if (( portlet != null )&&( portlet instanceof PortletState ))
        {
            ((PortletState)portlet).setMinimized( false, rundata );
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.portal.Portlet

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.