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=========================================================
21 package org.onap.so.apihandlerinfra.tenantisolation.process;
23 import org.apache.http.HttpStatus;
24 import org.onap.so.apihandler.common.ErrorNumbers;
25 import org.onap.so.apihandlerinfra.exceptions.ApiException;
26 import org.onap.so.apihandlerinfra.exceptions.ValidateException;
27 import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
28 import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
29 import org.onap.so.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
30 import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
31 import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
32 import org.onap.so.logger.MessageEnum;
33 import org.onap.so.logger.MsoLogger;
34 import org.onap.so.requestsdb.RequestsDBHelper;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.stereotype.Component;
39 public class CreateEcompOperationalEnvironment {
41 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CreateEcompOperationalEnvironment.class);
44 private AAIClientObjectBuilder aaiClientObjectBuilder;
46 private AAIClientHelper aaiHelper;
48 private RequestsDBHelper requestDb;
50 private DmaapOperationalEnvClient dmaapClient;
52 public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{
54 //Create ECOMP Managing Environment object in A&AI
55 aaiHelper.createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("ACTIVE", request));
57 // Call client to publish to DMaap
59 msoLogger.debug("1" + request.getOperationalEnvironmentId());
60 msoLogger.debug("2" + request.getRequestDetails().getRequestInfo().getInstanceName());
61 msoLogger.debug("3" + request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString());
62 msoLogger.debug("4" + request.getRequestDetails().getRequestParameters().getTenantContext());
63 msoLogger.debug("5" + request.getRequestDetails().getRequestParameters().getWorkloadContext());
66 dmaapClient.dmaapPublishOperationalEnvRequest(request.getOperationalEnvironmentId(),
67 request.getRequestDetails().getRequestInfo().getInstanceName(),
68 request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString(),
69 request.getRequestDetails().getRequestParameters().getTenantContext(),
70 request.getRequestDetails().getRequestParameters().getWorkloadContext(),
73 ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
74 ValidateException validateException = new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
75 .errorInfo(errorLoggerInfo).build();
76 requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, request.getOperationalEnvironmentId());
77 throw validateException;
79 //Update request database
80 requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId());