Package org.apache.jetspeed.portal

Examples of org.apache.jetspeed.portal.PortletException


        }
        catch (Exception e)
        {
            logger.error("Exception in init()", e);
            throw new PortletException(e.getMessage());
        }
    }
View Full Code Here


            }

            //if it is still null something is wrong
            if ( screen == null )
            {
                throw new PortletException( "You need to specify a " + SCREEN + " parameter for this portlet" );
            }

            /* Save the parameters if any */
            String param = null;
            String value = null;
            java.util.Map dict = pc.getInitParameters();
            Iterator en = dict.keySet().iterator();
            int index = -1;
            String tParam = screen + ".param";
            String newParam = null;
            paramSet = new Hashtable();
            while ( en.hasNext() )
            {
                param = ( String ) en.next();
                index = param.indexOf( tParam );
                if ( index != -1 )
                {
                    value = ( String ) dict.get( param );
                    if ( value == null )
                    {
                        throw new PortletException( "Could not retrieve value for " + param );
                    }
                    newParam = param.substring( index + tParam.length() + 1 );
                    paramSet.put( newParam, value );
                }
            }
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 (!DEFAULT_TITLE.equals( meta.getTitle() ) )
                    {
                        portlet.setTitle( meta.getTitle() );
                    }
   
                    if (!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

        PortletConfig config = this.getPortletConfig();
       
        provider = config.getInitParameter( PROVIDER_NAME_KEY );
       
        if ( provider == null ) {
            throw new PortletException( "You need to specify " + PROVIDER_NAME_KEY );
        }

        //NOTE:  There are no HARD keys here in JetspeedResources.  If you change
        //this format of this it will break at runtime.  CAREFULL!
       
        this.url = JetspeedResources.getString( "content.provider." + provider + ".url" );
       
        this.stylesheet = JetspeedResources.getString( "content.provider." + provider + ".stylesheet.url" );
       
        String title = JetspeedResources.getString( "content.provider." + provider + ".title" );

        String description = JetspeedResources.getString( "content.provider." + provider + ".description" );

        this.setTitle( title );
        this.setDescription( description );
      
        this.setContent( this.parse( url ) );
           
        //now make sure all the above 4 values are define within JetspeedResources
        if ( url == null ||
             stylesheet == null ||
             title == null ||
             description == null ) {
            throw new PortletException( "Not all properties defined in JetspeedResources.  See JetspeedResources.properties notes." );
        }
       
        this.getPortletConfig().setURL( url );
       
        //set the last modification date for this file so that if it is
View Full Code Here

        this.stylesheet = JetspeedDiskCache.getInstance()
            .getEntry( this.stylesheet ).getURL();
        } catch (IOException e) {
            logger.error( "Couldn't transform content.", e );
            throw new PortletException( "Couldn't transform content.  Please see error log" );
        }

       
        try {
           
            return new JetspeedClearElement( SimpleTransform.transform( url, stylesheet ) );
           
        } catch (SAXException e) {
            logger.error( "Couldn't transform content.", e );
            throw new PortletException( "Couldn't transform content.  Please see error log" );
        }

      
    }
View Full Code Here

        catch (Throwable t)
        {

            String message = "XSLViewProcessor:  Couldn't parse out XML document -> " + url;
            logger.error(message, t);
            throw new PortletException(t.getMessage());
        }

    }
View Full Code Here

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

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


    }
View Full Code Here

        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
        {
            Node fc = tn.getFirstChild();
            if (fc != null)
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.