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.sdc.be.distribution.servlet;
22 import com.jcabi.aspects.Loggable;
23 import fj.data.Either;
24 import io.swagger.v3.oas.annotations.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.Parameters;
27 import io.swagger.v3.oas.annotations.media.ArraySchema;
28 import io.swagger.v3.oas.annotations.media.Content;
29 import io.swagger.v3.oas.annotations.media.Schema;
30 import io.swagger.v3.oas.annotations.responses.ApiResponse;
31 import io.swagger.v3.oas.annotations.servers.Server;
32 import io.swagger.v3.oas.annotations.servers.Servers;
33 import io.swagger.v3.oas.annotations.tags.Tag;
34 import io.swagger.v3.oas.annotations.tags.Tags;
35 import javax.inject.Inject;
36 import javax.servlet.http.HttpServletRequest;
37 import javax.ws.rs.Consumes;
38 import javax.ws.rs.GET;
39 import javax.ws.rs.HeaderParam;
40 import javax.ws.rs.POST;
41 import javax.ws.rs.Path;
42 import javax.ws.rs.Produces;
43 import javax.ws.rs.core.Context;
44 import javax.ws.rs.core.MediaType;
45 import javax.ws.rs.core.Response;
46 import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
47 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
48 import org.openecomp.sdc.be.config.BeEcompErrorManager;
49 import org.openecomp.sdc.be.dao.api.ActionStatus;
50 import org.openecomp.sdc.be.distribution.AuditHandler;
51 import org.openecomp.sdc.be.distribution.DistributionBusinessLogic;
52 import org.openecomp.sdc.be.distribution.api.client.KafkaDataResponse;
53 import org.openecomp.sdc.be.distribution.api.client.RegistrationRequest;
54 import org.openecomp.sdc.be.distribution.api.client.ServerListResponse;
55 import org.openecomp.sdc.be.distribution.api.client.TopicRegistrationResponse;
56 import org.openecomp.sdc.be.distribution.api.client.TopicUnregistrationResponse;
57 import org.openecomp.sdc.be.impl.ComponentsUtils;
58 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
59 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
60 import org.openecomp.sdc.be.servlets.BeGenericServlet;
61 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
62 import org.openecomp.sdc.common.api.Constants;
63 import org.openecomp.sdc.common.datastructure.Wrapper;
64 import org.openecomp.sdc.common.log.wrappers.Logger;
65 import org.openecomp.sdc.common.util.HttpUtil;
66 import org.openecomp.sdc.exception.ResponseFormat;
67 import org.springframework.stereotype.Controller;
70 * This Servlet serves external users for distribution purposes.
74 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
76 @Tags({@Tag(name = "SDCE-6 APIs")})
77 @Servers({@Server(url = "/sdc")})
79 public class DistributionServlet extends BeGenericServlet {
81 private static final String START_HANDLE_REQUEST_OF = "Start handle request of {}";
82 private static final Logger log = Logger.getLogger(DistributionServlet.class);
83 private final DistributionBusinessLogic distributionLogic;
85 private HttpServletRequest request;
88 public DistributionServlet(ComponentsUtils componentsUtils, DistributionBusinessLogic distributionLogic) {
89 super(componentsUtils);
90 this.distributionLogic = distributionLogic;
97 * @param authorization
101 @Path("/distributionUebCluster")
102 @Consumes(MediaType.APPLICATION_JSON)
103 @Produces(MediaType.APPLICATION_JSON)
104 @Operation(description = "UEB Server List", method = "GET", summary = "return the available UEB Server List", responses = {
105 @ApiResponse(responseCode = "200", description = "ECOMP component is authenticated and list of Cambria API server’s FQDNs is returned", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ServerListResponse.class)))),
106 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
107 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its credentials for Basic Authentication - POL5002"),
108 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
109 @ApiResponse(responseCode = "405", description = "Method Not Allowed: Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
110 @ApiResponse(responseCode = "500", description = "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")})
111 //TODO Tal G fix response headers
113 /*responseHeaders = {
114 @ResponseHeader(name = Constants.CONTENT_TYPE_HEADER, description = "Determines the format of the response body", response = String.class),
115 @ResponseHeader(name = "Content-Length", description = "Length of the response body", response = String.class)})*/
116 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
117 public Response getUebServerList(
118 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
119 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
120 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
121 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization) {
122 String url = request.getMethod() + " " + request.getRequestURI();
123 log.debug(START_HANDLE_REQUEST_OF, url);
124 Response response = null;
125 ResponseFormat responseFormat = null;
126 if (instanceId == null) {
127 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
128 response = buildErrorResponse(responseFormat);
129 getComponentsUtils().auditGetUebCluster(null, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
133 Either<ServerListResponse, ResponseFormat> actionResponse = distributionLogic.getUebServerList();
134 if (actionResponse.isRight()) {
135 responseFormat = actionResponse.right().value();
136 response = buildErrorResponse(responseFormat);
138 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
139 response = buildOkResponse(responseFormat, actionResponse.left().value());
141 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
143 } catch (Exception e) {
144 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("failed to get ueb serbver list from cofiguration");
145 log.debug("failed to get ueb serbver list from cofiguration", e);
146 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
147 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
148 return buildErrorResponse(responseFormat);
153 * @param requestId UUID to track the incoming request
154 * @param instanceId UUID to identify the requesting instance
155 * @param accept Determines the format of the body of the response
156 * @param authorization Username and password auth towards SDC
157 * @return KafkaDataResponse (Kafka bootstrap server and topic list to be used by clients)
160 @Path("/distributionKafkaData")
161 @Consumes(MediaType.APPLICATION_JSON)
162 @Produces(MediaType.APPLICATION_JSON)
163 @Operation(description = "Kafka data", method = "GET", summary = "return the kafka cluster and topic list", responses = {
164 @ApiResponse(responseCode = "200", description = "ECOMP component is authenticated and kafka endpoint and topic list is returned", content = @Content(array = @ArraySchema(schema = @Schema(implementation = KafkaDataResponse.class)))),
165 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
166 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its credentials for Basic Authentication - POL5002"),
167 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
168 @ApiResponse(responseCode = "405", description = "Method Not Allowed: Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
169 @ApiResponse(responseCode = "500", description = "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")})
170 public Response getKafkaData(
171 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
172 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
173 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
174 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization) {
175 String url = request.getMethod() + " " + request.getRequestURI();
176 log.debug(START_HANDLE_REQUEST_OF, url);
177 ResponseFormat responseFormat;
178 if (instanceId == null) {
179 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
180 getComponentsUtils().auditGetUebCluster(null, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
181 return buildErrorResponse(responseFormat);
185 Either<KafkaDataResponse, ResponseFormat> actionResponse = distributionLogic.getKafkaData();
186 if (actionResponse.isRight()) {
187 responseFormat = actionResponse.right().value();
188 response = buildErrorResponse(responseFormat);
190 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
191 response = buildOkResponse(responseFormat, actionResponse.left().value());
193 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
195 } catch (Exception e) {
196 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("failed to get kafka cluster and topic list from configuration");
197 log.debug("failed to get kafka cluster and topic list from configuration", e);
198 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
199 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
200 return buildErrorResponse(responseFormat);
209 * @param contenLength
210 * @param authorization
215 @Path("/registerForDistribution")
216 @Consumes(MediaType.APPLICATION_JSON)
217 @Produces(MediaType.APPLICATION_JSON)
218 @Operation(parameters = {
219 @Parameter(name = "requestJson", required = true, schema = @Schema(implementation = org.openecomp.sdc.be.distribution.api.client.RegistrationRequest.class))}, description = "Subscription status", method = "POST", summary = "Subscribes for distribution notifications", responses = {
220 @ApiResponse(responseCode = "200", description = "ECOMP component is successfully registered for distribution", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TopicRegistrationResponse.class)))),
221 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
222 @ApiResponse(responseCode = "400", description = "Missing Body - POL4500"),
223 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'apiPublicKey' - POL4501"),
224 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'distrEnvName' - POL4502"),
225 @ApiResponse(responseCode = "400", description = "Invalid Body : Specified 'distrEnvName' doesn’t exist - POL4137"),
226 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
227 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
228 @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
229 @ApiResponse(responseCode = "500", description = "The registration failed due to internal SDC problem or Cambria Service failure ECOMP Component should continue the attempts to register for distribution - POL5000")})
230 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
231 public Response registerForDistribution(
232 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
233 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
234 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
235 @Parameter(description = "Determines the format of the body of the request", required = true) @HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contentType,
236 @Parameter(description = "Length of the request body", required = true) @HeaderParam(value = Constants.CONTENT_LENGTH_HEADER) String contenLength,
237 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
238 @Parameter(hidden = true) String requestJson) {
239 String url = request.getMethod() + " " + request.getRequestURI();
240 log.debug(START_HANDLE_REQUEST_OF, url);
241 Wrapper<Response> responseWrapper = new Wrapper<>();
242 Wrapper<RegistrationRequest> registrationRequestWrapper = new Wrapper<>();
243 validateHeaders(responseWrapper, request, AuditingActionEnum.ADD_KEY_TO_TOPIC_ACL);
244 if (responseWrapper.isEmpty()) {
245 validateJson(responseWrapper, registrationRequestWrapper, requestJson);
247 if (responseWrapper.isEmpty()) {
248 validateEnv(responseWrapper);
250 if (responseWrapper.isEmpty()) {
251 distributionLogic.handleRegistration(responseWrapper, registrationRequestWrapper.getInnerElement(),
252 buildAuditHandler(request, registrationRequestWrapper.getInnerElement()));
254 BeEcompErrorManager.getInstance()
255 .logBeDistributionEngineSystemError(DistributionBusinessLogic.REGISTER_IN_DISTRIBUTION_ENGINE, "registration validation failed");
257 return responseWrapper.getInnerElement();
261 * Returns list of valid artifact types for validation done in the distribution client.<br> The list is the representation of the values of the
262 * enum ArtifactTypeEnum.
265 @Path("/artifactTypes")
266 @Consumes(MediaType.APPLICATION_JSON)
267 @Produces(MediaType.APPLICATION_JSON)
268 @Operation(description = "Artifact types list", method = "GET", summary = "Fetches available artifact types list", responses = {
269 @ApiResponse(responseCode = "200", description = "Artifact types list fetched successfully", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))),
270 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
271 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
272 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
273 @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( POST,PUT,DELETE will be rejected) - POL4050"),
274 @ApiResponse(responseCode = "500", description = "The registration failed due to internal SDC problem or Cambria Service failure ECOMP Component should continue the attempts to register for distribution - POL5000")})
275 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
276 public Response getValidArtifactTypes(
277 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
278 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
279 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
280 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept) {
281 String url = request.getMethod() + " " + request.getRequestURI();
282 log.debug(START_HANDLE_REQUEST_OF, url);
283 Wrapper<Response> responseWrapper = new Wrapper<>();
284 //TODO check if in use
285 validateHeaders(responseWrapper, request, AuditingActionEnum.GET_VALID_ARTIFACT_TYPES);
286 if (responseWrapper.isEmpty()) {
287 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), ArtifactTypeEnum.values());
289 return responseWrapper.getInnerElement();
294 * Removes from subscription for distribution notifications
300 * @param contenLength
301 * @param authorization
306 @Path("/unRegisterForDistribution")
307 @Consumes(MediaType.APPLICATION_JSON)
308 @Produces(MediaType.APPLICATION_JSON)
309 @Operation(parameters = @Parameter(name = "requestJson", required = true), description = "Subscription status", method = "POST", summary = "Removes from subscription for distribution notifications", responses = {
310 @ApiResponse(responseCode = "204", description = "ECOMP component is successfully unregistered", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TopicUnregistrationResponse.class)))),
311 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
312 @ApiResponse(responseCode = "400", description = "Missing Body - POL4500"),
313 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'apiPublicKey' - POL4501"),
314 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'distrEnvName' - SVC4506"),
315 @ApiResponse(responseCode = "400", description = "Invalid Body : Specified 'distrEnvName' doesn’t exist - POL4137"),
316 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
317 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
318 @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
319 @ApiResponse(responseCode = "500", description = "The registration failed due to internal SDC problem or Cambria Service failure ECOMP Component should continue the attempts to register for distribution - POL5000")})
320 //TODO Edit the responses
322 @Parameter(name = "requestJson", required = true, schema = @Schema(implementation = org.openecomp.sdc.be.distribution.api.client.RegistrationRequest.class), description = "json describe the artifact")})
323 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
324 public Response unRegisterForDistribution(
325 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
326 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
327 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
328 @Parameter(description = "Determines the format of the body of the request", required = true) @HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contentType,
329 @Parameter(description = "Length of the request body", required = true) @HeaderParam(value = Constants.CONTENT_LENGTH_HEADER) String contenLength,
330 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
331 @Parameter(hidden = true) String requestJson) {
332 String url = request.getMethod() + " " + request.getRequestURI();
333 log.debug(START_HANDLE_REQUEST_OF, url);
334 Wrapper<Response> responseWrapper = new Wrapper<>();
335 Wrapper<RegistrationRequest> unRegistrationRequestWrapper = new Wrapper<>();
336 validateHeaders(responseWrapper, request, AuditingActionEnum.REMOVE_KEY_FROM_TOPIC_ACL);
337 if (responseWrapper.isEmpty()) {
338 validateJson(responseWrapper, unRegistrationRequestWrapper, requestJson);
340 if (responseWrapper.isEmpty()) {
341 validateEnv(responseWrapper);
343 if (responseWrapper.isEmpty()) {
344 distributionLogic.handleUnRegistration(responseWrapper, unRegistrationRequestWrapper.getInnerElement(),
345 buildAuditHandler(request, unRegistrationRequestWrapper.getInnerElement()));
347 BeEcompErrorManager.getInstance()
348 .logBeDistributionEngineSystemError(DistributionBusinessLogic.UN_REGISTER_IN_DISTRIBUTION_ENGINE, "unregistration validation failed");
350 return responseWrapper.getInnerElement();
353 private void validateEnv(Wrapper<Response> responseWrapper) {
355 StorageOperationStatus environmentStatus = distributionLogic.getDistributionEngine().isEnvironmentAvailable();
356 if (environmentStatus != StorageOperationStatus.OK) {
357 if (environmentStatus == StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND) {
358 Response missingHeaderResponse = buildErrorResponse(
359 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.DISTRIBUTION_ENV_DOES_NOT_EXIST));
360 responseWrapper.setInnerElement(missingHeaderResponse);
362 Response missingHeaderResponse = buildErrorResponse(
363 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.GENERAL_ERROR));
364 responseWrapper.setInnerElement(missingHeaderResponse);
369 private void validateHeaders(Wrapper<Response> responseWrapper, HttpServletRequest request, AuditingActionEnum auditingAction) {
370 if (request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER) == null) {
371 Response missingHeaderResponse = buildErrorResponse(
372 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID));
373 responseWrapper.setInnerElement(missingHeaderResponse);
374 ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
375 getComponentsUtils().auditMissingInstanceIdAsDistributionEngineEvent(auditingAction, responseFormat.getStatus().toString());
379 private void validateJson(Wrapper<Response> responseWrapper, Wrapper<RegistrationRequest> registrationRequestWrapper, String requestJson) {
380 if (requestJson == null || requestJson.isEmpty()) {
381 Response missingBodyResponse = buildErrorResponse(
382 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_BODY));
383 responseWrapper.setInnerElement(missingBodyResponse);
385 Either<RegistrationRequest, Exception> eitherRegistration = HttpUtil.convertJsonStringToObject(requestJson, RegistrationRequest.class);
386 if (eitherRegistration.isLeft()) {
387 RegistrationRequest registrationRequest = eitherRegistration.left().value();
388 if (registrationRequest.getApiPublicKey() == null) {
389 Response missingBodyResponse = buildErrorResponse(
390 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_PUBLIC_KEY));
391 responseWrapper.setInnerElement(missingBodyResponse);
392 } else if (registrationRequest.getDistrEnvName() == null) {
393 Response missingBodyResponse = buildErrorResponse(
394 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_ENV_NAME));
395 responseWrapper.setInnerElement(missingBodyResponse);
397 registrationRequestWrapper.setInnerElement(registrationRequest);
400 Response missingBodyResponse = buildErrorResponse(
401 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_BODY));
402 responseWrapper.setInnerElement(missingBodyResponse);
407 private AuditHandler buildAuditHandler(HttpServletRequest request, RegistrationRequest registrationRequest) {
408 return new AuditHandler(getComponentsUtils(), request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER), registrationRequest);