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
43 public class PortletPreferencesWrapper
44 implements PortletPreferences, Serializable {
45
46 public PortletPreferencesWrapper(
47 PortletPreferences prefs, String lifecycle) {
48
49 _prefs = prefs;
50 _lifecycle = lifecycle;
51 }
52
53 public Map<String, String[]> getMap() {
54 return _prefs.getMap();
55 }
56
57 public Enumeration<String> getNames() {
58 return _prefs.getNames();
59 }
60
61 public String getValue(String key, String def) {
62 return _prefs.getValue(key, def);
63 }
64
65 public void setValue(String key, String value) throws ReadOnlyException {
66 _prefs.setValue(key, value);
67 }
68
69 public String[] getValues(String key, String[] def) {
70 return _prefs.getValues(key, def);
71 }
72
73 public void setValues(String key, String[] values)
74 throws ReadOnlyException {
75
76 _prefs.setValues(key, values);
77 }
78
79 public boolean isReadOnly(String key) {
80 return _prefs.isReadOnly(key);
81 }
82
83 public void reset(String key) throws ReadOnlyException {
84 _prefs.reset(key);
85 }
86
87 public void store() throws IOException, ValidatorException {
88 if (PropsValues.TCK_URL) {
89
90
92 if (_lifecycle.equals(PortletRequest.ACTION_PHASE)) {
93 _prefs.store();
94 }
95 else {
96 throw new IllegalStateException(
97 "Preferences cannot be stored inside a render call");
98 }
99 }
100 else {
101
102
104 _prefs.store();
105 }
106 }
107
108 public PortletPreferencesImpl getPreferencesImpl() {
109 return (PortletPreferencesImpl)_prefs;
110 }
111
112 public boolean equals(Object obj) {
113 PortletPreferencesWrapper portletPreferences =
114 (PortletPreferencesWrapper)obj;
115
116 if (this == portletPreferences) {
117 return true;
118 }
119
120 if (getPreferencesImpl().equals(
121 portletPreferences.getPreferencesImpl())) {
122
123 return true;
124 }
125 else {
126 return false;
127 }
128 }
129
130 private PortletPreferences _prefs;
131 private String _lifecycle;
132
133 }