Asterisk-Java

org.asteriskjava.manager.action
Class OriginateAction

java.lang.Object
  extended by org.asteriskjava.manager.action.AbstractManagerAction
      extended by org.asteriskjava.manager.action.OriginateAction
All Implemented Interfaces:
java.io.Serializable, EventGeneratingAction, ManagerAction

public class OriginateAction
extends AbstractManagerAction
implements EventGeneratingAction

The OriginateAction generates an outgoing call to the extension in the given context with the given priority or to a given application with optional parameters.

If you want to connect to an extension use the properties context, exten and priority. If you want to connect to an application use the properties application and data if needed. Note that no call detail record will be written when directly connecting to an application, so it may be better to connect to an extension that starts the application you wish to connect to.

The response to this action is sent when the channel has been answered and asterisk starts connecting it to the given extension. So be careful not to choose a too short timeout when waiting for the response.

If you set async to true Asterisk reports an OriginateSuccess- and OriginateFailureEvents. The action id of these events equals the action id of this OriginateAction.

Version:
$Id: OriginateAction.java 1174 2008-09-22 23:42:11Z srt $
Author:
srt
See Also:
OriginateResponseEvent, Serialized Form

Constructor Summary
OriginateAction()
           
 
Method Summary
 java.lang.String getAccount()
          Returns the account code to use for the originated call.
 java.lang.String getAction()
          Returns the name of this action, i.e.
 java.lang.Class<? extends ResponseEvent> getActionCompleteEventClass()
          Returns the event type that indicates that Asterisk is finished sending response events for this action.
 java.lang.String getApplication()
          Returns the name of the application to connect to.
 java.lang.Boolean getAsync()
          Returns true if this is a fast origination.
 java.lang.String getCallerId()
          Returns the caller id to set on the outgoing channel.
 java.lang.Integer getCallingPres()
          Returns the calling presentation for the outgoing channel.
 java.lang.String getChannel()
          Returns the name of the channel to connect to the outgoing call.
 java.lang.String getCodecs()
          Returns the codecs to use for the call.
 java.lang.String getContext()
          Returns the name of the context of the extension to connect to.
 java.lang.String getData()
          Returns the parameters to pass to the application.
 java.lang.String getExten()
          Returns the extension to connect to.
 java.lang.Integer getPriority()
          Returns the priority of the extension to connect to.
 java.lang.Long getTimeout()
          Returns the timeout for the origination.
 java.util.Map<java.lang.String,java.lang.String> getVariables()
          Returns the variables to set on the originated call.
 void setAccount(java.lang.String account)
          Sets the account code to use for the originated call.
 void setApplication(java.lang.String application)
          Sets the name of the application to connect to.
 void setAsync(java.lang.Boolean async)
          Set to true for fast origination.
 void setCallerId(java.lang.String callerId)
          Sets the caller id to set on the outgoing channel.
 void setCallingPres(java.lang.Integer callingPres)
          Sets the calling presentation for the outgoing channel.
 void setChannel(java.lang.String channel)
          Sets the name of the channel to connect to the outgoing call.
 void setCodecs(java.util.List<java.lang.String> codecs)
          Sets the codecs to use for the call.
 void setCodecs(java.lang.String codecs)
          Sets the codecs to use for the call.
 void setContext(java.lang.String context)
          Sets the name of the context of the extension to connect to.
 void setData(java.lang.String data)
          Sets the parameters to pass to the application.
 void setExten(java.lang.String exten)
          Sets the extension to connect to.
 void setPriority(java.lang.Integer priority)
          Sets the priority of the extension to connect to.
 void setTimeout(java.lang.Integer timeout)
          Deprecated. use setTimeout(Long) instead.
 void setTimeout(java.lang.Long timeout)
          Sets the timeout (in milliseconds) for the origination.
 void setVariable(java.lang.String variable)
          Deprecated. use setVariables(Map) instead.
 void setVariable(java.lang.String name, java.lang.String value)
          Sets an variable on the originated call.
 void setVariables(java.util.Map<java.lang.String,java.lang.String> variables)
          Sets the variables to set on the originated call.
 
Methods inherited from class org.asteriskjava.manager.action.AbstractManagerAction
getActionId, setActionId, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.asteriskjava.manager.action.ManagerAction
getActionId, setActionId
 

Constructor Detail

OriginateAction

public OriginateAction()
Method Detail

getAction

public java.lang.String getAction()
Returns the name of this action, i.e. "Originate".

Specified by:
getAction in interface ManagerAction
Specified by:
getAction in class AbstractManagerAction
Returns:
the name of this action.

getAccount

public java.lang.String getAccount()
Returns the account code to use for the originated call.

Returns:
the account code to use for the originated call.

setAccount

public void setAccount(java.lang.String account)
Sets the account code to use for the originated call.

The account code is included in the call detail record generated for this call and will be used for billing.

Parameters:
account - the account code to use for the originated call.

getCallerId

public java.lang.String getCallerId()
Returns the caller id to set on the outgoing channel.


setCallerId

public void setCallerId(java.lang.String callerId)
Sets the caller id to set on the outgoing channel.

This includes both the Caller*Id Number and Caller*Id Name in the form "Jon Doe <1234>".

Parameters:
callerId - the caller id to set on the outgoing channel.

getCallingPres

public java.lang.Integer getCallingPres()
Returns the calling presentation for the outgoing channel.

This property is only available on BRIstuffed Asterisk servers.

Returns:
the calling presentation for the outgoing channel.
See Also:
setCallingPres(Integer)

setCallingPres

public void setCallingPres(java.lang.Integer callingPres)
Sets the calling presentation for the outgoing channel.

The number is an octet and the only bits you need worry about are bits 1,2,6 and 7.

Bits 1 and 2 define the screening indicator and bits 6 and 7 define the presentation indicator.

In essence, it says, 'Is the person who has been called allowed to see the callers number?' (presentation) and 'What authority was used to verify that this is a genuine number?' (screening).

Presentation indicator (Bits 6 and 7):

 Bits Meaning
  7 6
  0 0 Presentation allowed
  0 1 Presentation restricted
  1 0 Number not available due to interworking
  1 1 Reserved
 
Screening indicator (Bits 1 and 2):
 Bits Meaning
  2 1
  0 0 User-provided, not screened
  0 1 User-provided, verified and passed
  1 0 User-provided, verified and failed
  1 1 Network provided
 
Examples for some general settings:
 Presentation Allowed, Network Provided: 3 (00000011)
 Presentation Restricted, User-provided, not screened: 32 (00100000)
 Presentation Restricted, User-provided, verified, and passed: 33 (00100001)
 Presentation Restricted, Network Provided: 35 (00100011)
 
This property is only available on BRIstuffed Asterisk servers.

Parameters:
callingPres - the calling presentation for the outgoing channel.

getChannel

public java.lang.String getChannel()
Returns the name of the channel to connect to the outgoing call.


setChannel

public void setChannel(java.lang.String channel)
Sets the name of the channel to connect to the outgoing call.

This property is mandatory.


getContext

public java.lang.String getContext()
Returns the name of the context of the extension to connect to.


setContext

public void setContext(java.lang.String context)
Sets the name of the context of the extension to connect to.

If you set the context you also have to set the exten and priority properties.


getExten

public java.lang.String getExten()
Returns the extension to connect to.


setExten

public void setExten(java.lang.String exten)
Sets the extension to connect to.

If you set the extension you also have to set the context and priority properties.


getPriority

public java.lang.Integer getPriority()
Returns the priority of the extension to connect to.


setPriority

public void setPriority(java.lang.Integer priority)
Sets the priority of the extension to connect to. If you set the priority you also have to set the context and exten properties.


getApplication

public java.lang.String getApplication()
Returns the name of the application to connect to.


setApplication

public void setApplication(java.lang.String application)
Sets the name of the application to connect to.


getData

public java.lang.String getData()
Returns the parameters to pass to the application.


setData

public void setData(java.lang.String data)
Sets the parameters to pass to the application.


getTimeout

public java.lang.Long getTimeout()
Returns the timeout for the origination.


setTimeout

public void setTimeout(java.lang.Integer timeout)
Deprecated. use setTimeout(Long) instead.

Sets the timeout (in milliseconds) for the origination.

The channel must be answered within this time, otherwise the origination is considered to have failed and an OriginateFailureEvent is generated.

If not set, Asterisk assumes a default value of 30000 meaning 30 seconds.

Parameters:
timeout - the timeout in milliseconds

setTimeout

public void setTimeout(java.lang.Long timeout)
Sets the timeout (in milliseconds) for the origination.

The channel must be answered within this time, otherwise the origination is considered to have failed and an OriginateFailureEvent is generated.

If not set, Asterisk assumes a default value of 30000 meaning 30 seconds.

Parameters:
timeout - the timeout in milliseconds

setVariable

public void setVariable(java.lang.String variable)
Deprecated. use setVariables(Map) instead.

Sets the variables to set on the originated call.

Variable assignments are of the form "VARNAME=VALUE". You can specify multiple variable assignments separated by the '|' character.

Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def".


setVariable

public void setVariable(java.lang.String name,
                        java.lang.String value)
Sets an variable on the originated call.

Parameters:
name - the name of the variable to set.
value - the value of the variable to set.
Since:
0.3

getVariables

public java.util.Map<java.lang.String,java.lang.String> getVariables()
Returns the variables to set on the originated call.

Returns:
a Map containing the variable names as key and their values as value.
Since:
0.2

setVariables

public void setVariables(java.util.Map<java.lang.String,java.lang.String> variables)
Sets the variables to set on the originated call.

Parameters:
variables - a Map containing the variable names as key and their values as value.
Since:
0.2

getAsync

public java.lang.Boolean getAsync()
Returns true if this is a fast origination.


setAsync

public void setAsync(java.lang.Boolean async)
Set to true for fast origination. Only with fast origination Asterisk will send OriginateSuccess- and OriginateFailureEvents.


getCodecs

public java.lang.String getCodecs()
Returns the codecs to use for the call.

Returns:
the codecs to use for the call.
Since:
1.0.0

setCodecs

public void setCodecs(java.lang.String codecs)
Sets the codecs to use for the call. For example "alaw, ulaw, h264".

Available since Asterisk 1.6.

Parameters:
codecs - comma separated list of codecs to use for the call.
Since:
1.0.0

setCodecs

public void setCodecs(java.util.List<java.lang.String> codecs)
Sets the codecs to use for the call.

Available since Asterisk 1.6.

Parameters:
codecs - list of codecs to use for the call.
Since:
1.0.0

getActionCompleteEventClass

public java.lang.Class<? extends ResponseEvent> getActionCompleteEventClass()
Description copied from interface: EventGeneratingAction
Returns the event type that indicates that Asterisk is finished sending response events for this action.

Specified by:
getActionCompleteEventClass in interface EventGeneratingAction
Returns:
a Class that is an instance of ResponseEvent.
See Also:
ResponseEvent

Asterisk-Java

Copyright © 2004-2009 Stefan Reuter. All Rights Reserved.