Re: [Asterisk-java-users] DB actions and events
Brought to you by:
srt
From: Gaetan M. <gm...@ea...> - 2007-03-09 12:58:00
|
Hi Stefan Following those patches and a bit more research, it seems in fact that the "val" key is changed to "value" by the BRIStuff patches ? For the DBGetResponseEvent the proposed fix does the job anyway. But obviously for the DBPutAction and DBGetAction it breaks compatibility with non Bristuffed versions .. Do you have any idea how the library could support both versions in Actions ? Send both "val" and "value" keys ? Regards Gaetan Gaetan Minet wrote: > Hi Stefan > > If you're interested here is a small patch against db actions and event: > > - Fix DBGetREsponseEvent, the key for the value is "value" and no "val" > (at least in my * 1.2.9) , so added an additional setValue() on the event. > - Fix DBPutAction also, key is value and not val (see comment about > documentation mistakes on voip-info.org's page for dbput). > - Created DBDelAction (quite recent addition to the manager api in > spring 2006 ?). > > Gaetan > > ------------------------------------------------------------------------ > > Index: /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/action/DbDelAction.java > =================================================================== > --- /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/action/DbDelAction.java (revision 0) > +++ /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/action/DbDelAction.java (revision 0) > @@ -0,0 +1,99 @@ > +/* > + * Copyright 2004-2006 Stefan Reuter > + * > + * Licensed under the Apache License, Version 2.0 (the "License"); > + * you may not use this file except in compliance with the License. > + * You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + * > + */ > +package org.asteriskjava.manager.action; > + > +/** > + * Deletes an entry in the Asterisk database for a given family, key, > + * and value.<p> > + * Available since Asterisk 1.2 > + * > + * @author gmi > + */ > +public class DbDelAction extends AbstractManagerAction > +{ > + /** > + * Serial version identifier > + */ > + private static final long serialVersionUID = 921037572305993779L; > + private String family; > + private String key; > + > + /** > + * Creates a new empty DbDelAction. > + */ > + public DbDelAction() > + { > + > + } > + > + /** > + * Creates a new DbDelAction that deletes the value of the database > + * > + * @param family the family of the key > + * @param key the key of the entry to delete > + */ > + public DbDelAction(String family, String key) > + { > + this.family = family; > + this.key = key; > + } > + > + public String getAction() > + { > + return "DBDel"; > + } > + > + /** > + * Returns the family of the key to delete > + * > + * @return the family of the key to delete > + */ > + public String getFamily() > + { > + return family; > + } > + > + /** > + * Sets the family of the key to delete > + * > + * @param family the family of the key to delete > + */ > + public void setFamily(String family) > + { > + this.family = family; > + } > + > + /** > + * Returns the the key to delete > + * > + * @return the key to delete > + */ > + public String getKey() > + { > + return key; > + } > + > + /** > + * Sets the key to delete > + * > + * @param key the key to delete > + */ > + public void setKey(String key) > + { > + this.key = key; > + } > +} > Index: /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/action/DbPutAction.java > =================================================================== > --- /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/action/DbPutAction.java (revision 598) > +++ /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/action/DbPutAction.java (working copy) > @@ -33,7 +33,7 @@ > private static final long serialVersionUID = 921037572305993779L; > private String family; > private String key; > - private String val; > + private String value; > > /** > * Creates a new empty DbPutAction. > @@ -52,11 +52,11 @@ > * @param val the value to set > * @since 0.2 > */ > - public DbPutAction(String family, String key, String val) > + public DbPutAction(String family, String key, String value) > { > this.family = family; > this.key = key; > - this.val = val; > + this.value = value; > } > > public String getAction() > @@ -109,9 +109,9 @@ > * > * @return the value to set. > */ > - public String getVal() > + public String getValue() > { > - return val; > + return value; > } > > /** > @@ -121,6 +121,6 @@ > */ > public void setVal(String val) > { > - this.val = val; > + this.value = val; > } > } > > ------------------------------------------------------------------------ > > Index: /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/event/DbGetResponseEvent.java > =================================================================== > --- /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/event/DbGetResponseEvent.java (revision 608) > +++ /Users/Gaetan/Documents/workspace/asterisk-java-trunk/src/main/java/org/asteriskjava/manager/event/DbGetResponseEvent.java (working copy) > @@ -104,4 +104,16 @@ > { > this.val = val; > } > + > + /** > + * Sets the value of the database entry that was queried. > + * It seems that in ast 1.2 (1.2.9 ?) at least the header is > + * not val anymore but value. > + * > + * @param val the value of the database entry that was queried. > + */ > + public void setValue(String val) > + { > + this.val = val; > + } > } > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > |