From do-not-reply at jboss.org Fri May 20 04:53:49 2011
Content-Type: multipart/mixed; boundary="===============4997243161601053368=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: gatein-commits at lists.jboss.org
Subject: [gatein-commits] gatein SVN: r6514 - in
portal/branches/stax-integration/component/portal/src:
test/java/org/exoplatform/portal/stax and 1 other directories.
Date: Fri, 20 May 2011 04:53:49 -0400
Message-ID: <201105200853.p4K8rnaY006547@svn01.web.mwc.hst.phx2.redhat.com>
--===============4997243161601053368==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/exop=
latform/portal/config/stax/AbstractStAXParserFactory.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/ContentHandler.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/GadgetWindowStAXParer.java
portal/branches/stax-integration/component/portal/src/test/java/org/exop=
latform/portal/stax/TestParsingContainer.java
portal/branches/stax-integration/component/portal/src/test/java/org/exop=
latform/portal/stax/TestParsingGadgetWindow.java
portal/branches/stax-integration/component/portal/src/test/java/org/exop=
latform/portal/stax/TestParsingPortalConfig.java
portal/branches/stax-integration/component/portal/src/test/java/org/exop=
latform/portal/stax/TestParsingPortletWindow.java
portal/branches/stax-integration/component/portal/src/test/resources/sta=
x/container.xml
portal/branches/stax-integration/component/portal/src/test/resources/sta=
x/portal.xml
portal/branches/stax-integration/component/portal/src/test/resources/sta=
x/portlet-application.xml
Modified:
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/AbstractStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/ContainerStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/PageBodyStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/PageStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/PortalConfigStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/PortletWindowStAXParser.java
portal/branches/stax-integration/component/portal/src/main/java/org/exop=
latform/portal/config/stax/StAXElement.java
portal/branches/stax-integration/component/portal/src/test/java/org/exop=
latform/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/o=
rg/exoplatform/portal/config/stax/AbstractStAXParser.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/AbstractStAXParser.java 2011-05-20 08:52:12 UTC=
(rev 6513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/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 Minh Hoang TO
@@ -58,7 +59,7 @@
}
else
{
- throw new StaxNavException(navigator.getLocation(), "Was expectin=
g element " + staxElement + " to be present at the place of " + navigator.g=
etName());
+ throw new StaxNavException(navigator.getLocation(), "Was expectin=
g element " + staxElement + " to be present");
}
=
}
Added: portal/branches/stax-integration/component/portal/src/main/java/org/=
exoplatform/portal/config/stax/AbstractStAXParserFactory.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/AbstractStAXParserFactory.java =
(rev 0)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/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 Minh Hoang TO
+ * @date 5/19/11
+ */
+public class AbstractStAXParserFactory
+{
+
+ public static AbstractStAXParser getParser(StAXElement element, StaxNav=
igator 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/o=
rg/exoplatform/portal/config/stax/ContainerStAXParser.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/ContainerStAXParser.java 2011-05-20 08:52:12 UT=
C (rev 6513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/ContainerStAXParser.java 2011-05-20 08:53:49 UT=
C (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 =3D new Container();
=
+ String templateName =3D elementNavigator.getAttribute("template");
+ if(templateName !=3D 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, StAXElem=
ent.access_permissions).split(","));
+ container.setFactoryId(getContent(elementNavigator, StAXElement.fact=
ory_id));
+
+
final Set childElementSet =3D new HashSet(=
);
childElementSet.add(StAXElement.portlet_application);
childElementSet.add(StAXElement.container);
=
- StAXElement tempElement =3D elementNavigator.next(childElementSet);
+ elementNavigator.next(childElementSet);
+ StAXElement tempElement =3D elementNavigator.getName();
=
- while(tempElement !=3D null)
+ while(childElementSet.contains(tempElement))
{
- switch(tempElement)
- {
- case container:
- ContainerStAXParser subElementStAXParser =3D new ContainerSt=
AXParser(elementNavigator);
- container.getChildren().add(subElementStAXParser.parseXML());
- break;
+ //The fork() move current element navigator to its sibling
+ AbstractStAXParser modelObjectParser =3D AbstractStA=
XParserFactory.getParser(tempElement, elementNavigator.fork());
+ ModelObject modelObject =3D modelObjectParser.parseXML();
+ container.getChildren().add(modelObject);
=
- case portlet_application:
- PortletWindowStAXParser portletWindowStAXParser =3D new Port=
letWindowStAXParser(elementNavigator);
- container.getChildren().add(portletWindowStAXParser.parseXML=
());
- break;
- }
-
- tempElement =3D elementNavigator.next(childElementSet);
+ tempElement =3D elementNavigator.getName();
}
=
return container;
@@ -71,6 +81,15 @@
@Override
public boolean isOptional(StAXElement staxElement)
{
- return false; //To change body of implemented methods use File | Se=
ttings | 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/ContentHandler.java (re=
v 0)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/ContentHandler.java 2011-05-20 08:53:49 UTC (re=
v 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 Minh Hoang TO
+ * @date 5/20/11
+ */
+public abstract class ContentHandler
+{
+
+ public final static ContentHandler OWNER_PATTERN_HANDLER =3D new OwnerP=
atternContentHandler();
+
+ 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@".equals(currentContent))
+ {
+ return replacement;
+ }
+ else
+ {
+ return currentContent;
+ }
+ }
+ }
+}
Added: portal/branches/stax-integration/component/portal/src/main/java/org/=
exoplatform/portal/config/stax/GadgetWindowStAXParer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/GadgetWindowStAXParer.java =
(rev 0)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/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 Minh Hoang TO
+ * @date 5/19/11
+ */
+public class GadgetWindowStAXParer extends AbstractStAXParser>
+{
+
+ public GadgetWindowStAXParer(StaxNavigator elementNavigato=
r)
+ {
+ super(elementNavigator);
+ }
+
+ @Override
+ public Application parseXML() throws StaxNavException
+ {
+ elementNavigator.next(StAXElement.gadget);
+
+ String gadgetName =3D getContent(elementNavigator, StAXElement.gadge=
t_ref);
+ TransientApplicationState state =3D new TransientApplication=
State(gadgetName, null);
+ Application app =3D 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/o=
rg/exoplatform/portal/config/stax/PageBodyStAXParser.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/PageBodyStAXParser.java 2011-05-20 08:52:12 UTC=
(rev 6513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/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 | Set=
tings | File Templates.
+ return new PageBody();
}
=
@Override
public boolean isOptional(StAXElement staxElement)
{
- return false; //To change body of implemented methods use File | Se=
ttings | File Templates.
+ return true;
}
}
Modified: portal/branches/stax-integration/component/portal/src/main/java/o=
rg/exoplatform/portal/config/stax/PageStAXParser.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/PageStAXParser.java 2011-05-20 08:52:12 UTC (re=
v 6513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/PageStAXParser.java 2011-05-20 08:53:49 UTC (re=
v 6514)
@@ -68,24 +68,17 @@
modelObjectElements.add(StAXElement.portlet_application);
modelObjectElements.add(StAXElement.container);
=
- StAXElement tempElement =3D elementNavigator.next(modelObjectElement=
s);
+ elementNavigator.next(modelObjectElements);
=
- while(tempElement !=3D null)
+ StAXElement tempElement =3D elementNavigator.getName();
+ while(modelObjectElements.contains(tempElement))
{
- switch(tempElement)
- {
- case portlet_application:
- PortletWindowStAXParser portletWindowStAXParser =3D new Por=
tletWindowStAXParser(elementNavigator);
- children.add(portletWindowStAXParser.parseXML());
- break;
+ //Call to fork() move the element navigator to sibling of actual =
element
+ AbstractStAXParser modelObjectParser =3D AbstractStA=
XParserFactory.getParser(tempElement, elementNavigator.fork());
+ ModelObject modelObject =3D modelObjectParser.parseXML();
+ children.add(modelObject);
=
- case container:
- ContainerStAXParser containerStAXParser =3D new ContainerSt=
AXParser(elementNavigator);
- children.add(containerStAXParser.parseXML());
- break;
- }
-
- tempElement =3D elementNavigator.next(modelObjectElements);
+ tempElement =3D elementNavigator.getName();
}
=
page.setChildren(children);
Modified: portal/branches/stax-integration/component/portal/src/main/java/o=
rg/exoplatform/portal/config/stax/PortalConfigStAXParser.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/PortalConfigStAXParser.java 2011-05-20 08:52:12=
UTC (rev 6513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/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 Minh Hoang TO
@@ -31,18 +35,70 @@
=
public PortalConfigStAXParser(StaxNavigator elementNavigat=
or) throws IllegalArgumentException
{
- super(elementNavigator); //To change body of overridden methods u=
se File | Settings | File Templates.
+ super(elementNavigator);
}
=
@Override
public PortalConfig parseXML() throws StaxNavException
{
- return null; //To change body of implemented methods use File | Set=
tings | File Templates.
+ PortalConfig portalConfig =3D new PortalConfig();
+
+ portalConfig.setName(getContent(elementNavigator, StAXElement.portal=
_name));
+ portalConfig.setLocale(getContent(elementNavigator, StAXElement.loca=
le));
+ portalConfig.setAccessPermissions(getContent(elementNavigator, StAXE=
lement.access_permissions).split(","));
+ portalConfig.setEditPermission(getContent(elementNavigator, StAXElem=
ent.edit_permission));
+
+ if(elementNavigator.next(StAXElement.properties))
+ {
+ Properties properties =3D new Properties();
+ StaxNavigator propertiesElement =3D elementNavigator=
.fork();
+
+ while(elementNavigator.next(StAXElement.entry))
+ {
+ String propertyName =3D elementNavigator.getAttribute("key");
+ String propertyValue =3D elementNavigator.getContent();
+ properties.setProperty(propertyName, propertyValue);
+ }
+
+ portalConfig.setProperties(properties);
+ }
+
+ elementNavigator.next(StAXElement.portal_layout);//Parse over portal=
_layout element
+
+ final Set modelElementSet =3D new HashSet(=
);
+ modelElementSet.add(StAXElement.container);
+ modelElementSet.add(StAXElement.portlet_application);
+ modelElementSet.add(StAXElement.page_body);
+
+ elementNavigator.next(modelElementSet);
+
+ StAXElement tempElement =3D elementNavigator.getName();
+ while(modelElementSet.contains(tempElement))
+ {
+ //The fork() move current element navigator to its sibling
+ AbstractStAXParser modelObjectParser =3D AbstractStA=
XParserFactory.getParser(tempElement, elementNavigator.fork());
+ ModelObject modelObject =3D modelObjectParser.parseXML();
+ portalConfig.getPortalLayout().getChildren().add(modelObject);
+
+ tempElement =3D elementNavigator.getName();
+ }
+
+ return portalConfig;
}
=
@Override
public boolean isOptional(StAXElement staxElement)
{
- return false; //To change body of implemented methods use File | Se=
ttings | 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/o=
rg/exoplatform/portal/config/stax/PortletWindowStAXParser.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/PortletWindowStAXParser.java 2011-05-20 08:52:1=
2 UTC (rev 6513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/PortletWindowStAXParser.java 2011-05-20 08:53:4=
9 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/o=
rg/exoplatform/portal/config/stax/StAXElement.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/StAXElement.java 2011-05-20 08:52:12 UTC (rev 6=
513)
+++ portal/branches/stax-integration/component/portal/src/main/java/org/exo=
platform/portal/config/stax/StAXElement.java 2011-05-20 08:53:49 UTC (rev 6=
514)
@@ -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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/portal/stax/TestParsingContainer.java (rev=
0)
+++ portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/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 Minh Hoang TO
+ * @date 5/20/11
+ */
+public class TestParsingContainer extends TestCase
+{
+ private StaxNavigator elementNavigator;
+
+ protected void setUp() throws Exception
+ {
+ InputStream in =3D ClassLoader.getSystemClassLoader().getResourceAsS=
tream("./stax/container.xml");
+ XMLInputFactory inputFactory =3D XMLInputFactory.newInstance();
+
+ XMLStreamReader streamReader =3D inputFactory.createXMLStreamReader(=
in);
+ elementNavigator =3D new StaxNavigatorImpl(new Naming.E=
numerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamRea=
der);
+ }
+
+ public void testContainer()
+ {
+ ContainerStAXParser containerParser =3D new ContainerStAXParser(elem=
entNavigator);
+
+ Container rootContainer =3D containerParser.parseXML();
+ assertEquals(4, rootContainer.getChildren().size());
+
+ Container firstChild =3D (Container)rootContainer.getChildren().get(=
0);
+
+ assertEquals("system:/groovy/portal/webui/container/UITableColumnCon=
tainer.gtmpl", firstChild.getTemplate());
+
+ for(ModelObject descendant : firstChild.getChildren())
+ {
+ assertEquals("system:/groovy/portal/webui/container/UIContainer.g=
tmpl", ((Container)descendant).getTemplate());
+ }
+
+ for(int i =3D 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/portal/stax/TestParsingGadgetWindow.java (=
rev 0)
+++ portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/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 Minh Hoang TO
+ * @date 5/20/11
+ */
+public class TestParsingGadgetWindow extends TestCase
+{
+}
Modified: portal/branches/stax-integration/component/portal/src/test/java/o=
rg/exoplatform/portal/stax/TestParsingPageSet.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/portal/stax/TestParsingPageSet.java 2011-05-20 08:52:12 UTC (rev 6=
513)
+++ portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/portal/stax/TestParsingPageSet.java 2011-05-20 08:53:49 UTC (rev 6=
514)
@@ -58,5 +58,11 @@
List pages =3D 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/portal/stax/TestParsingPortalConfig.java (=
rev 0)
+++ portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/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 Minh Hoang TO
+ * @date 5/20/11
+ */
+public class TestParsingPortalConfig extends TestCase
+{
+
+ private StaxNavigator elementNavigator;
+
+ protected void setUp() throws Exception
+ {
+ InputStream in =3D ClassLoader.getSystemClassLoader().getResourceAsS=
tream("./stax/portal.xml");
+ XMLInputFactory inputFactory =3D XMLInputFactory.newInstance();
+
+ XMLStreamReader streamReader =3D inputFactory.createXMLStreamReader(=
in);
+ elementNavigator =3D new StaxNavigatorImpl(new Naming.E=
numerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamRea=
der);
+ }
+
+ public void testPortalConfig()
+ {
+ PortalConfigStAXParser portalConfigParser =3D new PortalConfigStAXPa=
rser(elementNavigator);
+ PortalConfig portalConfig =3D portalConfigParser.parseXML();
+
+ Container layout =3D portalConfig.getPortalLayout();
+ List children =3D 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/portal/stax/TestParsingPortletWindow.java =
(rev 0)
+++ portal/branches/stax-integration/component/portal/src/test/java/org/exo=
platform/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 Minh Hoang TO
+ * @date 5/20/11
+ */
+public class TestParsingPortletWindow extends TestCase
+{
+
+ private StaxNavigator elementNavigator;
+
+ protected void setUp() throws Exception
+ {
+ InputStream in =3D ClassLoader.getSystemClassLoader().getResourceAsS=
tream("./stax/portlet-application.xml");
+ XMLInputFactory inputFactory =3D XMLInputFactory.newInstance();
+
+ XMLStreamReader streamReader =3D inputFactory.createXMLStreamReader(=
in);
+ elementNavigator =3D new StaxNavigatorImpl(new Naming.E=
numerated.Simple(StAXElement.class, StAXElement.NO_SUCH_ELEMENT), streamRea=
der);
+ }
+
+ public void testPortletApplication()
+ {
+
+ }
+}
+
Added: portal/branches/stax-integration/component/portal/src/test/resources=
/stax/container.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/resources/st=
ax/container.xml (rev 0)
+++ portal/branches/stax-integration/component/portal/src/test/resources/st=
ax/container.xml 2011-05-20 08:53:49 UTC (rev 6514)
@@ -0,0 +1,43 @@
+
+
+
+
+ Everyone
+
+ Everyone
+
+
+ Everyone
+
+
+
+
+ Everyone
+
+
+ Everyone
+
+
+ Everyone
+
+
+
Added: portal/branches/stax-integration/component/portal/src/test/resources=
/stax/portal.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/resources/st=
ax/portal.xml (rev 0)
+++ portal/branches/stax-integration/component/portal/src/test/resources/st=
ax/portal.xml 2011-05-20 08:53:49 UTC (rev 6514)
@@ -0,0 +1,90 @@
+
+
+
+
+ classic
+ en
+ Everyone
+ *:/platform/administrators
+
+ onDemand
+
+ =
+
+
+
+ web
+ BannerPortlet
+
+
+ template
+ par:/groovy/groovy/webui/component/UIBannerPortlet.gtmp=
l
+ false
+
+
+
+ Everyone
+ false
+
+
+
+
+ web
+ NavigationPortlet
+
+ Everyone
+ false
+
+ =
+
+
+ web
+ BreadcumbsPortlet
+
+ Everyone
+ false
+
+ =
+
+ =
+
+
+ web
+ FooterPortlet
+
+
+ template
+ par:/groovy/groovy/webui/component/UIFooterPortlet.gtm=
pl
+ false
+
+
+
+ Everyone
+ false
+
+
+
+ =
+
Added: portal/branches/stax-integration/component/portal/src/test/resources=
/stax/portlet-application.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/branches/stax-integration/component/portal/src/test/resources/st=
ax/portlet-application.xml (rev 0)
+++ portal/branches/stax-integration/component/portal/src/test/resources/st=
ax/portlet-application.xml 2011-05-20 08:53:49 UTC (rev 6514)
@@ -0,0 +1,42 @@
+
+
+
+
+
+ web
+ HomePagePortlet
+
+
+ template
+ system:/templates/groovy/webui/component/UIHomePagePortlet.=
gtmpl
+ false
+
+
+
+ Home Page portlet
+ Everyone
+ false
+ false
+ false
+
+
+
--===============4997243161601053368==--