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.PortletPreferencesImpl;
021 import com.liferay.portlet.PortletPreferencesSerializer;
022
023 import javax.portlet.ReadOnlyException;
024
025
028 public class VelocityPortletPreferences {
029
030 public VelocityPortletPreferences() {
031 _preferencesImpl = new PortletPreferencesImpl();
032 }
033
034 public void reset() {
035 _preferencesImpl.reset();
036 }
037
038 public void setValue(String key, String value) throws ReadOnlyException {
039 _preferencesImpl.setValue(key, value);
040 }
041
042 public void setValues(String key, String[] values)
043 throws ReadOnlyException {
044
045 _preferencesImpl.setValues(key, values);
046 }
047
048 public String toString() {
049 try {
050 return PortletPreferencesSerializer.toXML(_preferencesImpl);
051 }
052 catch (Exception e) {
053 _log.error(e, e);
054
055 return PortletConstants.DEFAULT_PREFERENCES;
056 }
057 }
058
059 private static Log _log = LogFactoryUtil.getLog(
060 VelocityPortletPreferences.class);
061
062 private PortletPreferencesImpl _preferencesImpl;
063
064 }