Search in sources :

Example 11 with ControlledEntity

use of org.apache.cloudstack.acl.ControlledEntity in project cloudstack by apache.

the class ManagementServerImpl method archiveEvents.

@Override
public boolean archiveEvents(final ArchiveEventsCmd cmd) {
    final Account caller = getCaller();
    final List<Long> ids = cmd.getIds();
    boolean result = true;
    List<Long> permittedAccountIds = new ArrayList<Long>();
    if (_accountService.isNormalUser(caller.getId()) || caller.getType() == Account.ACCOUNT_TYPE_PROJECT) {
        permittedAccountIds.add(caller.getId());
    } else {
        final DomainVO domain = _domainDao.findById(caller.getDomainId());
        final List<Long> permittedDomainIds = _domainDao.getDomainChildrenIds(domain.getPath());
        permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
    }
    final List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
    final ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
    _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, false, sameOwnerEvents);
    if (ids != null && events.size() < ids.size()) {
        result = false;
        return result;
    }
    _eventDao.archiveEvents(events);
    return result;
}
Also used : Account(com.cloud.user.Account) NetworkDomainVO(com.cloud.network.dao.NetworkDomainVO) DomainVO(com.cloud.domain.DomainVO) ControlledEntity(org.apache.cloudstack.acl.ControlledEntity) ArrayList(java.util.ArrayList) EventVO(com.cloud.event.EventVO)

Aggregations

ControlledEntity (org.apache.cloudstack.acl.ControlledEntity)11 ArrayList (java.util.ArrayList)5 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)4 Account (com.cloud.user.Account)4 DomainVO (com.cloud.domain.DomainVO)3 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)3 HashMap (java.util.HashMap)3 EventVO (com.cloud.event.EventVO)2 NetworkDomainVO (com.cloud.network.dao.NetworkDomainVO)2 DB (com.cloud.utils.db.DB)2 TransactionStatus (com.cloud.utils.db.TransactionStatus)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 List (java.util.List)2 Map (java.util.Map)2 InfrastructureEntity (org.apache.cloudstack.acl.InfrastructureEntity)2 Domain (com.cloud.domain.Domain)1 ActionEvent (com.cloud.event.ActionEvent)1 Network (com.cloud.network.Network)1 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)1 NetworkVO (com.cloud.network.dao.NetworkVO)1