2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.sparky.subscription.payload.entity;
24 import java.io.IOException;
26 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
27 import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
29 import com.fasterxml.jackson.annotation.JsonInclude;
30 import com.fasterxml.jackson.annotation.JsonProperty;
31 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
32 import com.fasterxml.jackson.core.JsonParseException;
33 import com.fasterxml.jackson.databind.JsonMappingException;
34 import com.fasterxml.jackson.databind.ObjectMapper;
36 @JsonInclude(JsonInclude.Include.NON_NULL)
37 @JsonPropertyOrder({ "target", "origin", "messageType", "topic", "message" })
38 public class ObjectInspectorPayload {
40 @JsonProperty("target")
41 private String target;
42 @JsonProperty("origin")
43 private String origin;
44 @JsonProperty("messageType")
45 private String messageType;
46 @JsonProperty("topic")
48 @JsonProperty("message")
49 private Message message;
51 @JsonProperty("target")
52 public String getTarget() {
56 @JsonProperty("target")
57 public void setTarget(String target) {
61 @JsonProperty("origin")
62 public String getOrigin() {
66 @JsonProperty("origin")
67 public void setOrigin(String origin) {
71 @JsonProperty("messageType")
72 public String getMessageType() {
76 @JsonProperty("messageType")
77 public void setMessageType(String messageType) {
78 this.messageType = messageType;
81 @JsonProperty("topic")
82 public String getTopic() {
86 @JsonProperty("topic")
87 public void setTopic(String topic) {
91 @JsonProperty("message")
92 public Message getMessage() {
96 @JsonProperty("message")
97 public void setMessage(Message message) {
98 this.message = message;
101 private static ObjectInspectorPayload lic;
102 public static ObjectInspectorPayload getOIPayload(SubscriptionConfig subscriptionConf) throws JsonParseException, JsonMappingException, IOException{
104 ObjectMapper mapper = new ObjectMapper();
105 lic = mapper.readValue(new File(SparkyConstants.SUBSCRIPTION_OI_MAPPING), ObjectInspectorPayload.class);
106 lic.intitializeOIPayload(subscriptionConf);
112 private void intitializeOIPayload(SubscriptionConfig subscriptionConf) {
114 lic.setOrigin(subscriptionConf.getLaunchOIOrigin());
115 lic.setTarget(subscriptionConf.getLaunchOITarget());
116 lic.setTopic(subscriptionConf.getLaunchOITopic());
117 lic.setMessageType(subscriptionConf.getLaunchOIMessageType());
118 } catch (Exception e) {
119 // TODO Auto-generated catch block