Asterisk-Java

org.asteriskjava.manager.action
Class UpdateConfigAction

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

public class UpdateConfigAction
extends AbstractManagerAction

The UpdateConfigAction sends an UpdateConfig command to the asterisk server. Please take note that unlike the manager documentation, this command does not dump back the config file upon success -- it only tells you it succeeded. You should use the handy addCommand method this class provides for specifying what actions you would like to take on the configuration file. It will generate appropriate sequence numbers for the command. You may use the static ACTION_* fields provided by this action to specify what action you would like to take, while avoiding handling the strings required. Plain fields: SrcFilename: Configuration filename to read(e.g. foo.conf) DstFilename: Configuration filename to write(e.g. foo.conf) Reload: Whether or not a reload should take place (or name of specific module) Repeatable fields: Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append) Cat-XXXXXX: Category to operate on Var-XXXXXX: Variable to work on Value-XXXXXX: Value to work on Match-XXXXXX: Extra match required to match line

Since:
0.3
Author:
martins
See Also:
GetConfigResponse, addCommand(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String), Serialized Form

Field Summary
static java.lang.String ACTION_APPEND
           
static java.lang.String ACTION_DELCAT
           
static java.lang.String ACTION_DELETE
           
static java.lang.String ACTION_NEWCAT
           
static java.lang.String ACTION_RENAMECAT
           
static java.lang.String ACTION_UPDATE
           
protected  int actionCounter
           
protected  java.util.Map<java.lang.String,java.lang.String> actions
           
protected  java.lang.String dstFilename
           
protected  java.lang.String reload
           
protected  java.lang.String srcFilename
           
 
Constructor Summary
UpdateConfigAction()
          Creates a new UpdateConfigAction.
UpdateConfigAction(java.lang.String srcFilename, java.lang.String dstFilename, boolean reload)
          Creates a new UpdateConfigAction with the given parameters.
 
Method Summary
 void addCommand(java.lang.String action, java.lang.String cat, java.lang.String var, java.lang.String value, java.lang.String match)
          Adds a command to update a config file while sparing you the details of the Manager's required syntax.
 java.lang.String getAction()
          Returns the name of this action, i.e.
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
          Returns Map of the action's desired operations where Map keys contain: action,cat,var,value,match pairs followed by -XXXXXX, and the Map values contain the values for those keys.
 java.lang.String getDstFilename()
          Returns the destination filename.
 java.lang.String getReload()
           
 java.lang.String getSrcFilename()
          Returns the source filename.
 void setAttributes(java.util.Map<java.lang.String,java.lang.String> actions)
          You may use this field to directly, programmatically add your own Map of key,value pairs that you would like to send for this command.
 void setDstFilename(java.lang.String filename)
          Sets the source filename.
 void setReload(boolean reload)
          Sets the reload behavior of this action.
 void setReload(java.lang.String reload)
          Sets the reload behavior of this action, or sets a specific module to be reloaded
 void setSrcFilename(java.lang.String filename)
          Sets the source filename.
 
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
 

Field Detail

ACTION_NEWCAT

public static final java.lang.String ACTION_NEWCAT
See Also:
Constant Field Values

ACTION_RENAMECAT

public static final java.lang.String ACTION_RENAMECAT
See Also:
Constant Field Values

ACTION_DELCAT

public static final java.lang.String ACTION_DELCAT
See Also:
Constant Field Values

ACTION_UPDATE

public static final java.lang.String ACTION_UPDATE
See Also:
Constant Field Values

ACTION_DELETE

public static final java.lang.String ACTION_DELETE
See Also:
Constant Field Values

ACTION_APPEND

public static final java.lang.String ACTION_APPEND
See Also:
Constant Field Values

srcFilename

protected java.lang.String srcFilename

dstFilename

protected java.lang.String dstFilename

reload

protected java.lang.String reload

actionCounter

protected int actionCounter

actions

protected java.util.Map<java.lang.String,java.lang.String> actions
Constructor Detail

UpdateConfigAction

public UpdateConfigAction()
Creates a new UpdateConfigAction.


UpdateConfigAction

public UpdateConfigAction(java.lang.String srcFilename,
                          java.lang.String dstFilename,
                          boolean reload)
Creates a new UpdateConfigAction with the given parameters.

Parameters:
srcFilename - the name of the file to get.
Method Detail

addCommand

public void addCommand(java.lang.String action,
                       java.lang.String cat,
                       java.lang.String var,
                       java.lang.String value,
                       java.lang.String match)
Adds a command to update a config file while sparing you the details of the Manager's required syntax. If you want to omit one of the command's sections, provide a null value to this method. The command index will be incremented even if you supply a null for all parameters, though the map will be unaffected.

Parameters:
action - Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append), see static fields
cat - Category to operate on
var - Variable to work on
value - Value to work on
match - Extra match required to match line

getAction

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

Specified by:
getAction in interface ManagerAction
Specified by:
getAction in class AbstractManagerAction

getSrcFilename

public java.lang.String getSrcFilename()
Returns the source filename.


setSrcFilename

public void setSrcFilename(java.lang.String filename)
Sets the source filename.


getDstFilename

public java.lang.String getDstFilename()
Returns the destination filename.


setDstFilename

public void setDstFilename(java.lang.String filename)
Sets the source filename.


getReload

public java.lang.String getReload()
Returns:
should Asterisk reload, or the name of a specific module to reload

setReload

public void setReload(java.lang.String reload)
Sets the reload behavior of this action, or sets a specific module to be reloaded

Parameters:
reload - the reload parameter to set
See Also:
setReload(boolean)

setReload

public void setReload(boolean reload)
Sets the reload behavior of this action. If you don't know what string to feed Asterisk, this method will provide the appropriate one.

Parameters:
reload - the reload parameter to set
See Also:
setReload(String)

getAttributes

public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Returns Map of the action's desired operations where Map keys contain: action,cat,var,value,match pairs followed by -XXXXXX, and the Map values contain the values for those keys. This method will typically only be used by the ActionBuilder to generate the actual strings to be sent to the manager interface.

Returns:
a Map of the actions that should be taken
See Also:
addCommand(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

setAttributes

public void setAttributes(java.util.Map<java.lang.String,java.lang.String> actions)
You may use this field to directly, programmatically add your own Map of key,value pairs that you would like to send for this command. Setting your own map will reset the command index to the number of keys in the Map

Parameters:
actions - the actions to set
See Also:
addCommand(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

Asterisk-Java

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