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.oam.processor;
27 import com.att.eelf.configuration.EELFLogger;
28 import org.openecomp.appc.exceptions.APPCException;
29 import org.openecomp.appc.i18n.Msg;
30 import org.openecomp.appc.oam.AppcOam;
31 import org.openecomp.appc.oam.util.AsyncTaskHelper;
32 import org.openecomp.appc.oam.util.ConfigurationHelper;
33 import org.openecomp.appc.oam.util.OperationHelper;
34 import org.openecomp.appc.oam.util.StateHelper;
35 import org.openecomp.appc.statemachine.impl.readers.AppcOamStates;
38 * Processor to handle stop OAM API.
40 public class OamStopProcessor extends BaseProcessor {
44 * @param eelfLogger for logging
45 * @param configurationHelper for property reading
46 * @param stateHelper for APP-C OAM state checking
47 * @param asyncTaskHelper for scheduling async task
48 * @param operationHelper for operational helper
50 public OamStopProcessor(EELFLogger eelfLogger,
51 ConfigurationHelper configurationHelper,
52 StateHelper stateHelper,
53 AsyncTaskHelper asyncTaskHelper,
54 OperationHelper operationHelper) {
55 super(eelfLogger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
57 rpc = AppcOam.RPC.stop;
58 auditMsg = Msg.OAM_OPERATION_STOPPING;
63 protected void scheduleAsyncTask() {
64 runnable = new MyRunnable(this);
65 super.scheduleAsyncTask();
69 * This runnable does the async handling for the stop REST API. And it will be scheduled to run one time.
71 * <p>This runnable will the following operations: <br>
72 * - do APP-C OAM bundle stop and then refresh through BundlerHelper<br>
73 * <p>Once above operations are done, the runnale will <br>
74 * - post message through operatonHelper <br>
75 * - set APP-C OAM state to started <br>
76 * - audit log the state <br>
78 class MyRunnable extends BaseActionRunnable {
80 MyRunnable(BaseProcessor parent) {
82 actionName = "OAM Stop";
83 auditMsg = Msg.OAM_OPERATION_STOPPED;
84 finalState = AppcOamStates.Stopped;
88 * Do stop action, include stop bundle .
89 * @return true if action is successful, false when aciton is failed.
93 logDebug(String.format("Executing %s task", actionName));
96 boolean isBundleOperationCompleted = bundleHelper.bundleOperations(
97 rpc, bundleNameToFuture, myParent.asyncTaskHelper, this);
98 if (isBundleOperationCompleted) {
103 } catch (APPCException e) {
105 stateHelper.setState(AppcOamStates.Error);
112 * @param setState boolean to indicate if set OAM state or not
115 void postDoAction(boolean setState) {
116 postAction(setState ? finalState : null);
117 super.postDoAction(setState);