6add877fe07a8a8705fe8b1f3e380524a004b26a
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / distribution / servlet / DistributionServlet.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.distribution.servlet;
22
23 import javax.annotation.Resource;
24 import javax.inject.Singleton;
25 import javax.servlet.ServletContext;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.ws.rs.Consumes;
28 import javax.ws.rs.GET;
29 import javax.ws.rs.HeaderParam;
30 import javax.ws.rs.POST;
31 import javax.ws.rs.Path;
32 import javax.ws.rs.Produces;
33 import javax.ws.rs.core.Context;
34 import javax.ws.rs.core.MediaType;
35 import javax.ws.rs.core.Response;
36
37 import org.openecomp.sdc.be.config.BeEcompErrorManager;
38 import org.openecomp.sdc.be.dao.api.ActionStatus;
39 import org.openecomp.sdc.be.distribution.AuditHandler;
40 import org.openecomp.sdc.be.distribution.DistributionBusinessLogic;
41 import org.openecomp.sdc.be.distribution.api.client.RegistrationRequest;
42 import org.openecomp.sdc.be.distribution.api.client.ServerListResponse;
43 import org.openecomp.sdc.be.distribution.api.client.TopicRegistrationResponse;
44 import org.openecomp.sdc.be.distribution.api.client.TopicUnregistrationResponse;
45 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
46 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
47 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
48 import org.openecomp.sdc.be.servlets.BeGenericServlet;
49 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
50 import org.openecomp.sdc.common.api.Constants;
51 import org.openecomp.sdc.common.config.EcompErrorName;
52 import org.openecomp.sdc.common.datastructure.Wrapper;
53 import org.openecomp.sdc.common.util.HttpUtil;
54 import org.openecomp.sdc.exception.ResponseFormat;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
57 import org.springframework.web.context.WebApplicationContext;
58
59 import com.jcabi.aspects.Loggable;
60
61 import fj.data.Either;
62 import io.swagger.annotations.Api;
63 import io.swagger.annotations.ApiImplicitParam;
64 import io.swagger.annotations.ApiImplicitParams;
65 import io.swagger.annotations.ApiOperation;
66 import io.swagger.annotations.ApiParam;
67 import io.swagger.annotations.ApiResponse;
68 import io.swagger.annotations.ApiResponses;
69 import io.swagger.annotations.ResponseHeader;
70
71 /**
72  * This Servlet serves external users for distribution purposes.
73  * 
74  * @author tgitelman
75  *
76  */
77
78 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
79 @Path("/v1")
80 @Api(value = "Distribution Servlet", description = "This Servlet serves external users for distribution purposes.")
81 @Singleton
82 public class DistributionServlet extends BeGenericServlet {
83
84         private static Logger log = LoggerFactory.getLogger(DistributionServlet.class.getName());
85         @Resource
86         private DistributionBusinessLogic distributionLogic;
87         @Context
88         private HttpServletRequest request;
89         
90         /**
91          * 
92          * @param requestId
93          * @param instanceId
94          * @param accept
95          * @param authorization
96          * @return
97          */
98         @GET
99         @Path("/distributionUebCluster")
100         @Consumes(MediaType.APPLICATION_JSON)
101         @Produces(MediaType.APPLICATION_JSON)
102         @ApiOperation(value = "UEB Server List", httpMethod = "GET", notes = "return the available UEB Server List",
103         //TODO Tal G fix response headers
104         responseHeaders = {
105                         @ResponseHeader(name = Constants.CONTENT_TYPE_HEADER, description = "Determines the format of the response body", response = String.class), 
106                         @ResponseHeader(name = "Content-Length", description = "Length of  the response body", response = String.class)})
107         @ApiResponses(value = {
108                         @ApiResponse(code = 200, message = "ECOMP component is authenticated and list of Cambria API server’s FQDNs is returned", response = ServerListResponse.class),
109                         @ApiResponse(code = 400, message = "Missing  'X-ECOMP-InstanceID'  HTTP header - POL5001"),
110                         @ApiResponse(code = 401, message = "ECOMP component  should authenticate itself  and  to  re-send  again  HTTP  request  with its credentials  for  Basic Authentication - POL5002"),
111                         @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
112                         @ApiResponse(code = 405, message = "Method  Not Allowed: Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
113                         @ApiResponse(code = 500, message = "The GET request failed either due to internal SDC problem or Cambria Service failure. ECOMP Component should continue the attempts to get the needed information - POL5000")})
114         public Response getUebServerList( 
115                         @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
116                         @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId, 
117                         @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
118                         @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization) {
119                 
120                 init(request);
121                 String url = request.getMethod() + " " + request.getRequestURI();
122                 log.debug("Start handle request of {}", url);
123                 Response response = null;
124                 ResponseFormat responseFormat = null;
125                 
126                 if (instanceId == null) {
127                         responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
128                         response = buildErrorResponse(responseFormat);
129                         getComponentsUtils().auditMissingInstanceId(AuditingActionEnum.GET_UEB_CLUSTER, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
130                         return response;
131                 }
132                 
133                 try {
134                         Either<ServerListResponse, ResponseFormat> actionResponse = distributionLogic.getUebServerList();
135
136                         if (actionResponse.isRight()) {
137                                 responseFormat = actionResponse.right().value();
138                                 response = buildErrorResponse(responseFormat);
139                         } else {
140                                 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
141                                 response = buildOkResponse(responseFormat, actionResponse.left().value());
142                         }
143
144                         getComponentsUtils().auditGetUebCluster(AuditingActionEnum.GET_UEB_CLUSTER, instanceId, null, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
145                         return response;
146
147                 } catch (Exception e) {
148                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "failed to get ueb serbver list from cofiguration");
149                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("failed to get ueb serbver list from cofiguration");
150                         log.debug("failed to get ueb serbver list from cofiguration", e);
151                         responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
152                         getComponentsUtils().auditGetUebCluster(AuditingActionEnum.GET_UEB_CLUSTER, instanceId, null, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
153                         response = buildErrorResponse(responseFormat);
154                         return response;
155                 }
156
157         }
158         
159         /**
160          * 
161          * @param requestId
162          * @param instanceId
163          * @param accept
164          * @param contenType
165          * @param contenLength
166          * @param authorization
167          * @param requestJson
168          * @return
169          */
170         @POST
171         @Path("/registerForDistribution")
172         @Consumes(MediaType.APPLICATION_JSON)
173         @Produces(MediaType.APPLICATION_JSON)
174         @ApiOperation(value = "Subscription status", httpMethod = "POST", notes = "Subscribes for distribution notifications")
175         @ApiResponses(value = {
176                         @ApiResponse(code = 200, message = "ECOMP component is successfully registered for distribution", response = TopicRegistrationResponse.class),
177                         @ApiResponse(code = 400, message = "Missing  'X-ECOMP-InstanceID'  HTTP header - POL5001"),
178                         @ApiResponse(code = 400, message = "Missing  Body - POL4500"),
179                         @ApiResponse(code = 400, message = "Invalid  Body  : missing mandatory parameter 'apiPublicKey' - POL4501"),
180                         @ApiResponse(code = 400, message = "Invalid  Body  : missing mandatory parameter 'distrEnvName' - POL4502"),
181                         @ApiResponse(code = 400, message = "Invalid Body :  Specified 'distrEnvName' doesn’t exist - POL4137"),
182                         @ApiResponse(code = 401, message = "ECOMP component  should authenticate itself  and  to  re-send  again  HTTP  request  with its Basic Authentication credentials - POL5002"),
183                         @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
184                         @ApiResponse(code = 405, message = "Method  Not Allowed  :  Invalid HTTP method type used to  register for  distribution ( PUT,DELETE,GET  will be rejected) - POL4050"),
185                         @ApiResponse(code = 500, message = "The registration failed due to internal SDC problem or Cambria Service failure ECOMP Component  should  continue the attempts to  register for  distribution - POL5000")})
186         //TODO Tal G fix response headers and to check missing header validations with Michael L
187                         @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.distribution.api.client.RegistrationRequest", paramType = "body", value = "json describe the artifact")
188         public Response registerForDistribution(
189                         @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
190                         @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId, 
191                         @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
192                         @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
193                         @ApiParam(value = "Length  of  the request body", required = true)@HeaderParam(value = Constants.CONTENT_LENGTH_HEADER) String contenLength,
194                         @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
195                         String requestJson) {
196                 String url = request.getMethod() + " " + request.getRequestURI();
197                 log.debug("Start handle request of {}", url);
198                 init(request);
199
200                 Wrapper<Response> responseWrapper = new Wrapper<>();
201                 Wrapper<RegistrationRequest> registrationRequestWrapper = new Wrapper<>();
202
203                 validateHeaders(responseWrapper, request, AuditingActionEnum.ADD_KEY_TO_TOPIC_ACL);
204
205                 if (responseWrapper.isEmpty()) {
206                         validateJson(responseWrapper, registrationRequestWrapper, requestJson);
207                 }
208                 if (responseWrapper.isEmpty()) {
209                         validateEnv(responseWrapper, registrationRequestWrapper.getInnerElement().getDistrEnvName());
210                 }
211
212                 if (responseWrapper.isEmpty()) {
213                         distributionLogic.handleRegistration(responseWrapper, registrationRequestWrapper.getInnerElement(), buildAuditHandler(request, registrationRequestWrapper.getInnerElement()));
214                 } else {
215                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDistributionEngineSystemError, DistributionBusinessLogic.REGISTER_IN_DISTRIBUTION_ENGINE, "registration validation failed");
216                         BeEcompErrorManager.getInstance().logBeDistributionEngineSystemError(DistributionBusinessLogic.REGISTER_IN_DISTRIBUTION_ENGINE, "registration validation failed");
217                 }
218
219                 return responseWrapper.getInnerElement();
220         }
221         
222         /**
223          * Returns list of valid artifact types for validation done in the distribution client.<br>
224          * The list is the representation of the values of the enum ArtifactTypeEnum.
225          * 
226          * @param requestId
227          * @param instanceId
228          * @param authorization
229          * @param accept
230          * @return
231          */
232         @GET
233         @Path("/artifactTypes")
234         @Consumes(MediaType.APPLICATION_JSON)
235         @Produces(MediaType.APPLICATION_JSON)
236         @ApiOperation(value = "Artifact types list", httpMethod = "GET", notes = "Fetches available artifact types list")
237         @ApiResponses(value = {
238                         @ApiResponse(code = 200, message = "Artifact types list fetched successfully", response = String.class),
239                         @ApiResponse(code = 400, message = "Missing  'X-ECOMP-InstanceID'  HTTP header - POL5001"),
240                         @ApiResponse(code = 401, message = "ECOMP component  should authenticate itself  and  to  re-send  again  HTTP  request  with its Basic Authentication credentials - POL5002"),
241                         @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
242                         @ApiResponse(code = 405, message = "Method  Not Allowed  :  Invalid HTTP method type used to  register for  distribution ( POST,PUT,DELETE  will be rejected) - POL4050"),
243                         @ApiResponse(code = 500, message = "The registration failed due to internal SDC problem or Cambria Service failure ECOMP Component  should  continue the attempts to  register for  distribution - POL5000")})
244         public Response getValidArtifactTypes(
245                         @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
246                         @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId, 
247                         @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization, 
248                         @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept) {
249                 init(request);
250                 String url = request.getMethod() + " " + request.getRequestURI();
251                 log.debug("Start handle request of {}", url);
252                 Response response = null;
253
254                 Wrapper<Response> responseWrapper = new Wrapper<>();
255
256                 validateHeaders(responseWrapper, request, AuditingActionEnum.GET_VALID_ARTIFACT_TYPES);
257                 if (responseWrapper.isEmpty()) {
258                         response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), ArtifactTypeEnum.values());
259                 } else {
260                         response = responseWrapper.getInnerElement();
261                 }
262                 return response;
263         }
264         
265         /**
266          * Removes from subscription for distribution notifications
267          * 
268          * @param requestId
269          * @param instanceId
270          * @param accept
271          * @param contenType
272          * @param contenLength
273          * @param authorization
274          * @param requestJson
275          * @return
276          */
277         @POST
278         @Path("/unRegisterForDistribution")
279         @Consumes(MediaType.APPLICATION_JSON)
280         @Produces(MediaType.APPLICATION_JSON)
281         @ApiOperation(value = "Subscription status", httpMethod = "POST", notes = "Removes from subscription for distribution notifications")
282         //TODO Edit the responses
283         @ApiResponses(value = {
284                         @ApiResponse(code = 204, message = "ECOMP component is successfully unregistered", response = TopicUnregistrationResponse.class),
285                         @ApiResponse(code = 400, message = "Missing  'X-ECOMP-InstanceID'  HTTP header - POL5001"),
286                         @ApiResponse(code = 400, message = "Missing  Body - POL4500"),
287                         @ApiResponse(code = 400, message = "Invalid  Body  : missing mandatory parameter 'apiPublicKey' - POL4501"),
288                         @ApiResponse(code = 400, message = "Invalid  Body  : missing mandatory parameter 'distrEnvName' - SVC4506"),
289                         @ApiResponse(code = 400, message = "Invalid Body :  Specified 'distrEnvName' doesn’t exist - POL4137"),
290                         @ApiResponse(code = 401, message = "ECOMP component  should authenticate itself  and  to  re-send  again  HTTP  request  with its Basic Authentication credentials - POL5002"),
291                         @ApiResponse(code = 403, message = "ECOMP component is not authorized - POL5003"),
292                         @ApiResponse(code = 405, message = "Method  Not Allowed  :  Invalid HTTP method type used to  register for  distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
293                         @ApiResponse(code = 500, message = "The registration failed due to internal SDC problem or Cambria Service failure ECOMP Component  should  continue the attempts to  register for  distribution - POL5000")})
294                         @ApiImplicitParam(required = true, dataType = "org.openecomp.sdc.be.distribution.api.client.RegistrationRequest", paramType = "body", value = "json describe the artifact")
295         public Response unRegisterForDistribution( 
296                         @ApiParam(value = "X-ECOMP-RequestID header", required = false)@HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
297                         @ApiParam(value = "X-ECOMP-InstanceID header", required = true)@HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId, 
298                         @ApiParam(value = "Determines the format of the body of the response", required = false)@HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
299                         @ApiParam(value = "Determines the format of the body of the request", required = true)@HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contenType,
300                         @ApiParam(value = "Length  of  the request body", required = true)@HeaderParam(value = Constants.CONTENT_LENGTH_HEADER) String contenLength,
301                         @ApiParam(value = "The username and password", required = true)@HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
302                         String requestJson) {
303                 
304                 String url = request.getMethod() + " " + request.getRequestURI();
305                 log.debug("Start handle request of {}", url);
306                 init(request);
307
308                 Wrapper<Response> responseWrapper = new Wrapper<>();
309                 Wrapper<RegistrationRequest> unRegistrationRequestWrapper = new Wrapper<>();
310
311                 validateHeaders(responseWrapper, request, AuditingActionEnum.REMOVE_KEY_FROM_TOPIC_ACL);
312
313                 if (responseWrapper.isEmpty()) {
314                         validateJson(responseWrapper, unRegistrationRequestWrapper, requestJson);
315                 }
316                 if (responseWrapper.isEmpty()) {
317                         validateEnv(responseWrapper, unRegistrationRequestWrapper.getInnerElement().getDistrEnvName());
318                 }
319                 if (responseWrapper.isEmpty()) {
320                         distributionLogic.handleUnRegistration(responseWrapper, unRegistrationRequestWrapper.getInnerElement(), buildAuditHandler(request, unRegistrationRequestWrapper.getInnerElement()));
321                 } else {
322                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeDistributionEngineSystemError, DistributionBusinessLogic.UN_REGISTER_IN_DISTRIBUTION_ENGINE, "unregistration validation failed");
323                         BeEcompErrorManager.getInstance().logBeDistributionEngineSystemError(DistributionBusinessLogic.UN_REGISTER_IN_DISTRIBUTION_ENGINE, "unregistration validation failed");
324                 }
325
326                 return responseWrapper.getInnerElement();
327         }
328
329         private void validateEnv(Wrapper<Response> responseWrapper, String distrEnvName) {
330
331                 // DE194021
332                 StorageOperationStatus environmentStatus = distributionLogic.getDistributionEngine().isEnvironmentAvailable();
333                 // DE194021
334                 // StorageOperationStatus environmentStatus =
335                 // distributionLogic.getDistributionEngine().isEnvironmentAvailable(distrEnvName);
336                 if (environmentStatus != StorageOperationStatus.OK) {
337                         if (environmentStatus == StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND) {
338                                 Response missingHeaderResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.DISTRIBUTION_ENV_DOES_NOT_EXIST));
339                                 responseWrapper.setInnerElement(missingHeaderResponse);
340                         } else {
341                                 Response missingHeaderResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.GENERAL_ERROR));
342                                 responseWrapper.setInnerElement(missingHeaderResponse);
343                         }
344                 }
345
346         }
347
348         private void init(HttpServletRequest request) {
349                 if (distributionLogic == null) {
350                         distributionLogic = getDistributionBL(request.getSession().getServletContext());
351                 }
352         }
353
354         private void validateHeaders(Wrapper<Response> responseWrapper, HttpServletRequest request, AuditingActionEnum auditingAction) {
355                 if (request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER) == null) {
356                         Response missingHeaderResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID));
357                         responseWrapper.setInnerElement(missingHeaderResponse);
358                         // Audit
359                         ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
360                         getComponentsUtils().auditMissingInstanceId(auditingAction, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
361
362                 }
363
364         }
365
366         private void validateJson(Wrapper<Response> responseWrapper, Wrapper<RegistrationRequest> registrationRequestWrapper, String requestJson) {
367                 if (requestJson == null || requestJson.isEmpty()) {
368                         Response missingBodyResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_BODY));
369                         responseWrapper.setInnerElement(missingBodyResponse);
370                 } else {
371                         Either<RegistrationRequest, Exception> eitherRegistration = HttpUtil.convertJsonStringToObject(requestJson, RegistrationRequest.class);
372                         if (eitherRegistration.isLeft()) {
373                                 RegistrationRequest registrationRequest = eitherRegistration.left().value();
374                                 if (registrationRequest.getApiPublicKey() == null) {
375                                         Response missingBodyResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_PUBLIC_KEY));
376                                         responseWrapper.setInnerElement(missingBodyResponse);
377
378                                 } else if (registrationRequest.getDistrEnvName() == null) {
379                                         Response missingBodyResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_ENV_NAME));
380                                         responseWrapper.setInnerElement(missingBodyResponse);
381                                 } else {
382                                         registrationRequestWrapper.setInnerElement(registrationRequest);
383                                 }
384                         } else {
385                                 Response missingBodyResponse = buildErrorResponse(distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_BODY));
386                                 responseWrapper.setInnerElement(missingBodyResponse);
387                         }
388                 }
389
390         }
391
392         private DistributionBusinessLogic getDistributionBL(ServletContext context) {
393                 WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
394                 WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(context);
395                 return webApplicationContext.getBean(DistributionBusinessLogic.class);
396         }
397
398         private AuditHandler buildAuditHandler(HttpServletRequest request, RegistrationRequest registrationRequest) {
399                 return new AuditHandler(getComponentsUtils(), request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER), registrationRequest);
400         }
401 }