Class OriginateTransaction
- All Implemented Interfaces:
Expirable
This class manages the logic for initiating an originate action, processing responses and events, and handling failure and success conditions. It also supports adding variables to the originate action and logging important steps in the transaction lifecycle.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.siperf.amistream.connection.both.transcation.Transaction
Transaction.FinalState -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.LoggerLogger instance for logging events related to originate transactions.Fields inherited from class com.siperf.amistream.connection.client.transaction.ClientActionTransaction
callbackFields inherited from class com.siperf.amistream.connection.client.transaction.ClientAmiTransaction
clientConnectionFields inherited from class com.siperf.amistream.connection.both.transcation.Transaction
executionTimer, finishedAt, name, processor, startedAt -
Constructor Summary
ConstructorsConstructorDescriptionOriginateTransaction(ClientConnection clientConnection, String caller, String called, String calledServer, DialplanStep dialplanStep, long timeout) Constructs anOriginateTransactionwith the specified parameters.OriginateTransaction(ClientConnection clientConnection, String caller, String called, String calledServer, String context, String extension, String priority, long timeout) Constructs anOriginateTransactionwith the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInitialVariable(String name, String value) Adds an initial variable to the originate transaction.protected AmiActionCreates anAmiActionfor the originate transaction.Returns the called number.Returns the caller's number.Returns the message explaining why the originate action was refused.Returns the reason for the refusal of the originate action.booleanisOk()Determines if the originate transaction is successful.protected voidprocessErrorResponse(AmiResponse response) Processes an error response to the originate action.protected voidprocessEvent(AmiEvent event) Processes an event related to the originate action.protected voidprocessOkResponse(AmiResponse response) Processes a successful response to the originate action.Methods inherited from class com.siperf.amistream.connection.client.transaction.ClientActionTransaction
isOkResponse, processResponse, setCallbackMethods inherited from class com.siperf.amistream.connection.client.transaction.ClientAmiTransaction
execute, getAmiActionId, getClientConnection, startMethods inherited from class com.siperf.amistream.connection.both.transcation.Transaction
getExecutionTime, getExecutionTimer, getFinalState, getFinishedAt, getId, getName, getProcessor, getStartedAt, isActive, isCompleted, isResultOK, stop, stopOkMethods inherited from class com.siperf.commons.data.expirable.ExpirableObject
getCreatedAt, getExpireAt, isExpired, isExpired
-
Field Details
-
log
protected static final org.slf4j.Logger logLogger instance for logging events related to originate transactions.
-
-
Constructor Details
-
OriginateTransaction
public OriginateTransaction(ClientConnection clientConnection, String caller, String called, String calledServer, DialplanStep dialplanStep, long timeout) Constructs anOriginateTransactionwith the specified parameters.This constructor initializes an originate transaction using information from a
DialplanStep.- Parameters:
clientConnection- theClientConnectionto use for the transaction.caller- the caller's number.called- the called number.calledServer- the server to route the call.dialplanStep- theDialplanStepcontaining the context, extension, and priority.timeout- the timeout for the originate action in milliseconds.
-
OriginateTransaction
public OriginateTransaction(ClientConnection clientConnection, String caller, String called, String calledServer, String context, String extension, String priority, long timeout) Constructs anOriginateTransactionwith the specified parameters.This constructor initializes an originate transaction with the provided caller, called, called server, context, extension, priority, and timeout.
- Parameters:
clientConnection- theClientConnectionto use for the transaction.caller- the caller's number.called- the called number.calledServer- the server to route the call.context- the context for the call in the dialplan.extension- the extension to dial in the dialplan.priority- the priority for the call in the dialplan.timeout- the timeout for the originate action in milliseconds.
-
-
Method Details
-
addInitialVariable
Adds an initial variable to the originate transaction.- Parameters:
name- the name of the variable.value- the value of the variable.
-
getCaller
Returns the caller's number.- Returns:
- the caller's number.
-
getCalled
Returns the called number.- Returns:
- the called number.
-
isOk
public boolean isOk()Determines if the originate transaction is successful.If the transaction has no refusal reason, it is considered successful.
- Returns:
trueif the transaction is successful,falseotherwise.
-
getRefuseMessage
Returns the message explaining why the originate action was refused.- Returns:
- the refuse message, or
nullif the action was not refused.
-
getRefuseReason
Returns the reason for the refusal of the originate action.- Returns:
- the refusal reason, or
nullif the action was not refused.
-
createAction
Creates anAmiActionfor the originate transaction.This method uses the provided parameters to create an
OriginateActionand add any additional variables to it.- Specified by:
createActionin classClientActionTransaction- Returns:
- the
AmiActionrepresenting the originate transaction.
-
processOkResponse
Processes a successful response to the originate action.This method is called when a successful response is received, and it logs the completion of the originate action.
- Overrides:
processOkResponsein classClientActionTransaction- Parameters:
response- the successfulAmiResponse.
-
processErrorResponse
Processes an error response to the originate action.This method is called when an error response is received, and it logs the refusal message and sets the refusal reason.
- Specified by:
processErrorResponsein classClientActionTransaction- Parameters:
response- the errorAmiResponse.
-
processEvent
Processes an event related to the originate action.This method is invoked when an event related to the originate action is received. It checks for success or failure and logs the appropriate response.
- Overrides:
processEventin classClientActionTransaction- Parameters:
event- theAmiEventrelated to the originate action.
-