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 java.util.ArrayList;
33 import java.util.List;
34 import javax.ws.rs.core.Response.Status;
36 public class VertexPayload {
41 private JsonElement properties;
42 private List<EdgePayload> in = new ArrayList<EdgePayload>();
43 private List<EdgePayload> out = new ArrayList<EdgePayload>();
45 private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
47 public String toJson() {
48 return gson.toJson(this);
51 public static VertexPayload fromJson(String payload) throws CrudException {
53 if (payload == null || payload.isEmpty()) {
54 throw new CrudException("Invalid Json Payload", Status.BAD_REQUEST);
56 return gson.fromJson(payload, VertexPayload.class);
57 } catch (Exception ex) {
58 throw new CrudException("Invalid Json Payload", Status.BAD_REQUEST);
62 public String getId() {
66 public void setId(String id) {
70 public String getType() {
74 public void setType(String type) {
78 public String getUrl() {
82 public void setUrl(String url) {
86 public JsonElement getProperties() {
90 public void setProperties(JsonElement properties) {
91 this.properties = properties;
94 public List<EdgePayload> getIn() {
98 public void setIn(List<EdgePayload> in) {
102 public List<EdgePayload> getOut() {
106 public void setOut(List<EdgePayload> out) {
112 public String toString() {
113 return "VertexPayload [id=" + id + ", type=" + type + ", url=" + url + ", properties="
114 + properties + ", in=" + in + ", out=" + out + "]";