2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
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=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.openecomp.appc.executor.impl;
25 import org.openecomp.appc.domainmodel.lcm.Status;
26 import org.openecomp.appc.executor.objects.CommandResponse;
27 import org.openecomp.appc.executor.objects.LCMCommandStatus;
28 import org.openecomp.appc.executor.objects.Params;
29 import org.openecomp.appc.requesthandler.RequestHandler;
30 import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
31 import org.openecomp.appc.workflow.WorkFlowManager;
32 import org.openecomp.appc.workflow.objects.WorkflowRequest;
33 import org.openecomp.appc.workflow.objects.WorkflowResponse;
34 import com.att.eelf.configuration.EELFLogger;
35 import com.att.eelf.configuration.EELFManager;
38 * This abstract class is base class for all Command tasks. All command task must inherit this class.
41 public abstract class CommandTask implements Runnable {
43 protected final RequestHandler requestHandler;
44 protected final WorkFlowManager workflowManager;
45 protected final RuntimeContext commandRequest;
47 protected CommandTask(RuntimeContext commandRequest, RequestHandler requestHandler,
48 WorkFlowManager workflowManager) {
50 this.commandRequest = commandRequest;
51 this.requestHandler = requestHandler;
52 this.workflowManager = workflowManager;
55 private static final EELFLogger logger = EELFManager.getInstance().getLogger(CommandTask.class);
57 public void onRequestCompletion(CommandResponse response, boolean isAAIUpdated) {
58 logger.debug("Entry: onRequestCompletion()");
59 requestHandler.onRequestExecutionEnd(commandRequest, isAAIUpdated);
62 public abstract void onRequestCompletion(CommandResponse response);
64 protected CommandResponse buildCommandResponse(WorkflowResponse response) {
66 return new CommandResponse(commandRequest);
70 public void execute() {
71 final RuntimeContext runtimeContext = commandRequest;
72 WorkflowRequest workflowRequest = new WorkflowRequest();
73 workflowRequest.setRequestContext(runtimeContext.getRequestContext());
74 workflowRequest.setResponseContext(runtimeContext.getResponseContext());
75 workflowRequest.setVnfContext(runtimeContext.getVnfContext());
77 WorkflowResponse response = workflowManager.executeWorkflow(workflowRequest);
79 CommandResponse commandResponse = buildCommandResponse(response);
80 this.onRequestCompletion(commandResponse);