001 /** 002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved. 003 * Licensed under the Apache License, Version 2.0 (the "License"); 004 * you may not use this file except in compliance with the License. 005 * You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software 010 * distributed under the License is distributed on an "AS IS" BASIS, 011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 * See the License for the specific language governing permissions and 013 * limitations under the License. See accompanying LICENSE file. 014 */ 015 package org.apache.oozie.workflow.lite; 016 017 import org.apache.oozie.workflow.WorkflowException; 018 import org.apache.oozie.ErrorCode; 019 020 import java.util.List; 021 022 //TODO javadoc 023 public abstract class ActionNodeHandler extends NodeHandler { 024 public static final String OK = "OK"; 025 public static final String ERROR = "ERROR"; 026 027 @Override 028 public final boolean enter(Context context) throws WorkflowException { 029 start(context); 030 return false; 031 } 032 033 @Override 034 public final String exit(Context context) throws WorkflowException { 035 end(context); 036 List<String> transitions = context.getNodeDef().getTransitions(); 037 String signalValue = context.getSignalValue(); 038 if (OK.equals(signalValue)) { 039 return transitions.get(0); 040 } 041 else { 042 if (ERROR.equals(signalValue)) { 043 return transitions.get(1); 044 } 045 } 046 throw new WorkflowException(ErrorCode.E0722, context.getNodeDef().getName()); 047 } 048 049 public abstract void start(Context context) throws WorkflowException; 050 051 public abstract void end(Context context) throws WorkflowException; 052 053 }