001    /**
002     * Copyright (c) 2000-2012 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 String[] getDataPortletPreferences() {
053                    return new String[0];
054            }
055    
056            public PortletDataHandlerControl[] getExportControls() {
057                    return new PortletDataHandlerControl[0];
058            }
059    
060            public PortletDataHandlerControl[] getExportMetadataControls() {
061                    return new PortletDataHandlerControl[0];
062            }
063    
064            public PortletDataHandlerControl[] getImportControls() {
065                    return new PortletDataHandlerControl[0];
066            }
067    
068            public PortletDataHandlerControl[] getImportMetadataControls() {
069                    return new PortletDataHandlerControl[0];
070            }
071    
072            public PortletPreferences importData(
073                            PortletDataContext portletDataContext, String portletId,
074                            PortletPreferences portletPreferences, String data)
075                    throws PortletDataException {
076    
077                    try {
078                            return doImportData(
079                                    portletDataContext, portletId, portletPreferences, data);
080                    }
081                    catch (Exception e) {
082                            throw new PortletDataException(e);
083                    }
084            }
085    
086            public boolean isAlwaysExportable() {
087                    return _ALWAYS_EXPORTABLE;
088            }
089    
090            public boolean isAlwaysStaged() {
091                    return _ALWAYS_STAGED;
092            }
093    
094            public boolean isDataLocalized() {
095                    return _DATA_LOCALIZED;
096            }
097    
098            public boolean isPublishToLiveByDefault() {
099                    return _PUBLISH_TO_LIVE_BY_DEFAULT;
100            }
101    
102            protected PortletPreferences doDeleteData(
103                            PortletDataContext portletDataContext, String portletId,
104                            PortletPreferences portletPreferences)
105                    throws Exception {
106    
107                    return null;
108            }
109    
110            protected String doExportData(
111                            PortletDataContext portletDataContext, String portletId,
112                            PortletPreferences portletPreferences)
113                    throws Exception {
114    
115                    return null;
116            }
117    
118            protected PortletPreferences doImportData(
119                            PortletDataContext portletDataContext, String portletId,
120                            PortletPreferences portletPreferences, String data)
121                    throws Exception {
122    
123                    return null;
124            }
125    
126            private static final boolean _ALWAYS_EXPORTABLE = false;
127    
128            private static final boolean _ALWAYS_STAGED = false;
129    
130            private static final boolean _DATA_LOCALIZED = false;
131    
132            private static final boolean _PUBLISH_TO_LIVE_BY_DEFAULT = false;
133    
134    }