2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.crud.service;
26 import com.google.gson.Gson;
27 import com.google.gson.GsonBuilder;
28 import com.google.gson.JsonElement;
30 import org.onap.crud.exception.CrudException;
32 import javax.ws.rs.core.Response.Status;
34 public class EdgePayload {
39 private String source;
40 private String target;
41 private JsonElement properties;
43 private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
47 public String toString() {
48 return "EdgePayload [id=" + id + ", type=" + type + ", url=" + url + ", source="
49 + source + ", target=" + target + ", properties=" + properties + "]";
52 public String toJson() {
53 return gson.toJson(this);
56 public static EdgePayload fromJson(String payload) throws CrudException {
58 if (payload == null || payload.isEmpty()) {
59 throw new CrudException("Invalid Json Payload", Status.BAD_REQUEST);
61 return gson.fromJson(payload, EdgePayload.class);
62 } catch (Exception ex) {
63 throw new CrudException("Invalid Json Payload", Status.BAD_REQUEST);
67 public String getId() {
71 public void setId(String id) {
75 public String getType() {
79 public void setType(String type) {
83 public String getUrl() {
87 public void setUrl(String url) {
91 public String getSource() {
95 public void setSource(String source) {
99 public String getTarget() {
103 public void setTarget(String target) {
104 this.target = target;
107 public JsonElement getProperties() {
111 public void setProperties(JsonElement properties) {
112 this.properties = properties;