Package org.apache.jetspeed.portal

Examples of org.apache.jetspeed.portal.PortletConfig


    /** Initialize the content of the portlet
    */
    public void init() throws PortletException {

        PortletConfig config = this.getPortletConfig();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            // RL: disable the SAX filter due to a class path problem
            // with Tomcat 3.2
            /*
            String url = JetspeedDiskCache.getInstance().getEntry( config.getURL() ).getURL();

            WMLFilter myFilter = new WMLFilter(new PrintWriter(bos));
            myFilter.filter(url);
            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();
View Full Code Here


            {
                continue;
            }           

            String mstate = p.getAttribute("_menustate", null, rundata);
            PortletConfig pc= p.getPortletConfig();
            if (mstate == null && pc != null)
            {
                mstate = pc.getInitParameter("_menustate", "open");
            }
           
            if (mstate.equals("closed"))
            {
                continue;
View Full Code Here

    */
    public int getPadding() {
        int padding = 0;

        try {
            PortletConfig conf = getPortlets().getPortletConfig();
            padding =  Integer.parseInt( conf.getSkin( "padding" , String.valueOf( DEFAULT_PADDING ) ) );
        } catch ( RuntimeException e ) {
            logger.error("Exception getting padding value", e);
            padding = DEFAULT_PADDING;
        }

View Full Code Here

    /**
    Sets the padding space to be put between portlets
    */
    public void setPadding(int padding) {
        try {
            PortletConfig conf = getPortlets().getPortletConfig();
            conf.setSkin( "padding" , String.valueOf( padding ) );
        } catch ( RuntimeException e ) {
            logger.error("Exception setting padding value", e);
            // FIXME: What should we do if there's no portlets, config or skin defined ?
        }

View Full Code Here

    /**
    Sets the padding space to be put between portlets
    */
    public void setPadding(String padding) {
        try {
            PortletConfig conf = getPortlets().getPortletConfig();
            conf.setSkin( "padding" , padding );
        } catch ( RuntimeException e ) {
            logger.error("Exception setting padding value", e);
            // FIXME: What should we do if there's no portlets, config or skin defined ?
        }
    }
View Full Code Here

    */
    public static String getConfigParameter(Portlet portlet,
                                            String attrName,
                                            String attrDefaultValue)
    {
        PortletConfig pc = portlet.getPortletConfig();
        return pc.getInitParameter(attrName, attrDefaultValue);
    }
View Full Code Here

    }

    public ConcreteElement getContent(RunData rundata)
    {       
        JetspeedRunData jrun = (JetspeedRunData) rundata;
        PortletConfig pc = this.getPortletConfig();

        CapabilityMap map = jrun.getCapability();
       
        StringBuffer text = new StringBuffer();
       
        String mimeType = map.getPreferredType().toString();

        if (this.supportsType(map.getPreferredType()))
        {
            text.append("Supports preferred MimeType: " + mimeType);
        }
        else
        {
            text.append("Doesn't support preferred MimeType: " + mimeType);
        }
       

        // **** getPortletConfig().getInitParameter() example
        //String greeting = getPortletConfig ().getInitParameter ("greeting");
        //text.append(greeting);
        text.append("<BR/>"); // bad bad bad

        String name = rundata.getUser().getFirstName();
        if (name == null)
            name ="Anonymous";
        text.append (name);
        text.append ("!");

        text.append("<BR/>"); // bad bad bad

        text.append("Portlet id = " + this.getID());
        text.append("<BR/>"); // bad bad bad
        text.append("Init Parameter (version): " + pc.getInitParameter("version", "NOT FOUND!"));       
        text.append("<BR/>"); // bad bad bad
        text.append("Page Attribute (city): " + this.getAttribute("city", "NOT FOUND!", rundata));
        text.append("<BR/>"); // bad bad bad

        switch (jrun.getMode())
View Full Code Here

        if ((p == null) || (changeRequested == false))
        {
            doCancel(rundata, context);
            return;
        }
        PortletConfig pc = p.getPortletConfig();
        Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
        Entry entry = profile.getDocument().getEntryById(p.getID());

        // Only update the security ref if the parent changed
        if ((newSecurityParent != null))
        {
            boolean securityChanged = false;
            SecurityReference currentSecurityRef = pc.getSecurityRef();
            if (currentSecurityRef != null)
            {
                securityChanged =
                    (newSecurityParent.equals(currentSecurityRef.getParent())
                        == false);
            }
            else
            {
                securityChanged = (newSecurityParent.trim().length() > 0);
            }
            if (securityChanged == true)
            {
                SecurityReference securityRef = null;
                if ((newSecurityParent.trim().length() > 0))
                {
                    securityRef = new BaseSecurityReference();
                    securityRef.setParent(newSecurityParent);
                }
                // Note: setting the portlet's config may not be a good idea -
                // it might be used as the Portlet for other PSMLDocument Entries that
                // have a different idea of security - and the caching of Portlets does
                // NOT include security -ggolden.
                pc.setSecurityRef(securityRef);
                entry.setSecurityRef(securityRef);
                madePcChange = true;
            }
        }

        // Only update the skin if the name changed
        if (newSkinName != null)
        {
            boolean skinChanged = false;
            String currentSkinName = null;

            if (pc.getSkin() != null)
                currentSkinName = pc.getPortletSkin().getName();

            if (currentSkinName != null)
            {
                skinChanged = (newSkinName.equals(currentSkinName) == false);
            }
            else
            {
                skinChanged = (newSkinName.trim().length() > 0);
            }

            if (skinChanged == true)
            {
                PortletSkin skin = null;
                if ((newSkinName.trim().length() > 0))
                {
                    skin = PortalToolkit.getSkin(newSkinName);
                    if (skin != null)
                    {
                        // Note: setting the portlet's config may not be a good idea -
                        // it might be used as the Portlet for other PSMLDocument Entries that
                        // have a different idea of skin - and the caching of Portlets does
                        // NOT include skin -ggolden.
                        pc.setPortletSkin(skin);

                        Skin psmlSkin = entry.getSkin();
                        if (psmlSkin == null)
                        {
                            entry.setSkin(new PsmlSkin());
                        }
                        entry.getSkin().setName(newSkinName);
                    }
                    else
                    {
                        logger.warn(
                            "Unable to update skin for portlet entry "
                                + entry.getId()
                                + " because skin "
                                + skin
                                + " does not exist.");
                    }
                }
                else
                {
                    // Note: setting the portlet's config may not be a good idea -
                    // it might be used as the Portlet for other PSMLDocument Entries that
                    // have a different idea of skin - and the caching of Portlets does
                    // NOT include skin -ggolden.
                    pc.setPortletSkin(null);
                    entry.setSkin(null);
                }
                madePcChange = true;
            }
        }

        // Only update the title if the title changed
        if (newTitle != null)
        {
            boolean titleChanged = false;
            String currentTitle = entry.getTitle();

            MetaData md = pc.getMetainfo();
            if (currentTitle == null && md != null && md.getTitle() != null)
                currentTitle = md.getTitle();

            if (currentTitle != null)
            {
                titleChanged = (newTitle.equals(currentTitle) == false);
            }
            else
            {
                titleChanged = (newTitle.trim().length() > 0);
            }

            if (titleChanged == true)
            {

                if ((newTitle.trim().length() > 0))
                {
                    // Note: setting the portlet's config may not be a good idea -
                    // it might be used as the Portlet for other PSMLDocument Entries that
                    // have a different idea of title - and the caching of Portlets does
                    // NOT include title -ggolden.
                    if (md == null)
                    {
                        md = new MetaData();
                        pc.setMetainfo(md);
                    }
                    md.setTitle(newTitle);
                    entry.setTitle(newTitle);
                    madePcChange = true;
                }
View Full Code Here

    @return the newly created PortletConfig object
    */
    protected PortletConfig getPortletConfig(Portlets portlets)
    {

        PortletConfig pc = new BasePortletConfig();

        pc.setName(portlets.getName());
        pc.setInitParameters(getParameters(portlets));

        //Invocation of new skin-locating algorithim
        pc.setPortletSkin(getSkin(findSkin(portlets)));

        pc.setSecurityRef(portlets.getSecurityRef());
        pc.setMetainfo(getMetaData(portlets));

        return pc;
    }
View Full Code Here

        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
        pc.getInitParameters().putAll(getParameters(entry));
        pc.setPortletSkin( PortalToolkit.getSkin( entry.getSkin() ) );
        pc.setSecurityRef( getSecurityReference(entry, regEntry));

        return getPortlet( getClassname(regEntry), pc, entry.getId() );
    }
View Full Code Here

TOP

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

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.