2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
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 and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
25 package org.onap.aai.sparky.subscription.payload.entity;
28 import java.io.IOException;
30 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
31 import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
33 import com.fasterxml.jackson.annotation.JsonInclude;
34 import com.fasterxml.jackson.annotation.JsonProperty;
35 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
36 import com.fasterxml.jackson.core.JsonParseException;
37 import com.fasterxml.jackson.databind.JsonMappingException;
38 import com.fasterxml.jackson.databind.ObjectMapper;
40 @JsonInclude(JsonInclude.Include.NON_NULL)
41 @JsonPropertyOrder({ "target", "origin", "messageType", "topic", "message" })
42 public class ObjectInspectorPayload {
44 @JsonProperty("target")
45 private String target;
46 @JsonProperty("origin")
47 private String origin;
48 @JsonProperty("messageType")
49 private String messageType;
50 @JsonProperty("topic")
52 @JsonProperty("message")
53 private Message message;
55 @JsonProperty("target")
56 public String getTarget() {
60 @JsonProperty("target")
61 public void setTarget(String target) {
65 @JsonProperty("origin")
66 public String getOrigin() {
70 @JsonProperty("origin")
71 public void setOrigin(String origin) {
75 @JsonProperty("messageType")
76 public String getMessageType() {
80 @JsonProperty("messageType")
81 public void setMessageType(String messageType) {
82 this.messageType = messageType;
85 @JsonProperty("topic")
86 public String getTopic() {
90 @JsonProperty("topic")
91 public void setTopic(String topic) {
95 @JsonProperty("message")
96 public Message getMessage() {
100 @JsonProperty("message")
101 public void setMessage(Message message) {
102 this.message = message;
105 private static ObjectInspectorPayload lic;
106 public static ObjectInspectorPayload getOIPayload(SubscriptionConfig subscriptionConf) throws JsonParseException, JsonMappingException, IOException{
108 ObjectMapper mapper = new ObjectMapper();
109 lic = mapper.readValue(new File(SparkyConstants.SUBSCRIPTION_OI_MAPPING), ObjectInspectorPayload.class);
110 lic.intitializeOIPayload(subscriptionConf);
116 private void intitializeOIPayload(SubscriptionConfig subscriptionConf) {
118 lic.setOrigin(subscriptionConf.getLaunchOIOrigin());
119 lic.setTarget(subscriptionConf.getLaunchOITarget());
120 lic.setTopic(subscriptionConf.getLaunchOITopic());
121 lic.setMessageType(subscriptionConf.getLaunchOIMessageType());
122 } catch (Exception e) {
123 // TODO Auto-generated catch block