3 import interfaces
.DJInterface
;
7 import notification
.LibraryListener
;
9 import dacp
.DACPTreeBuilder
;
11 public class Update
implements Command
, LibraryListener
{
15 public void init(Map
<String
, String
> args
) {
16 String rev
= args
.get("revision-number");
19 System
.err
.println("update: revision number not present");
23 revision
= Integer
.parseInt(rev
);
25 catch (NumberFormatException ex
) {
26 throw new IllegalArgumentException("revision number " + rev
+ " is not valid");
31 public Node
run(DJInterface dj
) {
33 if (this.revision
>= dj
.library().version()) {
35 dj
.library().registerLibraryListener(this);
39 this.wait(10000); //wait 10 seconds if nothing has changed
41 } catch (InterruptedException e
) {
45 dj
.library().removeLibraryListener(this);
48 //TODO use version to check whether update is needed
49 return DACPTreeBuilder
.buildUpdateResponse(dj
.library().version());
52 public void libraryVersionChanged(int version
) {