@Override public void doInTransactionWithoutResult(TransactionStatus status) { for (String key : tags.keySet()) { for (String resourceId : resourceIds) { if (!resourceType.resourceTagsSupport()) { throw new InvalidParameterValueException("The resource type " + resourceType + " doesn't support resource tags"); } long id = getResourceId(resourceId, resourceType); String resourceUuid = getUuid(resourceId, resourceType); Pair<Long, Long> accountDomainPair = getAccountDomain(id, resourceType); Long domainId = accountDomainPair.second(); Long accountId = accountDomainPair.first(); checkResourceAccessible(accountId, domainId, "Account '" + caller + "' doesn't have permissions to create tags" + " for resource '" + id + "(" + key + ")'."); String value = tags.get(key); if (value == null || value.isEmpty()) { throw new InvalidParameterValueException("Value for the key " + key + " is either null or empty"); } ResourceTagVO resourceTag = new ResourceTagVO(key, value, accountDomainPair.first(), accountDomainPair.second(), id, resourceType, customer, resourceUuid); resourceTag = _resourceTagDao.persist(resourceTag); resourceTags.add(resourceTag); } } } });