2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
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=========================================================
22 package org.openecomp.mso.adapters.nwrest;
26 import java.io.ByteArrayOutputStream;
28 import javax.xml.bind.JAXBContext;
29 import javax.xml.bind.Marshaller;
31 import org.codehaus.jackson.map.ObjectMapper;
32 import org.codehaus.jackson.map.SerializationConfig;
33 import org.openecomp.mso.logger.MsoLogger;
36 * Everything that is common between all Network Requests.
38 public abstract class NetworkRequestCommon {
39 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
40 private Boolean skipAAI = false;
41 private String messageId;
42 private String notificationUrl;
44 public Boolean getSkipAAI() {
48 public void setSkipAAI(Boolean skipAAI) {
49 this.skipAAI = skipAAI;
52 public String getMessageId() {
56 public void setMessageId(String messageId) {
57 this.messageId = messageId;
60 public String getNotificationUrl() {
61 return notificationUrl;
64 public void setNotificationUrl(String notificationUrl) {
65 this.notificationUrl = notificationUrl;
68 public boolean isSynchronous() {
69 return notificationUrl == null || (notificationUrl.isEmpty());
72 public String toJsonString() {
73 String jsonString = null;
75 ObjectMapper mapper = new ObjectMapper();
76 mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE);
77 jsonString = mapper.writeValueAsString(this);
78 } catch (Exception e) {
79 LOGGER.debug("Exception:", e);
84 public String toXmlString() {
86 ByteArrayOutputStream bs = new ByteArrayOutputStream();
87 JAXBContext context = JAXBContext.newInstance(this.getClass());
88 Marshaller marshaller = context.createMarshaller();
89 marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML
90 marshaller.marshal(this, bs);
92 } catch (Exception e) {
93 LOGGER.debug("Exception:", e);