Package org.apache.jetspeed.portal

Examples of org.apache.jetspeed.portal.PortletException


        Node channel = null;
        NodeList list = this.document.getElementsByTagName("channel");

        if (list.getLength() != 1)
        {
            throw new PortletException(ERROR_NOT_VALID);
        }

        channel = list.item(0);

        Node tn = getNode( channel, "title" );

        if ( tn == null ) {
            throw new PortletException( ERROR_NOT_VALID );
        }
        else
        {
            Node fc = tn.getFirstChild();
            if (fc != null)
View Full Code Here


            initDone = true;
        }
        catch (Exception e)
        {
            logger.info("Exception occurred:" + e.toString(), e);
            throw new PortletException( e.toString() );
        }
    }
View Full Code Here

        }
        catch (Exception e)
        {
            logger.info("Exception occurred:" + e.toString());
            e.printStackTrace();
            throw new PortletException(e.toString());
        }
    }
View Full Code Here

            String message = "RSSPortlet:  Couldn't parse out XML document -> " +
                              url;

            logger.error( message, t );
            throw new PortletException( t.getMessage() );

        }

        //SGP giving NullPointer
        try {
            //now that we have the document set the items for this

            this.setItems( this.parseItems( document ) );

            String title = null;
            String description = null;

            //this a hack until DOM2 namespace support becomes better in Xerces.
            Node root = document.getFirstChild();
            //now find the channel node.
            Node channel = null;

            NodeList list = document.getElementsByTagName( "channel" );

            if ( list.getLength() != 1 ) {
                throw new PortletException( ERROR_NOT_VALID );
        }

            channel = list.item( 0 );

            Node tn = getNode( channel, "title" );

            if ( tn == null ) {
                throw new PortletException( ERROR_NOT_VALID );
            } else {
                title = tn.getFirstChild().getNodeValue();
            }

            Node dn = getNode( channel, "description" );

            if ( dn != null ) {
                description = dn.getFirstChild().getNodeValue();
            }

            this.setTitle( title );
            this.setDescription( description );


            //now that we have the DOM we should be able to do a transform here.

            String stylesheet = this.getPortletConfig().getInitParameter( "stylesheet" );

            if ( stylesheet == null ) {
                throw new PortletException( "The 'stylesheet' parameter was not defined." );
        }

            try {
                //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 ) {
                logger.error("Exception",  e);
                throw new PortletException( e.getMessage() );
            }
        } catch (Throwable t) {
            String message = "RSSPortlet:  Couldn't set items for XML document -> " +
                url;


            logger.error( message, t );
            throw new PortletException( t.getMessage() );
        }


    }
View Full Code Here

            contentStale = true;
            initDone = true;
        } catch (Exception e) {
            logger.info("Exception occurred:" + e.toString());
            e.printStackTrace();
            throw new PortletException( e.toString() );
        }
    }
View Full Code Here

            content = new JetspeedClearElement( bos.toString() );
            */
            content = new JetspeedClearElement(
                JetspeedDiskCache.getInstance().getEntry( config.getURL() ).getData() );
        } catch (Exception e) {
            throw new PortletException( e.getMessage() );
        } finally {
            try {
                bos.close();
            } catch (IOException e) {}
        }
View Full Code Here

    {
        PortletEntry regEntry = (PortletEntry)Registry.getEntry(Registry.PORTLET,
                                                                entry.getParent() );
        if (regEntry == null)
        {
            throw new PortletException("PortletFactory: unknown portlet entry in Registry: "+entry.getParent());
        }
       
        if (PortletEntry.TYPE_ABSTRACT.equals(regEntry.getType()))
        {
            throw new PortletException("PortletFactory: can't instanciate abstract registry entry: "+regEntry.getName());
        }
           
        PortletConfig pc = getPortletConfig(regEntry, entry.getId());

        // Set portlet config with values from PSML Entry
View Full Code Here

    {
        PortletEntry regEntry = (PortletEntry)Registry.getEntry(Registry.PORTLET, name );

        if (regEntry == null)
        {
            throw new PortletException("PortletFactory: unknown portlet entry in Registry: "+name);
        }
       
        if (PortletEntry.TYPE_ABSTRACT.equals(regEntry.getType()))
        {
            throw new PortletException("PortletFactory: can't instanciate abstract registry entry: "+name);
        }
           
        PortletConfig pc = getPortletConfig(regEntry, id);
       
        return getPortlet( getClassname(regEntry), pc, null );
View Full Code Here

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

            content = new JetspeedClearElement( bos.toString() );
            */
            content = new JetspeedClearElement(
                JetspeedDiskCache.getInstance().getEntry( config.getURL() ).getData() );
        } catch (Exception e) {
            throw new PortletException( e.getMessage() );
        } finally {
            try {
                bos.close();
            } catch (IOException e) {}
        }
View Full Code Here

TOP

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

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.