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.AssetTagProperty; 021 import com.liferay.portlet.asset.service.base.AssetTagPropertyServiceBaseImpl; 022 import com.liferay.portlet.asset.service.permission.AssetTagPermission; 023 024 import java.util.List; 025 026 /** 027 * Provides the remote service for accessing, adding, deleting, and updating 028 * asset tag properties. Its methods include permission checks. 029 * 030 * @author Brian Wing Shun Chan 031 */ 032 public class AssetTagPropertyServiceImpl 033 extends AssetTagPropertyServiceBaseImpl { 034 035 /** 036 * Adds an asset tag property. 037 * 038 * @param tagId the primary key of the tag 039 * @param key the key to be associated to the value 040 * @param value the value to which the key will refer 041 * @return the created asset tag property 042 * @throws PortalException if the user did not have permission to update the 043 * asset tag, or if the key or value were invalid 044 * @throws SystemException if a system exception occurred 045 */ 046 @Override 047 public AssetTagProperty addTagProperty(long tagId, String key, String value) 048 throws PortalException, SystemException { 049 050 AssetTagPermission.check( 051 getPermissionChecker(), tagId, ActionKeys.UPDATE); 052 053 return assetTagPropertyLocalService.addTagProperty( 054 getUserId(), tagId, key, value); 055 } 056 057 /** 058 * Deletes the asset tag property with the specified ID. 059 * 060 * @param tagPropertyId the primary key of the asset tag property instance 061 * @throws PortalException if an asset tag property with the primary key 062 * could not be found or if the user did not have permission to 063 * update the asset tag property 064 * @throws SystemException if a system exception occurred 065 */ 066 @Override 067 public void deleteTagProperty(long tagPropertyId) 068 throws PortalException, SystemException { 069 070 AssetTagProperty assetTagProperty = 071 assetTagPropertyLocalService.getTagProperty(tagPropertyId); 072 073 AssetTagPermission.check( 074 getPermissionChecker(), assetTagProperty.getTagId(), 075 ActionKeys.UPDATE); 076 077 assetTagPropertyLocalService.deleteTagProperty(tagPropertyId); 078 } 079 080 /** 081 * Returns all the asset tag property instances with the specified tag ID. 082 * 083 * @param tagId the primary key of the tag 084 * @return the matching asset tag properties 085 * @throws SystemException if a system exception occurred 086 */ 087 @Override 088 public List<AssetTagProperty> getTagProperties(long tagId) 089 throws SystemException { 090 091 return assetTagPropertyLocalService.getTagProperties(tagId); 092 } 093 094 /** 095 * Returns asset tag properties with the specified group and key. 096 * 097 * @param companyId the primary key of the company 098 * @param key the key that refers to some value 099 * @return the matching asset tag properties 100 * @throws SystemException if a system exception occurred 101 */ 102 @Override 103 public List<AssetTagProperty> getTagPropertyValues( 104 long companyId, String key) 105 throws SystemException { 106 107 return assetTagPropertyLocalService.getTagPropertyValues( 108 companyId, key); 109 } 110 111 /** 112 * Updates the asset tag property. 113 * 114 * @param tagPropertyId the primary key of the asset tag property 115 * @param key the new key to be associated to the value 116 * @param value the new value to which the key will refer 117 * @return the updated asset tag property 118 * @throws PortalException if an asset tag property with the primary key 119 * could not be found, if the user did not have permission to update 120 * the asset tag, or if the key or value were invalid 121 * @throws SystemException if a system exception occurred 122 */ 123 @Override 124 public AssetTagProperty updateTagProperty( 125 long tagPropertyId, String key, String value) 126 throws PortalException, SystemException { 127 128 AssetTagProperty assetTagProperty = 129 assetTagPropertyLocalService.getTagProperty(tagPropertyId); 130 131 AssetTagPermission.check( 132 getPermissionChecker(), assetTagProperty.getTagId(), 133 ActionKeys.UPDATE); 134 135 return assetTagPropertyLocalService.updateTagProperty( 136 tagPropertyId, key, value); 137 } 138 139 }