taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

add_watcher does not add watcher to the issue in redmine #247

Closed prbourget closed 8 years ago

prbourget commented 8 years ago

Everything seems straightforward but it does not work for me.

if (ticket.getWatcher() != null) {
    Set<Watcher> watchers = new HashSet<>();
    int watcherId=config.getUserId(ticket.getWatcher());
    Watcher w=WatcherFactory.create(watcherId);
    watchers.add(w);        
    issue.addWatchers(watchers);
    issueManager.update(issue);    
    log.info("adding watcher " + ticket.getWatcher() + " id " + watcherId);
}

If I look at issue 12555 there are no watchers. I can add this watcher through the UI.

Any ideas would be appreciated!

From redmine/htdocs/log/production.log

_Note the watcher_userids entry

Started PUT "/redmine/issues/12555.json?key=1ccaf01079ef17d7a2559869e74c8da97f28f457" for 192.168.201.191 at 2016-04-26 12:19:08 -0400 Processing by IssuesController#update as JSON Parameters: {"issue"=>{"id"=>12555, "subject"=>"eLR not reporting - 11 Mercer, Suite #404 - End Use - 0x284ED70000EF", "priority_id"=>2, "done_ratio"=>0, "project_id"=>4, "author_id"=>24 , "start_date"=>"2016-04-26", "tracker_id"=>6, "description"=>"", "created_on"=>"2016/04/26 12:19:07 -0400", "updated_on"=>"2016/04/26 12:19:06 -0400", "status_id"=>1, "custom_field_values "=>{"8"=>"OutSmart Power Systems", "9"=>"OutSmart Power Systems - 11 Mercer, Suite #404", "13"=>"Error", "14"=>"Error - eLR not reporting", "15"=>"eLR not reporting", "16"=>"eLR not report ing - OutSmart Power Systems - 11 Mercer, Suite #404 - End Use - 0x284ED70000EF", "17"=>"0x284ED70000EF", "19"=>"End Use", "20"=>"1461684062161", "21"=>"", "22"=>"2016-04-26 11:21:02 EDT", "23"=>"", "24"=>"eLR 0x284ED70000EF (paul test) not reporting, last sample was time unknown."}, "watcher_user_ids"=>[25]}, "key"=>"1ccaf01079ef17d7a2559869e74c8da97f28f457", "id"=>"12555" }

From the Bitnami redmine information page Environment: Redmine version 2.5.2.stable Ruby version 2.0.0-p481 (2014-05-08) [x86_64-linux] Rails version 3.2.19 Environment production Database adapter Mysql2 SCM: Git 1.7.10.4 Filesystem
Redmine plugins: a_common_libs 2.1.2 extra_queries 2.0.3 redmine_default_assign 0.4 redmine_importer 1.2.2 redmine_multi_column_custom_fields 0.0.1 redmine_silencer 0.4.1

prbourget commented 8 years ago

Figured it out. Use issueManager.addWatcherToIssue(w, issue); instead. It makes a separate REST call that updates the watchers table and doesn't touch the issue.

The watcher_user_ids doesn't do anything I can see.