1
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
55 public class PortletPreferencesModelImpl extends BaseModelImpl {
56 public static String TABLE_NAME = "PortletPreferences";
57 public static Object[][] TABLE_COLUMNS = {
58 { "portletPreferencesId", new Integer(Types.BIGINT) },
59 { "ownerId", new Integer(Types.BIGINT) },
60 { "ownerType", new Integer(Types.INTEGER) },
61 { "plid", new Integer(Types.BIGINT) },
62 { "portletId", new Integer(Types.VARCHAR) },
63 { "preferences", new Integer(Types.CLOB) }
64 };
65 public static String TABLE_SQL_CREATE = "create table PortletPreferences (portletPreferencesId LONG not null primary key,ownerId LONG,ownerType INTEGER,plid LONG,portletId VARCHAR(200) null,preferences TEXT null)";
66 public static String TABLE_SQL_DROP = "drop table PortletPreferences";
67 public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
68 "xss.allow.com.liferay.portal.model.PortletPreferences"),
69 XSS_ALLOW);
70 public static boolean XSS_ALLOW_PORTLETID = GetterUtil.getBoolean(PropsUtil.get(
71 "xss.allow.com.liferay.portal.model.PortletPreferences.portletId"),
72 XSS_ALLOW_BY_MODEL);
73 public static boolean XSS_ALLOW_PREFERENCES = GetterUtil.getBoolean(PropsUtil.get(
74 "xss.allow.com.liferay.portal.model.PortletPreferences.preferences"),
75 XSS_ALLOW_BY_MODEL);
76 public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
77 "lock.expiration.time.com.liferay.portal.model.PortletPreferencesModel"));
78
79 public PortletPreferencesModelImpl() {
80 }
81
82 public long getPrimaryKey() {
83 return _portletPreferencesId;
84 }
85
86 public void setPrimaryKey(long pk) {
87 setPortletPreferencesId(pk);
88 }
89
90 public Serializable getPrimaryKeyObj() {
91 return new Long(_portletPreferencesId);
92 }
93
94 public long getPortletPreferencesId() {
95 return _portletPreferencesId;
96 }
97
98 public void setPortletPreferencesId(long portletPreferencesId) {
99 if (portletPreferencesId != _portletPreferencesId) {
100 _portletPreferencesId = portletPreferencesId;
101 }
102 }
103
104 public long getOwnerId() {
105 return _ownerId;
106 }
107
108 public void setOwnerId(long ownerId) {
109 if (ownerId != _ownerId) {
110 _ownerId = ownerId;
111 }
112 }
113
114 public int getOwnerType() {
115 return _ownerType;
116 }
117
118 public void setOwnerType(int ownerType) {
119 if (ownerType != _ownerType) {
120 _ownerType = ownerType;
121 }
122 }
123
124 public long getPlid() {
125 return _plid;
126 }
127
128 public void setPlid(long plid) {
129 if (plid != _plid) {
130 _plid = plid;
131 }
132 }
133
134 public String getPortletId() {
135 return GetterUtil.getString(_portletId);
136 }
137
138 public void setPortletId(String portletId) {
139 if (((portletId == null) && (_portletId != null)) ||
140 ((portletId != null) && (_portletId == null)) ||
141 ((portletId != null) && (_portletId != null) &&
142 !portletId.equals(_portletId))) {
143 if (!XSS_ALLOW_PORTLETID) {
144 portletId = XSSUtil.strip(portletId);
145 }
146
147 _portletId = portletId;
148 }
149 }
150
151 public String getPreferences() {
152 return GetterUtil.getString(_preferences);
153 }
154
155 public void setPreferences(String preferences) {
156 if (((preferences == null) && (_preferences != null)) ||
157 ((preferences != null) && (_preferences == null)) ||
158 ((preferences != null) && (_preferences != null) &&
159 !preferences.equals(_preferences))) {
160 if (!XSS_ALLOW_PREFERENCES) {
161 preferences = XSSUtil.strip(preferences);
162 }
163
164 _preferences = preferences;
165 }
166 }
167
168 public Object clone() {
169 PortletPreferencesImpl clone = new PortletPreferencesImpl();
170 clone.setPortletPreferencesId(getPortletPreferencesId());
171 clone.setOwnerId(getOwnerId());
172 clone.setOwnerType(getOwnerType());
173 clone.setPlid(getPlid());
174 clone.setPortletId(getPortletId());
175 clone.setPreferences(getPreferences());
176
177 return clone;
178 }
179
180 public int compareTo(Object obj) {
181 if (obj == null) {
182 return -1;
183 }
184
185 PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl)obj;
186 long pk = portletPreferences.getPrimaryKey();
187
188 if (getPrimaryKey() < pk) {
189 return -1;
190 }
191 else if (getPrimaryKey() > pk) {
192 return 1;
193 }
194 else {
195 return 0;
196 }
197 }
198
199 public boolean equals(Object obj) {
200 if (obj == null) {
201 return false;
202 }
203
204 PortletPreferencesImpl portletPreferences = null;
205
206 try {
207 portletPreferences = (PortletPreferencesImpl)obj;
208 }
209 catch (ClassCastException cce) {
210 return false;
211 }
212
213 long pk = portletPreferences.getPrimaryKey();
214
215 if (getPrimaryKey() == pk) {
216 return true;
217 }
218 else {
219 return false;
220 }
221 }
222
223 public int hashCode() {
224 return (int)getPrimaryKey();
225 }
226
227 private long _portletPreferencesId;
228 private long _ownerId;
229 private int _ownerType;
230 private long _plid;
231 private String _portletId;
232 private String _preferences;
233 }