001    /**
002     * Copyright (c) 2000-present 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.portlet.messageboards.lar;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portlet.exportimport.lar.BaseStagedModelDataHandler;
019    import com.liferay.portlet.exportimport.lar.PortletDataContext;
020    import com.liferay.portlet.messageboards.model.MBThread;
021    import com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil;
022    
023    import java.util.List;
024    
025    /**
026     * @author Daniel Kocsis
027     */
028    public class MBThreadStagedModelDataHandler
029            extends BaseStagedModelDataHandler<MBThread> {
030    
031            public static final String[] CLASS_NAMES = {MBThread.class.getName()};
032    
033            @Override
034            public void deleteStagedModel(MBThread thread) throws PortalException {
035                    MBThreadLocalServiceUtil.deleteThread(thread);
036            }
037    
038            @Override
039            public void deleteStagedModel(
040                            String uuid, long groupId, String className, String extraData)
041                    throws PortalException {
042    
043                    MBThread thread = fetchStagedModelByUuidAndGroupId(uuid, groupId);
044    
045                    if (thread != null) {
046                            deleteStagedModel(thread);
047                    }
048            }
049    
050            @Override
051            public MBThread fetchStagedModelByUuidAndGroupId(
052                    String uuid, long groupId) {
053    
054                    return MBThreadLocalServiceUtil.fetchMBThreadByUuidAndGroupId(
055                            uuid, groupId);
056            }
057    
058            @Override
059            public List<MBThread> fetchStagedModelsByUuidAndCompanyId(
060                    String uuid, long companyId) {
061    
062                    return MBThreadLocalServiceUtil.getMBThreadsByUuidAndCompanyId(
063                            uuid, companyId);
064            }
065    
066            @Override
067            public String[] getClassNames() {
068                    return CLASS_NAMES;
069            }
070    
071            @Override
072            protected void doExportStagedModel(
073                            PortletDataContext portletDataContext, MBThread thread)
074                    throws Exception {
075            }
076    
077            @Override
078            protected void doImportStagedModel(
079                            PortletDataContext portletDataContext, MBThread thread)
080                    throws Exception {
081            }
082    
083    }