Examples of MutablePortletEntity


Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    while (it.hasNext())
    {
      JSEntity entity = (JSEntity)it.next();
      if (pd != null)
      {
          MutablePortletEntity portletEntity = entityAccess.getPortletEntity(entity.getId());
          if (portletEntity == null)
          {
              portletEntity = entityAccess.newPortletEntityInstance(pd, entity.getId());
              try
              {
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

        Mock mockf1 = new Mock(Fragment.class);
        mockf1.expects(new InvokeAtLeastOnceMatcher()).method("getName").will(new ReturnStub(pd.getUniqueName()));
        mockf1.expects(new InvokeAtLeastOnceMatcher()).method("getId").will(new ReturnStub(TEST_ENTITY));
        ContentFragment f1 = new ContentFragmentTestImpl((Fragment) mockf1.proxy(), new HashMap());

        MutablePortletEntity entity = entityAccess
                .generateEntityFromFragment(new ContentFragmentTestImpl(f1, new HashMap()));
        PreferenceSetComposite prefs = (PreferenceSetComposite) entity.getPreferenceSet();
        prefs.remove("pref1");
        assertNotNull(prefs);
        assertNull(prefs.get("pref1"));

        // test adding a pref
        prefs.add("pref1", Arrays.asList(new String[]
        { "1" }));
        assertNotNull(prefs.get("pref1"));

        // Remove should return the deleted pref
        assertNotNull(prefs.remove("pref1"));

        // Should be gone
        assertNull(prefs.get("pref1"));

        // Add it back so we can test tole back
        prefs.add("pref1", Arrays.asList(new String[]
        { "1" }));

        entityAccess.storePortletEntity(entity);

        prefs = (PreferenceSetComposite) entity.getPreferenceSet();

        assertNotNull(prefs.get("pref1"));

        PreferenceComposite pref = (PreferenceComposite) prefs.get("pref1");

        assertEquals("1", pref.getValueAt(0));

        pref.setValueAt(0, "2");

        assertEquals("2", pref.getValueAt(0));

        entity.reset();

        pref = (PreferenceComposite) prefs.get("pref1");

        assertEquals("1", pref.getValueAt(0));

        prefs.remove(pref);

        assertNull(prefs.get("pref1"));

        entity.reset();

        assertNotNull(prefs.get("pref1"));

        prefs.add("pref2", Arrays.asList(new String[]
        { "2", "3" }));

        entity.store();

        PreferenceComposite pref2 = (PreferenceComposite) prefs.get("pref2");

        assertNotNull(pref2);

        Iterator prefsValues = pref2.getValues();
        int count = 0;
        while (prefsValues.hasNext())
        {
            prefsValues.next();
            count++;
        }

        assertEquals(2, count);

        pref2.addValue("4");
        prefsValues = pref2.getValues();
        count = 0;
        while (prefsValues.hasNext())
        {
            assertEquals(String.valueOf(count + 2), prefsValues.next());
            count++;
        }
        assertEquals(3, count);

        entity.reset();

        prefsValues = pref2.getValues();
        count = 0;
        while (prefsValues.hasNext())
        {
            assertEquals(String.valueOf(count + 2), prefsValues.next());
            count++;
        }
        assertEquals(2, count);

        // testing preferences null values assignments fix, issue JS2-607
        pref2.setValueAt(0, null);       
        assertNull("pref2.value[0] should be null", pref2.getValueAt(0));       
        String[] values = pref2.getValueArray();
        assertEquals(2, values.length);
        assertNull("pref2.value[0] should be null", values[0]);
        assertEquals("3", values[1]);
        pref2.setValues(new String[]{"2",null,"3"});
        assertNull("pref2.value[1] should be null", pref2.getValueAt(1));
        values = pref2.getValueArray();
        assertEquals(3, values.length);
        assertEquals("2", values[0]);
        assertNull("pref2.value[1] should be null", values[1]);
        assertEquals("3", values[2]);
        assertTrue(pref2.isValueSet());
        pref2.setValues((String[])null);
        assertFalse(pref2.isValueSet());
        assertTrue(pref2.getValueArray().length == 0);
        entity.reset();
        assertTrue(pref2.getValueArray().length == 2);
        pref2.setValues(new String[]{});
        assertFalse(pref2.isValueSet());
        assertTrue(pref2.getValueArray().length == 0);
        entity.reset();
        assertTrue(pref2.getValueArray().length == 2);

        MutablePortletEntity entity2 = entityAccess.getPortletEntityForFragment(f1);
        assertTrue("entity id ", entity2.getId().toString().equals(TEST_ENTITY));
        assertNotNull("entity's portlet ", entity2.getPortletDefinition());
        mockf1.verify();

        Mock mockf2 = new Mock(Fragment.class);
        mockf2.expects(new InvokeAtLeastOnceMatcher()).method("getName").will(new ReturnStub(pd.getUniqueName()));
        ContentFragment f2 = new ContentFragmentTestImpl((Fragment) mockf2.proxy(), new HashMap());

        MutablePortletEntity entity5 = entityAccess.newPortletEntityInstance(pd);

        System.out.println("before storing entity: " + entity5.getId());

        entityAccess.storePortletEntity(entity5);
        System.out.println("store done: " + entity5.getId());
        mockf2.expects(new InvokeAtLeastOnceMatcher()).method("getId").will(new ReturnStub(entity5.getId().toString()));

        MutablePortletEntity entity6 = entityAccess.getPortletEntityForFragment(f2);
        assertNotNull(entity6);
        System.out.println("reget : " + entity6.getId());

        entityAccess.removePortletEntity(entity6);

    }
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    private void teardownTestData() throws Exception
    {

        JetspeedObjectID objId = JetspeedObjectID.createFromString(TEST_ENTITY);
        MutablePortletEntity entity = entityAccess.getPortletEntity(objId);
        System.out.println("entity == " + entity);

        if (entity != null)
        {
            entityAccess.removePortletEntity(entity);
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

      }
      JSEntities entities = new JSEntities();

      while (list.hasNext())
      {
        MutablePortletEntity entity = (MutablePortletEntity) list
            .next();
        JSEntity jsEntity = exportEntityPref(entity);
        if (jsEntity != null)
          entities.add(jsEntity);
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    JSEntities entities = portlet.getEntities();
    Iterator it = entities.iterator();
    while (it.hasNext())
    {
      JSEntity entity = (JSEntity)it.next();
      MutablePortletEntity portletEntity = entityAccess.getPortletEntity(entity.getId());
      if (portletEntity == null)
      {
        portletEntity = entityAccess.newPortletEntityInstance(pd, entity.getId());
        try
        {
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    public void testWindowAccess() throws Exception
    {
        List windows = new ArrayList();
        ContentFragment f1 = new ContentFragmentImpl((Fragment) fragMock.proxy(), new HashMap());
        MutablePortletEntity entity = (MutablePortletEntity) entityMock.proxy();
        CompositeWindowList windowList = (CompositeWindowList) windowListMock.proxy();
        entityAccessMock.expects(new InvokeAtLeastOnceMatcher()).method("getPortletEntityForFragment")
                .withAnyArguments().will(new ReturnStub(entity));
        fragMock.expects(new InvokeAtLeastOnceMatcher()).method("getId").withNoArguments()
                .will(new ReturnStub("frag1"));
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    private PortletWindow createPortletWindow(ContentFragment fragment, String principal) throws FailedToCreateWindowException, PortletEntityNotStoredException
    {       
        PortletWindow portletWindow = new PortletWindowImpl(fragment.getId());
        boolean temporaryWindow = false;
               
        MutablePortletEntity portletEntity = entityAccessor.getPortletEntityForFragment(fragment, principal);
        if (portletEntity == null)
        {
            log.info("No portlet entity defined for fragment ID "+fragment.getId()+" attempting to auto-generate...");
            try
            {
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    public MutablePortletEntity generateEntityFromFragment( ContentFragment fragment, String principal )
            throws PortletEntityNotGeneratedException
    {
        PortletDefinition pd = registry.getPortletDefinitionByUniqueName(fragment.getName());
        ObjectID entityKey = generateEntityKey(fragment, principal);
        MutablePortletEntity portletEntity = null;

        if (pd != null)
        {
            portletEntity = newPortletEntityInstance(pd);
            if (portletEntity == null)
            {
                throw new PortletEntityNotGeneratedException("Failed to create Portlet Entity for "
                        + fragment.getName());
            }
        }
        else
        {
            String msg = "Failed to retrieve Portlet Definition for " + fragment.getName();
            logger.warn(msg);
            portletEntity = new PortletEntityImpl(fragment);
            fragment.overrideRenderedContent(msg);
        }

        portletEntity.setId(entityKey.toString());

        return portletEntity;
    }
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

    protected MutablePortletEntity getPortletEntity(ObjectID id, ContentFragment fragment) throws PortletEntityNotStoredException
    {
        Criteria c = new Criteria();
        c.addEqualTo("id", id.toString());
        Query q = QueryFactory.newQuery(PortletEntityImpl.class, c);
        MutablePortletEntity portletEntity = (MutablePortletEntity) getPersistenceBrokerTemplate().getObjectByQuery(q);
        if (portletEntity == null)
        {
            return null;
        }
        else
        {
            String portletUniqueName = portletEntity.getPortletUniqueName();
            PortletDefinitionComposite parentPortletDef = registry.getPortletDefinitionByUniqueName(portletUniqueName);
            if(parentPortletDef != null)
            {
                //Indication that the fragment has changed the portlet it references.
                if(fragment != null && !portletUniqueName.equals(fragment.getName()))
View Full Code Here

Examples of org.apache.jetspeed.om.common.portlet.MutablePortletEntity

       
        MutablePortletApplication app = portletRegistry.getPortletApplication(TEST_PORTLET_APP_NAME);
       
        PortletDefinition portlet = (PortletDefinition) app.getPortletDefinitionList().iterator().next();
       
        MutablePortletEntity entity = entityAccess.newPortletEntityInstance(portlet);
        entity.setId("testEnity");
       
        entityAccess.storePortletEntity(entity);
       
       
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.