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.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  /**
36   * <a href="PermissionModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>Permission_</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portal.service.model.Permission
51   * @see com.liferay.portal.service.model.PermissionModel
52   * @see com.liferay.portal.service.model.impl.PermissionImpl
53   *
54   */
55  public class PermissionModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "Permission_";
57      public static Object[][] TABLE_COLUMNS = {
58              { "permissionId", new Integer(Types.BIGINT) },
59              { "companyId", new Integer(Types.BIGINT) },
60              { "actionId", new Integer(Types.VARCHAR) },
61              { "resourceId", new Integer(Types.BIGINT) }
62          };
63      public static String TABLE_SQL_CREATE = "create table Permission_ (permissionId LONG not null primary key,companyId LONG,actionId VARCHAR(75) null,resourceId LONG)";
64      public static String TABLE_SQL_DROP = "drop table Permission_";
65      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
66                  "xss.allow.com.liferay.portal.model.Permission"), XSS_ALLOW);
67      public static boolean XSS_ALLOW_ACTIONID = GetterUtil.getBoolean(PropsUtil.get(
68                  "xss.allow.com.liferay.portal.model.Permission.actionId"),
69              XSS_ALLOW_BY_MODEL);
70      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
71                  "lock.expiration.time.com.liferay.portal.model.PermissionModel"));
72  
73      public PermissionModelImpl() {
74      }
75  
76      public long getPrimaryKey() {
77          return _permissionId;
78      }
79  
80      public void setPrimaryKey(long pk) {
81          setPermissionId(pk);
82      }
83  
84      public Serializable getPrimaryKeyObj() {
85          return new Long(_permissionId);
86      }
87  
88      public long getPermissionId() {
89          return _permissionId;
90      }
91  
92      public void setPermissionId(long permissionId) {
93          if (permissionId != _permissionId) {
94              _permissionId = permissionId;
95          }
96      }
97  
98      public long getCompanyId() {
99          return _companyId;
100     }
101 
102     public void setCompanyId(long companyId) {
103         if (companyId != _companyId) {
104             _companyId = companyId;
105         }
106     }
107 
108     public String getActionId() {
109         return GetterUtil.getString(_actionId);
110     }
111 
112     public void setActionId(String actionId) {
113         if (((actionId == null) && (_actionId != null)) ||
114                 ((actionId != null) && (_actionId == null)) ||
115                 ((actionId != null) && (_actionId != null) &&
116                 !actionId.equals(_actionId))) {
117             if (!XSS_ALLOW_ACTIONID) {
118                 actionId = XSSUtil.strip(actionId);
119             }
120 
121             _actionId = actionId;
122         }
123     }
124 
125     public long getResourceId() {
126         return _resourceId;
127     }
128 
129     public void setResourceId(long resourceId) {
130         if (resourceId != _resourceId) {
131             _resourceId = resourceId;
132         }
133     }
134 
135     public Object clone() {
136         PermissionImpl clone = new PermissionImpl();
137         clone.setPermissionId(getPermissionId());
138         clone.setCompanyId(getCompanyId());
139         clone.setActionId(getActionId());
140         clone.setResourceId(getResourceId());
141 
142         return clone;
143     }
144 
145     public int compareTo(Object obj) {
146         if (obj == null) {
147             return -1;
148         }
149 
150         PermissionImpl permission = (PermissionImpl)obj;
151         long pk = permission.getPrimaryKey();
152 
153         if (getPrimaryKey() < pk) {
154             return -1;
155         }
156         else if (getPrimaryKey() > pk) {
157             return 1;
158         }
159         else {
160             return 0;
161         }
162     }
163 
164     public boolean equals(Object obj) {
165         if (obj == null) {
166             return false;
167         }
168 
169         PermissionImpl permission = null;
170 
171         try {
172             permission = (PermissionImpl)obj;
173         }
174         catch (ClassCastException cce) {
175             return false;
176         }
177 
178         long pk = permission.getPrimaryKey();
179 
180         if (getPrimaryKey() == pk) {
181             return true;
182         }
183         else {
184             return false;
185         }
186     }
187 
188     public int hashCode() {
189         return (int)getPrimaryKey();
190     }
191 
192     private long _permissionId;
193     private long _companyId;
194     private String _actionId;
195     private long _resourceId;
196 }