rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scot...@apache.org
Subject svn commit: r1171867 - in /incubator/rave/trunk/rave-portal/src/main: java/org/apache/rave/portal/model/Page.java java/org/apache/rave/portal/model/Region.java java/org/apache/rave/portal/model/Widget.java webapp/WEB-INF/dispatcher-servlet.xml
Date Sat, 17 Sep 2011 00:09:18 GMT
Author: scottbw
Date: Sat Sep 17 00:09:18 2011
New Revision: 1171867

URL: http://svn.apache.org/viewvc?rev=1171867&view=rev
Log:
Added support for export of pages via the REST API in XML as well as JSON, based on the accept
header of the request; see RAVE-256.

Modified:
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Region.java
    incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
    incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java?rev=1171867&r1=1171866&r2=1171867&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Page.java
Sat Sep 17 00:09:18 2011
@@ -22,6 +22,12 @@ import org.apache.rave.persistence.Basic
 import org.codehaus.jackson.annotate.JsonManagedReference;
 
 import javax.persistence.*;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
 import java.io.Serializable;
 import java.util.List;
 
@@ -36,6 +42,8 @@ import java.util.List;
  * 
  */
 @Entity
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
 @Table(name="page", uniqueConstraints={@UniqueConstraint(columnNames={"owner_id","name"})})
 @NamedQueries({
         @NamedQuery(name = "Page.getByUserId", query="SELECT p FROM Page p WHERE p.owner.entityId
= :userId ORDER BY p.renderSequence")
@@ -43,13 +51,15 @@ import java.util.List;
 @Access(AccessType.FIELD)
 public class Page implements BasicEntity, Serializable {
     private static final long serialVersionUID = 1L;
-      
+     
+    @XmlAttribute(name="id")
     @Id @Column(name="entity_id")
     @GeneratedValue(strategy = GenerationType.TABLE, generator = "pageIdGenerator")
     @TableGenerator(name = "pageIdGenerator", table = "RAVE_PORTAL_SEQUENCES", pkColumnName
= "SEQ_NAME",
             valueColumnName = "SEQ_COUNT", pkColumnValue = "page", allocationSize = 1, initialValue
= 1)
     private Long entityId;
 
+    @XmlElement
     @Basic(optional=false) @Column(name="name")
     private String name;
 
@@ -64,6 +74,7 @@ public class Page implements BasicEntity
     @JoinColumn(name="page_layout_id")
     private PageLayout pageLayout;
 
+    @XmlElement(name="region")
     @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
     @OrderBy("renderOrder")
     @JoinColumn(name="page_id")

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Region.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Region.java?rev=1171867&r1=1171866&r2=1171867&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Region.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Region.java
Sat Sep 17 00:09:18 2011
@@ -38,12 +38,17 @@ import javax.persistence.OrderBy;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.List;
 import javax.persistence.Basic;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
 
 /**
  * A region of a page, which can contain widget instances {@link RegionWidget}
  */
+@XmlAccessorType(XmlAccessType.NONE)
 @Entity
 @Table(name="region")
 @Access(AccessType.FIELD)
@@ -81,6 +86,19 @@ public class Region implements BasicEnti
         this.page = page;
         this.renderOrder = renderOrder;
     }
+    
+    @SuppressWarnings("unused")
+    @XmlElement(name="widget")
+    /**
+     * Only used for XML serialization, omitting regionwidget
+     */
+    private List<Widget> getWidgets(){
+        ArrayList<Widget> widgets = new ArrayList<Widget>();
+        for (RegionWidget rw: regionWidgets){
+            widgets.add(rw.getWidget());
+        }
+        return widgets;
+    }
 
     /**
      * Gets the persistence unique identifier

Modified: incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java?rev=1171867&r1=1171866&r2=1171867&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
(original)
+++ incubator/rave/trunk/rave-portal/src/main/java/org/apache/rave/portal/model/Widget.java
Sat Sep 17 00:09:18 2011
@@ -33,11 +33,16 @@ import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
 import java.io.Serializable;
 
 /**
  * A widget
  */
+@XmlAccessorType(XmlAccessType.NONE)
 @Entity
 @Table(name="widget")
 @NamedQueries({
@@ -87,11 +92,12 @@ public class Widget implements BasicEnti
     /*
         TODO RAVE-234: Figure out what the OpenJPA strategy is for functionality provided
by Eclisplink's @Convert
      */
-
+    @XmlElement
     @Basic @Column(name="title")
     private String title;
     //private InternationalString title;
 
+    @XmlElement
     @Basic @Column(name="url", unique = true)
     private String url;
 
@@ -101,15 +107,19 @@ public class Widget implements BasicEnti
     @Basic @Column(name="screenshot_url")
     private String screenshotUrl;
 
+    @XmlElement
     @Basic @Column(name="type")
     private String type;
 
+    @XmlElement
     @Basic @Column(name="author")
     private String author;
 
+    @XmlElement
     @Basic @Column(name = "description") @Lob
     private String description;
 
+    @XmlElement(name="status")
     @Basic @Column(name = "widget_status")
     @Enumerated(EnumType.STRING)
     private WidgetStatus widgetStatus;

Modified: incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=1171867&r1=1171866&r2=1171867&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml (original)
+++ incubator/rave/trunk/rave-portal/src/main/webapp/WEB-INF/dispatcher-servlet.xml Sat Sep
17 00:09:18 2011
@@ -44,6 +44,7 @@
     </bean>
 
     <oxm:jaxb2-marshaller id="marshaller">
+        <oxm:class-to-be-bound name="org.apache.rave.portal.model.Page"/>
         <oxm:class-to-be-bound name="org.apache.rave.portal.model.RegionWidgetPreference"/>
         <oxm:class-to-be-bound name="org.apache.rave.portal.web.model.RegionWidgetPreferenceListWrapper"/>
     </oxm:jaxb2-marshaller>
@@ -51,6 +52,7 @@
     <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
         <property name="messageConverters">
             <list>
+            	<bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter"></bean>
                 <bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter"
                       p:marshaller-ref="marshaller" p:unmarshaller-ref="marshaller"/>
             </list>



Mime
View raw message