use of org.pentaho.platform.api.engine.UnresolvedParameterException in project pentaho-platform by pentaho.
the class RuntimeContext method executeAction.
private void executeAction(final ISolutionActionDefinition actionDefinition, final Map pParameterProviders, final IActionCompleteListener doneListener, final IExecutionListener execListener, final boolean async) throws ActionInitializationException, ActionExecutionException, UnresolvedParameterException {
this.parameterProviders = pParameterProviders;
// TODO get audit setting from action definition
long start = new Date().getTime();
if (audit) {
// $NON-NLS-1$
audit(MessageTypes.COMPONENT_EXECUTE_START, MessageTypes.START, "", 0);
}
try {
// resolve the parameters
resolveParameters();
} catch (UnresolvedParameterException ex) {
audit(MessageTypes.COMPONENT_EXECUTE_FAILED, MessageTypes.VALIDATION, Messages.getInstance().getErrorString("RuntimeContext.ERROR_0013_BAD_PARAMETERS"), // $NON-NLS-1$
0);
if (doneListener != null) {
doneListener.actionComplete(this);
}
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
ex.setActionClass(actionDefinition.getComponentName());
ex.setStepDescription(actionDefinition.getDescription());
throw ex;
}
status = IRuntimeContext.RUNTIME_CONTEXT_RESOLVE_OK;
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("RuntimeContext.DEBUG_PRE-EXECUTE_AUDIT"));
}
List auditPre = actionDefinition.getPreExecuteAuditList();
audit(auditPre);
// initialize the component
IComponent component = actionDefinition.getComponent();
if (RuntimeContext.debug) {
debug(Messages.getInstance().getString("RuntimeContext.DEBUG_SETTING_LOGGING", // $NON-NLS-1$
Logger.getLogLevelName(loggingLevel)));
}
component.setLoggingLevel(loggingLevel);
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("RuntimeContext.DEBUG_INITIALIZING_COMPONENT"));
}
boolean initResult = false;
try {
initResult = component.init();
/*
* We need to catch checked and unchecked exceptions here so we can create an ActionSequeceException with
* contextual information, including the root cause. Allowing unchecked exceptions to pass through would
* prevent valuable feedback in the log or response.
*/
} catch (Throwable t) {
throw new ActionInitializationException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED"), // $NON-NLS-1$
t, session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition());
}
if (!initResult) {
status = IRuntimeContext.RUNTIME_STATUS_INITIALIZE_FAIL;
audit(MessageTypes.COMPONENT_EXECUTE_FAILED, MessageTypes.VALIDATION, Messages.getInstance().getErrorString("RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED"), // $NON-NLS-1$
0);
if (doneListener != null) {
doneListener.actionComplete(this);
}
throw new ActionInitializationException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0016_COMPONENT_INITIALIZE_FAILED"), session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition());
}
try {
executeComponent(actionDefinition);
} catch (ActionExecutionException ex) {
if (doneListener != null) {
doneListener.actionComplete(this);
}
throw ex;
}
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("RuntimeContext.DEBUG_POST-EXECUTE_AUDIT"));
}
List auditPost = actionDefinition.getPostExecuteAuditList();
audit(auditPost);
if (audit) {
long end = new Date().getTime();
// $NON-NLS-1$
audit(MessageTypes.COMPONENT_EXECUTE_END, MessageTypes.END, "", (int) (end - start));
}
if (doneListener != null) {
doneListener.actionComplete(this);
}
if (execListener != null) {
execListener.action(this, actionDefinition);
}
}
use of org.pentaho.platform.api.engine.UnresolvedParameterException in project pentaho-platform by pentaho.
the class RuntimeContext method executeSequence.
public void executeSequence(final IActionCompleteListener doneListener, final IExecutionListener execListener, final boolean async) throws ActionSequenceException {
paramManager.resetParameters();
long start = new Date().getTime();
status = IRuntimeContext.RUNTIME_STATUS_RUNNING;
// create an IActionDef object
List actionDefinitions = actionSequence.getActionDefinitionsAndSequences();
if (actionDefinitions == null) {
audit(MessageTypes.ACTION_SEQUENCE_FAILED, MessageTypes.VALIDATION, Messages.getInstance().getErrorString("RuntimeContext.ERROR_0011_NO_VALID_ACTIONS"), // $NON-NLS-1$
0);
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
throw new ActionValidationException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0011_NO_VALID_ACTIONS"), session.getName(), instanceId, getActionSequence().getSequenceName(), null);
}
setLoggingLevel(loggingLevel);
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("RuntimeContext.DEBUG_EXECUTING_ACTIONS"));
}
paramManager.setCurrentParameters(null);
try {
resolveParameters();
if (execListener != null) {
execListener.loaded(this);
}
executeSequence(actionSequence, doneListener, execListener, async);
if (this.feedbackAllowed() && ((promptStatus != IRuntimeContext.PROMPT_NO) || (xformBody.length() > 0) || (parameterTemplate != null))) {
sendFeedbackForm();
}
paramManager.setCurrentParameters(null);
if (audit) {
// $NON-NLS-1$
audit(MessageTypes.ACTION_SEQUENCE_END, MessageTypes.END, "", (int) (new Date().getTime() - start));
}
if (!isPromptPending()) {
Map returnParamMap = paramManager.getReturnParameters();
for (Iterator it = returnParamMap.entrySet().iterator(); it.hasNext(); ) {
Map.Entry mapEntry = (Map.Entry) it.next();
String paramName = (String) mapEntry.getKey();
ParameterManager.ReturnParameter returnParam = (ParameterManager.ReturnParameter) mapEntry.getValue();
if (returnParam == null) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0029_SAVE_PARAM_NOT_FOUND", paramName));
} else {
if (IParameterProvider.SCOPE_SESSION.equals(returnParam.destinationName)) {
session.setAttribute(returnParam.destinationParameter, returnParam.value);
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(paramName + " - session - " + returnParam.destinationParameter);
}
} else if ("response".equals(returnParam.destinationName)) {
// $NON-NLS-1$
if (outputHandler != null) {
outputHandler.setOutput(returnParam.destinationParameter, returnParam.value);
} else {
// $NON-NLS-1$
info(Messages.getInstance().getString("RuntimeContext.INFO_NO_OUTPUT_HANDLER"));
}
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(paramName + " - response - " + returnParam.destinationParameter);
}
} else if (PentahoSystem.SCOPE_GLOBAL.equals(returnParam.destinationName)) {
PentahoSystem.putInGlobalAttributesMap(returnParam.destinationParameter, returnParam.value);
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(paramName + " - global - " + returnParam.destinationParameter);
}
} else {
// Unrecognized scope
warn(Messages.getInstance().getString("RuntimeContext.WARN_UNRECOGNIZED_SCOPE", returnParam.destinationName, // $NON-NLS-1$
returnParam.destinationParameter));
}
}
}
}
} catch (UnresolvedParameterException ex) {
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
audit(MessageTypes.ACTION_SEQUENCE_FAILED, MessageTypes.VALIDATION, Messages.getInstance().getErrorString("RuntimeContext.ERROR_0013_BAD_PARAMETERS"), // $NON-NLS-1$
0);
throw ex;
} catch (ActionSequenceException ex) {
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
// $NON-NLS-1$
audit(MessageTypes.ACTION_SEQUENCE_FAILED, MessageTypes.EXECUTION, "", (int) (new Date().getTime() - start));
throw ex;
} catch (IOException ex) {
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
// $NON-NLS-1$
audit(MessageTypes.ACTION_SEQUENCE_FAILED, MessageTypes.EXECUTION, "", (int) (new Date().getTime() - start));
throw new ActionSequenceException(ex);
}
}
use of org.pentaho.platform.api.engine.UnresolvedParameterException in project pentaho-platform by pentaho.
the class RuntimeContext method resolveParameters.
private void resolveParameters() throws UnresolvedParameterException {
Set inputNames = getInputNames();
Iterator inputNamesIterator = inputNames.iterator();
IActionParameter actionParameter;
List variables;
Iterator variablesIterator;
ActionParameterSource variable;
String sourceName;
String sourceValue;
Object variableValue = null;
IParameterProvider parameterProvider;
while (inputNamesIterator.hasNext()) {
variableValue = null;
String inputName = (String) inputNamesIterator.next();
actionParameter = paramManager.getCurrentInput(inputName);
if (actionParameter == null) {
throw new UnresolvedParameterException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0031_INPUT_NOT_FOUND", // $NON-NLS-1$
inputName), session.getName(), instanceId, getActionSequence().getSequenceName(), null);
}
variables = actionParameter.getVariables();
variablesIterator = variables.iterator();
while (variablesIterator.hasNext()) {
variable = (ActionParameterSource) variablesIterator.next();
sourceName = variable.getSourceName();
sourceValue = variable.getValue();
variableValue = null;
// e.g. runtme.parent
if ("runtime".equals(sourceName)) {
// $NON-NLS-1$
// first check the standard variables
variableValue = getStringParameter(sourceValue, null);
if (variableValue == null) {
// now check the runtime data
variableValue = runtimeData.getStringProperty(sourceValue, null);
}
if (variableValue != null) {
break;
}
} else {
parameterProvider = (IParameterProvider) parameterProviders.get(sourceName);
if (parameterProvider == null) {
warn(Messages.getInstance().getString("RuntimeContext.WARN_REQUESTED_PARAMETER_SOURCE_NOT_AVAILABLE", sourceName, // $NON-NLS-1$
inputName));
} else {
variableValue = parameterProvider.getParameter(sourceValue);
if (variableValue != null) {
break;
}
}
}
}
if (variableValue == null) {
if (actionParameter.getValue() != null) {
if (actionParameter.hasDefaultValue()) {
if (PentahoSystem.trace) {
// $NON-NLS-1$
trace(Messages.getInstance().getString("RuntimeContext.TRACE_USING_DEFAULT_PARAMETER_VALUE", inputName));
}
} else {
if (PentahoSystem.trace) {
trace(Messages.getInstance().getString(// $NON-NLS-1$
"RuntimeContext.TRACE_INFO_USING_CURRENT_PARAMETER_VALUE" + inputName));
}
}
} else if ("content".equals(actionParameter.getType())) {
// $NON-NLS-1$
// $NON-NLS-1$
variableValue = "";
}
} else {
actionParameter.setValue(variableValue);
}
}
// while
}
Aggregations