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