/*
* AEFActionImpl
*
* 07/29/2002
*
* Copyright:
* Licensed Materials - Property of IBM
* "Restricted Materials of IBM"
* 5724-AEF
* (C) Copyright IBM Corp. 2003.
*
* %W% %E%
*/
package com.ibm.retail.AEF.action;
import com.ibm.retail.AEF.automation.*;
import com.ibm.retail.AEF.util.*;
import com.ibm.retail.si.util.*;
import com.ibm.retail.si.util.AEFConst;
import com.ibm.retail.AEF.factory.*;
import com.ibm.retail.AEF.thread.*;
import com.ibm.retail.AEF.data.*;
import com.ibm.retail.AEF.session.*;
import com.ibm.retail.si.Copyright;
import java.util.*;
import java.rmi.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* AEFActionImpl is a base convenience class for subclasses which implement
* the AEFAction interface.
*
*/
public class AEFActionImpl implements AEFAction
{
static String copyright()
{ return com.ibm.retail.si.Copyright.IBM_COPYRIGHT_SHORT;}
public static ActionFactory actionFactory = null;
/**
* Constructor
*
* @param request The ActionRequest which contains a hashtable of arguments.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.FACTORY_ERROR
*
Common Errors
*/
public AEFActionImpl(ActionRequest request) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter constructor of AEFActionImpl.");
log.trace(tempAEFMessage);
}
try
{
session = SessionContext.getSession();
if (session != null)
{
sessionID = session.getTerminalNumber();
dataProvider = session.getPOSDataProvider();
automationProvider = session.getPOSAutomationProvider();
}
else
{
if (log.isWarnEnabled())
{
tempAEFMessage.setMessage("Could not get the session object in the constructor for AEFActionImpl.");
log.warn(tempAEFMessage);
}
}
}
catch (RemoteException re)
{
// Impossible to get here.
tempAEFMessage.setMessage("There was a remote exception thrown in the constructor of AEFActionImp.");
log.error(tempAEFMessage, re);
}
tempAEFMessage.setSessionID(sessionID);
if (actionFactory == null)
{
try
{
actionFactory = (ActionFactory)(FactoryImpl.getFactory("ActionFactory"));
if (actionFactory == null)
{
// Couldn't find the classname in classes.pro, fully qualify the classname
// and try to make the factory.
actionFactory = (ActionFactory)(FactoryImpl.getFactory("com.ibm.retail.AEF.factory.ActionFactory"));
}
if (actionFactory == null)
{
AEFException tempException = new AEFException(AEFConst.FACTORY_ERROR, 0, "AEFActionImpl(): Could not create ActionFactory.");
tempAEFMessage.setMessage("Could not create ActionFactory in the constructor of AEFActionImp.");
log.error(tempAEFMessage, tempException);
throw tempException;
}
}
catch (ClassCastException cce)
{
AEFException tempException = new AEFException(AEFConst.FACTORY_ERROR, 0, "AEFActionImpl(): Could not cast object to ActionFactory.", cce);
tempAEFMessage.setMessage("Class cast error trying to create ActionFactory in the constructor of AEFActionImp.");
log.error(tempAEFMessage, tempException);
throw tempException;
}
}
try
{
maxErrorLevels = automationProvider.getMaxErrorToHandle();
}
catch (RemoteException e)
{
// Ignore because we are calling it locally.
tempAEFMessage.setMessage("There was a remote exception thrown in the constructor of AEFActionImp.");
log.error(tempAEFMessage, e);
}
catch (AEFException e1)
{
maxErrorLevels = 10; // USE a default and log error
tempAEFMessage.setMessage("There was an AEF exception thrown in the constructor of AEFActionImpl.");
log.error(tempAEFMessage, e1);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit constructor of AEFActionImpl.");
log.trace(tempAEFMessage);
}
}
/**
* Perform the action represented by the ActionRequest and return an object.
* It is up to the client to know the return type of the object. For general
* actions, the return type may be assumed to be ActionResult.
*
* NOTE: All sub-classes should have super.performAction() as the first line of
* their performAction() event. This will allow common processing to be done in
* this class.
*
* @return Object The required return value (may be null).
* @exception AEFException
* Because of the nature of this method, just about any error code could be returned.
*/
public Object performAction() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.performAction().");
log.trace(tempAEFMessage);
}
int retVal = 0;
int tmpTimeout = 0;
ConditionLock lock = null;
AEFErrorHandler errorHandler = null;
Condition conditions[] = BadConditionsImpl.getInstance().getLogicalOpposite();
Condition badConditions[] = BadConditionsImpl.getInstance().getBadConditions();
// Check to make sure that we are not in an error condition before we start the action.
// Because any errors would be from a previous command, we should not throw an exception
// if the errors handled were fatal. If the errors were not cleared, then the automation
// command will throw the exception as it will more than likely be in the wrong state.
try
{
if (getErrorHandlingMode() == POSAutomationProvider.HANDLE_DEFAULT)
{
tmpTimeout = 0;
}
else
{
tmpTimeout = getTimeout();
}
lock = new ConditionLock();
retVal = lock.wait("check-for-non-error-condition-before-action", conditions, badConditions, tmpTimeout, true);
{
if (retVal < 0)
{
try
{
errorHandler = new AEFErrorHandler("The POS application was in an error state before the current action was started. The Error Handler was called to try to clear the error before continuing.");
retVal = errorHandler.handleError(lock, null, conditions, badConditions, tmpTimeout, retVal);
}
catch (Exception e)
{
if (retVal < 0)
{
tempAEFMessage.setMessage("The POS application was in an error state before the current action was started. The Error Handler was not able to clear the error.");
log.error(tempAEFMessage, errorHandler.getAllExceptions());
throw errorHandler.getAllExceptions();
}
}
}
}
}
catch (AEFException e)
{
// Ignore the error as this was from a previous command.
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.performAction().");
log.trace(tempAEFMessage);
}
return null;
}
/**
* The method returns the object resulting from the performAction call.
*
*
* @return Object The value set as a return value from the performAction call.
*/
public Object getResult()
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter and -Exit AEFActionImpl.getResult().");
log.trace(tempAEFMessage);
}
return resultObj;
}
/**
* The method sets the result of performing the action.
* As a side effect, this method signals the ConditionVariable (if any) so
* that if a thread was blocking until the result was set, it will unblock after
* the result is set.
*
*
* @param Object The value set as a return value from the performAction call.
*/
public void setResult(Object obj)
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.setResult().");
log.trace(tempAEFMessage);
}
if (cv != null)
{
cv.getLock().getMutexLock();
this.resultObj = obj;
cv.cvSignal();
cv.getLock().freeMutexLock();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.setResult().");
log.trace(tempAEFMessage);
}
}
/**
* Sets a ConditionVariable for the action. This must be set prior to performing a user action.
*
*
* @param cv The condition variable.
*/
public void setConditionVariable(ConditionVariable cv)
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.setConditionVariable().");
log.trace(tempAEFMessage);
}
this.cv = cv;
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.setConditionVariable().");
log.trace(tempAEFMessage);
}
}
/**
* Returns the timeout value in milliseconds to wait for a condition set to complete.
* The timeout is configured in config.properties.
*
*
* @return int The timeout in milliseconds.
*/
public int getTimeout()
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.getTimeout().");
log.trace(tempAEFMessage);
}
if (opTimeout == 0)
{
try
{
opTimeout = 60000;
String timeout = ConfigProps.get("KEY_SEQUENCE_TIMEOUT");
if (timeout != null)
{
opTimeout = Integer.parseInt(timeout);
}
}
catch (NumberFormatException nfe)
{
// Just use the default of 60000.
if (log.isWarnEnabled())
{
tempAEFMessage.setMessage("The timeout value to wait for a condition could not be determined. The default value from AEFActionImpl will be used.");
log.warn(tempAEFMessage);
}
}
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.getTimeout().");
log.trace(tempAEFMessage);
}
return opTimeout;
}
/**
* Returns the timeout value in milliseconds to wait for a host related
* condition set to complete.
* The timeout is configured in config.properties.
*
*
* @return int The timeout in milliseconds.
*/
public int getPaymentHostTimeout()
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.getPaymentHostTimeout().");
log.trace(tempAEFMessage);
}
if (paymentHostTimeout == 0)
{
try
{
paymentHostTimeout = 60000;
String timeout = ConfigProps.get("PAYMENT_HOST_SEQUENCE_TIMEOUT");
if (timeout != null)
{
paymentHostTimeout = Integer.parseInt(timeout);
}
}
catch (NumberFormatException nfe)
{
// Just use the default of 60000.
if (log.isWarnEnabled())
{
tempAEFMessage.setMessage("The timeout value to wait for a host related condition could not be determined. The default value from AEFActionImpl will be used.");
log.warn(tempAEFMessage);
}
}
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.getPaymentHostTimeout().");
log.trace(tempAEFMessage);
}
return paymentHostTimeout;
}
/**
* Gets the current state.
*
*
* @return String The current application state.
*/
public String getCurrentState()
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.getCurrentState().");
log.trace(tempAEFMessage);
}
String retVal = null;
try
{
retVal = dataProvider.getPropertyValue(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE).toString();
}
catch (RemoteException re)
{
// Not expected to get here since we are calling locally.
tempAEFMessage.setMessage("There was a remote exception thrown in the getCurrentState of AEFActionImp.");
log.error(tempAEFMessage, re);
}
if (log.isDebugEnabled())
{
tempAEFMessage.setMessage("getCurrentState returned " + retVal + ".");
log.debug(tempAEFMessage);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.getCurrentState().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* WaitForStates - wait for the application to go into specific states.
*
* @param states An array of strings that contains the states that we are interested in.
* @return int The index number of the state (in the states array) that satisfied the wait.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForStates(String[] states) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter and -Exit AEFActionImpl.waitForStates().");
log.trace(tempAEFMessage);
}
return waitForStates(states, getTimeout());
}
/**
* WaitForStates - wait for the application to go into specific states.
*
* @param states An array of strings that contains the states that we are interested in.
* @param timeout An integer that tells the lock how long to wait for the state change.
* @return int The index number of the state (in the states array) that satisfied the wait.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForStates(String[] states, int timeout) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.waitForStates().");
log.trace(tempAEFMessage);
}
int retVal = -1;
ConditionLock lock = null;
AbstractPropertyCondition[] conditions = new AbstractPropertyCondition[states.length];
for (int i = 0; i < states.length; i++)
{
conditions[i] = new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, states[i]);
}
lock = new ConditionLock();
retVal = lock.wait("wait-for-states", conditions, timeout, true);
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.waitForStates().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* Gets a Boolean property from the data provider.
*
* @param The category of the property.
* @param The name of the property.
* @return boolean The value of the property.
* @exception RemoteException
*/
public boolean getBooleanProviderProperty(String category, String property) throws RemoteException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.getBooleanProviderProperty().");
log.trace(tempAEFMessage);
}
boolean retVal = false;
Object value = dataProvider.getPropertyValue(category, property);
if (value != null )
{
if (value instanceof Boolean)
{
retVal = ((Boolean)(value)).booleanValue();
}
else if (value instanceof String)
{
if ( ((String)(value)).equalsIgnoreCase("true"))
{
retVal = true;
}
}
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.getBooleanProviderProperty().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* WaitForStateChange Wait for the application to leave a specific state.
*
* @param states A string that contains the state that we are interested in leaving.
* @return int 0 if the state was left within the timeout period.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForStateChange(String state) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.waitForStateChange().");
log.trace(tempAEFMessage);
}
int retVal = -1;
ConditionLock lock = null;
AbstractPropertyCondition[] conditions =
{
new PropertyNotEqualsCondition(POSDeviceProperties.CATEGORY,
POSDeviceProperties.POS_STATE,
state)
};
lock = new ConditionLock();
if (log.isDebugEnabled())
{
tempAEFMessage.setMessage("About to wait on the perform action for 'WaitForStateChange'");
log.debug(tempAEFMessage);
}
retVal = lock.wait("wait-for-state-change", conditions, getTimeout(), true);
if (log.isDebugEnabled())
{
StringBuffer tmpBuffer = new StringBuffer(100);
tmpBuffer.append("WaitForStateChange return was ");
tmpBuffer.append(retVal);
tmpBuffer.append(".");
tempAEFMessage.setMessage(tmpBuffer.toString());
log.debug(tempAEFMessage);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.waitForStateChange().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* WaitForStateChange Wait for the application to make any state transition
* (even back to the same state).
*
* @param timeout An integer that tells the lock how long to wait for the state change.
* @return int 0 if the state was left within the timeout period.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForStateChange(int timeout) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.waitForStateChange().");
log.trace(tempAEFMessage);
}
int retVal = -1;
ConditionLock lock = null;
AbstractPropertyCondition[] conditions =
{
new PropertyNotEqualsCondition(POSDeviceProperties.CATEGORY,
POSDeviceProperties.POS_STATE,
"ANY")
};
lock = new ConditionLock();
if (log.isDebugEnabled())
{
tempAEFMessage.setMessage("About to wait on the perform action for 'WaitForStateChange'.");
log.debug(tempAEFMessage);
}
retVal = lock.wait("wait-for-state-change", conditions, timeout, false);
if (log.isDebugEnabled())
{
StringBuffer tmpBuffer = new StringBuffer(100);
tmpBuffer.append("WaitForStateChange return was ");
tmpBuffer.append(retVal);
tmpBuffer.append(".");
tempAEFMessage.setMessage(tmpBuffer.toString());
log.debug(tempAEFMessage);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.waitForStateChange().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* WaitForStateChange Wait for the application to make any state transition
* (even back to the same state).
*
* @return int 0 if the state was left within the timeout period.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForStateChange() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter and -Exit AEFActionImpl.waitForStateChange().");
log.trace(tempAEFMessage);
}
return(waitForStateChange(getTimeout()));
}
/**
* WaitForSubStateChange Wait for the application to leave a specific sub-state.
*
* @param states A string that contains the sub-state that we are interested in leaving.
* @param timeout An integer that tells the lock how long to wait for the state change.
* @return int 0 if the state was left within the timeout period.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForSubStateChange(String substate, int timeout) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.waitForSubStateChange().");
log.trace(tempAEFMessage);
}
int retVal = -1;
ConditionLock lock = null;
AbstractPropertyCondition[] conditions =
{
new PropertyNotEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_SUB_STATE, substate)
};
lock = new ConditionLock();
if (log.isDebugEnabled())
{
tempAEFMessage.setMessage("About to wait on the perform action for 'WaitForSubStateChange'.");
log.debug(tempAEFMessage);
}
retVal = lock.wait("wait-for-substate-change", conditions, timeout, true);
if (log.isDebugEnabled())
{
StringBuffer tmpBuffer = new StringBuffer(100);
tmpBuffer.append("WaitForSubStateChange return was ");
tmpBuffer.append(retVal);
tmpBuffer.append(".");
tempAEFMessage.setMessage(tmpBuffer.toString());
log.debug(tempAEFMessage);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.waitForSubStateChange().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* GetAutomationProvider returns the automation provider for this object.
*
* @return POSAutomationProvider The automation provider for this object.
*/
public POSAutomationProvider getAutomationProvider()
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter and -Exit AEFActionImpl.getAutomationProvider().");
log.trace(tempAEFMessage);
}
return automationProvider;
}
/**
* Sends the key sequence required to clear an error.
*
* @param wait True to wait for a state transition to any other state besides the clear state.
* @param callErrorHandler True to call the error handler in case of an error.
* @return int Integer value representing the result of the key sequence.
* @exception com.ibm.retail.AEF.util.AEFException
* Because of the nature of this method, just about any error code could be returned.
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int sendClearSequence(boolean wait, boolean callErrorHandler) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.sendClearSequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
args.clear();
args.put("SEQUENCE_ID", "clear-error");
AEFAction keySequenceAction = (AEFAction)
(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
if (wait)
{
AbstractPropertyCondition[] conditions =
{
new PropertyNotEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("CLEAR"))
};
ConditionLock lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-for-error-clear",
keySequenceAction,
conditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0 && callErrorHandler)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Clear Sequence Error");
retVal = errorHandler.handleError(lock,
keySequenceAction,
conditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
if (retVal < 0)
{
tempAEFMessage.setMessage("The sendClearSequence method encountered an error that the Error Handler was not able to clear.");
log.error(tempAEFMessage, errorHandler.getAllExceptions());
throw errorHandler.getAllExceptions();
}
}
}
else
{
keySequenceAction.performAction();
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.sendClearSequence().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* Sends the key sequence required to clear an error.
*
* @param wait True to wait for a state transition to any other state besides the clear state.
* @return int Integer value representing the result of the key sequence.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int sendClearSequence(boolean wait) throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter and -Exit AEFActionImpl.sendClearSequence().");
log.trace(tempAEFMessage);
}
return sendClearSequence(wait, true);
}
/**
* Sends the clear key sequence repeatedly until the application is no longer
* in the clear state, or until a maximum number of errors has been cleared.
*
*
* @return int Integer value representing the result of the key sequence.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
AEFConst.TOO_MANY_ERRORS
*
Common Errors
*/
public int clearErrors() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.clearErrors().");
log.trace(tempAEFMessage);
}
int retVal = -1;
args.clear();
args.put("SEQUENCE_ID", "clear-error");
AEFAction keySequenceAction = (AEFAction)
(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
String state = null;
int errorCount = 0;
boolean goOn = true;
while (goOn)
{
AbstractPropertyCondition[] conditions =
{
new PropertyNotEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, "ANY")
};
ConditionLock lock = new ConditionLock();
retVal = lock.performActionAndWait("wait-for-next-state-transition",
keySequenceAction,
conditions,
getTimeout());
try
{
state =
((String)(dataProvider.getPropertyValue(POSDeviceProperties.CATEGORY,
POSDeviceProperties.POS_STATE)));
}
catch (RemoteException re)
{
// Can't get here.
tempAEFMessage.setMessage("There was a remote exception thrown in clearErrors of AEFActionImp.");
log.error(tempAEFMessage, re);
}
errorCount++;
if (errorCount == maxErrorLevels)
{
AEFException tempException = new AEFException(AEFConst.TOO_MANY_ERRORS, 0, "AEFActionImpl.clearErrors(): The maximum number of errors to handle was exceeded.");
tempAEFMessage.setMessage("The maximum number of errors to handle was exceeded in clearErrors of AEFActionImpl.");
log.error(tempAEFMessage, tempException);
throw tempException;
}
if (!state.equalsIgnoreCase(State.getState("CLEAR")))
{
goOn = false;
}
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.clearErrors().");
log.trace(tempAEFMessage);
}
return retVal;
}
/**
* Waits for the clear state.
*
* @return int An integer value representing the result of the wait (a negative number is an error).
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public int waitForClearState() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.waitForClearState().");
log.trace(tempAEFMessage);
}
int retVal = 0;
AbstractPropertyCondition[] conditions =
{
new PropertyEqualsCondition(POSDeviceProperties.CATEGORY, POSDeviceProperties.POS_STATE, State.getState("CLEAR"))
};
ConditionLock lock = new ConditionLock();
retVal = lock.wait("wait-for-clear-state", conditions, getTimeout(), true);
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.waitForClearState().");
log.trace(tempAEFMessage);
}
return(retVal);
}
/**
* Sends the key sequence required to clear an error.
*
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.OPERATION_TIMEOUT
*
Common Errors
*/
public void sendClearSequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.sendClearSequence().");
log.trace(tempAEFMessage);
}
sendClearSequence(false);
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.sendClearSequence().");
log.trace(tempAEFMessage);
}
}
/**
* Gets the error handling mode from the Automation Provider.
*
* @return Int The error handling mode.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
PROPERTY_NOT_SUPPORTED
*
Common Errors
*/
public int getErrorHandlingMode() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter AEFActionImpl.getErrorHandlingMode().");
log.trace(tempAEFMessage);
}
int retVal = 0;
try
{
retVal = SessionContext.getSession().getPOSAutomationProvider().getErrorHandlingMode();
}
catch (RemoteException e)
{
// Ignore because we are calling it locally.
tempAEFMessage.setMessage("There was a remote exception thrown in getErrorHandlingMode() of AEFActionImpl.");
log.error(tempAEFMessage, e);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit AEFActionImpl.getErrorHandlingMode().");
log.trace(tempAEFMessage);
}
return(retVal);
}
/* Instance Variables */
protected Object resultObj;
protected ConditionVariable cv;
public static int opTimeout = 0;
public static int paymentHostTimeout = 0;
protected POSDataProvider dataProvider = null;
protected POSAutomationProvider automationProvider = null;
protected AEFSession session;
protected String sessionID = "Unknown";
private static Log log = LogFactory.getLog(AEFActionImpl.class);
protected HashMap args = new HashMap();
protected int maxErrorLevels;
protected AEFMessage tempAEFMessage = new AEFMessage(sessionID, "");
}