You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2013/11/11 19:55:56 UTC

svn commit: r1540803 - in /rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest: WidgetsResource.java model/Widget.java

Author: mfranklin
Date: Mon Nov 11 18:55:55 2013
New Revision: 1540803

URL: http://svn.apache.org/r1540803
Log:
Created new Widget REST model and interface

Added:
    rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java
    rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java

Added: rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java?rev=1540803&view=auto
==============================================================================
--- rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java (added)
+++ rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java Mon Nov 11 18:55:55 2013
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.rest;
+
+import org.apache.rave.rest.model.Widget;
+import org.apache.rave.rest.model.SearchResult;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * Widget REST API
+ */
+@Path("/widgets")
+public interface WidgetsResource {
+
+    /**
+     * Gets all widgets in the system
+     * @return a list of all widgets
+     */
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public SearchResult<Widget> getWidgets();
+
+    /**
+     * Gets a widget by its ID
+     * @param id ID of the widget
+     * @return a valid widget or null if not found
+     */
+    @GET
+    @Path("/{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Widget getWidget(@PathParam("id") String id);
+
+    /**
+     * Updates the widget in system
+     * @param id ID of the widget
+     * @param Widget The widget to use to update all properties
+     * @return the updated widget from the system
+     */
+    @PUT
+    @Path("/{id}")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Widget updateWidget(@PathParam("id") String id, Widget Widget);
+
+    /**
+     * Creates a new widget in the system
+     * @param Widget the widget to create
+     * @return the new widget from the system
+     */
+    @POST
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    public Widget createWidget(Widget Widget);
+    
+}

Added: rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java
URL: http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java?rev=1540803&view=auto
==============================================================================
--- rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java (added)
+++ rave/trunk/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java Mon Nov 11 18:55:55 2013
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rave.rest.model;
+
+import org.apache.rave.model.WidgetStatus;
+
+import javax.xml.bind.annotation.*;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Widget", propOrder = {
+        "id", "type", "title", "titleUrl", "url", "thumbnailUrl", "screenshotUrl", "author", "authorEmail",
+        "description", "status", "disable", "disabledMessage", "featured"
+})
+@XmlRootElement(name = "RegionWidget")
+public class Widget {
+    @XmlElement(name = "id")
+    private String id;
+    @XmlElement(name = "title")
+    private String title;
+    @XmlElement(name = "titleUrl")
+    private String titleUrl;
+    @XmlElement(name = "url")
+    private String url;
+    @XmlElement(name = "thumbnailUrl")
+    private String thumbnailUrl;
+    @XmlElement(name = "screenshotUrl")
+    private String screenshotUrl;
+    @XmlElement(name = "type")
+    private String type;
+    @XmlElement(name = "author")
+    private String author;
+    @XmlElement(name = "authorEmail")
+    private String authorEmail;
+    @XmlElement(name = "description")
+    private String description;
+    @XmlElement(name = "status")
+    private WidgetStatus status;
+    @XmlElement(name = "disable")
+    private boolean disable;
+    @XmlElement(name = "disabledMessage")
+    private String disabledMessage;
+    @XmlElement(name = "featured")
+    private boolean featured;
+
+    public Widget() {    }
+
+    public Widget(org.apache.rave.model.Widget base) {
+        this.id = base.getId();
+        this.title = base.getTitle();
+        this.titleUrl = base.getTitleUrl();
+        this.url = base.getUrl();
+        this.thumbnailUrl = base.getThumbnailUrl();
+        this.screenshotUrl = base.getScreenshotUrl();
+        this.type = base.getType();
+        this.author = base.getAuthor();
+        this.authorEmail = base.getAuthorEmail();
+        this.description = base.getDescription();
+        this.status = base.getWidgetStatus();
+        this.disable = base.isDisableRendering();
+        this.disabledMessage = base.getDisableRenderingMessage();
+        this.featured = base.isFeatured();
+    }
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getTitleUrl() {
+        return titleUrl;
+    }
+
+    public void setTitleUrl(String titleUrl) {
+        this.titleUrl = titleUrl;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getThumbnailUrl() {
+        return thumbnailUrl;
+    }
+
+    public void setThumbnailUrl(String thumbnailUrl) {
+        this.thumbnailUrl = thumbnailUrl;
+    }
+
+    public String getScreenshotUrl() {
+        return screenshotUrl;
+    }
+
+    public void setScreenshotUrl(String screenshotUrl) {
+        this.screenshotUrl = screenshotUrl;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+
+    public String getAuthorEmail() {
+        return authorEmail;
+    }
+
+    public void setAuthorEmail(String authorEmail) {
+        this.authorEmail = authorEmail;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public WidgetStatus getStatus() {
+        return status;
+    }
+
+    public void setStatus(WidgetStatus status) {
+        this.status = status;
+    }
+
+    public boolean isDisable() {
+        return disable;
+    }
+
+    public void setDisable(boolean disable) {
+        this.disable = disable;
+    }
+
+    public String getDisabledMessage() {
+        return disabledMessage;
+    }
+
+    public void setDisabledMessage(String disabledMessage) {
+        this.disabledMessage = disabledMessage;
+    }
+
+    public boolean isFeatured() {
+        return featured;
+    }
+
+    public void setFeatured(boolean featured) {
+        this.featured = featured;
+    }
+}