001
014
015 package com.liferay.portal.velocity;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.model.PortletConstants;
020 import com.liferay.portlet.PortletPreferencesFactoryUtil;
021 import com.liferay.portlet.PortletPreferencesImpl;
022
023 import javax.portlet.ReadOnlyException;
024
025
028 public class VelocityPortletPreferences {
029
030 public VelocityPortletPreferences() {
031 _portletPreferencesImpl = new PortletPreferencesImpl();
032 }
033
034 public void reset() {
035 _portletPreferencesImpl.reset();
036 }
037
038 public void setValue(String key, String value) throws ReadOnlyException {
039 _portletPreferencesImpl.setValue(key, value);
040 }
041
042 public void setValues(String key, String[] values)
043 throws ReadOnlyException {
044
045 _portletPreferencesImpl.setValues(key, values);
046 }
047
048 @Override
049 public String toString() {
050 try {
051 return PortletPreferencesFactoryUtil.toXML(_portletPreferencesImpl);
052 }
053 catch (Exception e) {
054 _log.error(e, e);
055
056 return PortletConstants.DEFAULT_PREFERENCES;
057 }
058 }
059
060 private static Log _log = LogFactoryUtil.getLog(
061 VelocityPortletPreferences.class);
062
063 private PortletPreferencesImpl _portletPreferencesImpl;
064
065 }