test_class.declarator: s_logger = LoggerFactory.getLogger(ResourceLimitManagerImplTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger s_logger = LoggerFactory.getLogger(ResourceLimitManagerImplTest.class);
test_class.type: Logger
test_class.var_name: s_logger
test_class.declarator: _resourceLimitService = new MockResourceLimitManagerImpl()
test_class.original_string: MockResourceLimitManagerImpl _resourceLimitService = new MockResourceLimitManagerImpl();
test_class.type: MockResourceLimitManagerImpl
test_class.var_name: _resourceLimitService
test_class.file: cosmic-core/server/src/test/java/com/cloud/resourcelimit/ResourceLimitManagerImplTest.java
test_class.identifier: ResourceLimitManagerImplTest
test_class.superclass: extends TestCase
test_case.body: @Test
      public void testInjected() throws Exception {
          s_logger.info("Starting test for Resource Limit manager");
          updateResourceCount();
          updateResourceLimit();
          //listResourceLimits();
          s_logger.info("Resource Limit Manager: TEST PASSED");
      }
test_case.class_method_signature: ResourceLimitManagerImplTest.testInjected()
test_case.full_signature: @Test public void testInjected()
test_case.identifier: testInjected
test_case.invocations: info updateResourceCount updateResourceLimit info
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInjected()
focal_class.declarator: s_logger = LoggerFactory.getLogger(ResourceLimitManagerImpl.class)
focal_class.modifier: public static final
focal_class.original_string: public static final Logger s_logger = LoggerFactory.getLogger(ResourceLimitManagerImpl.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: _snapshotDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected SnapshotDao _snapshotDao;
focal_class.type: SnapshotDao
focal_class.var_name: _snapshotDao
focal_class.declarator: _vmTemplateDao
focal_class.modifier: @Inject
      protected
focal_class.original_string: @Inject
      protected VMTemplateDao _vmTemplateDao;
focal_class.type: VMTemplateDao
focal_class.var_name: _vmTemplateDao
focal_class.declarator: templateSizeSearch
focal_class.modifier: protected
focal_class.original_string: protected GenericSearchBuilder<TemplateDataStoreVO, SumCount> templateSizeSearch;
focal_class.type: GenericSearchBuilder<TemplateDataStoreVO, SumCount>
focal_class.var_name: templateSizeSearch
focal_class.declarator: snapshotSizeSearch
focal_class.modifier: protected
focal_class.original_string: protected GenericSearchBuilder<SnapshotDataStoreVO, SumCount> snapshotSizeSearch;
focal_class.type: GenericSearchBuilder<SnapshotDataStoreVO, SumCount>
focal_class.var_name: snapshotSizeSearch
focal_class.declarator: ResourceCountSearch
focal_class.modifier: protected
focal_class.original_string: protected SearchBuilder<ResourceCountVO> ResourceCountSearch;
focal_class.type: SearchBuilder<ResourceCountVO>
focal_class.var_name: ResourceCountSearch
focal_class.declarator: _rcExecutor
focal_class.original_string: ScheduledExecutorService _rcExecutor;
focal_class.type: ScheduledExecutorService
focal_class.var_name: _rcExecutor
focal_class.declarator: _resourceCountCheckInterval = 0
focal_class.original_string: long _resourceCountCheckInterval = 0;
focal_class.type: long
focal_class.var_name: _resourceCountCheckInterval
focal_class.declarator: accountResourceLimitMap = new EnumMap<>(ResourceType.class)
focal_class.original_string: Map<ResourceType, Long> accountResourceLimitMap = new EnumMap<>(ResourceType.class);
focal_class.type: Map<ResourceType, Long>
focal_class.var_name: accountResourceLimitMap
focal_class.declarator: domainResourceLimitMap = new EnumMap<>(ResourceType.class)
focal_class.original_string: Map<ResourceType, Long> domainResourceLimitMap = new EnumMap<>(ResourceType.class);
focal_class.type: Map<ResourceType, Long>
focal_class.var_name: domainResourceLimitMap
focal_class.declarator: projectResourceLimitMap = new EnumMap<>(ResourceType.class)
focal_class.original_string: Map<ResourceType, Long> projectResourceLimitMap = new EnumMap<>(ResourceType.class);
focal_class.type: Map<ResourceType, Long>
focal_class.var_name: projectResourceLimitMap
focal_class.declarator: _domainDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private DomainDao _domainDao;
focal_class.type: DomainDao
focal_class.var_name: _domainDao
focal_class.declarator: _accountMgr
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private AccountManager _accountMgr;
focal_class.type: AccountManager
focal_class.var_name: _accountMgr
focal_class.declarator: _alertMgr
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private AlertManager _alertMgr;
focal_class.type: AlertManager
focal_class.var_name: _alertMgr
focal_class.declarator: _resourceCountDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ResourceCountDao _resourceCountDao;
focal_class.type: ResourceCountDao
focal_class.var_name: _resourceCountDao
focal_class.declarator: _resourceLimitDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ResourceLimitDao _resourceLimitDao;
focal_class.type: ResourceLimitDao
focal_class.var_name: _resourceLimitDao
focal_class.declarator: _userVmDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private UserVmDao _userVmDao;
focal_class.type: UserVmDao
focal_class.var_name: _userVmDao
focal_class.declarator: _accountDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private AccountDao _accountDao;
focal_class.type: AccountDao
focal_class.var_name: _accountDao
focal_class.declarator: _volumeDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private VolumeDao _volumeDao;
focal_class.type: VolumeDao
focal_class.var_name: _volumeDao
focal_class.declarator: _ipAddressDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private IPAddressDao _ipAddressDao;
focal_class.type: IPAddressDao
focal_class.var_name: _ipAddressDao
focal_class.declarator: _vmDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private VMInstanceDao _vmDao;
focal_class.type: VMInstanceDao
focal_class.var_name: _vmDao
focal_class.declarator: _configDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ConfigurationDao _configDao;
focal_class.type: ConfigurationDao
focal_class.var_name: _configDao
focal_class.declarator: _entityMgr
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private EntityManager _entityMgr;
focal_class.type: EntityManager
focal_class.var_name: _entityMgr
focal_class.declarator: _projectDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ProjectDao _projectDao;
focal_class.type: ProjectDao
focal_class.var_name: _projectDao
focal_class.declarator: _projectAccountDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ProjectAccountDao _projectAccountDao;
focal_class.type: ProjectAccountDao
focal_class.var_name: _projectAccountDao
focal_class.declarator: _networkDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private NetworkDao _networkDao;
focal_class.type: NetworkDao
focal_class.var_name: _networkDao
focal_class.declarator: _vpcDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private VpcDao _vpcDao;
focal_class.type: VpcDao
focal_class.var_name: _vpcDao
focal_class.declarator: _serviceOfferingDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private ServiceOfferingDao _serviceOfferingDao;
focal_class.type: ServiceOfferingDao
focal_class.var_name: _serviceOfferingDao
focal_class.declarator: _vmTemplateStoreDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private TemplateDataStoreDao _vmTemplateStoreDao;
focal_class.type: TemplateDataStoreDao
focal_class.var_name: _vmTemplateStoreDao
focal_class.declarator: _vlanDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private VlanDao _vlanDao;
focal_class.type: VlanDao
focal_class.var_name: _vlanDao
focal_class.declarator: _snapshotDataStoreDao
focal_class.modifier: @Inject
      private
focal_class.original_string: @Inject
      private SnapshotDataStoreDao _snapshotDataStoreDao;
focal_class.type: SnapshotDataStoreDao
focal_class.var_name: _snapshotDataStoreDao
focal_class.file: cosmic-core/server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
focal_class.identifier: ResourceLimitManagerImpl
focal_class.interfaces: implements ResourceLimitService
focal_class.class_method_signature: ResourceLimitManagerImpl.configure(final String name, final Map<String, Object> params)
focal_class.full_signature: @Override public boolean configure(final String name, final Map<String, Object> params)
focal_class.identifier: configure
focal_class.modifiers: @Override public
focal_class.parameters: (final String name, final Map<String, Object> params)
focal_class.return: boolean
focal_class.signature: boolean configure(final String name, final Map<String, Object> params)
focal_class.class_method_signature: ResourceLimitManagerImpl.start()
focal_class.full_signature: @Override public boolean start()
focal_class.identifier: start
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean start()
focal_class.class_method_signature: ResourceLimitManagerImpl.stop()
focal_class.full_signature: @Override public boolean stop()
focal_class.identifier: stop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean stop()
focal_class.class_method_signature: ResourceLimitManagerImpl.updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_class.full_signature: @Override public ResourceLimitVO updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_class.identifier: updateResourceLimit
focal_class.modifiers: @Override public
focal_class.parameters: (final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_class.return: ResourceLimitVO
focal_class.signature: ResourceLimitVO updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_class.class_method_signature: ResourceLimitManagerImpl.recalculateResourceCount(final Long accountId, final Long domainId, final Integer typeId)
focal_class.full_signature: @Override public List<ResourceCountVO> recalculateResourceCount(final Long accountId, final Long domainId, final Integer typeId)
focal_class.identifier: recalculateResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final Long accountId, final Long domainId, final Integer typeId)
focal_class.return: List<ResourceCountVO>
focal_class.signature: List<ResourceCountVO> recalculateResourceCount(final Long accountId, final Long domainId, final Integer typeId)
focal_class.class_method_signature: ResourceLimitManagerImpl.searchForLimits(final Long id, Long accountId, Long domainId, final Integer type, final Long startIndex, final Long pageSizeVal)
focal_class.full_signature: @Override public List<ResourceLimitVO> searchForLimits(final Long id, Long accountId, Long domainId, final Integer type, final Long startIndex, final Long pageSizeVal)
focal_class.identifier: searchForLimits
focal_class.modifiers: @Override public
focal_class.parameters: (final Long id, Long accountId, Long domainId, final Integer type, final Long startIndex, final Long pageSizeVal)
focal_class.return: List<ResourceLimitVO>
focal_class.signature: List<ResourceLimitVO> searchForLimits(final Long id, Long accountId, Long domainId, final Integer type, final Long startIndex, final Long pageSizeVal)
focal_class.class_method_signature: ResourceLimitManagerImpl.findCorrectResourceLimitForAccount(final Account account, final ResourceType type)
focal_class.full_signature: @Override public long findCorrectResourceLimitForAccount(final Account account, final ResourceType type)
focal_class.identifier: findCorrectResourceLimitForAccount
focal_class.modifiers: @Override public
focal_class.parameters: (final Account account, final ResourceType type)
focal_class.return: long
focal_class.signature: long findCorrectResourceLimitForAccount(final Account account, final ResourceType type)
focal_class.class_method_signature: ResourceLimitManagerImpl.findCorrectResourceLimitForAccount(final long accountId, final Long limit, final ResourceType type)
focal_class.full_signature: @Override public long findCorrectResourceLimitForAccount(final long accountId, final Long limit, final ResourceType type)
focal_class.identifier: findCorrectResourceLimitForAccount
focal_class.modifiers: @Override public
focal_class.parameters: (final long accountId, final Long limit, final ResourceType type)
focal_class.return: long
focal_class.signature: long findCorrectResourceLimitForAccount(final long accountId, final Long limit, final ResourceType type)
focal_class.class_method_signature: ResourceLimitManagerImpl.findCorrectResourceLimitForDomain(final Domain domain, final ResourceType type)
focal_class.full_signature: @Override public long findCorrectResourceLimitForDomain(final Domain domain, final ResourceType type)
focal_class.identifier: findCorrectResourceLimitForDomain
focal_class.modifiers: @Override public
focal_class.parameters: (final Domain domain, final ResourceType type)
focal_class.return: long
focal_class.signature: long findCorrectResourceLimitForDomain(final Domain domain, final ResourceType type)
focal_class.class_method_signature: ResourceLimitManagerImpl.incrementResourceCount(final long accountId, final ResourceType type, final Long... delta)
focal_class.full_signature: @Override public void incrementResourceCount(final long accountId, final ResourceType type, final Long... delta)
focal_class.identifier: incrementResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final long accountId, final ResourceType type, final Long... delta)
focal_class.return: void
focal_class.signature: void incrementResourceCount(final long accountId, final ResourceType type, final Long... delta)
focal_class.class_method_signature: ResourceLimitManagerImpl.decrementResourceCount(final long accountId, final ResourceType type, final Long... delta)
focal_class.full_signature: @Override public void decrementResourceCount(final long accountId, final ResourceType type, final Long... delta)
focal_class.identifier: decrementResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final long accountId, final ResourceType type, final Long... delta)
focal_class.return: void
focal_class.signature: void decrementResourceCount(final long accountId, final ResourceType type, final Long... delta)
focal_class.class_method_signature: ResourceLimitManagerImpl.checkResourceLimit(final Account account, final ResourceType type, final long... count)
focal_class.full_signature: @Override @DB public void checkResourceLimit(final Account account, final ResourceType type, final long... count)
focal_class.identifier: checkResourceLimit
focal_class.modifiers: @Override @DB public
focal_class.parameters: (final Account account, final ResourceType type, final long... count)
focal_class.return: void
focal_class.signature: void checkResourceLimit(final Account account, final ResourceType type, final long... count)
focal_class.class_method_signature: ResourceLimitManagerImpl.getResourceCount(final Account account, final ResourceType type)
focal_class.full_signature: @Override public long getResourceCount(final Account account, final ResourceType type)
focal_class.identifier: getResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final Account account, final ResourceType type)
focal_class.return: long
focal_class.signature: long getResourceCount(final Account account, final ResourceType type)
focal_class.class_method_signature: ResourceLimitManagerImpl.checkResourceLimit(final Account account, final ResourceType type, final Boolean displayResource, final long... count)
focal_class.full_signature: @Override public void checkResourceLimit(final Account account, final ResourceType type, final Boolean displayResource, final long... count)
focal_class.identifier: checkResourceLimit
focal_class.modifiers: @Override public
focal_class.parameters: (final Account account, final ResourceType type, final Boolean displayResource, final long... count)
focal_class.return: void
focal_class.signature: void checkResourceLimit(final Account account, final ResourceType type, final Boolean displayResource, final long... count)
focal_class.class_method_signature: ResourceLimitManagerImpl.isDisplayFlagOn(final Boolean displayResource)
focal_class.full_signature: private boolean isDisplayFlagOn(final Boolean displayResource)
focal_class.identifier: isDisplayFlagOn
focal_class.modifiers: private
focal_class.parameters: (final Boolean displayResource)
focal_class.return: boolean
focal_class.signature: boolean isDisplayFlagOn(final Boolean displayResource)
focal_class.class_method_signature: ResourceLimitManagerImpl.incrementResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.full_signature: @Override public void incrementResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.identifier: incrementResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.return: void
focal_class.signature: void incrementResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.class_method_signature: ResourceLimitManagerImpl.updateResourceCountForAccount(final long accountId, final ResourceType type, final boolean increment, final long delta)
focal_class.full_signature: @DB protected boolean updateResourceCountForAccount(final long accountId, final ResourceType type, final boolean increment, final long delta)
focal_class.identifier: updateResourceCountForAccount
focal_class.modifiers: @DB protected
focal_class.parameters: (final long accountId, final ResourceType type, final boolean increment, final long delta)
focal_class.return: boolean
focal_class.signature: boolean updateResourceCountForAccount(final long accountId, final ResourceType type, final boolean increment, final long delta)
focal_class.class_method_signature: ResourceLimitManagerImpl.changeResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.full_signature: @Override public void changeResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.identifier: changeResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.return: void
focal_class.signature: void changeResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.class_method_signature: ResourceLimitManagerImpl.decrementResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.full_signature: @Override public void decrementResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.identifier: decrementResourceCount
focal_class.modifiers: @Override public
focal_class.parameters: (final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.return: void
focal_class.signature: void decrementResourceCount(final long accountId, final ResourceType type, final Boolean displayResource, final Long... delta)
focal_class.class_method_signature: ResourceLimitManagerImpl.recalculateDomainResourceCount(final long domainId, final ResourceType type)
focal_class.full_signature: @DB protected long recalculateDomainResourceCount(final long domainId, final ResourceType type)
focal_class.identifier: recalculateDomainResourceCount
focal_class.modifiers: @DB protected
focal_class.parameters: (final long domainId, final ResourceType type)
focal_class.return: long
focal_class.signature: long recalculateDomainResourceCount(final long domainId, final ResourceType type)
focal_class.class_method_signature: ResourceLimitManagerImpl.recalculateAccountResourceCount(final long accountId, final ResourceType type)
focal_class.full_signature: @DB protected long recalculateAccountResourceCount(final long accountId, final ResourceType type)
focal_class.identifier: recalculateAccountResourceCount
focal_class.modifiers: @DB protected
focal_class.parameters: (final long accountId, final ResourceType type)
focal_class.return: long
focal_class.signature: long recalculateAccountResourceCount(final long accountId, final ResourceType type)
focal_class.class_method_signature: ResourceLimitManagerImpl.countCpusForAccount(final long accountId)
focal_class.full_signature: public long countCpusForAccount(final long accountId)
focal_class.identifier: countCpusForAccount
focal_class.modifiers: public
focal_class.parameters: (final long accountId)
focal_class.return: long
focal_class.signature: long countCpusForAccount(final long accountId)
focal_class.class_method_signature: ResourceLimitManagerImpl.calculateMemoryForAccount(final long accountId)
focal_class.full_signature: public long calculateMemoryForAccount(final long accountId)
focal_class.identifier: calculateMemoryForAccount
focal_class.modifiers: public
focal_class.parameters: (final long accountId)
focal_class.return: long
focal_class.signature: long calculateMemoryForAccount(final long accountId)
focal_class.class_method_signature: ResourceLimitManagerImpl.calculateSecondaryStorageForAccount(final long accountId)
focal_class.full_signature: public long calculateSecondaryStorageForAccount(final long accountId)
focal_class.identifier: calculateSecondaryStorageForAccount
focal_class.modifiers: public
focal_class.parameters: (final long accountId)
focal_class.return: long
focal_class.signature: long calculateSecondaryStorageForAccount(final long accountId)
focal_class.class_method_signature: ResourceLimitManagerImpl.calculatePublicIpForAccount(final long accountId)
focal_class.full_signature: private long calculatePublicIpForAccount(final long accountId)
focal_class.identifier: calculatePublicIpForAccount
focal_class.modifiers: private
focal_class.parameters: (final long accountId)
focal_class.return: long
focal_class.signature: long calculatePublicIpForAccount(final long accountId)
focal_class.superclass: extends ManagerBase
focal_method.body: @Override
      public ResourceLimitVO updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max) {
          final Account caller = CallContext.current().getCallingAccount();
  
          if (max == null) {
              max = new Long(Resource.RESOURCE_UNLIMITED);
          } else if (max.longValue() < Resource.RESOURCE_UNLIMITED) {
              throw new InvalidParameterValueException("Please specify either '-1' for an infinite limit, or a limit that is at least '0'.");
          }
  
          // Map resource type
          ResourceType resourceType = null;
          if (typeId != null) {
              for (final ResourceType type : Resource.ResourceType.values()) {
                  if (type.getOrdinal() == typeId.intValue()) {
                      resourceType = type;
                  }
              }
              if (resourceType == null) {
                  throw new InvalidParameterValueException("Please specify valid resource type");
              }
          }
  
          //Convert max storage size from GiB to bytes
          if ((resourceType == ResourceType.primary_storage || resourceType == ResourceType.secondary_storage) && max >= 0) {
              max = max * ResourceType.bytesToGiB;
          }
  
          ResourceOwnerType ownerType = null;
          Long ownerId = null;
  
          if (accountId != null) {
              final Account account = this._entityMgr.findById(Account.class, accountId);
              if (account == null) {
                  throw new InvalidParameterValueException("Unable to find account " + accountId);
              }
              if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
                  throw new InvalidParameterValueException("Can't update system account");
              }
  
              //only Unlimited value is accepted if account is  Root Admin
              if (this._accountMgr.isRootAdmin(account.getId()) && max.shortValue() != Resource.RESOURCE_UNLIMITED) {
                  throw new InvalidParameterValueException("Only " + Resource.RESOURCE_UNLIMITED + " limit is supported for Root Admin accounts");
              }
  
              if ((caller.getAccountId() == accountId.longValue()) &&
                      (this._accountMgr.isDomainAdmin(caller.getId()) ||
                              caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)) {
                  // If the admin is trying to update his own account, disallow.
                  throw new PermissionDeniedException("Unable to update resource limit for his own account " + accountId + ", permission denied");
              }
  
              if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
                  this._accountMgr.checkAccess(caller, AccessType.ModifyProject, true, account);
              } else {
                  this._accountMgr.checkAccess(caller, null, true, account);
              }
  
              ownerType = ResourceOwnerType.Account;
              ownerId = accountId;
          } else if (domainId != null) {
              final Domain domain = this._entityMgr.findById(Domain.class, domainId);
  
              this._accountMgr.checkAccess(caller, domain);
  
              if (Domain.ROOT_DOMAIN == domainId.longValue()) {
                  // no one can add limits on ROOT domain, disallow...
                  throw new PermissionDeniedException("Cannot update resource limit for ROOT domain " + domainId + ", permission denied");
              }
  
              if ((caller.getDomainId() == domainId.longValue()) && caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN ||
                      caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
                  // if the admin is trying to update their own domain, disallow...
                  throw new PermissionDeniedException("Unable to update resource limit for domain " + domainId + ", permission denied");
              }
              final Long parentDomainId = domain.getParent();
              if (parentDomainId != null) {
                  final DomainVO parentDomain = this._domainDao.findById(parentDomainId);
                  final long parentMaximum = findCorrectResourceLimitForDomain(parentDomain, resourceType);
                  if ((parentMaximum >= 0) && (max.longValue() > parentMaximum)) {
                      throw new InvalidParameterValueException("Domain " + domain.getName() + "(id: " + parentDomain.getId() + ") has maximum allowed resource limit " +
                              parentMaximum + " for " + resourceType + ", please specify a value less that or equal to " + parentMaximum);
                  }
              }
              ownerType = ResourceOwnerType.Domain;
              ownerId = domainId;
          }
  
          if (ownerId == null) {
              throw new InvalidParameterValueException("AccountId or domainId have to be specified in order to update resource limit");
          }
  
          final ResourceLimitVO limit = this._resourceLimitDao.findByOwnerIdAndType(ownerId, ownerType, resourceType);
          if (limit != null) {
              // Update the existing limit
              this._resourceLimitDao.update(limit.getId(), max);
              return this._resourceLimitDao.findById(limit.getId());
          } else {
              return this._resourceLimitDao.persist(new ResourceLimitVO(resourceType, max, ownerId, ownerType));
          }
      }
focal_method.class_method_signature: ResourceLimitManagerImpl.updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_method.full_signature: @Override public ResourceLimitVO updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_method.identifier: updateResourceLimit
focal_method.invocations: getCallingAccount current longValue values getOrdinal intValue findById getId isRootAdmin getId shortValue getAccountId longValue isDomainAdmin getId getType getType checkAccess checkAccess findById checkAccess longValue getDomainId longValue getType getType getParent findById findCorrectResourceLimitForDomain longValue getName getId findByOwnerIdAndType update getId findById getId persist
focal_method.modifiers: @Override public
focal_method.parameters: (final Long accountId, final Long domainId, final Integer typeId, Long max)
focal_method.return: ResourceLimitVO
focal_method.signature: ResourceLimitVO updateResourceLimit(final Long accountId, final Long domainId, final Integer typeId, Long max)