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.DLFolder;
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 DLFolderCacheModel implements CacheModel<DLFolder>, Externalizable {
038 @Override
039 public String toString() {
040 StringBundler sb = new StringBundler(45);
041
042 sb.append("{uuid=");
043 sb.append(uuid);
044 sb.append(", folderId=");
045 sb.append(folderId);
046 sb.append(", groupId=");
047 sb.append(groupId);
048 sb.append(", companyId=");
049 sb.append(companyId);
050 sb.append(", userId=");
051 sb.append(userId);
052 sb.append(", userName=");
053 sb.append(userName);
054 sb.append(", createDate=");
055 sb.append(createDate);
056 sb.append(", modifiedDate=");
057 sb.append(modifiedDate);
058 sb.append(", repositoryId=");
059 sb.append(repositoryId);
060 sb.append(", mountPoint=");
061 sb.append(mountPoint);
062 sb.append(", parentFolderId=");
063 sb.append(parentFolderId);
064 sb.append(", treePath=");
065 sb.append(treePath);
066 sb.append(", name=");
067 sb.append(name);
068 sb.append(", description=");
069 sb.append(description);
070 sb.append(", lastPostDate=");
071 sb.append(lastPostDate);
072 sb.append(", defaultFileEntryTypeId=");
073 sb.append(defaultFileEntryTypeId);
074 sb.append(", hidden=");
075 sb.append(hidden);
076 sb.append(", overrideFileEntryTypes=");
077 sb.append(overrideFileEntryTypes);
078 sb.append(", status=");
079 sb.append(status);
080 sb.append(", statusByUserId=");
081 sb.append(statusByUserId);
082 sb.append(", statusByUserName=");
083 sb.append(statusByUserName);
084 sb.append(", statusDate=");
085 sb.append(statusDate);
086 sb.append("}");
087
088 return sb.toString();
089 }
090
091 @Override
092 public DLFolder toEntityModel() {
093 DLFolderImpl dlFolderImpl = new DLFolderImpl();
094
095 if (uuid == null) {
096 dlFolderImpl.setUuid(StringPool.BLANK);
097 }
098 else {
099 dlFolderImpl.setUuid(uuid);
100 }
101
102 dlFolderImpl.setFolderId(folderId);
103 dlFolderImpl.setGroupId(groupId);
104 dlFolderImpl.setCompanyId(companyId);
105 dlFolderImpl.setUserId(userId);
106
107 if (userName == null) {
108 dlFolderImpl.setUserName(StringPool.BLANK);
109 }
110 else {
111 dlFolderImpl.setUserName(userName);
112 }
113
114 if (createDate == Long.MIN_VALUE) {
115 dlFolderImpl.setCreateDate(null);
116 }
117 else {
118 dlFolderImpl.setCreateDate(new Date(createDate));
119 }
120
121 if (modifiedDate == Long.MIN_VALUE) {
122 dlFolderImpl.setModifiedDate(null);
123 }
124 else {
125 dlFolderImpl.setModifiedDate(new Date(modifiedDate));
126 }
127
128 dlFolderImpl.setRepositoryId(repositoryId);
129 dlFolderImpl.setMountPoint(mountPoint);
130 dlFolderImpl.setParentFolderId(parentFolderId);
131
132 if (treePath == null) {
133 dlFolderImpl.setTreePath(StringPool.BLANK);
134 }
135 else {
136 dlFolderImpl.setTreePath(treePath);
137 }
138
139 if (name == null) {
140 dlFolderImpl.setName(StringPool.BLANK);
141 }
142 else {
143 dlFolderImpl.setName(name);
144 }
145
146 if (description == null) {
147 dlFolderImpl.setDescription(StringPool.BLANK);
148 }
149 else {
150 dlFolderImpl.setDescription(description);
151 }
152
153 if (lastPostDate == Long.MIN_VALUE) {
154 dlFolderImpl.setLastPostDate(null);
155 }
156 else {
157 dlFolderImpl.setLastPostDate(new Date(lastPostDate));
158 }
159
160 dlFolderImpl.setDefaultFileEntryTypeId(defaultFileEntryTypeId);
161 dlFolderImpl.setHidden(hidden);
162 dlFolderImpl.setOverrideFileEntryTypes(overrideFileEntryTypes);
163 dlFolderImpl.setStatus(status);
164 dlFolderImpl.setStatusByUserId(statusByUserId);
165
166 if (statusByUserName == null) {
167 dlFolderImpl.setStatusByUserName(StringPool.BLANK);
168 }
169 else {
170 dlFolderImpl.setStatusByUserName(statusByUserName);
171 }
172
173 if (statusDate == Long.MIN_VALUE) {
174 dlFolderImpl.setStatusDate(null);
175 }
176 else {
177 dlFolderImpl.setStatusDate(new Date(statusDate));
178 }
179
180 dlFolderImpl.resetOriginalValues();
181
182 return dlFolderImpl;
183 }
184
185 @Override
186 public void readExternal(ObjectInput objectInput) throws IOException {
187 uuid = objectInput.readUTF();
188 folderId = objectInput.readLong();
189 groupId = objectInput.readLong();
190 companyId = objectInput.readLong();
191 userId = objectInput.readLong();
192 userName = objectInput.readUTF();
193 createDate = objectInput.readLong();
194 modifiedDate = objectInput.readLong();
195 repositoryId = objectInput.readLong();
196 mountPoint = objectInput.readBoolean();
197 parentFolderId = objectInput.readLong();
198 treePath = objectInput.readUTF();
199 name = objectInput.readUTF();
200 description = objectInput.readUTF();
201 lastPostDate = objectInput.readLong();
202 defaultFileEntryTypeId = objectInput.readLong();
203 hidden = objectInput.readBoolean();
204 overrideFileEntryTypes = objectInput.readBoolean();
205 status = objectInput.readInt();
206 statusByUserId = objectInput.readLong();
207 statusByUserName = objectInput.readUTF();
208 statusDate = objectInput.readLong();
209 }
210
211 @Override
212 public void writeExternal(ObjectOutput objectOutput)
213 throws IOException {
214 if (uuid == null) {
215 objectOutput.writeUTF(StringPool.BLANK);
216 }
217 else {
218 objectOutput.writeUTF(uuid);
219 }
220
221 objectOutput.writeLong(folderId);
222 objectOutput.writeLong(groupId);
223 objectOutput.writeLong(companyId);
224 objectOutput.writeLong(userId);
225
226 if (userName == null) {
227 objectOutput.writeUTF(StringPool.BLANK);
228 }
229 else {
230 objectOutput.writeUTF(userName);
231 }
232
233 objectOutput.writeLong(createDate);
234 objectOutput.writeLong(modifiedDate);
235 objectOutput.writeLong(repositoryId);
236 objectOutput.writeBoolean(mountPoint);
237 objectOutput.writeLong(parentFolderId);
238
239 if (treePath == null) {
240 objectOutput.writeUTF(StringPool.BLANK);
241 }
242 else {
243 objectOutput.writeUTF(treePath);
244 }
245
246 if (name == null) {
247 objectOutput.writeUTF(StringPool.BLANK);
248 }
249 else {
250 objectOutput.writeUTF(name);
251 }
252
253 if (description == null) {
254 objectOutput.writeUTF(StringPool.BLANK);
255 }
256 else {
257 objectOutput.writeUTF(description);
258 }
259
260 objectOutput.writeLong(lastPostDate);
261 objectOutput.writeLong(defaultFileEntryTypeId);
262 objectOutput.writeBoolean(hidden);
263 objectOutput.writeBoolean(overrideFileEntryTypes);
264 objectOutput.writeInt(status);
265 objectOutput.writeLong(statusByUserId);
266
267 if (statusByUserName == null) {
268 objectOutput.writeUTF(StringPool.BLANK);
269 }
270 else {
271 objectOutput.writeUTF(statusByUserName);
272 }
273
274 objectOutput.writeLong(statusDate);
275 }
276
277 public String uuid;
278 public long folderId;
279 public long groupId;
280 public long companyId;
281 public long userId;
282 public String userName;
283 public long createDate;
284 public long modifiedDate;
285 public long repositoryId;
286 public boolean mountPoint;
287 public long parentFolderId;
288 public String treePath;
289 public String name;
290 public String description;
291 public long lastPostDate;
292 public long defaultFileEntryTypeId;
293 public boolean hidden;
294 public boolean overrideFileEntryTypes;
295 public int status;
296 public long statusByUserId;
297 public String statusByUserName;
298 public long statusDate;
299 }