001
014
015 package com.liferay.portlet.documentlibrary.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.HashUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023
024 import com.liferay.portlet.documentlibrary.model.DLFolder;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031 import java.util.Date;
032
033
040 @ProviderType
041 public class DLFolderCacheModel implements CacheModel<DLFolder>, Externalizable {
042 @Override
043 public boolean equals(Object obj) {
044 if (this == obj) {
045 return true;
046 }
047
048 if (!(obj instanceof DLFolderCacheModel)) {
049 return false;
050 }
051
052 DLFolderCacheModel dlFolderCacheModel = (DLFolderCacheModel)obj;
053
054 if (folderId == dlFolderCacheModel.folderId) {
055 return true;
056 }
057
058 return false;
059 }
060
061 @Override
062 public int hashCode() {
063 return HashUtil.hash(0, folderId);
064 }
065
066 @Override
067 public String toString() {
068 StringBundler sb = new StringBundler(45);
069
070 sb.append("{uuid=");
071 sb.append(uuid);
072 sb.append(", folderId=");
073 sb.append(folderId);
074 sb.append(", groupId=");
075 sb.append(groupId);
076 sb.append(", companyId=");
077 sb.append(companyId);
078 sb.append(", userId=");
079 sb.append(userId);
080 sb.append(", userName=");
081 sb.append(userName);
082 sb.append(", createDate=");
083 sb.append(createDate);
084 sb.append(", modifiedDate=");
085 sb.append(modifiedDate);
086 sb.append(", repositoryId=");
087 sb.append(repositoryId);
088 sb.append(", mountPoint=");
089 sb.append(mountPoint);
090 sb.append(", parentFolderId=");
091 sb.append(parentFolderId);
092 sb.append(", treePath=");
093 sb.append(treePath);
094 sb.append(", name=");
095 sb.append(name);
096 sb.append(", description=");
097 sb.append(description);
098 sb.append(", lastPostDate=");
099 sb.append(lastPostDate);
100 sb.append(", defaultFileEntryTypeId=");
101 sb.append(defaultFileEntryTypeId);
102 sb.append(", hidden=");
103 sb.append(hidden);
104 sb.append(", restrictionType=");
105 sb.append(restrictionType);
106 sb.append(", status=");
107 sb.append(status);
108 sb.append(", statusByUserId=");
109 sb.append(statusByUserId);
110 sb.append(", statusByUserName=");
111 sb.append(statusByUserName);
112 sb.append(", statusDate=");
113 sb.append(statusDate);
114 sb.append("}");
115
116 return sb.toString();
117 }
118
119 @Override
120 public DLFolder toEntityModel() {
121 DLFolderImpl dlFolderImpl = new DLFolderImpl();
122
123 if (uuid == null) {
124 dlFolderImpl.setUuid(StringPool.BLANK);
125 }
126 else {
127 dlFolderImpl.setUuid(uuid);
128 }
129
130 dlFolderImpl.setFolderId(folderId);
131 dlFolderImpl.setGroupId(groupId);
132 dlFolderImpl.setCompanyId(companyId);
133 dlFolderImpl.setUserId(userId);
134
135 if (userName == null) {
136 dlFolderImpl.setUserName(StringPool.BLANK);
137 }
138 else {
139 dlFolderImpl.setUserName(userName);
140 }
141
142 if (createDate == Long.MIN_VALUE) {
143 dlFolderImpl.setCreateDate(null);
144 }
145 else {
146 dlFolderImpl.setCreateDate(new Date(createDate));
147 }
148
149 if (modifiedDate == Long.MIN_VALUE) {
150 dlFolderImpl.setModifiedDate(null);
151 }
152 else {
153 dlFolderImpl.setModifiedDate(new Date(modifiedDate));
154 }
155
156 dlFolderImpl.setRepositoryId(repositoryId);
157 dlFolderImpl.setMountPoint(mountPoint);
158 dlFolderImpl.setParentFolderId(parentFolderId);
159
160 if (treePath == null) {
161 dlFolderImpl.setTreePath(StringPool.BLANK);
162 }
163 else {
164 dlFolderImpl.setTreePath(treePath);
165 }
166
167 if (name == null) {
168 dlFolderImpl.setName(StringPool.BLANK);
169 }
170 else {
171 dlFolderImpl.setName(name);
172 }
173
174 if (description == null) {
175 dlFolderImpl.setDescription(StringPool.BLANK);
176 }
177 else {
178 dlFolderImpl.setDescription(description);
179 }
180
181 if (lastPostDate == Long.MIN_VALUE) {
182 dlFolderImpl.setLastPostDate(null);
183 }
184 else {
185 dlFolderImpl.setLastPostDate(new Date(lastPostDate));
186 }
187
188 dlFolderImpl.setDefaultFileEntryTypeId(defaultFileEntryTypeId);
189 dlFolderImpl.setHidden(hidden);
190 dlFolderImpl.setRestrictionType(restrictionType);
191 dlFolderImpl.setStatus(status);
192 dlFolderImpl.setStatusByUserId(statusByUserId);
193
194 if (statusByUserName == null) {
195 dlFolderImpl.setStatusByUserName(StringPool.BLANK);
196 }
197 else {
198 dlFolderImpl.setStatusByUserName(statusByUserName);
199 }
200
201 if (statusDate == Long.MIN_VALUE) {
202 dlFolderImpl.setStatusDate(null);
203 }
204 else {
205 dlFolderImpl.setStatusDate(new Date(statusDate));
206 }
207
208 dlFolderImpl.resetOriginalValues();
209
210 return dlFolderImpl;
211 }
212
213 @Override
214 public void readExternal(ObjectInput objectInput) throws IOException {
215 uuid = objectInput.readUTF();
216 folderId = objectInput.readLong();
217 groupId = objectInput.readLong();
218 companyId = objectInput.readLong();
219 userId = objectInput.readLong();
220 userName = objectInput.readUTF();
221 createDate = objectInput.readLong();
222 modifiedDate = objectInput.readLong();
223 repositoryId = objectInput.readLong();
224 mountPoint = objectInput.readBoolean();
225 parentFolderId = objectInput.readLong();
226 treePath = objectInput.readUTF();
227 name = objectInput.readUTF();
228 description = objectInput.readUTF();
229 lastPostDate = objectInput.readLong();
230 defaultFileEntryTypeId = objectInput.readLong();
231 hidden = objectInput.readBoolean();
232 restrictionType = objectInput.readInt();
233 status = objectInput.readInt();
234 statusByUserId = objectInput.readLong();
235 statusByUserName = objectInput.readUTF();
236 statusDate = objectInput.readLong();
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(folderId);
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(repositoryId);
264 objectOutput.writeBoolean(mountPoint);
265 objectOutput.writeLong(parentFolderId);
266
267 if (treePath == null) {
268 objectOutput.writeUTF(StringPool.BLANK);
269 }
270 else {
271 objectOutput.writeUTF(treePath);
272 }
273
274 if (name == null) {
275 objectOutput.writeUTF(StringPool.BLANK);
276 }
277 else {
278 objectOutput.writeUTF(name);
279 }
280
281 if (description == null) {
282 objectOutput.writeUTF(StringPool.BLANK);
283 }
284 else {
285 objectOutput.writeUTF(description);
286 }
287
288 objectOutput.writeLong(lastPostDate);
289 objectOutput.writeLong(defaultFileEntryTypeId);
290 objectOutput.writeBoolean(hidden);
291 objectOutput.writeInt(restrictionType);
292 objectOutput.writeInt(status);
293 objectOutput.writeLong(statusByUserId);
294
295 if (statusByUserName == null) {
296 objectOutput.writeUTF(StringPool.BLANK);
297 }
298 else {
299 objectOutput.writeUTF(statusByUserName);
300 }
301
302 objectOutput.writeLong(statusDate);
303 }
304
305 public String uuid;
306 public long folderId;
307 public long groupId;
308 public long companyId;
309 public long userId;
310 public String userName;
311 public long createDate;
312 public long modifiedDate;
313 public long repositoryId;
314 public boolean mountPoint;
315 public long parentFolderId;
316 public String treePath;
317 public String name;
318 public String description;
319 public long lastPostDate;
320 public long defaultFileEntryTypeId;
321 public boolean hidden;
322 public int restrictionType;
323 public int status;
324 public long statusByUserId;
325 public String statusByUserName;
326 public long statusDate;
327 }