use of org.pentaho.platform.api.action.ILoggingAction in project pentaho-platform by pentaho.
the class ActionDelegate method validateAction.
/**
* Validation of Action input values should happen in the {@link IAction#execute()} This method is used as a pre
* execution hook where we setup as much runtime information as possible prior to the actual execute call.
*/
@Override
protected boolean validateAction() {
if (actionBean == null) {
throw new IllegalArgumentException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"ActionDelegate.ERROR_0007_NO_ACTION_BEAN_SPECIFIED"));
}
//
if (actionBean instanceof ILoggingAction) {
((ILoggingAction) actionBean).setLogger(LogFactory.getLog(actionBean.getClass()));
}
//
if (actionBean instanceof ISessionAwareAction) {
((ISessionAwareAction) actionBean).setSession(getSession());
}
actionDefintionInputs = getActionDefinition().getInputs();
actionDefintionOutputs = getActionDefinition().getOutputs();
//
// If an Action is action-definition aware, then here is the place (prior to
// execution) to tell it about the action definition.
//
List<String> inputNames = new ArrayList<String>();
for (IActionInput input : actionDefintionInputs) {
inputNames.add(input.getName());
}
List<String> outputNames = new ArrayList<String>();
for (IActionOutput output : actionDefintionOutputs) {
outputNames.add(output.getName());
}
if (actionBean instanceof IDefinitionAwareAction) {
IDefinitionAwareAction definitionAwareAction = (IDefinitionAwareAction) actionBean;
definitionAwareAction.setInputNames(inputNames);
definitionAwareAction.setOutputNames(outputNames);
}
//
if (actionBean instanceof IPreProcessingAction) {
try {
((IPreProcessingAction) actionBean).doPreExecution();
} catch (ActionPreProcessingException e) {
throw new RuntimeException(e);
}
}
// we do not use the return value to indicate failure.
return true;
}
Aggregations