2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.subscription.payload.entity;
26 import java.io.IOException;
28 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
29 import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
31 import com.fasterxml.jackson.annotation.JsonInclude;
32 import com.fasterxml.jackson.annotation.JsonProperty;
33 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
34 import com.fasterxml.jackson.core.JsonParseException;
35 import com.fasterxml.jackson.databind.JsonMappingException;
36 import com.fasterxml.jackson.databind.ObjectMapper;
38 @JsonInclude(JsonInclude.Include.NON_NULL)
39 @JsonPropertyOrder({ "target", "origin", "messageType", "topic", "message" })
40 public class ObjectInspectorPayload {
42 @JsonProperty("target")
43 private String target;
44 @JsonProperty("origin")
45 private String origin;
46 @JsonProperty("messageType")
47 private String messageType;
48 @JsonProperty("topic")
50 @JsonProperty("message")
51 private Message message;
53 @JsonProperty("target")
54 public String getTarget() {
58 @JsonProperty("target")
59 public void setTarget(String target) {
63 @JsonProperty("origin")
64 public String getOrigin() {
68 @JsonProperty("origin")
69 public void setOrigin(String origin) {
73 @JsonProperty("messageType")
74 public String getMessageType() {
78 @JsonProperty("messageType")
79 public void setMessageType(String messageType) {
80 this.messageType = messageType;
83 @JsonProperty("topic")
84 public String getTopic() {
88 @JsonProperty("topic")
89 public void setTopic(String topic) {
93 @JsonProperty("message")
94 public Message getMessage() {
98 @JsonProperty("message")
99 public void setMessage(Message message) {
100 this.message = message;
103 private static ObjectInspectorPayload lic;
104 public static ObjectInspectorPayload getOIPayload(SubscriptionConfig subscriptionConf) throws JsonParseException, JsonMappingException, IOException{
106 ObjectMapper mapper = new ObjectMapper();
107 lic = mapper.readValue(new File(SparkyConstants.SUBSCRIPTION_OI_MAPPING), ObjectInspectorPayload.class);
108 lic.intitializeOIPayload(subscriptionConf);
114 private void intitializeOIPayload(SubscriptionConfig subscriptionConf) {
116 lic.setOrigin(subscriptionConf.getLaunchOIOrigin());
117 lic.setTarget(subscriptionConf.getLaunchOITarget());
118 lic.setTopic(subscriptionConf.getLaunchOITopic());
119 lic.setMessageType(subscriptionConf.getLaunchOIMessageType());
120 } catch (Exception e) {
121 // TODO Auto-generated catch block