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.onap.appc.executor.impl;
28 import org.onap.appc.domainmodel.lcm.ActionLevel;
29 import org.onap.appc.domainmodel.lcm.RuntimeContext;
30 import org.onap.appc.lifecyclemanager.LifecycleManager;
31 import org.onap.appc.requesthandler.RequestHandler;
32 import org.onap.appc.workflow.WorkFlowManager;
37 public class CommandTaskFactory {
39 // private LCMCommandTask lcmCommandTask;
40 // private LCMReadonlyCommandTask LCMReadonlyCommandTask;
42 private RequestHandler vnfRequestHandler;
43 private RequestHandler vmRequestHandler;
44 private WorkFlowManager workflowManager;
45 private LifecycleManager lifecyclemanager;
48 public void setWorkflowManager(WorkFlowManager workflowManager) {
49 this.workflowManager = workflowManager;
52 public void setVnfRequestHandler(RequestHandler vnfRequestHandler) {
53 this.vnfRequestHandler = vnfRequestHandler;
56 public void setVmRequestHandler(RequestHandler vmRequestHandler) {
57 this.vmRequestHandler = vmRequestHandler;
60 public void setLifecyclemanager(LifecycleManager lifecyclemanager) {
61 this.lifecyclemanager = lifecyclemanager;
65 public synchronized CommandTask getExecutionTask(RuntimeContext runtimeContext){
66 String action = runtimeContext.getRequestContext().getAction().name();
67 ActionLevel actionLevel = runtimeContext.getRequestContext().getActionLevel();
68 RequestHandler requestHandler = readRequestHandler(actionLevel);
69 if(ActionLevel.VM.equals(actionLevel)){
70 return new LCMReadonlyCommandTask(runtimeContext,requestHandler,workflowManager);
72 switch (runtimeContext.getRequestContext().getAction().getOperationType()){
74 case OperationStatusUpdate:
75 return new LCMReadonlyCommandTask(runtimeContext,requestHandler,workflowManager);
77 return new LCMCommandTask(runtimeContext,requestHandler,workflowManager,
82 private RequestHandler readRequestHandler(ActionLevel actionLevel) {
83 if (ActionLevel.VM.equals(actionLevel)) {
84 return vmRequestHandler;
86 return vnfRequestHandler;