shwstppr commented on code in PR #11443:
URL: https://github.com/apache/cloudstack/pull/11443#discussion_r2318744832


##########
server/src/main/java/com/cloud/server/ManagementServerImpl.java:
##########
@@ -1224,31 +1225,34 @@ public boolean archiveEvents(final ArchiveEventsCmd 
cmd) {
     }
 
     @Override
-    public boolean deleteEvents(final DeleteEventsCmd cmd) {
-        final Account caller = getCaller();
-        final List<Long> ids = cmd.getIds();
-        boolean result = true;
-        List<Long> permittedAccountIds = new ArrayList<>();
+    public boolean deleteEvents(DeleteEventsCmd cmd) {
+        List<Long> ids = cmd.getIds();
+        String type = cmd.getType();
+        Date startDate = cmd.getStartDate();
+        Date endDate = cmd.getEndDate();
 
-        if (_accountMgr.isNormalUser(caller.getId()) || caller.getType() == 
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);
+        if (CollectionUtils.isEmpty(ids) && ObjectUtils.allNull(type, 
endDate)) {
+            throw new InvalidParameterValueException("Either 'ids', 'type' or 
'enddate' must be specified.");
+        }
+        if (startDate != null && endDate == null) {
+            throw new InvalidParameterValueException("'startdate' must be 
specified with 'enddate' parameter.");

Review Comment:
   I've not checked the current behaviour but can't we allow  delete with only 
one of the params?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to