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.asset.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.security.permission.ActionKeys;
019    import com.liferay.portlet.asset.model.AssetCategoryProperty;
020    import com.liferay.portlet.asset.service.base.AssetCategoryPropertyServiceBaseImpl;
021    import com.liferay.portlet.asset.service.permission.AssetCategoryPermission;
022    
023    import java.util.List;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @author Jorge Ferrer
028     */
029    public class AssetCategoryPropertyServiceImpl
030            extends AssetCategoryPropertyServiceBaseImpl {
031    
032            @Override
033            public AssetCategoryProperty addCategoryProperty(
034                            long entryId, String key, String value)
035                    throws PortalException {
036    
037                    AssetCategoryPermission.check(
038                            getPermissionChecker(), entryId, ActionKeys.UPDATE);
039    
040                    return assetCategoryPropertyLocalService.addCategoryProperty(
041                            getUserId(), entryId, key, value);
042            }
043    
044            @Override
045            public void deleteCategoryProperty(long categoryPropertyId)
046                    throws PortalException {
047    
048                    AssetCategoryProperty assetCategoryProperty =
049                            assetCategoryPropertyLocalService.getAssetCategoryProperty(
050                                    categoryPropertyId);
051    
052                    AssetCategoryPermission.check(
053                            getPermissionChecker(), assetCategoryProperty.getCategoryId(),
054                            ActionKeys.UPDATE);
055    
056                    assetCategoryPropertyLocalService.deleteCategoryProperty(
057                            categoryPropertyId);
058            }
059    
060            @Override
061            public List<AssetCategoryProperty> getCategoryProperties(long entryId) {
062                    return assetCategoryPropertyLocalService.getCategoryProperties(entryId);
063            }
064    
065            @Override
066            public List<AssetCategoryProperty> getCategoryPropertyValues(
067                    long companyId, String key) {
068    
069                    return assetCategoryPropertyLocalService.getCategoryPropertyValues(
070                            companyId, key);
071            }
072    
073            @Override
074            public AssetCategoryProperty updateCategoryProperty(
075                            long userId, long categoryPropertyId, String key, String value)
076                    throws PortalException {
077    
078                    AssetCategoryProperty assetCategoryProperty =
079                            assetCategoryPropertyLocalService.getAssetCategoryProperty(
080                                    categoryPropertyId);
081    
082                    AssetCategoryPermission.check(
083                            getPermissionChecker(), assetCategoryProperty.getCategoryId(),
084                            ActionKeys.UPDATE);
085    
086                    return assetCategoryPropertyLocalService.updateCategoryProperty(
087                            userId, categoryPropertyId, key, value);
088            }
089    
090            @Override
091            public AssetCategoryProperty updateCategoryProperty(
092                            long categoryPropertyId, String key, String value)
093                    throws PortalException {
094    
095                    return updateCategoryProperty(0, categoryPropertyId, key, value);
096            }
097    
098    }