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.DLContent;
022
023 import java.io.Externalizable;
024 import java.io.IOException;
025 import java.io.ObjectInput;
026 import java.io.ObjectOutput;
027
028
035 public class DLContentCacheModel implements CacheModel<DLContent>,
036 Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(15);
040
041 sb.append("{contentId=");
042 sb.append(contentId);
043 sb.append(", groupId=");
044 sb.append(groupId);
045 sb.append(", companyId=");
046 sb.append(companyId);
047 sb.append(", repositoryId=");
048 sb.append(repositoryId);
049 sb.append(", path=");
050 sb.append(path);
051 sb.append(", version=");
052 sb.append(version);
053 sb.append(", size=");
054 sb.append(size);
055 sb.append("}");
056
057 return sb.toString();
058 }
059
060 public DLContent toEntityModel() {
061 DLContentImpl dlContentImpl = new DLContentImpl();
062
063 dlContentImpl.setContentId(contentId);
064 dlContentImpl.setGroupId(groupId);
065 dlContentImpl.setCompanyId(companyId);
066 dlContentImpl.setRepositoryId(repositoryId);
067
068 if (path == null) {
069 dlContentImpl.setPath(StringPool.BLANK);
070 }
071 else {
072 dlContentImpl.setPath(path);
073 }
074
075 if (version == null) {
076 dlContentImpl.setVersion(StringPool.BLANK);
077 }
078 else {
079 dlContentImpl.setVersion(version);
080 }
081
082 dlContentImpl.setSize(size);
083
084 dlContentImpl.resetOriginalValues();
085
086 return dlContentImpl;
087 }
088
089 public void readExternal(ObjectInput objectInput) throws IOException {
090 contentId = objectInput.readLong();
091 groupId = objectInput.readLong();
092 companyId = objectInput.readLong();
093 repositoryId = objectInput.readLong();
094 path = objectInput.readUTF();
095 version = objectInput.readUTF();
096 size = objectInput.readLong();
097 }
098
099 public void writeExternal(ObjectOutput objectOutput)
100 throws IOException {
101 objectOutput.writeLong(contentId);
102 objectOutput.writeLong(groupId);
103 objectOutput.writeLong(companyId);
104 objectOutput.writeLong(repositoryId);
105
106 if (path == null) {
107 objectOutput.writeUTF(StringPool.BLANK);
108 }
109 else {
110 objectOutput.writeUTF(path);
111 }
112
113 if (version == null) {
114 objectOutput.writeUTF(StringPool.BLANK);
115 }
116 else {
117 objectOutput.writeUTF(version);
118 }
119
120 objectOutput.writeLong(size);
121 }
122
123 public long contentId;
124 public long groupId;
125 public long companyId;
126 public long repositoryId;
127 public String path;
128 public String version;
129 public long size;
130 }