Author: theute
Date: 2011-09-06 07:36:51 -0400 (Tue, 06 Sep 2011)
New Revision: 7313
Added:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplication.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplicationHandler.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/jibx/gadget-application.xml
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/AbstractApplicationHandler.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/resources/binding.xml
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestJIBXXmlMapping.java
Log:
JBEPP-1149: Support for gadget applications in xml descriptor
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/AbstractApplicationHandler.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/AbstractApplicationHandler.java 2011-09-06
11:35:46 UTC (rev 7312)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/AbstractApplicationHandler.java 2011-09-06
11:36:51 UTC (rev 7313)
@@ -26,6 +26,7 @@
import org.exoplatform.portal.config.model.Application;
import org.exoplatform.portal.config.model.Properties;
import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
import org.jibx.runtime.IAliasable;
@@ -100,7 +101,7 @@
ctx.parsePastStartTag(m_uri, m_name);
//
- Application<Portlet> app;
+ Application<?> app;
if ("application".equals(m_name))
{
String instanceId = ctx.parseElementText(m_uri, "instance-id");
@@ -130,9 +131,25 @@
ownerId,
persistenceChunks[2]);
}
- app = Application.createPortletApplication();
- app.setState(state);
+ Application<Portlet> application =
Application.createPortletApplication();
+ application.setState(state);
+ app = application;
}
+ // Since we don't support dashboard's here, this only works for gadgets
using the gadget wrapper portlet.
+ else if ("gadget-application".equals(m_name))
+ {
+ ctx.parsePastStartTag(m_uri, "gadget");
+ String gadgetName = ctx.parseElementText(m_uri, "gadget-ref");
+ Gadget gadget = null;
+ // Once the gadget portlet wrapper is able to use gadget userPref's, include
parsing logic here.
+ // Gadget gadget = new Gadget();
+ // gadget.setUserPref();
+ TransientApplicationState<Gadget> state = new
TransientApplicationState<Gadget>(gadgetName, gadget);
+ Application<Gadget> application = Application.createGadgetApplication();
+ application.setState(state);
+ app = application;
+ ctx.parsePastEndTag(m_uri, "gadget");
+ }
else
{
ctx.parsePastStartTag(m_uri, "portlet");
@@ -155,8 +172,9 @@
{
state = new TransientApplicationState<Portlet>(applicationName +
"/" + portletName, null);
}
- app = Application.createPortletApplication();
- app.setState(state);
+ Application<Portlet> application =
Application.createPortletApplication();
+ application.setState(state);
+ app = application;
ctx.parsePastEndTag(m_uri, "portlet");
}
Copied:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplication.java
(from rev 6223,
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplication.java)
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplication.java
(rev 0)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplication.java 2011-09-06
11:36:51 UTC (rev 7313)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.serialize;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.pom.data.ApplicationData;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class GadgetApplication extends Application<Gadget>
+{
+ public GadgetApplication(ApplicationData<Gadget> gadgetApplicationData)
+ {
+ super(gadgetApplicationData);
+ }
+
+ public GadgetApplication(ApplicationType<Gadget> gadgetApplicationType, String
storageId)
+ {
+ super(gadgetApplicationType, storageId);
+ }
+
+ public GadgetApplication(ApplicationType<Gadget> gadgetApplicationType)
+ {
+ super(gadgetApplicationType);
+ }
+}
Copied:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplicationHandler.java
(from rev 6223,
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplicationHandler.java)
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplicationHandler.java
(rev 0)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/config/serialize/GadgetApplicationHandler.java 2011-09-06
11:36:51 UTC (rev 7313)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.config.serialize;
+
+/**
+ * @author <a href="mailto:nscavell@redhat.com">Nick Scavelli</a>
+ * @version $Revision$
+ */
+public class GadgetApplicationHandler extends AbstractApplicationHandler
+{
+ public GadgetApplicationHandler()
+ {
+ }
+
+ public GadgetApplicationHandler(String m_uri, int m_index, String m_name)
+ {
+ super(m_uri, m_index, m_name);
+ }
+}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/resources/binding.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/resources/binding.xml 2011-09-06
11:35:46 UTC (rev 7312)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/resources/binding.xml 2011-09-06
11:36:51 UTC (rev 7313)
@@ -50,9 +50,16 @@
unmarshaller="org.exoplatform.portal.config.serialize.PortletApplicationHandler">
</mapping>
+ <mapping name="gadget-application"
+ label="gadget-application"
+ class="org.exoplatform.portal.config.serialize.GadgetApplication"
+
marshaller="org.exoplatform.portal.config.serialize.GadgetApplicationHandler"
+
unmarshaller="org.exoplatform.portal.config.serialize.GadgetApplicationHandler">
+ </mapping>
+
<mapping name="page-body" label="pageBody"
class="org.exoplatform.portal.config.model.PageBody">
</mapping>
-
+
<mapping name="site-body" label="siteBody"
class="org.exoplatform.portal.config.model.SiteBody">
</mapping>
@@ -72,8 +79,9 @@
<structure map-as="org.exoplatform.portal.config.model.Container"
usage="optional"/>
<structure map-as="org.exoplatform.portal.config.model.Application"
usage="optional"/>
<structure map-as="org.exoplatform.portal.config.model.PageBody"
usage="optional"/>
- <structure map-as="org.exoplatform.portal.config.model.SiteBody"
usage="optional"/>
+ <structure map-as="org.exoplatform.portal.config.model.SiteBody"
usage="optional"/>
<structure
map-as="org.exoplatform.portal.config.serialize.PortletApplication"
usage="optional"/>
+ <structure
map-as="org.exoplatform.portal.config.serialize.GadgetApplication"
usage="optional"/>
</collection>
</mapping>
@@ -92,6 +100,7 @@
<structure map-as="org.exoplatform.portal.config.model.Application"
usage="optional"/>
<structure map-as="org.exoplatform.portal.config.model.PageBody"
usage="optional"/>
<structure
map-as="org.exoplatform.portal.config.serialize.PortletApplication"
usage="optional"/>
+ <structure
map-as="org.exoplatform.portal.config.serialize.GadgetApplication"
usage="optional"/>
</collection>
</mapping>
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestJIBXXmlMapping.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestJIBXXmlMapping.java 2011-09-06
11:35:46 UTC (rev 7312)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestJIBXXmlMapping.java 2011-09-06
11:36:51 UTC (rev 7313)
@@ -25,6 +25,7 @@
import org.exoplatform.portal.config.model.LocalizedString;
import org.exoplatform.portal.config.model.ModelUnmarshaller;
import org.exoplatform.portal.config.model.NavigationFragment;
+import org.exoplatform.portal.config.model.ApplicationType;
import org.exoplatform.portal.config.model.Page;
import org.exoplatform.portal.config.model.Page.PageSet;
import org.exoplatform.portal.config.model.PageNavigation;
@@ -33,6 +34,7 @@
import org.exoplatform.portal.config.model.TransientApplicationState;
import org.exoplatform.portal.config.model.UnmarshalledObject;
import org.exoplatform.portal.config.model.Version;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;
import org.gatein.common.util.Tools;
@@ -212,4 +214,21 @@
PageNode bar = fragment.getNode("bar");
assertNotNull(bar);
}
+
+ public void testGadgetApplicationMapping() throws Exception
+ {
+ IBindingFactory bfact = BindingDirectory.getFactory(PortalConfig.class);
+ IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
+ @SuppressWarnings("unchecked")
+ Application<Gadget> app =
+ (Application<Gadget>)uctx.unmarshalDocument(new FileInputStream(
+ "src/test/resources/jibx/gadget-application.xml"), null);
+
+ assertEquals(ApplicationType.GADGET, app.getType());
+ TransientApplicationState gadgetState = (TransientApplicationState)
app.getState();
+ assertNotNull(gadgetState);
+ assertEquals("Calendar", gadgetState.getContentId());
+ assertNull(gadgetState.getContentState());
+ // Add test for user-prefs when supported...
+ }
}
Copied:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/jibx/gadget-application.xml
(from rev 6223,
portal/trunk/component/portal/src/test/resources/jibx/gadget-application.xml)
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/jibx/gadget-application.xml
(rev 0)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/resources/jibx/gadget-application.xml 2011-09-06
11:36:51 UTC (rev 7313)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ as indicated by the @author tags. See the copyright.txt file in the
+ ~ distribution for a full listing of individual contributors.
+ ~
+ ~ This is free software; you can redistribute it and/or modify it
+ ~ under the terms of the GNU Lesser General Public License as
+ ~ published by the Free Software Foundation; either version 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+<gadget-application>
+ <gadget>
+ <gadget-ref>Calendar</gadget-ref>
+ </gadget>
+</gadget-application>