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