001    /**
002     * Copyright (c) 2000-2012 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            public AssetCategoryProperty addCategoryProperty(
034                            long entryId, String key, String value)
035                    throws PortalException, SystemException {
036    
037                    AssetCategoryPermission.check(
038                            getPermissionChecker(), entryId, ActionKeys.UPDATE);
039    
040                    return assetCategoryPropertyLocalService.addCategoryProperty(
041                            getUserId(), entryId, key, value);
042            }
043    
044            public void deleteCategoryProperty(long categoryPropertyId)
045                    throws PortalException, SystemException {
046    
047                    AssetCategoryProperty assetCategoryProperty =
048                            assetCategoryPropertyLocalService.getAssetCategoryProperty(
049                                    categoryPropertyId);
050    
051                    AssetCategoryPermission.check(
052                            getPermissionChecker(), assetCategoryProperty.getCategoryId(),
053                            ActionKeys.UPDATE);
054    
055                    assetCategoryPropertyLocalService.deleteCategoryProperty(
056                            categoryPropertyId);
057            }
058    
059            public List<AssetCategoryProperty> getCategoryProperties(long entryId)
060                    throws SystemException {
061    
062                    return assetCategoryPropertyLocalService.getCategoryProperties(entryId);
063            }
064    
065            public List<AssetCategoryProperty> getCategoryPropertyValues(
066                            long companyId, String key)
067                    throws SystemException {
068    
069                    return assetCategoryPropertyLocalService.getCategoryPropertyValues(
070                            companyId, key);
071            }
072    
073            public AssetCategoryProperty updateCategoryProperty(
074                            long categoryPropertyId, String key, String value)
075                    throws PortalException, SystemException {
076    
077                    AssetCategoryProperty assetCategoryProperty =
078                            assetCategoryPropertyLocalService.getAssetCategoryProperty(
079                                    categoryPropertyId);
080    
081                    AssetCategoryPermission.check(
082                            getPermissionChecker(), assetCategoryProperty.getCategoryId(),
083                            ActionKeys.UPDATE);
084    
085                    return assetCategoryPropertyLocalService.updateCategoryProperty(
086                            categoryPropertyId, key, value);
087            }
088    
089    }