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
54 public class PortletModelImpl extends BaseModelImpl {
55 public static String TABLE_NAME = "Portlet";
56 public static Object[][] TABLE_COLUMNS = {
57 { "id_", new Integer(Types.BIGINT) },
58 { "companyId", new Integer(Types.BIGINT) },
59 { "portletId", new Integer(Types.VARCHAR) },
60 { "roles", new Integer(Types.VARCHAR) },
61 { "active_", new Integer(Types.BOOLEAN) }
62 };
63 public static String TABLE_SQL_CREATE = "create table Portlet (id_ LONG not null primary key,companyId LONG,portletId VARCHAR(200) null,roles STRING null,active_ BOOLEAN)";
64 public static String TABLE_SQL_DROP = "drop table Portlet";
65 public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
66 "xss.allow.com.liferay.portal.model.Portlet"), XSS_ALLOW);
67 public static boolean XSS_ALLOW_PORTLETID = GetterUtil.getBoolean(PropsUtil.get(
68 "xss.allow.com.liferay.portal.model.Portlet.portletId"),
69 XSS_ALLOW_BY_MODEL);
70 public static boolean XSS_ALLOW_ROLES = GetterUtil.getBoolean(PropsUtil.get(
71 "xss.allow.com.liferay.portal.model.Portlet.roles"),
72 XSS_ALLOW_BY_MODEL);
73 public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
74 "lock.expiration.time.com.liferay.portal.model.PortletModel"));
75
76 public PortletModelImpl() {
77 }
78
79 public long getPrimaryKey() {
80 return _id;
81 }
82
83 public void setPrimaryKey(long pk) {
84 setId(pk);
85 }
86
87 public Serializable getPrimaryKeyObj() {
88 return new Long(_id);
89 }
90
91 public long getId() {
92 return _id;
93 }
94
95 public void setId(long id) {
96 if (id != _id) {
97 _id = id;
98 }
99 }
100
101 public long getCompanyId() {
102 return _companyId;
103 }
104
105 public void setCompanyId(long companyId) {
106 if (companyId != _companyId) {
107 _companyId = companyId;
108 }
109 }
110
111 public String getPortletId() {
112 return GetterUtil.getString(_portletId);
113 }
114
115 public void setPortletId(String portletId) {
116 if (((portletId == null) && (_portletId != null)) ||
117 ((portletId != null) && (_portletId == null)) ||
118 ((portletId != null) && (_portletId != null) &&
119 !portletId.equals(_portletId))) {
120 if (!XSS_ALLOW_PORTLETID) {
121 portletId = XSSUtil.strip(portletId);
122 }
123
124 _portletId = portletId;
125 }
126 }
127
128 public String getRoles() {
129 return GetterUtil.getString(_roles);
130 }
131
132 public void setRoles(String roles) {
133 if (((roles == null) && (_roles != null)) ||
134 ((roles != null) && (_roles == null)) ||
135 ((roles != null) && (_roles != null) && !roles.equals(_roles))) {
136 if (!XSS_ALLOW_ROLES) {
137 roles = XSSUtil.strip(roles);
138 }
139
140 _roles = roles;
141 }
142 }
143
144 public boolean getActive() {
145 return _active;
146 }
147
148 public boolean isActive() {
149 return _active;
150 }
151
152 public void setActive(boolean active) {
153 if (active != _active) {
154 _active = active;
155 }
156 }
157
158 public Object clone() {
159 PortletImpl clone = new PortletImpl();
160 clone.setId(getId());
161 clone.setCompanyId(getCompanyId());
162 clone.setPortletId(getPortletId());
163 clone.setRoles(getRoles());
164 clone.setActive(getActive());
165
166 return clone;
167 }
168
169 public int compareTo(Object obj) {
170 if (obj == null) {
171 return -1;
172 }
173
174 PortletImpl portlet = (PortletImpl)obj;
175 long pk = portlet.getPrimaryKey();
176
177 if (getPrimaryKey() < pk) {
178 return -1;
179 }
180 else if (getPrimaryKey() > pk) {
181 return 1;
182 }
183 else {
184 return 0;
185 }
186 }
187
188 public boolean equals(Object obj) {
189 if (obj == null) {
190 return false;
191 }
192
193 PortletImpl portlet = null;
194
195 try {
196 portlet = (PortletImpl)obj;
197 }
198 catch (ClassCastException cce) {
199 return false;
200 }
201
202 long pk = portlet.getPrimaryKey();
203
204 if (getPrimaryKey() == pk) {
205 return true;
206 }
207 else {
208 return false;
209 }
210 }
211
212 public int hashCode() {
213 return (int)getPrimaryKey();
214 }
215
216 private long _id;
217 private long _companyId;
218 private String _portletId;
219 private String _roles;
220 private boolean _active;
221 }