1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.connect.versioning;
17
18 import javax.jcr.Item;
19
20 import org.argeo.connect.ConnectException;
21
22
23 public class ItemDiff {
24
25 public final static Integer MODIFIED = 0;
26 public final static Integer ADDED = 1;
27 public final static Integer REMOVED = 2;
28
29 private final Integer type;
30 private final String relPath;
31 private final Item referenceItem;
32 private final Item observedItem;
33
34
35
36
37
38
39
40
41 public ItemDiff(Integer type, String relPath, Item referenceItem, Item observedItem) {
42 if (type == MODIFIED) {
43 if (referenceItem == null || observedItem == null)
44 throw new ConnectException("Reference and new items must be specified.");
45 } else if (type == ADDED) {
46 if (referenceItem != null || observedItem == null)
47 throw new ConnectException("New item and only it must be specified.");
48 } else if (type == REMOVED) {
49 if (referenceItem == null || observedItem != null)
50 throw new ConnectException("Reference item and only it must be specified.");
51 } else {
52 throw new ConnectException("Unkown diff type " + type);
53 }
54
55 if (relPath == null)
56 throw new ConnectException("Relative path must be specified");
57
58 this.type = type;
59 this.relPath = relPath;
60 this.referenceItem = referenceItem;
61 this.observedItem = observedItem;
62 }
63
64 public Integer getType() {
65 return type;
66 }
67
68 public String getRelPath() {
69 return relPath;
70 }
71
72 public Item getReferenceItem() {
73 return referenceItem;
74 }
75
76 public Item getObservedItem() {
77 return observedItem;
78 }
79
80 }