2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.executor.impl;
27 import org.openecomp.appc.domainmodel.lcm.Status;
28 import org.openecomp.appc.executor.objects.CommandResponse;
29 import org.openecomp.appc.executor.objects.LCMCommandStatus;
30 import org.openecomp.appc.executor.objects.Params;
31 import org.openecomp.appc.requesthandler.RequestHandler;
32 import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
33 import org.openecomp.appc.workflow.WorkFlowManager;
34 import org.openecomp.appc.workflow.objects.WorkflowRequest;
35 import org.openecomp.appc.workflow.objects.WorkflowResponse;
36 import com.att.eelf.configuration.EELFLogger;
37 import com.att.eelf.configuration.EELFManager;
40 * This abstract class is base class for all Command tasks. All command task must inherit this class.
43 public abstract class CommandTask implements Runnable {
45 protected final RequestHandler requestHandler;
46 protected final WorkFlowManager workflowManager;
47 protected final RuntimeContext commandRequest;
49 protected CommandTask(RuntimeContext commandRequest, RequestHandler requestHandler,
50 WorkFlowManager workflowManager) {
52 this.commandRequest = commandRequest;
53 this.requestHandler = requestHandler;
54 this.workflowManager = workflowManager;
57 private static final EELFLogger logger = EELFManager.getInstance().getLogger(CommandTask.class);
59 public void onRequestCompletion(CommandResponse response, boolean isAAIUpdated) {
60 logger.debug("Entry: onRequestCompletion()");
61 requestHandler.onRequestExecutionEnd(commandRequest, isAAIUpdated);
64 public abstract void onRequestCompletion(CommandResponse response);
66 protected CommandResponse buildCommandResponse(WorkflowResponse response) {
68 return new CommandResponse(commandRequest);
72 public void execute() {
73 final RuntimeContext runtimeContext = commandRequest;
74 WorkflowRequest workflowRequest = new WorkflowRequest();
75 workflowRequest.setRequestContext(runtimeContext.getRequestContext());
76 workflowRequest.setResponseContext(runtimeContext.getResponseContext());
77 workflowRequest.setVnfContext(runtimeContext.getVnfContext());
79 WorkflowResponse response = workflowManager.executeWorkflow(workflowRequest);
81 CommandResponse commandResponse = buildCommandResponse(response);
82 this.onRequestCompletion(commandResponse);