lib/ardtweeno/nodemanager.rb in ardtweeno-0.2.5 vs lib/ardtweeno/nodemanager.rb in ardtweeno-0.3.0

- old
+ new

@@ -176,12 +176,12 @@ # def watched?(node) @watchlist.each do |i| - @log.debug "Comparing " + i[:node].node + " and " + node.node - if i[:node].node == node.node + @log.debug "Comparing " + i[:node] + " and " + node.node + if i[:node] == node.node return true end end return false @@ -203,20 +203,26 @@ def addWatch(params) begin node = search({:node=>params[:node]}) @log.debug "Found Node: " + node.inspect - watch = { :node=>node, + if watched?(node) + raise Ardtweeno::AlreadyWatched + end + + watch = { :node=>params[:node], :notifyURL=> params[:notifyURL], - :method=>"POST", - :timeout=>"60" + :method=>params[:method], + :timeout=>params[:timeout] } @log.debug "Adding watch: " + watch.inspect @watchlist << watch - + + rescue Ardtweeno::AlreadyWatched => e + raise e rescue Ardtweeno::NotInNodeList => e raise e rescue Exception => e raise e end @@ -236,10 +242,10 @@ def removeWatch(node) begin node = search({:node=>node}) @watchlist.each do |i| - if i[:node] == node + if i[:node] == node.node @watchlist.delete(i) end end rescue Ardtweeno::NotInNodeList => e