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