2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.mso.adapters.sdnc.sdncrest;
22 import org.openecomp.mso.adapters.sdnc.impl.Constants;
23 import org.openecomp.mso.logger.MessageEnum;
24 import org.openecomp.mso.logger.MsoAlarmLogger;
25 import org.openecomp.mso.logger.MsoLogger;
27 import javax.servlet.http.HttpServletResponse;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.Response;
33 * A temporary interface to support notifications from SNIRO to BPMN.
34 * We added this to the SDNC adapter because we didn't have time to
35 * develop a SNIRO adapter in 1702.
38 public class SNIROResponse {
39 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
40 private static final MsoAlarmLogger ALARMLOGGER = new MsoAlarmLogger();
43 @Path("/SDNCNotify/SNIROResponse/{correlator}")
45 @Produces({MediaType.TEXT_PLAIN})
46 public Response serviceNotification(@PathParam("correlator") String correlator, String content) {
47 LOGGER.info(MessageEnum.RA_RECEIVE_SDNC_NOTIF, content, "SDNC", "SDNCNotify/SNIROResponse");
49 long startTime = System.currentTimeMillis();
51 String bpUrl = SDNCAdapterProperties.getProperty(Constants.BPEL_REST_URL_PROP, null);
54 String error = "Missing configuration for: " + Constants.BPEL_REST_URL_PROP;
55 LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.BPEL_REST_URL_PROP, "SDNC", "",
56 MsoLogger.ErrorCode.DataError, "Missing config param");
57 ALARMLOGGER.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
58 return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(error).build();
61 long bpStartTime = System.currentTimeMillis();
62 BPRestCallback callback = new BPRestCallback();
63 boolean callbackSuccess = callback.send(bpUrl, "SNIROResponse", correlator, content);
65 if (callbackSuccess) {
66 LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
67 "Sent notification", "BPMN", bpUrl, null);
68 LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
70 LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
71 "Failed to send notification", "BPMN", bpUrl, null);
72 LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
73 "Failed to send notification");
76 return Response.status(204).build();