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