Search in sources :

Example 11 with EventVO

use of com.cloud.event.EventVO 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

EventVO (com.cloud.event.EventVO)11 ArrayList (java.util.ArrayList)6 Account (com.cloud.user.Account)5 AccountVO (com.cloud.user.AccountVO)4 UserVO (com.cloud.user.UserVO)4 Before (org.junit.Before)4 ControlledEntity (com.cloud.acl.ControlledEntity)2 DomainVO (com.cloud.domain.DomainVO)2 NetworkDomainVO (com.cloud.network.dao.NetworkDomainVO)2 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)2 ControlledEntity (org.apache.cloudstack.acl.ControlledEntity)2 UsageEventVO (com.cloud.event.UsageEventVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 IOException (java.io.IOException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Matchers.anyLong (org.mockito.Matchers.anyLong)1