001    /**
002     * Copyright (c) 2000-2011 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 portletDataContext, String portletId,
026                            PortletPreferences portletPreferences)
027                    throws PortletDataException {
028    
029                    try {
030                            return doDeleteData(
031                                    portletDataContext, portletId, portletPreferences);
032                    }
033                    catch (Exception e) {
034                            throw new PortletDataException(e);
035                    }
036            }
037    
038            public String exportData(
039                            PortletDataContext portletDataContext, String portletId,
040                            PortletPreferences portletPreferences)
041                    throws PortletDataException {
042    
043                    try {
044                            return doExportData(
045                                    portletDataContext, portletId, portletPreferences);
046                    }
047                    catch (Exception e) {
048                            throw new PortletDataException(e);
049                    }
050            }
051    
052            public PortletDataHandlerControl[] getExportControls() {
053                    return new PortletDataHandlerControl[0];
054            }
055    
056            public PortletDataHandlerControl[] getImportControls() {
057                    return new PortletDataHandlerControl[0];
058            }
059    
060            public boolean isAlwaysExportable() {
061                    return _ALWAYS_EXPORTABLE;
062            }
063    
064            public boolean isPublishToLiveByDefault() {
065                    return _PUBLISH_TO_LIVE_BY_DEFAULT;
066            }
067    
068            public PortletPreferences importData(
069                            PortletDataContext portletDataContext, String portletId,
070                            PortletPreferences portletPreferences, String data)
071                    throws PortletDataException {
072    
073                    try {
074                            return doImportData(
075                                    portletDataContext, portletId, portletPreferences, data);
076                    }
077                    catch (Exception e) {
078                            throw new PortletDataException(e);
079                    }
080            }
081    
082            protected PortletPreferences doDeleteData(
083                            PortletDataContext portletDataContext, String portletId,
084                            PortletPreferences portletPreferences)
085                    throws Exception {
086    
087                    return null;
088            }
089    
090            protected String doExportData(
091                            PortletDataContext portletDataContext, String portletId,
092                            PortletPreferences portletPreferences)
093                    throws Exception {
094    
095                    return null;
096            }
097    
098            protected PortletPreferences doImportData(
099                            PortletDataContext portletDataContext, String portletId,
100                            PortletPreferences portletPreferences, String data)
101                    throws Exception {
102    
103                    return null;
104            }
105    
106            private static final boolean _ALWAYS_EXPORTABLE = false;
107    
108            private static final boolean _PUBLISH_TO_LIVE_BY_DEFAULT = false;
109    
110    }