001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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 isAlwaysStaged() {
065                    return _ALWAYS_STAGED;
066            }
067    
068            public boolean isPublishToLiveByDefault() {
069                    return _PUBLISH_TO_LIVE_BY_DEFAULT;
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            protected PortletPreferences doDeleteData(
087                            PortletDataContext portletDataContext, String portletId,
088                            PortletPreferences portletPreferences)
089                    throws Exception {
090    
091                    return null;
092            }
093    
094            protected String doExportData(
095                            PortletDataContext portletDataContext, String portletId,
096                            PortletPreferences portletPreferences)
097                    throws Exception {
098    
099                    return null;
100            }
101    
102            protected PortletPreferences doImportData(
103                            PortletDataContext portletDataContext, String portletId,
104                            PortletPreferences portletPreferences, String data)
105                    throws Exception {
106    
107                    return null;
108            }
109    
110            private static final boolean _ALWAYS_EXPORTABLE = false;
111    
112            private static final boolean _ALWAYS_STAGED = false;
113    
114            private static final boolean _PUBLISH_TO_LIVE_BY_DEFAULT = false;
115    
116    }