001
014
015 package com.liferay.portlet.wiki.model.impl;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.model.CacheModel;
020
021 import com.liferay.portlet.wiki.model.WikiPage;
022
023 import java.io.Externalizable;
024 import java.io.IOException;
025 import java.io.ObjectInput;
026 import java.io.ObjectOutput;
027
028 import java.util.Date;
029
030
037 public class WikiPageCacheModel implements CacheModel<WikiPage>, Externalizable {
038 @Override
039 public String toString() {
040 StringBundler sb = new StringBundler(47);
041
042 sb.append("{uuid=");
043 sb.append(uuid);
044 sb.append(", pageId=");
045 sb.append(pageId);
046 sb.append(", resourcePrimKey=");
047 sb.append(resourcePrimKey);
048 sb.append(", groupId=");
049 sb.append(groupId);
050 sb.append(", companyId=");
051 sb.append(companyId);
052 sb.append(", userId=");
053 sb.append(userId);
054 sb.append(", userName=");
055 sb.append(userName);
056 sb.append(", createDate=");
057 sb.append(createDate);
058 sb.append(", modifiedDate=");
059 sb.append(modifiedDate);
060 sb.append(", nodeId=");
061 sb.append(nodeId);
062 sb.append(", title=");
063 sb.append(title);
064 sb.append(", version=");
065 sb.append(version);
066 sb.append(", minorEdit=");
067 sb.append(minorEdit);
068 sb.append(", content=");
069 sb.append(content);
070 sb.append(", summary=");
071 sb.append(summary);
072 sb.append(", format=");
073 sb.append(format);
074 sb.append(", head=");
075 sb.append(head);
076 sb.append(", parentTitle=");
077 sb.append(parentTitle);
078 sb.append(", redirectTitle=");
079 sb.append(redirectTitle);
080 sb.append(", status=");
081 sb.append(status);
082 sb.append(", statusByUserId=");
083 sb.append(statusByUserId);
084 sb.append(", statusByUserName=");
085 sb.append(statusByUserName);
086 sb.append(", statusDate=");
087 sb.append(statusDate);
088 sb.append("}");
089
090 return sb.toString();
091 }
092
093 @Override
094 public WikiPage toEntityModel() {
095 WikiPageImpl wikiPageImpl = new WikiPageImpl();
096
097 if (uuid == null) {
098 wikiPageImpl.setUuid(StringPool.BLANK);
099 }
100 else {
101 wikiPageImpl.setUuid(uuid);
102 }
103
104 wikiPageImpl.setPageId(pageId);
105 wikiPageImpl.setResourcePrimKey(resourcePrimKey);
106 wikiPageImpl.setGroupId(groupId);
107 wikiPageImpl.setCompanyId(companyId);
108 wikiPageImpl.setUserId(userId);
109
110 if (userName == null) {
111 wikiPageImpl.setUserName(StringPool.BLANK);
112 }
113 else {
114 wikiPageImpl.setUserName(userName);
115 }
116
117 if (createDate == Long.MIN_VALUE) {
118 wikiPageImpl.setCreateDate(null);
119 }
120 else {
121 wikiPageImpl.setCreateDate(new Date(createDate));
122 }
123
124 if (modifiedDate == Long.MIN_VALUE) {
125 wikiPageImpl.setModifiedDate(null);
126 }
127 else {
128 wikiPageImpl.setModifiedDate(new Date(modifiedDate));
129 }
130
131 wikiPageImpl.setNodeId(nodeId);
132
133 if (title == null) {
134 wikiPageImpl.setTitle(StringPool.BLANK);
135 }
136 else {
137 wikiPageImpl.setTitle(title);
138 }
139
140 wikiPageImpl.setVersion(version);
141 wikiPageImpl.setMinorEdit(minorEdit);
142
143 if (content == null) {
144 wikiPageImpl.setContent(StringPool.BLANK);
145 }
146 else {
147 wikiPageImpl.setContent(content);
148 }
149
150 if (summary == null) {
151 wikiPageImpl.setSummary(StringPool.BLANK);
152 }
153 else {
154 wikiPageImpl.setSummary(summary);
155 }
156
157 if (format == null) {
158 wikiPageImpl.setFormat(StringPool.BLANK);
159 }
160 else {
161 wikiPageImpl.setFormat(format);
162 }
163
164 wikiPageImpl.setHead(head);
165
166 if (parentTitle == null) {
167 wikiPageImpl.setParentTitle(StringPool.BLANK);
168 }
169 else {
170 wikiPageImpl.setParentTitle(parentTitle);
171 }
172
173 if (redirectTitle == null) {
174 wikiPageImpl.setRedirectTitle(StringPool.BLANK);
175 }
176 else {
177 wikiPageImpl.setRedirectTitle(redirectTitle);
178 }
179
180 wikiPageImpl.setStatus(status);
181 wikiPageImpl.setStatusByUserId(statusByUserId);
182
183 if (statusByUserName == null) {
184 wikiPageImpl.setStatusByUserName(StringPool.BLANK);
185 }
186 else {
187 wikiPageImpl.setStatusByUserName(statusByUserName);
188 }
189
190 if (statusDate == Long.MIN_VALUE) {
191 wikiPageImpl.setStatusDate(null);
192 }
193 else {
194 wikiPageImpl.setStatusDate(new Date(statusDate));
195 }
196
197 wikiPageImpl.resetOriginalValues();
198
199 return wikiPageImpl;
200 }
201
202 @Override
203 public void readExternal(ObjectInput objectInput) throws IOException {
204 uuid = objectInput.readUTF();
205 pageId = objectInput.readLong();
206 resourcePrimKey = objectInput.readLong();
207 groupId = objectInput.readLong();
208 companyId = objectInput.readLong();
209 userId = objectInput.readLong();
210 userName = objectInput.readUTF();
211 createDate = objectInput.readLong();
212 modifiedDate = objectInput.readLong();
213 nodeId = objectInput.readLong();
214 title = objectInput.readUTF();
215 version = objectInput.readDouble();
216 minorEdit = objectInput.readBoolean();
217 content = objectInput.readUTF();
218 summary = objectInput.readUTF();
219 format = objectInput.readUTF();
220 head = objectInput.readBoolean();
221 parentTitle = objectInput.readUTF();
222 redirectTitle = objectInput.readUTF();
223 status = objectInput.readInt();
224 statusByUserId = objectInput.readLong();
225 statusByUserName = objectInput.readUTF();
226 statusDate = objectInput.readLong();
227 }
228
229 @Override
230 public void writeExternal(ObjectOutput objectOutput)
231 throws IOException {
232 if (uuid == null) {
233 objectOutput.writeUTF(StringPool.BLANK);
234 }
235 else {
236 objectOutput.writeUTF(uuid);
237 }
238
239 objectOutput.writeLong(pageId);
240 objectOutput.writeLong(resourcePrimKey);
241 objectOutput.writeLong(groupId);
242 objectOutput.writeLong(companyId);
243 objectOutput.writeLong(userId);
244
245 if (userName == null) {
246 objectOutput.writeUTF(StringPool.BLANK);
247 }
248 else {
249 objectOutput.writeUTF(userName);
250 }
251
252 objectOutput.writeLong(createDate);
253 objectOutput.writeLong(modifiedDate);
254 objectOutput.writeLong(nodeId);
255
256 if (title == null) {
257 objectOutput.writeUTF(StringPool.BLANK);
258 }
259 else {
260 objectOutput.writeUTF(title);
261 }
262
263 objectOutput.writeDouble(version);
264 objectOutput.writeBoolean(minorEdit);
265
266 if (content == null) {
267 objectOutput.writeUTF(StringPool.BLANK);
268 }
269 else {
270 objectOutput.writeUTF(content);
271 }
272
273 if (summary == null) {
274 objectOutput.writeUTF(StringPool.BLANK);
275 }
276 else {
277 objectOutput.writeUTF(summary);
278 }
279
280 if (format == null) {
281 objectOutput.writeUTF(StringPool.BLANK);
282 }
283 else {
284 objectOutput.writeUTF(format);
285 }
286
287 objectOutput.writeBoolean(head);
288
289 if (parentTitle == null) {
290 objectOutput.writeUTF(StringPool.BLANK);
291 }
292 else {
293 objectOutput.writeUTF(parentTitle);
294 }
295
296 if (redirectTitle == null) {
297 objectOutput.writeUTF(StringPool.BLANK);
298 }
299 else {
300 objectOutput.writeUTF(redirectTitle);
301 }
302
303 objectOutput.writeInt(status);
304 objectOutput.writeLong(statusByUserId);
305
306 if (statusByUserName == null) {
307 objectOutput.writeUTF(StringPool.BLANK);
308 }
309 else {
310 objectOutput.writeUTF(statusByUserName);
311 }
312
313 objectOutput.writeLong(statusDate);
314 }
315
316 public String uuid;
317 public long pageId;
318 public long resourcePrimKey;
319 public long groupId;
320 public long companyId;
321 public long userId;
322 public String userName;
323 public long createDate;
324 public long modifiedDate;
325 public long nodeId;
326 public String title;
327 public double version;
328 public boolean minorEdit;
329 public String content;
330 public String summary;
331 public String format;
332 public boolean head;
333 public String parentTitle;
334 public String redirectTitle;
335 public int status;
336 public long statusByUserId;
337 public String statusByUserName;
338 public long statusDate;
339 }