Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16627/src/java/net/sf/asterisk/manager/impl
Modified Files:
ManagerReaderImpl.java
Log Message:
Added patch for command action response from Derrick Shields
Index: ManagerReaderImpl.java
===================================================================
RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/impl/ManagerReaderImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -p -r1.5 -r1.6
--- ManagerReaderImpl.java 23 Apr 2005 22:56:31 -0000 1.5
+++ ManagerReaderImpl.java 7 Jun 2005 23:36:15 -0000 1.6
@@ -146,14 +146,32 @@ public class ManagerReaderImpl implement
{
CommandResponse commandResponse = new CommandResponse();
- if (!commandResult.isEmpty() && ((String) commandResult.get(0)).startsWith("ActionID"))
+ for (int crIdx = 0; crIdx < commandResult.size(); crIdx++)
{
- String tmp = (String) commandResult.get(0);
- int delimiterIndex = tmp.indexOf(":");
- if (delimiterIndex > 0 && tmp.length() > delimiterIndex + 2)
+ String[] crNVPair = ((String) commandResult.get(crIdx)).split(" *: *", 2);
+
+ if (crNVPair[0].equals("ActionID"))
{
- commandResult.remove(0);
- commandResponse.setActionId(tmp.substring(delimiterIndex + 2));
+ // Remove the command response nvpair from the
+ // command result array and decrement index so we
+ // don't skip the "new" current line
+ commandResult.remove(crIdx--);
+
+ // Register the action id with the command result
+ commandResponse.setActionId(crNVPair[1]);
+ }
+ else if (crNVPair[0].equals("Privilege"))
+ {
+ // Remove the command response nvpair from the
+ // command result array and decrement index so we
+ // don't skip the "new" current line
+ commandResult.remove(crIdx--);
+ }
+ else
+ {
+ // Didn't find a name:value pattern, so we're now in the
+ // command results. Stop processing the nv pairs.
+ break;
}
}
commandResponse.setResponse("Follows");
|