001
014
015 package com.liferay.portal.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 import com.liferay.portal.model.Lock;
021
022 import java.io.Externalizable;
023 import java.io.IOException;
024 import java.io.ObjectInput;
025 import java.io.ObjectOutput;
026
027 import java.util.Date;
028
029
036 public class LockCacheModel implements CacheModel<Lock>, Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(23);
040
041 sb.append("{uuid=");
042 sb.append(uuid);
043 sb.append(", lockId=");
044 sb.append(lockId);
045 sb.append(", companyId=");
046 sb.append(companyId);
047 sb.append(", userId=");
048 sb.append(userId);
049 sb.append(", userName=");
050 sb.append(userName);
051 sb.append(", createDate=");
052 sb.append(createDate);
053 sb.append(", className=");
054 sb.append(className);
055 sb.append(", key=");
056 sb.append(key);
057 sb.append(", owner=");
058 sb.append(owner);
059 sb.append(", inheritable=");
060 sb.append(inheritable);
061 sb.append(", expirationDate=");
062 sb.append(expirationDate);
063 sb.append("}");
064
065 return sb.toString();
066 }
067
068 @Override
069 public Lock toEntityModel() {
070 LockImpl lockImpl = new LockImpl();
071
072 if (uuid == null) {
073 lockImpl.setUuid(StringPool.BLANK);
074 }
075 else {
076 lockImpl.setUuid(uuid);
077 }
078
079 lockImpl.setLockId(lockId);
080 lockImpl.setCompanyId(companyId);
081 lockImpl.setUserId(userId);
082
083 if (userName == null) {
084 lockImpl.setUserName(StringPool.BLANK);
085 }
086 else {
087 lockImpl.setUserName(userName);
088 }
089
090 if (createDate == Long.MIN_VALUE) {
091 lockImpl.setCreateDate(null);
092 }
093 else {
094 lockImpl.setCreateDate(new Date(createDate));
095 }
096
097 if (className == null) {
098 lockImpl.setClassName(StringPool.BLANK);
099 }
100 else {
101 lockImpl.setClassName(className);
102 }
103
104 if (key == null) {
105 lockImpl.setKey(StringPool.BLANK);
106 }
107 else {
108 lockImpl.setKey(key);
109 }
110
111 if (owner == null) {
112 lockImpl.setOwner(StringPool.BLANK);
113 }
114 else {
115 lockImpl.setOwner(owner);
116 }
117
118 lockImpl.setInheritable(inheritable);
119
120 if (expirationDate == Long.MIN_VALUE) {
121 lockImpl.setExpirationDate(null);
122 }
123 else {
124 lockImpl.setExpirationDate(new Date(expirationDate));
125 }
126
127 lockImpl.resetOriginalValues();
128
129 return lockImpl;
130 }
131
132 @Override
133 public void readExternal(ObjectInput objectInput) throws IOException {
134 uuid = objectInput.readUTF();
135 lockId = objectInput.readLong();
136 companyId = objectInput.readLong();
137 userId = objectInput.readLong();
138 userName = objectInput.readUTF();
139 createDate = objectInput.readLong();
140 className = objectInput.readUTF();
141 key = objectInput.readUTF();
142 owner = objectInput.readUTF();
143 inheritable = objectInput.readBoolean();
144 expirationDate = objectInput.readLong();
145 }
146
147 @Override
148 public void writeExternal(ObjectOutput objectOutput)
149 throws IOException {
150 if (uuid == null) {
151 objectOutput.writeUTF(StringPool.BLANK);
152 }
153 else {
154 objectOutput.writeUTF(uuid);
155 }
156
157 objectOutput.writeLong(lockId);
158 objectOutput.writeLong(companyId);
159 objectOutput.writeLong(userId);
160
161 if (userName == null) {
162 objectOutput.writeUTF(StringPool.BLANK);
163 }
164 else {
165 objectOutput.writeUTF(userName);
166 }
167
168 objectOutput.writeLong(createDate);
169
170 if (className == null) {
171 objectOutput.writeUTF(StringPool.BLANK);
172 }
173 else {
174 objectOutput.writeUTF(className);
175 }
176
177 if (key == null) {
178 objectOutput.writeUTF(StringPool.BLANK);
179 }
180 else {
181 objectOutput.writeUTF(key);
182 }
183
184 if (owner == null) {
185 objectOutput.writeUTF(StringPool.BLANK);
186 }
187 else {
188 objectOutput.writeUTF(owner);
189 }
190
191 objectOutput.writeBoolean(inheritable);
192 objectOutput.writeLong(expirationDate);
193 }
194
195 public String uuid;
196 public long lockId;
197 public long companyId;
198 public long userId;
199 public String userName;
200 public long createDate;
201 public String className;
202 public String key;
203 public String owner;
204 public boolean inheritable;
205 public long expirationDate;
206 }