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