001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.lar;
016    
017    import javax.portlet.PortletPreferences;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     */
022    public abstract class BasePortletDataHandler implements PortletDataHandler {
023    
024            public PortletPreferences deleteData(
025                            PortletDataContext context, String portletId,
026                            PortletPreferences preferences)
027                    throws PortletDataException {
028    
029                    try {
030                            return doDeleteData(context, portletId, preferences);
031                    }
032                    catch (Exception e) {
033                            throw new PortletDataException(e);
034                    }
035            }
036    
037            public String exportData(
038                            PortletDataContext context, String portletId,
039                            PortletPreferences preferences)
040                    throws PortletDataException {
041    
042                    try {
043                            return doExportData(context, portletId, preferences);
044                    }
045                    catch (Exception e) {
046                            throw new PortletDataException(e);
047                    }
048            }
049    
050            public boolean isAlwaysExportable() {
051                    return _ALWAYS_EXPORTABLE;
052            }
053    
054            public boolean isPublishToLiveByDefault() {
055                    return _PUBLISH_TO_LIVE_BY_DEFAULT;
056            }
057    
058            public PortletPreferences importData(
059                            PortletDataContext context, String portletId,
060                            PortletPreferences preferences, String data)
061                    throws PortletDataException {
062    
063                    try {
064                            return doImportData(context, portletId, preferences, data);
065                    }
066                    catch (Exception e) {
067                            throw new PortletDataException(e);
068                    }
069            }
070    
071            protected PortletPreferences doDeleteData(
072                            PortletDataContext context, String portletId,
073                            PortletPreferences preferences)
074                    throws Exception {
075    
076                    return null;
077            }
078    
079            protected String doExportData(
080                            PortletDataContext context, String portletId,
081                            PortletPreferences preferences)
082                    throws Exception {
083    
084                    return null;
085            }
086    
087            protected PortletPreferences doImportData(
088                            PortletDataContext context, String portletId,
089                            PortletPreferences preferences, String data)
090                    throws Exception {
091    
092                    return null;
093            }
094    
095            private static final boolean _ALWAYS_EXPORTABLE = false;
096    
097            private static final boolean _PUBLISH_TO_LIVE_BY_DEFAULT = false;
098    
099    }