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.PortletPreferences;
021
022 import java.io.Externalizable;
023 import java.io.IOException;
024 import java.io.ObjectInput;
025 import java.io.ObjectOutput;
026
027
034 public class PortletPreferencesCacheModel implements CacheModel<PortletPreferences>,
035 Externalizable {
036 @Override
037 public String toString() {
038 StringBundler sb = new StringBundler(13);
039
040 sb.append("{portletPreferencesId=");
041 sb.append(portletPreferencesId);
042 sb.append(", ownerId=");
043 sb.append(ownerId);
044 sb.append(", ownerType=");
045 sb.append(ownerType);
046 sb.append(", plid=");
047 sb.append(plid);
048 sb.append(", portletId=");
049 sb.append(portletId);
050 sb.append(", preferences=");
051 sb.append(preferences);
052 sb.append("}");
053
054 return sb.toString();
055 }
056
057 public PortletPreferences toEntityModel() {
058 PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
059
060 portletPreferencesImpl.setPortletPreferencesId(portletPreferencesId);
061 portletPreferencesImpl.setOwnerId(ownerId);
062 portletPreferencesImpl.setOwnerType(ownerType);
063 portletPreferencesImpl.setPlid(plid);
064
065 if (portletId == null) {
066 portletPreferencesImpl.setPortletId(StringPool.BLANK);
067 }
068 else {
069 portletPreferencesImpl.setPortletId(portletId);
070 }
071
072 if (preferences == null) {
073 portletPreferencesImpl.setPreferences(StringPool.BLANK);
074 }
075 else {
076 portletPreferencesImpl.setPreferences(preferences);
077 }
078
079 portletPreferencesImpl.resetOriginalValues();
080
081 return portletPreferencesImpl;
082 }
083
084 public void readExternal(ObjectInput objectInput) throws IOException {
085 portletPreferencesId = objectInput.readLong();
086 ownerId = objectInput.readLong();
087 ownerType = objectInput.readInt();
088 plid = objectInput.readLong();
089 portletId = objectInput.readUTF();
090 preferences = objectInput.readUTF();
091 }
092
093 public void writeExternal(ObjectOutput objectOutput)
094 throws IOException {
095 objectOutput.writeLong(portletPreferencesId);
096 objectOutput.writeLong(ownerId);
097 objectOutput.writeInt(ownerType);
098 objectOutput.writeLong(plid);
099
100 if (portletId == null) {
101 objectOutput.writeUTF(StringPool.BLANK);
102 }
103 else {
104 objectOutput.writeUTF(portletId);
105 }
106
107 if (preferences == null) {
108 objectOutput.writeUTF(StringPool.BLANK);
109 }
110 else {
111 objectOutput.writeUTF(preferences);
112 }
113 }
114
115 public long portletPreferencesId;
116 public long ownerId;
117 public int ownerType;
118 public long plid;
119 public String portletId;
120 public String preferences;
121 }