001
014
015 package com.liferay.portlet.documentlibrary.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.documentlibrary.model.DLFileEntry;
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 DLFileEntryCacheModel implements CacheModel<DLFileEntry>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(57);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", fileEntryId=");
046 sb.append(fileEntryId);
047 sb.append(", groupId=");
048 sb.append(groupId);
049 sb.append(", companyId=");
050 sb.append(companyId);
051 sb.append(", userId=");
052 sb.append(userId);
053 sb.append(", userName=");
054 sb.append(userName);
055 sb.append(", createDate=");
056 sb.append(createDate);
057 sb.append(", modifiedDate=");
058 sb.append(modifiedDate);
059 sb.append(", classNameId=");
060 sb.append(classNameId);
061 sb.append(", classPK=");
062 sb.append(classPK);
063 sb.append(", repositoryId=");
064 sb.append(repositoryId);
065 sb.append(", folderId=");
066 sb.append(folderId);
067 sb.append(", treePath=");
068 sb.append(treePath);
069 sb.append(", name=");
070 sb.append(name);
071 sb.append(", extension=");
072 sb.append(extension);
073 sb.append(", mimeType=");
074 sb.append(mimeType);
075 sb.append(", title=");
076 sb.append(title);
077 sb.append(", description=");
078 sb.append(description);
079 sb.append(", extraSettings=");
080 sb.append(extraSettings);
081 sb.append(", fileEntryTypeId=");
082 sb.append(fileEntryTypeId);
083 sb.append(", version=");
084 sb.append(version);
085 sb.append(", size=");
086 sb.append(size);
087 sb.append(", readCount=");
088 sb.append(readCount);
089 sb.append(", smallImageId=");
090 sb.append(smallImageId);
091 sb.append(", largeImageId=");
092 sb.append(largeImageId);
093 sb.append(", custom1ImageId=");
094 sb.append(custom1ImageId);
095 sb.append(", custom2ImageId=");
096 sb.append(custom2ImageId);
097 sb.append(", manualCheckInRequired=");
098 sb.append(manualCheckInRequired);
099 sb.append("}");
100
101 return sb.toString();
102 }
103
104 @Override
105 public DLFileEntry toEntityModel() {
106 DLFileEntryImpl dlFileEntryImpl = new DLFileEntryImpl();
107
108 if (uuid == null) {
109 dlFileEntryImpl.setUuid(StringPool.BLANK);
110 }
111 else {
112 dlFileEntryImpl.setUuid(uuid);
113 }
114
115 dlFileEntryImpl.setFileEntryId(fileEntryId);
116 dlFileEntryImpl.setGroupId(groupId);
117 dlFileEntryImpl.setCompanyId(companyId);
118 dlFileEntryImpl.setUserId(userId);
119
120 if (userName == null) {
121 dlFileEntryImpl.setUserName(StringPool.BLANK);
122 }
123 else {
124 dlFileEntryImpl.setUserName(userName);
125 }
126
127 if (createDate == Long.MIN_VALUE) {
128 dlFileEntryImpl.setCreateDate(null);
129 }
130 else {
131 dlFileEntryImpl.setCreateDate(new Date(createDate));
132 }
133
134 if (modifiedDate == Long.MIN_VALUE) {
135 dlFileEntryImpl.setModifiedDate(null);
136 }
137 else {
138 dlFileEntryImpl.setModifiedDate(new Date(modifiedDate));
139 }
140
141 dlFileEntryImpl.setClassNameId(classNameId);
142 dlFileEntryImpl.setClassPK(classPK);
143 dlFileEntryImpl.setRepositoryId(repositoryId);
144 dlFileEntryImpl.setFolderId(folderId);
145
146 if (treePath == null) {
147 dlFileEntryImpl.setTreePath(StringPool.BLANK);
148 }
149 else {
150 dlFileEntryImpl.setTreePath(treePath);
151 }
152
153 if (name == null) {
154 dlFileEntryImpl.setName(StringPool.BLANK);
155 }
156 else {
157 dlFileEntryImpl.setName(name);
158 }
159
160 if (extension == null) {
161 dlFileEntryImpl.setExtension(StringPool.BLANK);
162 }
163 else {
164 dlFileEntryImpl.setExtension(extension);
165 }
166
167 if (mimeType == null) {
168 dlFileEntryImpl.setMimeType(StringPool.BLANK);
169 }
170 else {
171 dlFileEntryImpl.setMimeType(mimeType);
172 }
173
174 if (title == null) {
175 dlFileEntryImpl.setTitle(StringPool.BLANK);
176 }
177 else {
178 dlFileEntryImpl.setTitle(title);
179 }
180
181 if (description == null) {
182 dlFileEntryImpl.setDescription(StringPool.BLANK);
183 }
184 else {
185 dlFileEntryImpl.setDescription(description);
186 }
187
188 if (extraSettings == null) {
189 dlFileEntryImpl.setExtraSettings(StringPool.BLANK);
190 }
191 else {
192 dlFileEntryImpl.setExtraSettings(extraSettings);
193 }
194
195 dlFileEntryImpl.setFileEntryTypeId(fileEntryTypeId);
196
197 if (version == null) {
198 dlFileEntryImpl.setVersion(StringPool.BLANK);
199 }
200 else {
201 dlFileEntryImpl.setVersion(version);
202 }
203
204 dlFileEntryImpl.setSize(size);
205 dlFileEntryImpl.setReadCount(readCount);
206 dlFileEntryImpl.setSmallImageId(smallImageId);
207 dlFileEntryImpl.setLargeImageId(largeImageId);
208 dlFileEntryImpl.setCustom1ImageId(custom1ImageId);
209 dlFileEntryImpl.setCustom2ImageId(custom2ImageId);
210 dlFileEntryImpl.setManualCheckInRequired(manualCheckInRequired);
211
212 dlFileEntryImpl.resetOriginalValues();
213
214 return dlFileEntryImpl;
215 }
216
217 @Override
218 public void readExternal(ObjectInput objectInput) throws IOException {
219 uuid = objectInput.readUTF();
220 fileEntryId = objectInput.readLong();
221 groupId = objectInput.readLong();
222 companyId = objectInput.readLong();
223 userId = objectInput.readLong();
224 userName = objectInput.readUTF();
225 createDate = objectInput.readLong();
226 modifiedDate = objectInput.readLong();
227 classNameId = objectInput.readLong();
228 classPK = objectInput.readLong();
229 repositoryId = objectInput.readLong();
230 folderId = objectInput.readLong();
231 treePath = objectInput.readUTF();
232 name = objectInput.readUTF();
233 extension = objectInput.readUTF();
234 mimeType = objectInput.readUTF();
235 title = objectInput.readUTF();
236 description = objectInput.readUTF();
237 extraSettings = objectInput.readUTF();
238 fileEntryTypeId = objectInput.readLong();
239 version = objectInput.readUTF();
240 size = objectInput.readLong();
241 readCount = objectInput.readInt();
242 smallImageId = objectInput.readLong();
243 largeImageId = objectInput.readLong();
244 custom1ImageId = objectInput.readLong();
245 custom2ImageId = objectInput.readLong();
246 manualCheckInRequired = objectInput.readBoolean();
247 }
248
249 @Override
250 public void writeExternal(ObjectOutput objectOutput)
251 throws IOException {
252 if (uuid == null) {
253 objectOutput.writeUTF(StringPool.BLANK);
254 }
255 else {
256 objectOutput.writeUTF(uuid);
257 }
258
259 objectOutput.writeLong(fileEntryId);
260 objectOutput.writeLong(groupId);
261 objectOutput.writeLong(companyId);
262 objectOutput.writeLong(userId);
263
264 if (userName == null) {
265 objectOutput.writeUTF(StringPool.BLANK);
266 }
267 else {
268 objectOutput.writeUTF(userName);
269 }
270
271 objectOutput.writeLong(createDate);
272 objectOutput.writeLong(modifiedDate);
273 objectOutput.writeLong(classNameId);
274 objectOutput.writeLong(classPK);
275 objectOutput.writeLong(repositoryId);
276 objectOutput.writeLong(folderId);
277
278 if (treePath == null) {
279 objectOutput.writeUTF(StringPool.BLANK);
280 }
281 else {
282 objectOutput.writeUTF(treePath);
283 }
284
285 if (name == null) {
286 objectOutput.writeUTF(StringPool.BLANK);
287 }
288 else {
289 objectOutput.writeUTF(name);
290 }
291
292 if (extension == null) {
293 objectOutput.writeUTF(StringPool.BLANK);
294 }
295 else {
296 objectOutput.writeUTF(extension);
297 }
298
299 if (mimeType == null) {
300 objectOutput.writeUTF(StringPool.BLANK);
301 }
302 else {
303 objectOutput.writeUTF(mimeType);
304 }
305
306 if (title == null) {
307 objectOutput.writeUTF(StringPool.BLANK);
308 }
309 else {
310 objectOutput.writeUTF(title);
311 }
312
313 if (description == null) {
314 objectOutput.writeUTF(StringPool.BLANK);
315 }
316 else {
317 objectOutput.writeUTF(description);
318 }
319
320 if (extraSettings == null) {
321 objectOutput.writeUTF(StringPool.BLANK);
322 }
323 else {
324 objectOutput.writeUTF(extraSettings);
325 }
326
327 objectOutput.writeLong(fileEntryTypeId);
328
329 if (version == null) {
330 objectOutput.writeUTF(StringPool.BLANK);
331 }
332 else {
333 objectOutput.writeUTF(version);
334 }
335
336 objectOutput.writeLong(size);
337 objectOutput.writeInt(readCount);
338 objectOutput.writeLong(smallImageId);
339 objectOutput.writeLong(largeImageId);
340 objectOutput.writeLong(custom1ImageId);
341 objectOutput.writeLong(custom2ImageId);
342 objectOutput.writeBoolean(manualCheckInRequired);
343 }
344
345 public String uuid;
346 public long fileEntryId;
347 public long groupId;
348 public long companyId;
349 public long userId;
350 public String userName;
351 public long createDate;
352 public long modifiedDate;
353 public long classNameId;
354 public long classPK;
355 public long repositoryId;
356 public long folderId;
357 public String treePath;
358 public String name;
359 public String extension;
360 public String mimeType;
361 public String title;
362 public String description;
363 public String extraSettings;
364 public long fileEntryTypeId;
365 public String version;
366 public long size;
367 public int readCount;
368 public long smallImageId;
369 public long largeImageId;
370 public long custom1ImageId;
371 public long custom2ImageId;
372 public boolean manualCheckInRequired;
373 }