Package org.exoplatform.portal.pom.spi.portlet

Examples of org.exoplatform.portal.pom.spi.portlet.PortletBuilder


   public void testWindowScopedPortletPreferences() throws Exception
   {
      Page page = new Page();
      page.setPageId("portal::test::foo");
      TransientApplicationState<Portlet> state = new TransientApplicationState<Portlet>("web/BannerPortlet", new PortletBuilder().add("template", "bar").build());
      Application<Portlet> app = Application.createPortletApplication();
      app.setState(state);
      page.getChildren().add(app);
      storage_.save(page);
      page = storage_.getPage(page.getPageId());
View Full Code Here


      // Check instance id format
      assertEquals("web/BannerPortlet", storage_.getId(banner1.getState()));

      // Check state
      Portlet pagePrefs = storage_.load(instanceId, ApplicationType.PORTLET);
      assertEquals(new PortletBuilder().add("template", "par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl")
         .build(), pagePrefs);

      // Now save the cloned page
      storage_.save(clone);

      // Get cloned page
      clone = storage_.getPage("portal::test::_test4");
      assertEquals(2, clone.getChildren().size());
      banner1 = (Application<Portlet>)clone.getChildren().get(0);
      instanceId = banner1.getState();

      // Check instance id format
      assertEquals("web/BannerPortlet", storage_.getId(banner1.getState()));

      // Update site prefs
      PortletPreferences sitePrefs = new PortletPreferences();
      sitePrefs.setWindowId("portal#test:/web/BannerPortlet/banner");
      sitePrefs.setPreferences(new ArrayList<Preference>(Collections.singleton(new Preference())));
      sitePrefs.getPreferences().get(0).setName("template");
      sitePrefs.getPreferences().get(0).getValues().add("bar");
      storage_.save(sitePrefs);

      // Check that page prefs have not changed
      pagePrefs = storage_.load(instanceId, ApplicationType.PORTLET);
      assertEquals(new PortletBuilder().add("template", "par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl")
         .build(), pagePrefs);

      // Update page prefs
      pagePrefs.setValue("template", "foo");
      storage_.save(instanceId, pagePrefs);

      // Check that page prefs have changed
      pagePrefs = storage_.load(instanceId, ApplicationType.PORTLET);
      assertEquals(new PortletBuilder().add("template", "foo").build(), pagePrefs);

      // Check that site prefs have not changed
      sitePrefs = storage_.getPortletPreferences("portal#test:/web/BannerPortlet/banner");
      assertEquals("bar", sitePrefs.getPreferences().get(0).getValues().get(0));
View Full Code Here

            "src/test/resources/jibx/portlet-application.xml"), null);
      TransientApplicationState portletState = (TransientApplicationState)app.getState();
      assertNotNull(portletState);
      assertEquals("web/BannerPortlet", portletState.getContentId());
      Portlet preferences = (Portlet)portletState.getContentState();
      assertEquals(new PortletBuilder().add("template", "template_value").build(), preferences);
   }
View Full Code Here

      Application<Portlet> app = (Application<Portlet>)page.getChildren().get(0);
      PersistentApplicationState<Portlet> state = (PersistentApplicationState)app.getState();

      //
      Portlet prefs = storage_.load(state, ApplicationType.PORTLET);
      assertEquals(new PortletBuilder().add("template", "par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl")
         .build(), prefs);

      //
      prefs.setValue("template", "someanothervalue");
      storage_.save(state, prefs);

      //
      prefs = storage_.load(state, ApplicationType.PORTLET);
      assertNotNull(prefs);
      assertEquals(new PortletBuilder().add("template", "someanothervalue").build(), prefs);
   }
View Full Code Here

      storage_.save(state, prefs);

      //
      prefs = storage_.load(state, ApplicationType.PORTLET);
      assertNotNull(prefs);
      assertEquals(new PortletBuilder().add("template", "").build(), prefs);
   }
View Full Code Here

            assertEquals("test5", clone.getName());

            //
            Application<Portlet> app = (Application<Portlet>)clone.getChildren().get(0);
            Portlet prefs2 = storage_.load(app.getState(), ApplicationType.PORTLET);
            assertEquals(new PortletBuilder().add("template",
               "par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl").build(), prefs2);

            // Update prefs of original page
            PortletPreferences prefs = new PortletPreferences();
            prefs.setWindowId("portal#test:/web/BannerPortlet/banner");
            storage_.save(prefs);

            //
            prefs2 = storage_.load(app.getState(), ApplicationType.PORTLET);
            assertEquals(new PortletBuilder().add("template",
               "par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl").build(), prefs2);
         }
      }.execute(null);
   }
View Full Code Here

        // Portlet name
        requiresSibling(navigator, Element.PORTLET_REF);
        String portletRef = getRequiredContent(navigator, true);

        // Preferences
        PortletBuilder portletBuilder = null;
        if (navigator.sibling() == Element.PREFERENCES) {
            requiresChild(navigator, Element.PREFERENCE);
            portletBuilder = new PortletBuilder();
            for (StaxNavigator<Element> fork : navigator.fork(Element.PREFERENCE)) {
                // Preference name
                requiresChild(fork, Element.NAME);
                String prefName = getRequiredContent(fork, false);

                // Preference values
                List<String> values = null;
                while (fork.sibling() == Element.PREFERENCE_VALUE) {
                    if (values == null)
                        values = new ArrayList<String>();
                    values.add(getContent(fork, false));
                }
                if (values == null) {
                    values = Collections.singletonList(null);
                }

                // Preference readonly
                Boolean readOnly = null;
                if (fork.getName() == Element.PREFERENCE_READONLY) {
                    readOnly = parseRequiredContent(fork, ValueType.BOOLEAN);
                }

                // Ensure nothing is left.
                if (fork.next() != null) {
                    throw unexpectedElement(fork);
                }

                if (readOnly == null) {
                    portletBuilder.add(prefName, values);
                } else {
                    portletBuilder.add(prefName, values, readOnly);
                }
            }
        }

        TransientApplicationState<Portlet> state = new TransientApplicationState<Portlet>(applicationRef + "/" + portletRef);
        if (portletBuilder != null) {
            state.setContentState(portletBuilder.build());
        }

        return state;
    }
View Full Code Here

                  {
                     c.destroy();
                  }
                  customization =
                     page.getCustomizationContext().customize(a, Portlet.CONTENT_TYPE, applicationName + "/" + portletName,
                        new PortletBuilder().build());
               }
               else
               {
                  Customization c = site.getCustomizationContext().getCustomization(instanceName);
                  if (c != null)
                  {
                     c.destroy();
                  }
                  customization =
                     site.getCustomizationContext().customize(instanceName, Portlet.CONTENT_TYPE, applicationName + "/" + portletName,
                        new PortletBuilder().build());
               }
            }
         }

         //
         if (customization != null)
         {
            PortletBuilder builder = new PortletBuilder();
            ArrayList<Preference> list = prefs.getPreferences();
            if (list != null)
            {
               for (Preference pref : list)
               {
                  builder.add(pref.getName(), pref.getValues(), pref.isReadOnly());
               }
            }
            customization.setState(builder.build());
         }
         else
         {
            session.addPortletPreferences(prefs);
         }
View Full Code Here

         String applicationName = ctx.parseElementText(m_uri, "application-ref");
         String portletName = ctx.parseElementText(m_uri, "portlet-ref");
         TransientApplicationState<Portlet> state;
         if (ctx.isAt(m_uri, "preferences"))
         {
            PortletBuilder builder = new PortletBuilder();
            ctx.parsePastStartTag(m_uri, "preferences");
            while (ctx.isAt(m_uri, "preference"))
            {
               Preference value = (Preference)ctx.unmarshalElement();
               builder.add(value.getName(), value.getValues(), value.isReadOnly());
            }
            ctx.parsePastEndTag(m_uri, "preferences");
            state = new TransientApplicationState<Portlet>(applicationName + "/" + portletName, builder.build());
         }
         else
         {
            state = new TransientApplicationState<Portlet>(applicationName + "/" + portletName, null);
         }
View Full Code Here

      {
         throw new AssertionError("That should not happen");
      }

      //
      PortletBuilder builder = new PortletBuilder();

      //
      ctx.parsePastStartTag(m_uri, m_name);
      while (ctx.isAt(m_uri, "preference"))
      {
         Preference value = (Preference)ctx.unmarshalElement();
         builder.add(value.getName(), value.getValues(), value.isReadOnly());
      }
      ctx.parsePastEndTag(m_uri, m_name);

      //
      return builder.build();
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.portal.pom.spi.portlet.PortletBuilder

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.