root / src / org / gss_project / gss / server / domain / FileLock.java @ 1205:fbeae20462e6
History | View | Annotate | Download (4.2 kB)
1 |
/*
|
---|---|
2 |
* Copyright (c) 2011. Electronic Business Systems Ltd
|
3 |
*/
|
4 |
package org.gss_project.gss.server.domain; |
5 |
|
6 |
import java.util.Date; |
7 |
|
8 |
import javax.persistence.Column; |
9 |
import javax.persistence.Entity; |
10 |
import javax.persistence.Id; |
11 |
import javax.persistence.Temporal; |
12 |
import javax.persistence.TemporalType; |
13 |
import javax.persistence.Version; |
14 |
|
15 |
import org.hibernate.annotations.CollectionOfElements; |
16 |
import org.hibernate.annotations.IndexColumn; |
17 |
|
18 |
import com.bradmcevoy.http.LockInfo; |
19 |
import com.bradmcevoy.http.LockTimeout; |
20 |
import com.bradmcevoy.http.LockToken; |
21 |
import com.bradmcevoy.http.LockInfo.LockDepth; |
22 |
import com.bradmcevoy.http.LockInfo.LockScope; |
23 |
import com.bradmcevoy.http.LockInfo.LockType; |
24 |
|
25 |
|
26 |
/**
|
27 |
* @author kman
|
28 |
*
|
29 |
*/
|
30 |
@Entity
|
31 |
public class FileLock { |
32 |
@Id
|
33 |
String id;
|
34 |
public String lockedByUser; |
35 |
@Temporal(TemporalType.TIMESTAMP)
|
36 |
@Column(name="from_date") |
37 |
Date from;
|
38 |
String tokenId;
|
39 |
|
40 |
public LockScope scope;
|
41 |
public LockType type;
|
42 |
public LockDepth depth;
|
43 |
|
44 |
Long seconds;
|
45 |
@CollectionOfElements
|
46 |
@IndexColumn(name="secId") |
47 |
Long[] otherSeconds; |
48 |
@Version
|
49 |
private int version; |
50 |
|
51 |
/**
|
52 |
*
|
53 |
*/
|
54 |
public FileLock() { |
55 |
// TODO Auto-generated constructor stub
|
56 |
} |
57 |
|
58 |
public FileLock(String id,LockToken token){ |
59 |
this.id=id;
|
60 |
this.tokenId=token.tokenId;
|
61 |
if(token.info!=null){ |
62 |
this.depth=token.info.depth;
|
63 |
this.scope=token.info.scope;
|
64 |
this.type=token.info.type;
|
65 |
this.lockedByUser=token.info.lockedByUser;
|
66 |
} |
67 |
if(token.timeout!=null){ |
68 |
this.seconds=token.timeout.getSeconds();
|
69 |
this.otherSeconds=token.timeout.getOtherSeconds();
|
70 |
} |
71 |
this.from=token.getFrom();
|
72 |
|
73 |
} |
74 |
|
75 |
public LockToken toToken(){
|
76 |
LockToken res = new LockToken();
|
77 |
res.tokenId=tokenId; |
78 |
LockInfo info = new LockInfo(scope,type,lockedByUser,depth);
|
79 |
LockTimeout timeout = new LockTimeout(seconds);
|
80 |
res.timeout=timeout; |
81 |
res.info=info; |
82 |
res.setFrom(from); |
83 |
return res;
|
84 |
} |
85 |
|
86 |
|
87 |
/**
|
88 |
* Retrieve the id.
|
89 |
*
|
90 |
* @return the id
|
91 |
*/
|
92 |
public String getId() { |
93 |
return id;
|
94 |
} |
95 |
|
96 |
|
97 |
/**
|
98 |
* Modify the id.
|
99 |
*
|
100 |
* @param id the id to set
|
101 |
*/
|
102 |
public void setId(String id) { |
103 |
this.id = id;
|
104 |
} |
105 |
|
106 |
|
107 |
/**
|
108 |
* Retrieve the lockedByUser.
|
109 |
*
|
110 |
* @return the lockedByUser
|
111 |
*/
|
112 |
public String getLockedByUser() { |
113 |
return lockedByUser;
|
114 |
} |
115 |
|
116 |
|
117 |
/**
|
118 |
* Modify the lockedByUser.
|
119 |
*
|
120 |
* @param lockedByUser the lockedByUser to set
|
121 |
*/
|
122 |
public void setLockedByUser(String lockedByUser) { |
123 |
this.lockedByUser = lockedByUser;
|
124 |
} |
125 |
|
126 |
|
127 |
/**
|
128 |
* Retrieve the from.
|
129 |
*
|
130 |
* @return the from
|
131 |
*/
|
132 |
public Date getFrom() { |
133 |
return from;
|
134 |
} |
135 |
|
136 |
|
137 |
/**
|
138 |
* Modify the from.
|
139 |
*
|
140 |
* @param from the from to set
|
141 |
*/
|
142 |
public void setFrom(Date from) { |
143 |
this.from = from;
|
144 |
} |
145 |
|
146 |
|
147 |
/**
|
148 |
* Retrieve the tokenId.
|
149 |
*
|
150 |
* @return the tokenId
|
151 |
*/
|
152 |
public String getTokenId() { |
153 |
return tokenId;
|
154 |
} |
155 |
|
156 |
|
157 |
/**
|
158 |
* Modify the tokenId.
|
159 |
*
|
160 |
* @param tokenId the tokenId to set
|
161 |
*/
|
162 |
public void setTokenId(String tokenId) { |
163 |
this.tokenId = tokenId;
|
164 |
} |
165 |
|
166 |
|
167 |
/**
|
168 |
* Retrieve the scope.
|
169 |
*
|
170 |
* @return the scope
|
171 |
*/
|
172 |
public LockScope getScope() {
|
173 |
return scope;
|
174 |
} |
175 |
|
176 |
|
177 |
/**
|
178 |
* Modify the scope.
|
179 |
*
|
180 |
* @param scope the scope to set
|
181 |
*/
|
182 |
public void setScope(LockScope scope) { |
183 |
this.scope = scope;
|
184 |
} |
185 |
|
186 |
|
187 |
/**
|
188 |
* Retrieve the type.
|
189 |
*
|
190 |
* @return the type
|
191 |
*/
|
192 |
public LockType getType() {
|
193 |
return type;
|
194 |
} |
195 |
|
196 |
|
197 |
/**
|
198 |
* Modify the type.
|
199 |
*
|
200 |
* @param type the type to set
|
201 |
*/
|
202 |
public void setType(LockType type) { |
203 |
this.type = type;
|
204 |
} |
205 |
|
206 |
|
207 |
/**
|
208 |
* Retrieve the depth.
|
209 |
*
|
210 |
* @return the depth
|
211 |
*/
|
212 |
public LockDepth getDepth() {
|
213 |
return depth;
|
214 |
} |
215 |
|
216 |
|
217 |
/**
|
218 |
* Modify the depth.
|
219 |
*
|
220 |
* @param depth the depth to set
|
221 |
*/
|
222 |
public void setDepth(LockDepth depth) { |
223 |
this.depth = depth;
|
224 |
} |
225 |
|
226 |
|
227 |
/**
|
228 |
* Retrieve the seconds.
|
229 |
*
|
230 |
* @return the seconds
|
231 |
*/
|
232 |
public Long getSeconds() { |
233 |
return seconds;
|
234 |
} |
235 |
|
236 |
|
237 |
/**
|
238 |
* Modify the seconds.
|
239 |
*
|
240 |
* @param seconds the seconds to set
|
241 |
*/
|
242 |
public void setSeconds(Long seconds) { |
243 |
this.seconds = seconds;
|
244 |
} |
245 |
|
246 |
|
247 |
/**
|
248 |
* Retrieve the otherSeconds.
|
249 |
*
|
250 |
* @return the otherSeconds
|
251 |
*/
|
252 |
public Long[] getOtherSeconds() { |
253 |
return otherSeconds;
|
254 |
} |
255 |
|
256 |
|
257 |
/**
|
258 |
* Modify the otherSeconds.
|
259 |
*
|
260 |
* @param otherSeconds the otherSeconds to set
|
261 |
*/
|
262 |
public void setOtherSeconds(Long[] otherSeconds) { |
263 |
this.otherSeconds = otherSeconds;
|
264 |
} |
265 |
|
266 |
|
267 |
|
268 |
|
269 |
} |