1
22
23 package com.liferay.portlet;
24
25 import com.liferay.portal.util.PropsValues;
26
27 import java.io.IOException;
28 import java.io.Serializable;
29
30 import java.util.Enumeration;
31 import java.util.Map;
32
33 import javax.portlet.PortletPreferences;
34 import javax.portlet.PortletRequest;
35 import javax.portlet.ReadOnlyException;
36 import javax.portlet.ValidatorException;
37
38
44 public class PortletPreferencesWrapper
45 implements PortletPreferences, Serializable {
46
47 public PortletPreferencesWrapper(
48 PortletPreferences preferences, String lifecycle) {
49
50 _preferences = preferences;
51 _lifecycle = lifecycle;
52 }
53
54 public Map<String, String[]> getMap() {
55 return _preferences.getMap();
56 }
57
58 public Enumeration<String> getNames() {
59 return _preferences.getNames();
60 }
61
62 public String getValue(String key, String def) {
63 return _preferences.getValue(key, def);
64 }
65
66 public void setValue(String key, String value) throws ReadOnlyException {
67 _preferences.setValue(key, value);
68 }
69
70 public String[] getValues(String key, String[] def) {
71 return _preferences.getValues(key, def);
72 }
73
74 public void setValues(String key, String[] values)
75 throws ReadOnlyException {
76
77 _preferences.setValues(key, values);
78 }
79
80 public boolean isReadOnly(String key) {
81 return _preferences.isReadOnly(key);
82 }
83
84 public void reset(String key) throws ReadOnlyException {
85 _preferences.reset(key);
86 }
87
88 public void store() throws IOException, ValidatorException {
89 if (PropsValues.TCK_URL) {
90
91
93 if (_lifecycle.equals(PortletRequest.ACTION_PHASE)) {
94 _preferences.store();
95 }
96 else {
97 throw new IllegalStateException(
98 "Preferences cannot be stored inside a render call");
99 }
100 }
101 else {
102
103
105 _preferences.store();
106 }
107 }
108
109 public PortletPreferencesImpl getPreferencesImpl() {
110 return (PortletPreferencesImpl)_preferences;
111 }
112
113 public boolean equals(Object obj) {
114 PortletPreferencesWrapper portletPreferences =
115 (PortletPreferencesWrapper)obj;
116
117 if (this == portletPreferences) {
118 return true;
119 }
120
121 if (getPreferencesImpl().equals(
122 portletPreferences.getPreferencesImpl())) {
123
124 return true;
125 }
126 else {
127 return false;
128 }
129 }
130
131 private PortletPreferences _preferences;
132 private String _lifecycle;
133
134 }