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.PortalPreferences;
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 PortalPreferencesCacheModel implements CacheModel<PortalPreferences>,
035 Externalizable {
036 @Override
037 public String toString() {
038 StringBundler sb = new StringBundler(9);
039
040 sb.append("{portalPreferencesId=");
041 sb.append(portalPreferencesId);
042 sb.append(", ownerId=");
043 sb.append(ownerId);
044 sb.append(", ownerType=");
045 sb.append(ownerType);
046 sb.append(", preferences=");
047 sb.append(preferences);
048 sb.append("}");
049
050 return sb.toString();
051 }
052
053 public PortalPreferences toEntityModel() {
054 PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl();
055
056 portalPreferencesImpl.setPortalPreferencesId(portalPreferencesId);
057 portalPreferencesImpl.setOwnerId(ownerId);
058 portalPreferencesImpl.setOwnerType(ownerType);
059
060 if (preferences == null) {
061 portalPreferencesImpl.setPreferences(StringPool.BLANK);
062 }
063 else {
064 portalPreferencesImpl.setPreferences(preferences);
065 }
066
067 portalPreferencesImpl.resetOriginalValues();
068
069 return portalPreferencesImpl;
070 }
071
072 public void readExternal(ObjectInput objectInput) throws IOException {
073 portalPreferencesId = objectInput.readLong();
074 ownerId = objectInput.readLong();
075 ownerType = objectInput.readInt();
076 preferences = objectInput.readUTF();
077 }
078
079 public void writeExternal(ObjectOutput objectOutput)
080 throws IOException {
081 objectOutput.writeLong(portalPreferencesId);
082 objectOutput.writeLong(ownerId);
083 objectOutput.writeInt(ownerType);
084
085 if (preferences == null) {
086 objectOutput.writeUTF(StringPool.BLANK);
087 }
088 else {
089 objectOutput.writeUTF(preferences);
090 }
091 }
092
093 public long portalPreferencesId;
094 public long ownerId;
095 public int ownerType;
096 public String preferences;
097 }