001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }