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 2014/07/03 18:46:13 UTC
[19/50] git commit: Created new Widget REST model and interface
Created new Widget REST model and interface
git-svn-id: https://svn.apache.org/repos/asf/rave/trunk@1540803 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/rave/repo
Commit: http://git-wip-us.apache.org/repos/asf/rave/commit/23329585
Tree: http://git-wip-us.apache.org/repos/asf/rave/tree/23329585
Diff: http://git-wip-us.apache.org/repos/asf/rave/diff/23329585
Branch: refs/heads/angular
Commit: 2332958507aa2b6c8b561202b525ba53c7a642b7
Parents: dd45b76
Author: Matthew B. Franklin <mf...@apache.org>
Authored: Mon Nov 11 18:55:55 2013 +0000
Committer: Matthew B. Franklin <mf...@apache.org>
Committed: Mon Nov 11 18:55:55 2013 +0000
----------------------------------------------------------------------
.../org/apache/rave/rest/WidgetsResource.java | 74 +++++++
.../java/org/apache/rave/rest/model/Widget.java | 192 +++++++++++++++++++
2 files changed, 266 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/rave/blob/23329585/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java
----------------------------------------------------------------------
diff --git a/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java b/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java
new file mode 100644
index 0000000..6e2e03f
--- /dev/null
+++ b/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/WidgetsResource.java
@@ -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);
+
+}
http://git-wip-us.apache.org/repos/asf/rave/blob/23329585/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java
----------------------------------------------------------------------
diff --git a/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java b/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java
new file mode 100644
index 0000000..68d085d
--- /dev/null
+++ b/rave-components/rave-core-api/src/main/java/org/apache/rave/rest/model/Widget.java
@@ -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;
+ }
+}