1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.hippo.client.webdav;
17
18 import java.io.Serializable;
19 import java.util.Properties;
20
21 import nl.hippo.client.api.content.DocumentPath;
22
23 import org.apache.commons.lang.builder.EqualsBuilder;
24 import org.apache.commons.lang.builder.HashCodeBuilder;
25 import org.apache.commons.lang.builder.ToStringBuilder;
26 import org.apache.commons.lang.builder.ToStringStyle;
27
28 public class WebdavRequest implements Serializable {
29
30 private static final long serialVersionUID = 1L;
31
32 private final WebdavConfig config;
33 private final DocumentPath path;
34 private final String id;
35 private final String method;
36 private final String requestBody;
37
38
39 public WebdavRequest(WebdavConfig config, DocumentPath path, String method, String requestBody) {
40 this(config, null, path, method, requestBody);
41 }
42
43 public WebdavRequest(String method) {
44 this(new WebdavConfig(new Properties()), null, null, method, null);
45 }
46
47 public WebdavRequest(WebdavConfig config, String id, String method) {
48 this(config, id, null, method, null);
49 }
50
51
52 private WebdavRequest(WebdavConfig config, String id, DocumentPath path, String method, String requestBody) {
53 this.config = config;
54 this.id = id;
55 this.path = path;
56 this.method = method;
57 this.requestBody = requestBody;
58 }
59
60
61 public WebdavRequest transformedVariant() {
62 return new WebdavRequest(config, path, "TRANSFORMED-" + method, requestBody);
63 }
64
65
66 public WebdavConfig getConfig() {
67 return config;
68 }
69
70
71 public String getMethod() {
72 return method;
73 }
74
75
76 public String getId() {
77 return id;
78 }
79
80
81 public DocumentPath getPath() {
82 return path;
83 }
84
85
86 public String getRequestBody() {
87 return requestBody;
88 }
89
90
91 public String toString() {
92 return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("Path", path).append("Config", getConfig().toString()).append("Method", getMethod()).append("Id",
93 getId()).append("Path", getPath().toString()).append("RequestBody", getRequestBody()).toString();
94 }
95
96
97 public boolean equals(Object obj) {
98 if (obj == null) {
99 return false;
100 } else if (!(obj instanceof WebdavRequest)) {
101 return false;
102 } else {
103 WebdavRequest rhs = (WebdavRequest) obj;
104 return new EqualsBuilder().append(getConfig(), rhs.getConfig()).append(getMethod(), rhs.getMethod()).append(getId(), rhs.getId()).append(getPath(), rhs.getPath()).append(
105 getRequestBody(), rhs.getRequestBody()).isEquals();
106 }
107 }
108
109
110 public int hashCode() {
111 return new HashCodeBuilder(11, 7).append(getConfig()).append(getMethod()).append(getId()).append(getPath()).append(getRequestBody()).toHashCode();
112 }
113
114 }