2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.appc.executor.impl;
25 import org.apache.commons.lang3.StringUtils;
26 import org.openecomp.appc.domainmodel.lcm.CommonHeader;
27 import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
28 import org.openecomp.appc.executor.UnstableVNFException;
29 import org.openecomp.appc.executor.objects.CommandResponse;
30 import org.openecomp.appc.executor.objects.LCMCommandStatus;
31 import org.openecomp.appc.executor.objects.Params;
32 import org.openecomp.appc.executor.objects.UniqueRequestIdentifier;
33 import org.openecomp.appc.requesthandler.RequestHandler;
34 import org.openecomp.appc.workflow.WorkFlowManager;
36 import com.att.eelf.configuration.EELFLogger;
37 import com.att.eelf.configuration.EELFManager;
39 public class LCMReadonlyCommandTask extends CommandTask {
41 private static final EELFLogger logger = EELFManager.getInstance().getLogger(LCMReadonlyCommandTask.class);
43 public LCMReadonlyCommandTask(RuntimeContext commandRequest, RequestHandler requestHandler,
44 WorkFlowManager workflowManager) {
45 super(commandRequest, requestHandler, workflowManager);
49 public void onRequestCompletion(CommandResponse response) {
50 super.onRequestCompletion(response, true);
55 RuntimeContext request = commandRequest;
56 final CommonHeader commonHeader = request.getRequestContext().getCommonHeader();
57 final boolean forceFlag = commonHeader.getFlags().isForce();
58 UniqueRequestIdentifier requestIdentifier = new UniqueRequestIdentifier(commonHeader.getOriginatorId(), commonHeader.getRequestId(), commonHeader.getSubRequestId());
59 String requestIdentifierString = requestIdentifier.toIdentifierString();
60 final String vnfId = request.getVnfContext().getId();
62 requestHandler.onRequestExecutionStart(vnfId,true, requestIdentifierString, forceFlag);
64 } catch (UnstableVNFException e) {
65 logger.error(e.getMessage(), e);
66 Params params = new Params().addParam("vnfId",vnfId);
67 request.getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params));
68 }catch (Exception e) {
69 logger.error("Error during runing LCMReadonlyCommandTask.", e);
70 String errorMsg = StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage();
71 Params params = new Params().addParam("errorMsg",errorMsg);
72 request.getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));