1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.util.DateUtil;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.XSSUtil;
31  
32  import java.io.Serializable;
33  
34  import java.sql.Types;
35  
36  import java.util.Date;
37  
38  /**
39   * <a href="PasswordTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be overwritten
43   * the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>PasswordTracker</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.PasswordTracker
54   * @see com.liferay.portal.service.model.PasswordTrackerModel
55   * @see com.liferay.portal.service.model.impl.PasswordTrackerImpl
56   *
57   */
58  public class PasswordTrackerModelImpl extends BaseModelImpl {
59      public static String TABLE_NAME = "PasswordTracker";
60      public static Object[][] TABLE_COLUMNS = {
61              { "passwordTrackerId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "createDate", new Integer(Types.TIMESTAMP) },
64              { "password_", new Integer(Types.VARCHAR) }
65          };
66      public static String TABLE_SQL_CREATE = "create table PasswordTracker (passwordTrackerId LONG not null primary key,userId LONG,createDate DATE null,password_ VARCHAR(75) null)";
67      public static String TABLE_SQL_DROP = "drop table PasswordTracker";
68      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
69                  "xss.allow.com.liferay.portal.model.PasswordTracker"), XSS_ALLOW);
70      public static boolean XSS_ALLOW_PASSWORD = GetterUtil.getBoolean(PropsUtil.get(
71                  "xss.allow.com.liferay.portal.model.PasswordTracker.password"),
72              XSS_ALLOW_BY_MODEL);
73      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
74                  "lock.expiration.time.com.liferay.portal.model.PasswordTrackerModel"));
75  
76      public PasswordTrackerModelImpl() {
77      }
78  
79      public long getPrimaryKey() {
80          return _passwordTrackerId;
81      }
82  
83      public void setPrimaryKey(long pk) {
84          setPasswordTrackerId(pk);
85      }
86  
87      public Serializable getPrimaryKeyObj() {
88          return new Long(_passwordTrackerId);
89      }
90  
91      public long getPasswordTrackerId() {
92          return _passwordTrackerId;
93      }
94  
95      public void setPasswordTrackerId(long passwordTrackerId) {
96          if (passwordTrackerId != _passwordTrackerId) {
97              _passwordTrackerId = passwordTrackerId;
98          }
99      }
100 
101     public long getUserId() {
102         return _userId;
103     }
104 
105     public void setUserId(long userId) {
106         if (userId != _userId) {
107             _userId = userId;
108         }
109     }
110 
111     public Date getCreateDate() {
112         return _createDate;
113     }
114 
115     public void setCreateDate(Date createDate) {
116         if (((createDate == null) && (_createDate != null)) ||
117                 ((createDate != null) && (_createDate == null)) ||
118                 ((createDate != null) && (_createDate != null) &&
119                 !createDate.equals(_createDate))) {
120             _createDate = createDate;
121         }
122     }
123 
124     public String getPassword() {
125         return GetterUtil.getString(_password);
126     }
127 
128     public void setPassword(String password) {
129         if (((password == null) && (_password != null)) ||
130                 ((password != null) && (_password == null)) ||
131                 ((password != null) && (_password != null) &&
132                 !password.equals(_password))) {
133             if (!XSS_ALLOW_PASSWORD) {
134                 password = XSSUtil.strip(password);
135             }
136 
137             _password = password;
138         }
139     }
140 
141     public Object clone() {
142         PasswordTrackerImpl clone = new PasswordTrackerImpl();
143         clone.setPasswordTrackerId(getPasswordTrackerId());
144         clone.setUserId(getUserId());
145         clone.setCreateDate(getCreateDate());
146         clone.setPassword(getPassword());
147 
148         return clone;
149     }
150 
151     public int compareTo(Object obj) {
152         if (obj == null) {
153             return -1;
154         }
155 
156         PasswordTrackerImpl passwordTracker = (PasswordTrackerImpl)obj;
157         int value = 0;
158 
159         if (getUserId() < passwordTracker.getUserId()) {
160             value = -1;
161         }
162         else if (getUserId() > passwordTracker.getUserId()) {
163             value = 1;
164         }
165         else {
166             value = 0;
167         }
168 
169         value = value * -1;
170 
171         if (value != 0) {
172             return value;
173         }
174 
175         value = DateUtil.compareTo(getCreateDate(),
176                 passwordTracker.getCreateDate());
177         value = value * -1;
178 
179         if (value != 0) {
180             return value;
181         }
182 
183         return 0;
184     }
185 
186     public boolean equals(Object obj) {
187         if (obj == null) {
188             return false;
189         }
190 
191         PasswordTrackerImpl passwordTracker = null;
192 
193         try {
194             passwordTracker = (PasswordTrackerImpl)obj;
195         }
196         catch (ClassCastException cce) {
197             return false;
198         }
199 
200         long pk = passwordTracker.getPrimaryKey();
201 
202         if (getPrimaryKey() == pk) {
203             return true;
204         }
205         else {
206             return false;
207         }
208     }
209 
210     public int hashCode() {
211         return (int)getPrimaryKey();
212     }
213 
214     private long _passwordTrackerId;
215     private long _userId;
216     private Date _createDate;
217     private String _password;
218 }