001    /**
002     * Copyright (c) 2000-2010 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 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    }