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[] getExportMetadataControls() {
057                    return new PortletDataHandlerControl[0];
058            }
059    
060            public PortletDataHandlerControl[] getImportControls() {
061                    return new PortletDataHandlerControl[0];
062            }
063    
064            public PortletDataHandlerControl[] getImportMetadataControls() {
065                    return new PortletDataHandlerControl[0];
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            public boolean isAlwaysExportable() {
083                    return _ALWAYS_EXPORTABLE;
084            }
085    
086            public boolean isAlwaysStaged() {
087                    return _ALWAYS_STAGED;
088            }
089    
090            public boolean isPublishToLiveByDefault() {
091                    return _PUBLISH_TO_LIVE_BY_DEFAULT;
092            }
093    
094            protected PortletPreferences doDeleteData(
095                            PortletDataContext portletDataContext, String portletId,
096                            PortletPreferences portletPreferences)
097                    throws Exception {
098    
099                    return null;
100            }
101    
102            protected String doExportData(
103                            PortletDataContext portletDataContext, String portletId,
104                            PortletPreferences portletPreferences)
105                    throws Exception {
106    
107                    return null;
108            }
109    
110            protected PortletPreferences doImportData(
111                            PortletDataContext portletDataContext, String portletId,
112                            PortletPreferences portletPreferences, String data)
113                    throws Exception {
114    
115                    return null;
116            }
117    
118            private static final boolean _ALWAYS_EXPORTABLE = false;
119    
120            private static final boolean _ALWAYS_STAGED = false;
121    
122            private static final boolean _PUBLISH_TO_LIVE_BY_DEFAULT = false;
123    
124    }