Author: hoang_to
Date: 2011-05-20 04:53:49 -0400 (Fri, 20 May 2011)
New Revision: 6514
Added:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContentHandler.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageBodyStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/StAXElement.java
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPageSet.java
Log:
GTNPORTAL-1905: Commit GateIn object StAX parser and JUnit tests
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParser.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -21,6 +21,7 @@
import org.exoplatform.portal.config.model.ModelObject;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
+import java.util.Set;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
@@ -58,7 +59,7 @@
}
else
{
- throw new StaxNavException(navigator.getLocation(), "Was expecting element
" + staxElement + " to be present at the place of " +
navigator.getName());
+ throw new StaxNavException(navigator.getLocation(), "Was expecting element
" + staxElement + " to be present");
}
}
Added:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/AbstractStAXParserFactory.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+import org.staxnav.StaxNavigator;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/19/11
+ */
+public class AbstractStAXParserFactory
+{
+
+ public static AbstractStAXParser getParser(StAXElement element,
StaxNavigator<StAXElement> elementNavigator)
+ {
+ switch(element)
+ {
+ case page:
+ return new PageStAXParser(elementNavigator);
+ case page_body:
+ return new PageBodyStAXParser(elementNavigator);
+ case portal_config:
+ return new PortalConfigStAXParser(elementNavigator);
+ case portlet_application:
+ return new PortletWindowStAXParser(elementNavigator);
+ case gadget_application:
+ return new GadgetWindowStAXParer(elementNavigator);
+ case container:
+ return new ContainerStAXParser(elementNavigator);
+ default:
+ throw new IllegalArgumentException("StAXElement " + element +
" is not associated with any subclass of ModelObject");
+ }
+
+ }
+}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContainerStAXParser.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.config.stax;
import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
import java.util.HashSet;
@@ -41,28 +42,37 @@
{
Container container = new Container();
+ String templateName = elementNavigator.getAttribute("template");
+ if(templateName != null)
+ {
+ container.setTemplate(templateName);
+ }
+
+ container.setDecorator(elementNavigator.getAttribute("decorator"));
+ container.setWidth(elementNavigator.getAttribute("width"));
+ container.setHeight(elementNavigator.getAttribute("height"));
+
+ container.setTitle(getContent(elementNavigator, StAXElement.title));
+ container.setIcon(getContent(elementNavigator, StAXElement.icon));
+ container.setAccessPermissions(getContent(elementNavigator,
StAXElement.access_permissions).split(","));
+ container.setFactoryId(getContent(elementNavigator, StAXElement.factory_id));
+
+
final Set<StAXElement> childElementSet = new HashSet<StAXElement>();
childElementSet.add(StAXElement.portlet_application);
childElementSet.add(StAXElement.container);
- StAXElement tempElement = elementNavigator.next(childElementSet);
+ elementNavigator.next(childElementSet);
+ StAXElement tempElement = elementNavigator.getName();
- while(tempElement != null)
+ while(childElementSet.contains(tempElement))
{
- switch(tempElement)
- {
- case container:
- ContainerStAXParser subElementStAXParser = new
ContainerStAXParser(elementNavigator);
- container.getChildren().add(subElementStAXParser.parseXML());
- break;
+ //The fork() move current element navigator to its sibling
+ AbstractStAXParser<ModelObject> modelObjectParser =
AbstractStAXParserFactory.getParser(tempElement, elementNavigator.fork());
+ ModelObject modelObject = modelObjectParser.parseXML();
+ container.getChildren().add(modelObject);
- case portlet_application:
- PortletWindowStAXParser portletWindowStAXParser = new
PortletWindowStAXParser(elementNavigator);
- container.getChildren().add(portletWindowStAXParser.parseXML());
- break;
- }
-
- tempElement = elementNavigator.next(childElementSet);
+ tempElement = elementNavigator.getName();
}
return container;
@@ -71,6 +81,15 @@
@Override
public boolean isOptional(StAXElement staxElement)
{
- return false; //To change body of implemented methods use File | Settings | File
Templates.
+ switch(staxElement)
+ {
+ case access_permissions:
+ case title:
+ case icon:
+ case factory_id:
+ return true;
+ default:
+ return false;
+ }
}
}
Added:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContentHandler.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContentHandler.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/ContentHandler.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+/**
+ * A handler handling special content of an XML element
+ *
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/20/11
+ */
+public abstract class ContentHandler
+{
+
+ public final static ContentHandler OWNER_PATTERN_HANDLER = new
OwnerPatternContentHandler();
+
+ public abstract String handle(String currentContent, String replacement);
+
+ /**
+ * A class serves for handling @owner@ pattern
+ */
+ public static class OwnerPatternContentHandler extends ContentHandler
+ {
+
+ @Override
+ public String handle(String currentContent, String replacement)
+ {
+ if("@owner(a)".equals(currentContent))
+ {
+ return replacement;
+ }
+ else
+ {
+ return currentContent;
+ }
+ }
+ }
+}
Added:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/GadgetWindowStAXParer.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.config.serialize.GadgetApplication;
+import org.exoplatform.portal.pom.spi.gadget.Gadget;
+import org.staxnav.StaxNavException;
+import org.staxnav.StaxNavigator;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/19/11
+ */
+public class GadgetWindowStAXParer extends
AbstractStAXParser<Application<Gadget>>
+{
+
+ public GadgetWindowStAXParer(StaxNavigator<StAXElement> elementNavigator)
+ {
+ super(elementNavigator);
+ }
+
+ @Override
+ public Application<Gadget> parseXML() throws StaxNavException
+ {
+ elementNavigator.next(StAXElement.gadget);
+
+ String gadgetName = getContent(elementNavigator, StAXElement.gadget_ref);
+ TransientApplicationState<Gadget> state = new
TransientApplicationState<Gadget>(gadgetName, null);
+ Application<Gadget> app = Application.createGadgetApplication();
+ app.setState(state);
+
+ return app;
+ }
+
+ @Override
+ public boolean isOptional(StAXElement staxElement)
+ {
+ switch(staxElement)
+ {
+ case gadget_ref:
+ return false;
+ default:
+ return true;
+ }
+ }
+}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageBodyStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageBodyStAXParser.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageBodyStAXParser.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -37,12 +37,12 @@
@Override
public PageBody parseXML() throws StaxNavException
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ return new PageBody();
}
@Override
public boolean isOptional(StAXElement staxElement)
{
- return false; //To change body of implemented methods use File | Settings | File
Templates.
+ return true;
}
}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PageStAXParser.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -68,24 +68,17 @@
modelObjectElements.add(StAXElement.portlet_application);
modelObjectElements.add(StAXElement.container);
- StAXElement tempElement = elementNavigator.next(modelObjectElements);
+ elementNavigator.next(modelObjectElements);
- while(tempElement != null)
+ StAXElement tempElement = elementNavigator.getName();
+ while(modelObjectElements.contains(tempElement))
{
- switch(tempElement)
- {
- case portlet_application:
- PortletWindowStAXParser portletWindowStAXParser = new
PortletWindowStAXParser(elementNavigator);
- children.add(portletWindowStAXParser.parseXML());
- break;
+ //Call to fork() move the element navigator to sibling of actual element
+ AbstractStAXParser<ModelObject> modelObjectParser =
AbstractStAXParserFactory.getParser(tempElement, elementNavigator.fork());
+ ModelObject modelObject = modelObjectParser.parseXML();
+ children.add(modelObject);
- case container:
- ContainerStAXParser containerStAXParser = new
ContainerStAXParser(elementNavigator);
- children.add(containerStAXParser.parseXML());
- break;
- }
-
- tempElement = elementNavigator.next(modelObjectElements);
+ tempElement = elementNavigator.getName();
}
page.setChildren(children);
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortalConfigStAXParser.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -18,9 +18,13 @@
*/
package org.exoplatform.portal.config.stax;
+import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.model.Properties;
import org.staxnav.StaxNavException;
import org.staxnav.StaxNavigator;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
@@ -31,18 +35,70 @@
public PortalConfigStAXParser(StaxNavigator<StAXElement> elementNavigator)
throws IllegalArgumentException
{
- super(elementNavigator); //To change body of overridden methods use File |
Settings | File Templates.
+ super(elementNavigator);
}
@Override
public PortalConfig parseXML() throws StaxNavException
{
- return null; //To change body of implemented methods use File | Settings | File
Templates.
+ PortalConfig portalConfig = new PortalConfig();
+
+ portalConfig.setName(getContent(elementNavigator, StAXElement.portal_name));
+ portalConfig.setLocale(getContent(elementNavigator, StAXElement.locale));
+ portalConfig.setAccessPermissions(getContent(elementNavigator,
StAXElement.access_permissions).split(","));
+ portalConfig.setEditPermission(getContent(elementNavigator,
StAXElement.edit_permission));
+
+ if(elementNavigator.next(StAXElement.properties))
+ {
+ Properties properties = new Properties();
+ StaxNavigator<StAXElement> propertiesElement = elementNavigator.fork();
+
+ while(elementNavigator.next(StAXElement.entry))
+ {
+ String propertyName = elementNavigator.getAttribute("key");
+ String propertyValue = elementNavigator.getContent();
+ properties.setProperty(propertyName, propertyValue);
+ }
+
+ portalConfig.setProperties(properties);
+ }
+
+ elementNavigator.next(StAXElement.portal_layout);//Parse over portal_layout
element
+
+ final Set<StAXElement> modelElementSet = new HashSet<StAXElement>();
+ modelElementSet.add(StAXElement.container);
+ modelElementSet.add(StAXElement.portlet_application);
+ modelElementSet.add(StAXElement.page_body);
+
+ elementNavigator.next(modelElementSet);
+
+ StAXElement tempElement = elementNavigator.getName();
+ while(modelElementSet.contains(tempElement))
+ {
+ //The fork() move current element navigator to its sibling
+ AbstractStAXParser<ModelObject> modelObjectParser =
AbstractStAXParserFactory.getParser(tempElement, elementNavigator.fork());
+ ModelObject modelObject = modelObjectParser.parseXML();
+ portalConfig.getPortalLayout().getChildren().add(modelObject);
+
+ tempElement = elementNavigator.getName();
+ }
+
+ return portalConfig;
}
@Override
public boolean isOptional(StAXElement staxElement)
{
- return false; //To change body of implemented methods use File | Settings | File
Templates.
+ switch(staxElement)
+ {
+ case access_permissions:
+ case edit_permission:
+ case properties:
+ case portal_layout:
+ return true;
+ default:
+ return false;
+
+ }
}
}
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/PortletWindowStAXParser.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -97,6 +97,8 @@
case icon:
case width:
case height:
+ case read_only:
+ case title:
return true;
default:
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/StAXElement.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/StAXElement.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/main/java/org/exoplatform/portal/config/stax/StAXElement.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -74,10 +74,26 @@
gadget_application,
+ gadget,
+
+ gadget_ref,
+
container,
portal_config,
+ portal_name,
+
+ locale,
+
+ portal_layout,
+
+ page_body,
+
+ properties,
+
+ entry,
+
NO_SUCH_ELEMENT
}
Added:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingContainer.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.stax.ContainerStAXParser;
+import org.exoplatform.portal.config.stax.StAXElement;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavigator;
+import org.staxnav.StaxNavigatorImpl;
+import java.io.InputStream;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/20/11
+ */
+public class TestParsingContainer extends TestCase
+{
+ private StaxNavigator<StAXElement> elementNavigator;
+
+ protected void setUp() throws Exception
+ {
+ InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/container.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ XMLStreamReader streamReader = inputFactory.createXMLStreamReader(in);
+ elementNavigator = new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamReader);
+ }
+
+ public void testContainer()
+ {
+ ContainerStAXParser containerParser = new ContainerStAXParser(elementNavigator);
+
+ Container rootContainer = containerParser.parseXML();
+ assertEquals(4, rootContainer.getChildren().size());
+
+ Container firstChild = (Container)rootContainer.getChildren().get(0);
+
+
assertEquals("system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl",
firstChild.getTemplate());
+
+ for(ModelObject descendant : firstChild.getChildren())
+ {
+
assertEquals("system:/groovy/portal/webui/container/UIContainer.gtmpl",
((Container)descendant).getTemplate());
+ }
+
+ for(int i = 1; i < 4; i++)
+ {
+ assertEquals("system:/groovy/portal/webui/container/UIContainer" + i +
".gtmpl", ((Container)rootContainer.getChildren().get(i)).getTemplate());
+ }
+
+ }
+}
Added:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingGadgetWindow.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/20/11
+ */
+public class TestParsingGadgetWindow extends TestCase
+{
+}
Modified:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPageSet.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPageSet.java 2011-05-20
08:52:12 UTC (rev 6513)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPageSet.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -58,5 +58,11 @@
List<Page> pages = pageSet.getPages();
assertEquals(5, pages.size());
+
+ assertEquals("homepage", pages.get(0).getName());
+ assertEquals("groupnavigation", pages.get(1).getName());
+ assertEquals("portalnavigation", pages.get(2).getName());
+ assertEquals("register", pages.get(3).getName());
+ assertEquals("sitemap", pages.get(4).getName());
}
}
Added:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortalConfig.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.model.Application;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.ModelObject;
+import org.exoplatform.portal.config.model.PageBody;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.config.stax.PortalConfigStAXParser;
+import org.exoplatform.portal.config.stax.StAXElement;
+import org.json.XML;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavigator;
+import org.staxnav.StaxNavigatorImpl;
+import java.io.InputStream;
+import java.util.List;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/20/11
+ */
+public class TestParsingPortalConfig extends TestCase
+{
+
+ private StaxNavigator<StAXElement> elementNavigator;
+
+ protected void setUp() throws Exception
+ {
+ InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/portal.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ XMLStreamReader streamReader = inputFactory.createXMLStreamReader(in);
+ elementNavigator = new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamReader);
+ }
+
+ public void testPortalConfig()
+ {
+ PortalConfigStAXParser portalConfigParser = new
PortalConfigStAXParser(elementNavigator);
+ PortalConfig portalConfig = portalConfigParser.parseXML();
+
+ Container layout = portalConfig.getPortalLayout();
+ List<ModelObject> children = layout.getChildren();
+
+ assertEquals(5, children.size());
+
+ assertTrue(children.get(0) instanceof Application);
+ assertTrue(children.get(1) instanceof Application);
+ assertTrue(children.get(2) instanceof Application);
+ assertTrue(children.get(3) instanceof PageBody);
+ assertTrue(children.get(4) instanceof Application);
+ }
+
+
+}
Added:
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/java/org/exoplatform/portal/stax/TestParsingPortletWindow.java 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * 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.stax;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.stax.StAXElement;
+import org.staxnav.Naming;
+import org.staxnav.StaxNavigator;
+import org.staxnav.StaxNavigatorImpl;
+import java.io.InputStream;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * @author <a href="hoang281283(a)gmail.com">Minh Hoang TO</a>
+ * @date 5/20/11
+ */
+public class TestParsingPortletWindow extends TestCase
+{
+
+ private StaxNavigator<StAXElement> elementNavigator;
+
+ protected void setUp() throws Exception
+ {
+ InputStream in =
ClassLoader.getSystemClassLoader().getResourceAsStream("./stax/portlet-application.xml");
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+
+ XMLStreamReader streamReader = inputFactory.createXMLStreamReader(in);
+ elementNavigator = new StaxNavigatorImpl<StAXElement>(new
Naming.Enumerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamReader);
+ }
+
+ public void testPortletApplication()
+ {
+
+ }
+}
+
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/container.xml 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ 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.
+
+-->
+<container>
+<container
template='system:/groovy/portal/webui/container/UITableColumnContainer.gtmpl'>
+ <access-permissions>Everyone</access-permissions>
+ <container
template='system:/groovy/portal/webui/container/UIContainer.gtmpl'>
+ <access-permissions>Everyone</access-permissions>
+ </container>
+ <container
template='system:/groovy/portal/webui/container/UIContainer.gtmpl'>
+ <access-permissions>Everyone</access-permissions>
+ </container>
+</container>
+
+<container
template="system:/groovy/portal/webui/container/UIContainer1.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+</container>
+<container
template="system:/groovy/portal/webui/container/UIContainer2.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+</container>
+<container
template="system:/groovy/portal/webui/container/UIContainer3.gtmpl">
+ <access-permissions>Everyone</access-permissions>
+</container>
+</container>
+
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml
===================================================================
--- portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portal.xml 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ 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.
+
+-->
+
+<portal-config
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_objects_1_1
http://www.gatein.org/xml/ns/gatein_objects_1_1"
+
xmlns="http://www.gatein.org/xml/ns/gatein_objects_1_1">
+ <portal-name>classic</portal-name>
+ <locale>en</locale>
+ <access-permissions>Everyone</access-permissions>
+ <edit-permission>*:/platform/administrators</edit-permission>
+ <properties>
+ <entry key="sessionAlive">onDemand</entry>
+ </properties>
+
+ <portal-layout>
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BannerPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>par:/groovy/groovy/webui/component/UIBannerPortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
+
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>NavigationPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
+
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>BreadcumbsPortlet</portlet-ref>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
+
+ <page-body> </page-body>
+
+ <portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>FooterPortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>par:/groovy/groovy/webui/component/UIFooterPortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ </portlet-application>
+
+ </portal-layout>
+
+</portal-config>
Added:
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml
===================================================================
---
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml
(rev 0)
+++
portal/branches/stax-integration/component/portal/src/test/resources/stax/portlet-application.xml 2011-05-20
08:53:49 UTC (rev 6514)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ 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.
+
+-->
+
+<portlet-application>
+ <portlet>
+ <application-ref>web</application-ref>
+ <portlet-ref>HomePagePortlet</portlet-ref>
+ <preferences>
+ <preference>
+ <name>template</name>
+
<value>system:/templates/groovy/webui/component/UIHomePagePortlet.gtmpl</value>
+ <read-only>false</read-only>
+ </preference>
+ </preferences>
+ </portlet>
+ <title>Home Page portlet</title>
+ <access-permissions>Everyone</access-permissions>
+ <show-info-bar>false</show-info-bar>
+ <show-application-state>false</show-application-state>
+ <show-application-mode>false</show-application-mode>
+</portlet-application>
+
+