Use exponential backoff when updating the password or last login time in WebDAV.
[pithos] / src / gr / ebs / gss / server / domain / AuditInfo.java
1 /*\r
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.\r
3  *\r
4  * This file is part of GSS.\r
5  *\r
6  * GSS is free software: you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation, either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * GSS is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with GSS.  If not, see <http://www.gnu.org/licenses/>.\r
18  */\r
19 package gr.ebs.gss.server.domain;\r
20 \r
21 import gr.ebs.gss.server.domain.dto.AuditInfoDTO;\r
22 \r
23 import java.io.Serializable;\r
24 import java.util.Date;\r
25 \r
26 import javax.persistence.Column;\r
27 import javax.persistence.Embeddable;\r
28 import javax.persistence.JoinColumn;\r
29 import javax.persistence.ManyToOne;\r
30 import javax.persistence.Temporal;\r
31 import javax.persistence.TemporalType;\r
32 \r
33 import org.hibernate.annotations.Cache;\r
34 import org.hibernate.annotations.CacheConcurrencyStrategy;\r
35 \r
36 /**\r
37  * This class holds audit information pertaining to the associated domain\r
38  * object. This information includes the user that created the object, the\r
39  * creation time, the user that modified the object and the modification date.\r
40  */\r
41 @Embeddable\r
42 @Cache(usage=CacheConcurrencyStrategy.READ_WRITE)\r
43 public class AuditInfo  implements Serializable{\r
44 \r
45         /**\r
46          * The date the associated object was created. We can never change it after\r
47          * creation.\r
48          */\r
49         @Temporal(TemporalType.TIMESTAMP)\r
50         @Column(updatable = false, nullable = false)\r
51         private Date creationDate;\r
52 \r
53         /**\r
54          * The user that created the associated object. We can never change it after\r
55          * creation.\r
56          */\r
57         @ManyToOne\r
58         @JoinColumn(updatable = false)\r
59         private User createdBy;\r
60 \r
61         /**\r
62          * The date the associated object was modified.\r
63          */\r
64         @Temporal(TemporalType.TIMESTAMP)\r
65         @Column(nullable = false)\r
66         private Date modificationDate;\r
67 \r
68         /**\r
69          * The user that modified the associated object.\r
70          */\r
71         @ManyToOne\r
72         private User modifiedBy;\r
73 \r
74         /**\r
75          * Retrieve the creation date for the associated object.\r
76          *\r
77          * @return the date of creation\r
78          */\r
79         public Date getCreationDate() {\r
80                 return creationDate;\r
81         }\r
82 \r
83         /**\r
84          * Modify the creation date for the associated object.\r
85          *\r
86          * @param _creationDate the new date of creation\r
87          */\r
88         public void setCreationDate(final Date _creationDate) {\r
89                 creationDate = _creationDate;\r
90         }\r
91 \r
92         /**\r
93          * Retrieve the user that created the associated object.\r
94          *\r
95          * @return the user that created the associated object\r
96          */\r
97         public User getCreatedBy() {\r
98                 return createdBy;\r
99         }\r
100 \r
101         /**\r
102          * Modify the user that created the associated object.\r
103          *\r
104          * @param _createdBy the new user that created the associated object\r
105          */\r
106         public void setCreatedBy(final User _createdBy) {\r
107                 createdBy = _createdBy;\r
108         }\r
109 \r
110         /**\r
111          * Retrieve the modification date for the associated object.\r
112          *\r
113          * @return the date of modification\r
114          */\r
115         public Date getModificationDate() {\r
116                 return modificationDate;\r
117         }\r
118 \r
119         /**\r
120          * Modify the modification date for the associated object.\r
121          *\r
122          * @param _modificationDate the new date of modification\r
123          */\r
124         public void setModificationDate(final Date _modificationDate) {\r
125                 modificationDate = _modificationDate;\r
126         }\r
127 \r
128         /**\r
129          * Retrieve the user that modified the associated object.\r
130          *\r
131          * @return the user that modified the associated object\r
132          */\r
133         public User getModifiedBy() {\r
134                 return modifiedBy;\r
135         }\r
136 \r
137         /**\r
138          * Modify the user that modified the associated object.\r
139          *\r
140          * @param _modifiedBy the new user that modified the associated object\r
141          */\r
142         public void setModifiedBy(final User _modifiedBy) {\r
143                 modifiedBy = _modifiedBy;\r
144         }\r
145 \r
146         /**\r
147          * Retrieve the Data Transfer Object for this audit info, that pays\r
148          * particular attention to avoid any instances of java.sql.Timestamp in the\r
149          * creation and modification dates.\r
150          *\r
151          * @return a DTO object with audit info\r
152          */\r
153         public AuditInfoDTO getDTO() {\r
154                 final AuditInfoDTO dto = new AuditInfoDTO();\r
155                 dto.setCreatedBy(createdBy.getDTO());\r
156                 dto.setCreationDate(new Date(creationDate.getTime()));\r
157                 dto.setModificationDate(new Date(modificationDate.getTime()));\r
158                 dto.setModifiedBy(modifiedBy.getDTO());\r
159                 return dto;\r
160         }\r
161 }\r