Author: mwringe
Date: 2009-04-02 18:37:21 -0400 (Thu, 02 Apr 2009)
New Revision: 13126
Added:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/adapter/RegionsAdapter.java
Removed:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/RegionsMetaData.java
Modified:
modules/metadata/trunk/build/pom.xml
modules/metadata/trunk/theme/pom.xml
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/PortalLayoutMetaData.java
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/URIMetaData.java
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/renderset/PortalRenderSetsMetaData.java
Log:
Minor code cleanup and refactoring.
Modified: modules/metadata/trunk/build/pom.xml
===================================================================
--- modules/metadata/trunk/build/pom.xml 2009-04-02 21:40:32 UTC (rev 13125)
+++ modules/metadata/trunk/build/pom.xml 2009-04-02 22:37:21 UTC (rev 13126)
@@ -17,6 +17,7 @@
<version.jboss-metadata>1.0.0.CR1</version.jboss-metadata>
<version.jboss.jbossxb>2.0.0.CR15</version.jboss.jbossxb>
<version.jaxb>2.1</version.jaxb>
+ <version.junit>3.8.2-brew</version.junit>
</properties>
<repositories>
@@ -68,6 +69,11 @@
<artifactId>jaxb-api</artifactId>
<version>${version.jaxb}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: modules/metadata/trunk/theme/pom.xml
===================================================================
--- modules/metadata/trunk/theme/pom.xml 2009-04-02 21:40:32 UTC (rev 13125)
+++ modules/metadata/trunk/theme/pom.xml 2009-04-02 22:37:21 UTC (rev 13126)
@@ -28,6 +28,13 @@
<artifactId>jaxb-api</artifactId>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
Modified:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/PortalLayoutMetaData.java
===================================================================
---
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/PortalLayoutMetaData.java 2009-04-02
21:40:32 UTC (rev 13125)
+++
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/PortalLayoutMetaData.java 2009-04-02
22:37:21 UTC (rev 13126)
@@ -26,7 +26,11 @@
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.jboss.portal.metadata.layout.adapter.RegionAdapter;
+
/**
* @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
* @version $Revision$
@@ -40,12 +44,13 @@
protected List<URIMetaData> uris;
- protected RegionsMetaData regions;
+ protected List<String> regions;
public PortalLayoutMetaData()
{
classname = "org.jboss.portal.theme.impl.JSPLayout";
uris = new ArrayList<URIMetaData>();
+ regions = new ArrayList<String>();
}
@XmlElement(name = "name")
@@ -81,13 +86,15 @@
this.uris = uris;
}
- @XmlElement(name = "regions")
- public RegionsMetaData getRegions()
+ @XmlElementWrapper(name = "regions")
+ @XmlElement(name="region")
+ @XmlJavaTypeAdapter(RegionAdapter.class)
+ public List<String> getRegions()
{
return regions;
}
- public void setRegions(RegionsMetaData regions)
+ public void setRegions(List<String> regions)
{
this.regions = regions;
}
Deleted:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/RegionsMetaData.java
===================================================================
---
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/RegionsMetaData.java 2009-04-02
21:40:32 UTC (rev 13125)
+++
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/RegionsMetaData.java 2009-04-02
22:37:21 UTC (rev 13126)
@@ -1,59 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt 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.jboss.portal.metadata.layout;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.jboss.portal.metadata.layout.adapter.RegionAdapter;
-
-/**
- * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
- * @version $Revision$
- */
-public class RegionsMetaData
-{
-
- protected List<String> regions;
-
- public RegionsMetaData()
- {
- this.regions = new ArrayList<String>();
- }
-
- @XmlElement(name = "region")
- @XmlJavaTypeAdapter(RegionAdapter.class)
- public List<String> getRegions()
- {
- return regions;
- }
-
- public void setRegions(List<String> regions)
- {
- this.regions = regions;
- }
-
-}
Modified:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/URIMetaData.java
===================================================================
---
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/URIMetaData.java 2009-04-02
21:40:32 UTC (rev 13125)
+++
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/URIMetaData.java 2009-04-02
22:37:21 UTC (rev 13126)
@@ -23,6 +23,7 @@
package org.jboss.portal.metadata.layout;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlValue;
/**
@@ -36,6 +37,15 @@
protected String uri;
+ public URIMetaData ()
+ {}
+
+ public URIMetaData (String state, String uri)
+ {
+ this.state = state;
+ this.uri = uri;
+ }
+
@XmlAttribute(name = "state")
public String getState()
{
@@ -57,4 +67,42 @@
{
this.uri = uri;
}
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof URIMetaData)
+ {
+ URIMetaData uri = (URIMetaData) obj;
+ if (compareString(uri.getState(), this.getState()) &&
compareString(uri.getUri(), this.getUri()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private boolean compareString (String string1, String string2)
+ {
+ // if both strings are null, then return true
+ if (string1 == null && string2 == null)
+ {
+ return true;
+ }
+ else if (string1 != null && string1.equals(string2))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
}
Added:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/adapter/RegionsAdapter.java
===================================================================
---
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/adapter/RegionsAdapter.java
(rev 0)
+++
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/layout/adapter/RegionsAdapter.java 2009-04-02
22:37:21 UTC (rev 13126)
@@ -0,0 +1,52 @@
+///******************************************************************************
+// * JBoss, a division of Red Hat *
+// * Copyright 2009, Red Hat Middleware, LLC, and individual *
+// * contributors as indicated by the @authors tag. See the *
+// * copyright.txt 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.jboss.portal.metadata.layout.adapter;
+//
+//import java.util.List;
+//
+//import javax.naming.OperationNotSupportedException;
+//import javax.xml.bind.annotation.adapters.XmlAdapter;
+//
+//import org.jboss.portal.metadata.layout.RegionsMetaData;
+//
+///**
+// * @author <a href="mailto:mwringe@redhat.com">Matt Wringe</a>
+// * @version $Revision$
+// */
+//public class RegionsAdapter extends XmlAdapter<RegionsMetaData,
List<String>>
+//{
+//
+// @Override
+// public RegionsMetaData marshal(List<String> arg0) throws Exception
+// {
+// throw new OperationNotSupportedException();
+// }
+//
+// @Override
+// public List<String> unmarshal(RegionsMetaData regions) throws Exception
+// {
+// return regions.getRegions();
+// }
+//
+//}
+//
Modified:
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/renderset/PortalRenderSetsMetaData.java
===================================================================
---
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/renderset/PortalRenderSetsMetaData.java 2009-04-02
21:40:32 UTC (rev 13125)
+++
modules/metadata/trunk/theme/src/main/java/org/jboss/portal/metadata/renderset/PortalRenderSetsMetaData.java 2009-04-02
22:37:21 UTC (rev 13126)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.metadata.renderset;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
@@ -36,7 +37,12 @@
{
protected List<RenderSetMetaData> renderSets;
- @XmlElement (name = "renderSet")
+ public PortalRenderSetsMetaData()
+ {
+ renderSets = new ArrayList<RenderSetMetaData>();
+ }
+
+ @XmlElement (name = "renderSet", required = true)
public List<RenderSetMetaData> getRenderSets()
{
return renderSets;