001    /**
002     * Copyright (c) 2000-2013 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.asset.lar;
016    
017    import com.liferay.portal.kernel.lar.BaseStagedModelDataHandler;
018    import com.liferay.portal.kernel.lar.PortletDataContext;
019    import com.liferay.portlet.asset.model.AssetCategory;
020    import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
021    
022    /**
023     * @author Zsolt Berentey
024     */
025    public class AssetCategoryStagedModelDataHandler
026            extends BaseStagedModelDataHandler<AssetCategory> {
027    
028            public static final String[] CLASS_NAMES = {AssetCategory.class.getName()};
029    
030            @Override
031            public void deleteStagedModel(
032                    String uuid, long groupId, String className, String extraData) {
033            }
034    
035            @Override
036            public String[] getClassNames() {
037                    return CLASS_NAMES;
038            }
039    
040            @Override
041            public String getDisplayName(AssetCategory category) {
042                    return category.getTitleCurrentValue();
043            }
044    
045            @Override
046            protected void doExportStagedModel(
047                            PortletDataContext portletDataContext, AssetCategory category)
048                    throws Exception {
049            }
050    
051            @Override
052            protected void doImportStagedModel(
053                            PortletDataContext portletDataContext, AssetCategory category)
054                    throws Exception {
055            }
056    
057            @Override
058            protected boolean validateMissingReference(
059                            String uuid, long companyId, long groupId)
060                    throws Exception {
061    
062                    AssetCategory category =
063                            AssetCategoryLocalServiceUtil.fetchAssetCategoryByUuidAndGroupId(
064                                    uuid, groupId);
065    
066                    if (category == null) {
067                            return false;
068                    }
069    
070                    return true;
071            }
072    
073    }