Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-sdnc-adapter / src / main / java / org / onap / so / adapters / sdnc / sdncrest / SNIROResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (C) 2018 IBM.
8  * Modifications Copyright (c) 2019 Samsung
9  * ================================================================================
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  * 
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  * 
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.so.adapters.sdnc.sdncrest;
25
26 import javax.servlet.http.HttpServletResponse;
27 import javax.ws.rs.Consumes;
28 import javax.ws.rs.POST;
29 import javax.ws.rs.Path;
30 import javax.ws.rs.PathParam;
31 import javax.ws.rs.Produces;
32 import javax.ws.rs.core.MediaType;
33 import javax.ws.rs.core.Response;
34 import org.onap.so.adapters.sdnc.impl.Constants;
35 import org.onap.so.logger.ErrorCode;
36 import org.onap.so.logger.MessageEnum;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.core.env.Environment;
41 import org.springframework.stereotype.Component;
42
43 /**
44  * A temporary interface to support notifications from SNIRO to BPMN. We added this to the SDNC adapter because we
45  * didn't have time to develop a SNIRO adapter in 1702.
46  */
47 @Path("/")
48 @Component
49 public class SNIROResponse {
50     private static final Logger logger = LoggerFactory.getLogger(SNIROResponse.class);
51
52
53     @Autowired
54     private Environment env;
55
56     @Autowired
57     private BPRestCallback callback;
58
59     @POST
60     @Path("/SDNCNotify/SNIROResponse/{correlator}")
61     @Consumes("*/*")
62     @Produces({MediaType.TEXT_PLAIN})
63     public Response serviceNotification(@PathParam("correlator") String correlator, String content) {
64         logger.info("{} {} {} {}", MessageEnum.RA_RECEIVE_SDNC_NOTIF.toString(), content, "SDNC",
65                 "SDNCNotify/SNIROResponse");
66
67         String bpUrl = env.getProperty(Constants.BPEL_REST_URL_PROP, "");
68
69         if (bpUrl == null || ("").equals(bpUrl)) {
70             String error = "Missing configuration for: " + Constants.BPEL_REST_URL_PROP;
71             logger.error("{} {} {} {} {}", MessageEnum.RA_SDNC_MISS_CONFIG_PARAM.toString(),
72                     Constants.BPEL_REST_URL_PROP, "SDNC", ErrorCode.DataError.getValue(), "Missing config param");
73
74             return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(error).build();
75         }
76         return Response.status(204).build();
77     }
78 }