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.be.user.UserBusinessLogic;
62 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
63 import org.openecomp.sdc.common.api.Constants;
64 import org.openecomp.sdc.common.datastructure.Wrapper;
65 import org.openecomp.sdc.common.log.wrappers.Logger;
66 import org.openecomp.sdc.common.util.HttpUtil;
67 import org.openecomp.sdc.exception.ResponseFormat;
68 import org.springframework.stereotype.Controller;
71 * This Servlet serves external users for distribution purposes.
75 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
77 @Tags({@Tag(name = "SDCE-6 APIs")})
78 @Servers({@Server(url = "/sdc")})
80 public class DistributionServlet extends BeGenericServlet {
82 private static final String START_HANDLE_REQUEST_OF = "Start handle request of {}";
83 private static final Logger log = Logger.getLogger(DistributionServlet.class);
84 private final DistributionBusinessLogic distributionLogic;
86 private HttpServletRequest request;
89 public DistributionServlet(UserBusinessLogic userBusinessLogic, ComponentsUtils componentsUtils, DistributionBusinessLogic distributionLogic) {
90 super(userBusinessLogic, componentsUtils);
91 this.distributionLogic = distributionLogic;
98 * @param authorization
102 @Path("/distributionUebCluster")
103 @Consumes(MediaType.APPLICATION_JSON)
104 @Produces(MediaType.APPLICATION_JSON)
105 @Operation(description = "UEB Server List", method = "GET", summary = "return the available UEB Server List", responses = {
106 @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)))),
107 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
108 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its credentials for Basic Authentication - POL5002"),
109 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
110 @ApiResponse(responseCode = "405", description = "Method Not Allowed: Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
111 @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")})
112 //TODO Tal G fix response headers
114 /*responseHeaders = {
115 @ResponseHeader(name = Constants.CONTENT_TYPE_HEADER, description = "Determines the format of the response body", response = String.class),
116 @ResponseHeader(name = "Content-Length", description = "Length of the response body", response = String.class)})*/
117 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
118 public Response getUebServerList(
119 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
120 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
121 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
122 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization) {
123 String url = request.getMethod() + " " + request.getRequestURI();
124 log.debug(START_HANDLE_REQUEST_OF, url);
125 Response response = null;
126 ResponseFormat responseFormat = null;
127 if (instanceId == null) {
128 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
129 response = buildErrorResponse(responseFormat);
130 getComponentsUtils().auditGetUebCluster(null, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
134 Either<ServerListResponse, ResponseFormat> actionResponse = distributionLogic.getUebServerList();
135 if (actionResponse.isRight()) {
136 responseFormat = actionResponse.right().value();
137 response = buildErrorResponse(responseFormat);
139 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
140 response = buildOkResponse(responseFormat, actionResponse.left().value());
142 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
144 } catch (Exception e) {
145 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("failed to get ueb serbver list from cofiguration");
146 log.debug("failed to get ueb serbver list from cofiguration", e);
147 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
148 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
149 return buildErrorResponse(responseFormat);
154 * @param requestId UUID to track the incoming request
155 * @param instanceId UUID to identify the requesting instance
156 * @param accept Determines the format of the body of the response
157 * @param authorization Username and password auth towards SDC
158 * @return KafkaDataResponse (Kafka bootstrap server and topic list to be used by clients)
161 @Path("/distributionKafkaData")
162 @Consumes(MediaType.APPLICATION_JSON)
163 @Produces(MediaType.APPLICATION_JSON)
164 @Operation(description = "Kafka data", method = "GET", summary = "return the kafka cluster and topic list", responses = {
165 @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)))),
166 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
167 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its credentials for Basic Authentication - POL5002"),
168 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
169 @ApiResponse(responseCode = "405", description = "Method Not Allowed: Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"),
170 @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")})
171 public Response getKafkaData(
172 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
173 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
174 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
175 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization) {
176 String url = request.getMethod() + " " + request.getRequestURI();
177 log.debug(START_HANDLE_REQUEST_OF, url);
178 ResponseFormat responseFormat;
179 if (instanceId == null) {
180 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
181 getComponentsUtils().auditGetUebCluster(null, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
182 return buildErrorResponse(responseFormat);
186 Either<KafkaDataResponse, ResponseFormat> actionResponse = distributionLogic.getKafkaData();
187 if (actionResponse.isRight()) {
188 responseFormat = actionResponse.right().value();
189 response = buildErrorResponse(responseFormat);
191 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
192 response = buildOkResponse(responseFormat, actionResponse.left().value());
194 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
196 } catch (Exception e) {
197 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("failed to get kafka cluster and topic list from configuration");
198 log.debug("failed to get kafka cluster and topic list from configuration", e);
199 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
200 getComponentsUtils().auditGetUebCluster(instanceId, responseFormat.getStatus().toString(), responseFormat.getFormattedMessage());
201 return buildErrorResponse(responseFormat);
210 * @param contenLength
211 * @param authorization
216 @Path("/registerForDistribution")
217 @Consumes(MediaType.APPLICATION_JSON)
218 @Produces(MediaType.APPLICATION_JSON)
219 @Operation(parameters = {
220 @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 = {
221 @ApiResponse(responseCode = "200", description = "ECOMP component is successfully registered for distribution", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TopicRegistrationResponse.class)))),
222 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
223 @ApiResponse(responseCode = "400", description = "Missing Body - POL4500"),
224 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'apiPublicKey' - POL4501"),
225 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'distrEnvName' - POL4502"),
226 @ApiResponse(responseCode = "400", description = "Invalid Body : Specified 'distrEnvName' doesn’t exist - POL4137"),
227 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
228 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
229 @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
230 @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")})
231 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
232 public Response registerForDistribution(
233 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
234 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
235 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
236 @Parameter(description = "Determines the format of the body of the request", required = true) @HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contentType,
237 @Parameter(description = "Length of the request body", required = true) @HeaderParam(value = Constants.CONTENT_LENGTH_HEADER) String contenLength,
238 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
239 @Parameter(hidden = true) String requestJson) {
240 String url = request.getMethod() + " " + request.getRequestURI();
241 log.debug(START_HANDLE_REQUEST_OF, url);
242 Wrapper<Response> responseWrapper = new Wrapper<>();
243 Wrapper<RegistrationRequest> registrationRequestWrapper = new Wrapper<>();
244 validateHeaders(responseWrapper, request, AuditingActionEnum.ADD_KEY_TO_TOPIC_ACL);
245 if (responseWrapper.isEmpty()) {
246 validateJson(responseWrapper, registrationRequestWrapper, requestJson);
248 if (responseWrapper.isEmpty()) {
249 validateEnv(responseWrapper);
251 if (responseWrapper.isEmpty()) {
252 distributionLogic.handleRegistration(responseWrapper, registrationRequestWrapper.getInnerElement(),
253 buildAuditHandler(request, registrationRequestWrapper.getInnerElement()));
255 BeEcompErrorManager.getInstance()
256 .logBeDistributionEngineSystemError(DistributionBusinessLogic.REGISTER_IN_DISTRIBUTION_ENGINE, "registration validation failed");
258 return responseWrapper.getInnerElement();
262 * Returns list of valid artifact types for validation done in the distribution client.<br> The list is the representation of the values of the
263 * enum ArtifactTypeEnum.
266 @Path("/artifactTypes")
267 @Consumes(MediaType.APPLICATION_JSON)
268 @Produces(MediaType.APPLICATION_JSON)
269 @Operation(description = "Artifact types list", method = "GET", summary = "Fetches available artifact types list", responses = {
270 @ApiResponse(responseCode = "200", description = "Artifact types list fetched successfully", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))),
271 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
272 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
273 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
274 @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( POST,PUT,DELETE will be rejected) - POL4050"),
275 @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")})
276 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
277 public Response getValidArtifactTypes(
278 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
279 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
280 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
281 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept) {
282 String url = request.getMethod() + " " + request.getRequestURI();
283 log.debug(START_HANDLE_REQUEST_OF, url);
284 Wrapper<Response> responseWrapper = new Wrapper<>();
285 //TODO check if in use
286 validateHeaders(responseWrapper, request, AuditingActionEnum.GET_VALID_ARTIFACT_TYPES);
287 if (responseWrapper.isEmpty()) {
288 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), ArtifactTypeEnum.values());
290 return responseWrapper.getInnerElement();
295 * Removes from subscription for distribution notifications
301 * @param contenLength
302 * @param authorization
307 @Path("/unRegisterForDistribution")
308 @Consumes(MediaType.APPLICATION_JSON)
309 @Produces(MediaType.APPLICATION_JSON)
310 @Operation(parameters = @Parameter(name = "requestJson", required = true), description = "Subscription status", method = "POST", summary = "Removes from subscription for distribution notifications", responses = {
311 @ApiResponse(responseCode = "204", description = "ECOMP component is successfully unregistered", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TopicUnregistrationResponse.class)))),
312 @ApiResponse(responseCode = "400", description = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"),
313 @ApiResponse(responseCode = "400", description = "Missing Body - POL4500"),
314 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'apiPublicKey' - POL4501"),
315 @ApiResponse(responseCode = "400", description = "Invalid Body : missing mandatory parameter 'distrEnvName' - SVC4506"),
316 @ApiResponse(responseCode = "400", description = "Invalid Body : Specified 'distrEnvName' doesn’t exist - POL4137"),
317 @ApiResponse(responseCode = "401", description = "ECOMP component should authenticate itself and to re-send again HTTP request with its Basic Authentication credentials - POL5002"),
318 @ApiResponse(responseCode = "403", description = "ECOMP component is not authorized - POL5003"),
319 @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used to register for distribution ( PUT,DELETE,GET will be rejected) - POL4050"),
320 @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")})
321 //TODO Edit the responses
323 @Parameter(name = "requestJson", required = true, schema = @Schema(implementation = org.openecomp.sdc.be.distribution.api.client.RegistrationRequest.class), description = "json describe the artifact")})
324 @PermissionAllowed({AafPermission.PermNames.READ_VALUE})
325 public Response unRegisterForDistribution(
326 @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId,
327 @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) String instanceId,
328 @Parameter(description = "Determines the format of the body of the response", required = false) @HeaderParam(value = Constants.ACCEPT_HEADER) String accept,
329 @Parameter(description = "Determines the format of the body of the request", required = true) @HeaderParam(value = Constants.CONTENT_TYPE_HEADER) String contentType,
330 @Parameter(description = "Length of the request body", required = true) @HeaderParam(value = Constants.CONTENT_LENGTH_HEADER) String contenLength,
331 @Parameter(description = "The username and password", required = true) @HeaderParam(value = Constants.AUTHORIZATION_HEADER) String authorization,
332 @Parameter(hidden = true) String requestJson) {
333 String url = request.getMethod() + " " + request.getRequestURI();
334 log.debug(START_HANDLE_REQUEST_OF, url);
335 Wrapper<Response> responseWrapper = new Wrapper<>();
336 Wrapper<RegistrationRequest> unRegistrationRequestWrapper = new Wrapper<>();
337 validateHeaders(responseWrapper, request, AuditingActionEnum.REMOVE_KEY_FROM_TOPIC_ACL);
338 if (responseWrapper.isEmpty()) {
339 validateJson(responseWrapper, unRegistrationRequestWrapper, requestJson);
341 if (responseWrapper.isEmpty()) {
342 validateEnv(responseWrapper);
344 if (responseWrapper.isEmpty()) {
345 distributionLogic.handleUnRegistration(responseWrapper, unRegistrationRequestWrapper.getInnerElement(),
346 buildAuditHandler(request, unRegistrationRequestWrapper.getInnerElement()));
348 BeEcompErrorManager.getInstance()
349 .logBeDistributionEngineSystemError(DistributionBusinessLogic.UN_REGISTER_IN_DISTRIBUTION_ENGINE, "unregistration validation failed");
351 return responseWrapper.getInnerElement();
354 private void validateEnv(Wrapper<Response> responseWrapper) {
356 StorageOperationStatus environmentStatus = distributionLogic.getDistributionEngine().isEnvironmentAvailable();
357 if (environmentStatus != StorageOperationStatus.OK) {
358 if (environmentStatus == StorageOperationStatus.DISTR_ENVIRONMENT_NOT_FOUND) {
359 Response missingHeaderResponse = buildErrorResponse(
360 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.DISTRIBUTION_ENV_DOES_NOT_EXIST));
361 responseWrapper.setInnerElement(missingHeaderResponse);
363 Response missingHeaderResponse = buildErrorResponse(
364 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.GENERAL_ERROR));
365 responseWrapper.setInnerElement(missingHeaderResponse);
370 private void validateHeaders(Wrapper<Response> responseWrapper, HttpServletRequest request, AuditingActionEnum auditingAction) {
371 if (request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER) == null) {
372 Response missingHeaderResponse = buildErrorResponse(
373 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID));
374 responseWrapper.setInnerElement(missingHeaderResponse);
375 ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID);
376 getComponentsUtils().auditMissingInstanceIdAsDistributionEngineEvent(auditingAction, responseFormat.getStatus().toString());
380 private void validateJson(Wrapper<Response> responseWrapper, Wrapper<RegistrationRequest> registrationRequestWrapper, String requestJson) {
381 if (requestJson == null || requestJson.isEmpty()) {
382 Response missingBodyResponse = buildErrorResponse(
383 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_BODY));
384 responseWrapper.setInnerElement(missingBodyResponse);
386 Either<RegistrationRequest, Exception> eitherRegistration = HttpUtil.convertJsonStringToObject(requestJson, RegistrationRequest.class);
387 if (eitherRegistration.isLeft()) {
388 RegistrationRequest registrationRequest = eitherRegistration.left().value();
389 if (registrationRequest.getApiPublicKey() == null) {
390 Response missingBodyResponse = buildErrorResponse(
391 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_PUBLIC_KEY));
392 responseWrapper.setInnerElement(missingBodyResponse);
393 } else if (registrationRequest.getDistrEnvName() == null) {
394 Response missingBodyResponse = buildErrorResponse(
395 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_ENV_NAME));
396 responseWrapper.setInnerElement(missingBodyResponse);
398 registrationRequestWrapper.setInnerElement(registrationRequest);
401 Response missingBodyResponse = buildErrorResponse(
402 distributionLogic.getResponseFormatManager().getResponseFormat(ActionStatus.MISSING_BODY));
403 responseWrapper.setInnerElement(missingBodyResponse);
408 private AuditHandler buildAuditHandler(HttpServletRequest request, RegistrationRequest registrationRequest) {
409 return new AuditHandler(getComponentsUtils(), request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER), registrationRequest);