Package org.apache.jetspeed.om.registry

Examples of org.apache.jetspeed.om.registry.PortletEntry


                assertNotNull(fragment);
                Vector portlets = fragment.getPortlets();

                // test abstract

                PortletEntry rss = (PortletEntry) portlets.elementAt(1);
                assertNotNull(rss);
                assertTrue(rss.getName().equals("RSS"));
                assertTrue(!rss.isHidden());
                assertTrue(rss.getType().equals("abstract"));
                assertNull(rss.getParent());
                assertTrue(!rss.isApplication());
                assertTrue(rss.getClassname().equals("org.apache.jetspeed.portal.portlets.NewRSSPortlet"));
                // params
                Iterator it = rss.getParameterNames();
                HashMap mapParams = new HashMap();
                while (it.hasNext())
                {
                    String name = (String) it.next();
                    Parameter p = rss.getParameter(name);
                    assertNotNull(p);
                    //System.out.println("PARAM:" + p.getName() + " = " + p.getValue());
                    mapParams.put(p.getName(), p);
                }
                assertTrue(mapParams.containsKey("showtitle"));
                assertTrue(mapParams.containsKey("stylesheet"));
                assertTrue(mapParams.containsKey("itemdisplayed"));

                // test ref
                PortletEntry hack = (PortletEntry) portlets.elementAt(2);
                assertNotNull(hack);
                assertTrue(hack.getName().equals("XMLHack"));
                assertTrue(hack.isHidden());
                assertTrue(hack.getType().equals("ref"));
                assertTrue(hack.getParent().equals("RSS"));
                assertTrue(!hack.isApplication());
                assertTrue(hack.getTitle().equals("XMLHack Title"));
                assertTrue(hack.getDescription().equals("XMLHack Description"));
                assertTrue(hack.getMetaInfo().getTitle().equals("XMLHack Title"));
                assertTrue(hack.getMetaInfo().getDescription().equals("XMLHack Description"));
                assertTrue(hack.getClassname().equals("org.apache.jetspeed.portal.portlets.NewRSSPortlet"));

                mapParams.clear();
                it = hack.getParameterNames();
                while (it.hasNext())
                {
                    String name = (String) it.next();
                    Parameter p = hack.getParameter(name);
                    assertNotNull(p);
                    //System.out.println("HACK PARAM:" + p.getName() + " = " + p.getValue());
                    mapParams.put(p.getName(), p);
                }
                assertTrue(mapParams.containsKey("showtitle"));
                assertTrue(mapParams.containsKey("stylesheet"));
                assertTrue(mapParams.containsKey("itemdisplayed"));
                assertTrue(mapParams.containsKey("HACK"));
                Parameter p = (Parameter) mapParams.get("HACK");
                assertTrue(p.getValue().equals("hacker"));
                Parameter p2 = (Parameter) mapParams.get("showtitle");
                MetaInfo p2m = p2.getMetaInfo();
                assertTrue(p2m.getTitle().equals("Show title description ?"));
                assertTrue(p2.getTitle().equals("Show title description ?"));
                Map pMap = hack.getParameterMap();
                String v15 = (String) pMap.get("itemdisplayed");
                assertTrue(v15.equals("15"));

                // test falling back on meta info

                PortletEntry mp = (PortletEntry) portlets.elementAt(5);
                assertNotNull(mp);
                assertTrue(mp.getName().equals("MetaTest"));
                assertTrue(mp.getType().equals("ref"));
                assertTrue(mp.getParent().equals("AdminScreen"));
                assertTrue(mp.getClassname().equals("org.apache.jetspeed.portal.portlets.TurbineScreenPortlet"));
                String title = mp.getTitle();
                assertNotNull(title);
                assertTrue(title.equals("Turbine Screen in a portlet"));
                assertTrue(mp.getDescription().equals("We put the Admin Screen in a portlet."));
                MetaInfo meta = mp.getMetaInfo();
                assertNotNull(meta);
                assertTrue(mp.getMetaInfo().getTitle().equals("Turbine Screen in a portlet"));
                assertTrue(meta.getDescription().equals("We put the Admin Screen in a portlet."));

                // media type
                Iterator mpi = mp.listMediaTypes();
                assertNotNull(mpi);
                HashMap mpMap = new HashMap();
                while (mpi.hasNext())
                {
                    String s = (String) mpi.next();
                    mpMap.put(s, s);
                }
                assertTrue(mpMap.containsKey("html"));
                assertTrue(mpMap.containsKey("wml"));
                assertTrue(mpMap.containsKey("xml"));
                assertTrue(mp.hasMediaType("wml"));

                PortletEntry mt = (PortletEntry) portlets.elementAt(6);
                assertNotNull(mt);
                assertTrue(mt.getName().equals("NoMediaType"));
                assertTrue(mt.getType().equals("ref"));
                Iterator mti = mt.listMediaTypes();
                assertNotNull(mti);
                assertTrue(mti.hasNext());
                String s = (String) mti.next();
                assertTrue(s.equals("html"));

                assertTrue(hack.getURL().equals("http://www.xmlhack.com/rss.php"));
                assertTrue(hack.isCachedOnURL());

                PortletEntry keytest = (PortletEntry) portlets.elementAt(7);
                assertNotNull(keytest);
                assertTrue(keytest.getName().equals("KeyTest"));
                assertTrue(keytest.getType().equals("ref"));
                it = keytest.getParameterNames();
                mpMap.clear();
                while (it.hasNext())
                {
                    String name = (String) it.next();
                    CachedParameter cp = keytest.getCachedParameter(name);
                    mpMap.put(cp.getName(), cp);
                    //System.out.println("param = " + cp.getName() + "," + cp.getValue());
                    //System.out.println("keys = " + cp.isCachedOnName() + "," + cp.isCachedOnValue());

                }
                assertTrue(keytest.isCachedOnURL() == false);
                CachedParameter cp = (CachedParameter) mpMap.get("newsid");
                assertNotNull(cp);
                assertTrue(cp.isCachedOnName() == false);
                assertTrue(cp.isCachedOnValue() == true);
                cp = (CachedParameter) mpMap.get("sportsid");
                assertNotNull(cp);
                assertTrue(cp.isCachedOnName() == true);
                assertTrue(cp.isCachedOnValue() == false);
                cp = (CachedParameter) mpMap.get("contact2");
                assertNotNull(cp);
                assertTrue(cp.isCachedOnName() == true);
                assertTrue(cp.isCachedOnValue() == true);
                cp = (CachedParameter) mpMap.get("showtitle");
                assertNotNull(cp);
                assertTrue(cp.isCachedOnName() == true);
                assertTrue(cp.isCachedOnValue() == true);

                // categories
                PortletEntry feeder = (PortletEntry) portlets.elementAt(3);
                assertNotNull(feeder);
                assertTrue(feeder.getName().equals("Feeder"));
                assertTrue(feeder.getType().equals("ref"));
                Iterator fi = feeder.listCategories();
                Category cat = (Category) fi.next();
                assertTrue(cat.getName().equals("news.world.politics"));
                assertTrue(cat.getGroup().equals("news"));
                assertTrue(feeder.hasCategory("news.world.politics", "news"));
                feeder.addCategory("news.us.economy");
                assertTrue(feeder.hasCategory("news.us.economy"));
                feeder.removeCategory("news.us.economy");
                assertTrue(!feeder.hasCategory("news.us.economy"));
                /*
                Iterator fi = feeder.listCategories();
                    Category cat = (Category)fi.next();
                    System.out.println("cat = " + cat.getName());
                    System.out.println("cat.group = " + cat.getGroup());
View Full Code Here


                System.out.println("debug name  = " + names.nextElement());
            }
            boolean testAdd = true;
            if (testAdd)
            {           
                PortletEntry entry = (PortletEntry)Registry.createEntry(Registry.PORTLET);
                entry.setApplication(false);
                entry.setCachedOnURL(false);
                entry.setClassname("org.apache.jetspeed.portlets.BigKahunaPortlet");
                entry.setDescription("This is the big kahuna portlet");
                entry.setHidden(false);
                MetaInfo meta = new BaseMetaInfo();
                meta.setImage("/images/image.gif");
                meta.setDescription("This is the big kahuna meta portlet");
                meta.setTitle("The Meta Kahuna Portlet");
                entry.setMetaInfo(meta);
                entry.setName("BigKahuna");           
                entry.setParent(null);
                SecurityReference ref = new BaseSecurityReference();
                ref.setParent("admin-only");
                entry.setSecurityRef(ref);
                entry.setTitle("The Kahuna Portlet");
                entry.setType(PortletEntry.TYPE_ABSTRACT);               
                entry.setURL("http://bigkahuna.org");
                   
                // parameters
                entry.addParameter("simple", "simple-value");
               
                CachedParameter param = new BaseCachedParameter();
                param.setDescription("pdescription");
                param.setHidden(false);
                meta = new BaseMetaInfo();
                meta.setDescription("meta desc");
                meta.setImage("meta image");
                meta.setTitle("meta title");
                param.setMetaInfo(meta);
                param.setName("coconut");               
                SecurityReference ref2 = new BaseSecurityReference();
                ref2.setParent("admin-only");               
                param.setSecurityRef(ref2);
                param.setTitle("Coconut");
                param.setType("hmm");
                param.setValue("hawaii");
                entry.addParameter(param);
                param.setCachedOnName(true);
                param.setCachedOnValue(false);

               
                param = new BaseCachedParameter();
                param.setDescription("second pdescription");
                param.setHidden(true);
                meta = new BaseMetaInfo();
                meta.setDescription("second meta desc");
                meta.setImage("second meta image");
                meta.setTitle("second meta title");
                param.setMetaInfo(meta);
                param.setName("second coconut");
                SecurityReference ref3 = new BaseSecurityReference();
                ref3.setParent("second admin-only");               
                param.setSecurityRef(ref3);
                param.setTitle("second Coconut");
                param.setType("second hmm");
                param.setValue("second hawaii");
                entry.addParameter(param);
                param.setCachedOnName(false);
                param.setCachedOnValue(true);
               
                // media types
                entry.addMediaType("xml");
                entry.addMediaType("wml");
                entry.addMediaType("html");
                               
                Iterator it = entry.listMediaTypes();
                while (it.hasNext())
                {
                    System.out.println("media type = " + it.next());
                }
                // categories
                entry.addCategory("cat1", "group1");
                entry.addCategory("cat2", "group2");
                entry.addCategory("cat3", "group3");
               
               
                Registry.addEntry(Registry.PORTLET, (RegistryEntry)entry);
               
                // add a portlet ref
               
                PortletEntry pref = (PortletEntry)Registry.createEntry(Registry.PORTLET);
                pref.setParent("BigKahuna");
                pref.setName("BigKahunaRef");
                pref.setType(PortletEntry.TYPE_REF);
                Registry.addEntry(Registry.PORTLET, (RegistryEntry)pref);
               
            }
           
            PortletEntry pe = (PortletEntry)Registry.getEntry(Registry.PORTLET, "BigKahuna");
            assertNotNull(pe);
            assertPortlet(pe);
           
            pe.addCategory("cat4");
            pe.setDescription("new description");
            pe.addParameter("last", "lastvalue");
            pe.addMediaType("vml");
           
            Registry.saveEntry(Registry.PORTLET, (RegistryEntry)pe);
           
            PortletEntry pe2 = (PortletEntry)Registry.getEntry(Registry.PORTLET, "BigKahuna");
            assertNotNull(pe2);           
            assertPortlet2(pe2);

            PortletEntry pe3 = (PortletEntry)Registry.getEntry(Registry.PORTLET, "BigKahunaRef");
            assertNotNull(pe3);
            assertPortletRef(pe3);
            // Registry.removeEntry(Registry.PORTLET, "BigKahuna");
           
        }
View Full Code Here

        {
            logger.error("PortletEntryToDocHandler: invalid object type: " + o);
            return null;
        }

        PortletEntry portletEntry = (PortletEntry) o;
       
        HashMap fields = new HashMap();
        fields.put(PARENT, portletEntry.getParent());
        fields.put(TYPE, portletEntry.getType());
       
        result.setFields(fields);

        StringBuffer content = new StringBuffer();
        String title = portletEntry.getTitle();
        content.append(title == null ? portletEntry.getName() : title);
        content.append(" ");
        content.append(portletEntry.getDescription());
        content.append(" ");
        Iterator it = portletEntry.listCategories();
        while (it.hasNext())
        {
            Category cat = (Category) it.next();
            content.append(cat.getName());
            content.append(" ");
View Full Code Here

    /**
     */
    public boolean supportsType( MimeType mimeType )
    {
        PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET, getName() );
        String baseType = mimeType.toString();
        if (entry!=null)
        {
            Iterator i = entry.listMediaTypes();

            while(i.hasNext())
            {
                String name = (String)i.next();
                MediaTypeEntry media = (MediaTypeEntry)Registry.getEntry(Registry.MEDIA_TYPE, name);
View Full Code Here

     * @param id the PSML entry's portlet id    
     * @return an instanciated portlet corresponding to this entry
     */
    public Portlet getPortlet( Entry entry ) throws PortletException
    {
        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

     * @param name the name of a portlet in the registry
     * @return an instanciated portlet corresponding to this entry
     */
    public Portlet getPortlet( String name, String id ) throws PortletException
    {
        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);
View Full Code Here

        }

        if ( entry.getParent() != null )
        {

            PortletEntry parent = (PortletEntry)Registry
                .getEntry( Registry.PORTLET, entry.getParent() );

            if (parent != null)
            {
                MetaData parentData = getMetaData( parent );
View Full Code Here

     * @return PortletEntry Parent of Entry
     * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
     */
    protected static PortletEntry getParentEntry(PortletEntry entry)
    {
        PortletEntry result = null;
        String parent = entry.getParent();
        if (parent != null)
        {
            result = (PortletEntry) Registry.getEntry(Registry.PORTLET, parent);
        }
View Full Code Here

    protected String getClassname(PortletEntry entry)
    {
        String className = entry.getClassname();
        if (className == null)
        {
            PortletEntry parent = getParentEntry(entry);
            if (parent != null)
            {
              // We must walk up the hierarchy just to be safe
                className = getClassname(parent);
            }
View Full Code Here

     * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
     */
    protected void addParentInitParameters(PortletEntry entry, Map hash)
    {
        // Now map any parameters from the parent that the child does not have
        PortletEntry parent = getParentEntry(entry);
        if (parent != null)
        {
            Map parentMap = parent.getParameterMap();
            Iterator names = parent.getParameterNames();

            while (names.hasNext())
            {
                String key = (String) names.next();
                if (!hash.containsKey(key))
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.registry.PortletEntry

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.