You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by se...@apache.org on 2013/07/12 09:51:22 UTC

[27/50] git commit: updated refs/heads/sdnextensions to bcfb4e6

CLOUDSTACK-1768: Ability to delete Events and Alerts: Delete by a time period is required.
User should be able to delete/archive alerts and events by selecting a time period or by
choosing the alerts and events older than a date. Added the ability to choose a time period
too.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/429e6bd4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/429e6bd4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/429e6bd4

Branch: refs/heads/sdnextensions
Commit: 429e6bd4bb084a568c74d5412729e5e8c09d4c9a
Parents: 47de56d
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Tue Jun 4 16:03:53 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Thu Jul 11 14:12:17 2013 +0530

----------------------------------------------------------------------
 .../org/apache/cloudstack/api/ApiConstants.java |  1 -
 .../admin/resource/ArchiveAlertsCmd.java        | 24 +++++++++----
 .../command/admin/resource/DeleteAlertsCmd.java | 23 ++++++++----
 .../command/user/event/ArchiveEventsCmd.java    | 24 +++++++++----
 .../api/command/user/event/DeleteEventsCmd.java | 21 ++++++++---
 .../src/com/cloud/alert/dao/AlertDao.java       |  4 +--
 .../src/com/cloud/alert/dao/AlertDaoImpl.java   | 37 ++++++++++++--------
 .../src/com/cloud/event/dao/EventDao.java       |  2 +-
 .../src/com/cloud/event/dao/EventDaoImpl.java   | 11 +++---
 server/src/com/cloud/api/ApiDispatcher.java     | 11 ++++--
 .../com/cloud/server/ManagementServerImpl.java  |  8 ++---
 .../com/cloud/alert/AlertControlsUnitTest.java  |  8 ++---
 .../com/cloud/event/EventControlsUnitTest.java  |  2 +-
 13 files changed, 116 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index e2857b8..83999b6 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -498,7 +498,6 @@ public class ApiConstants {
     public static final String UCS_BLADE_DN = "bladedn";
     public static final String UCS_BLADE_ID = "bladeid";
     public static final String VM_GUEST_IP = "vmguestip";
-    public static final String OLDER_THAN = "olderthan";
     public static final String HEALTHCHECK_RESPONSE_TIMEOUT = "responsetimeout";
     public static final String HEALTHCHECK_INTERVAL_TIME = "intervaltime";
     public static final String HEALTHCHECK_HEALTHY_THRESHOLD = "healthythreshold";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java
index 2a1a47a..eed914e 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java
@@ -26,7 +26,6 @@ import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.AlertResponse;
-import org.apache.cloudstack.api.response.ConditionResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.log4j.Logger;
 
@@ -48,8 +47,13 @@ public class ArchiveAlertsCmd extends BaseCmd {
             description = "the IDs of the alerts")
     private List<Long> ids;
 
-    @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="archive alerts older than this date (use format \"yyyy-MM-dd\")")
-    private Date olderThan;
+    @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to archive alerts" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date endDate;
+
+    @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to archive alerts" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date startDate;
 
     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "archive by alert type")
     private String type;
@@ -62,8 +66,12 @@ public class ArchiveAlertsCmd extends BaseCmd {
         return ids;
     }
 
-    public Date getOlderThan() {
-        return olderThan;
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public Date getStartDate() {
+        return startDate;
     }
 
     public String getType() {
@@ -86,8 +94,10 @@ public class ArchiveAlertsCmd extends BaseCmd {
 
     @Override
     public void execute() {
-        if(ids == null && type == null && olderThan == null) {
-            throw new InvalidParameterValueException("either ids, type or olderthan must be specified");
+        if(ids == null && type == null && endDate == null) {
+            throw new InvalidParameterValueException("either ids, type, startdate or enddate must be specified");
+        } else if (startDate != null && endDate == null) {
+            throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
         }
         boolean result = _mgr.archiveAlerts(this);
         if (result) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java
index f03793c..b0deaa9 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java
@@ -47,8 +47,13 @@ public class DeleteAlertsCmd extends BaseCmd {
             description = "the IDs of the alerts")
     private List<Long> ids;
 
-    @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="delete alerts older than (including) this date (use format \"yyyy-MM-dd\")")
-    private Date olderThan;
+    @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to delete alerts" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date endDate;
+
+    @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to delete alerts" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date startDate;
 
     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "delete by alert type")
     private String type;
@@ -61,8 +66,12 @@ public class DeleteAlertsCmd extends BaseCmd {
         return ids;
     }
 
-    public Date getOlderThan() {
-        return olderThan;
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public Date getStartDate() {
+        return startDate;
     }
 
     public String getType() {
@@ -85,8 +94,10 @@ public class DeleteAlertsCmd extends BaseCmd {
 
     @Override
     public void execute() {
-        if(ids == null && type == null && olderThan == null) {
-            throw new InvalidParameterValueException("either ids, type or olderthan must be specified");
+        if(ids == null && type == null && endDate == null) {
+            throw new InvalidParameterValueException("either ids, type or enddate must be specified");
+        } else if (startDate != null && endDate == null) {
+            throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
         }
         boolean result = _mgr.deleteAlerts(this);
         if (result) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
index 481607c..c5594e2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java
@@ -25,7 +25,6 @@ import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.AlertResponse;
 import org.apache.cloudstack.api.response.EventResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.log4j.Logger;
@@ -49,8 +48,13 @@ public class ArchiveEventsCmd extends BaseCmd {
             description = "the IDs of the events")
     private List<Long> ids;
 
-    @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="archive events older than (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
-    private Date olderThan;
+    @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to archive events" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date endDate;
+
+    @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to archive events" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date startDate;
 
     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "archive by event type")
     private String type;
@@ -63,8 +67,12 @@ public class ArchiveEventsCmd extends BaseCmd {
         return ids;
     }
 
-    public Date getOlderThan() {
-        return olderThan;
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public Date getStartDate() {
+        return startDate;
     }
 
     public String getType() {
@@ -91,8 +99,10 @@ public class ArchiveEventsCmd extends BaseCmd {
 
     @Override
     public void execute() {
-        if(ids == null && type == null && olderThan == null) {
-            throw new InvalidParameterValueException("either ids, type or olderthan must be specified");
+        if(ids == null && type == null && endDate == null) {
+            throw new InvalidParameterValueException("either ids, type or enddate must be specified");
+        } else if (startDate != null && endDate == null) {
+            throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
         }
         boolean result = _mgr.archiveEvents(this);
         if (result) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
index a03e6d9..548c2f3 100644
--- a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java
@@ -48,8 +48,13 @@ public class DeleteEventsCmd extends BaseCmd {
             description = "the IDs of the events")
     private List<Long> ids;
 
-    @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="delete events older than (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")")
-    private Date olderThan;
+    @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to delete events" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date endDate;
+
+    @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to delete events" +
+            " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")")
+    private Date startDate;
 
     @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "delete by event type")
     private String type;
@@ -62,8 +67,12 @@ public class DeleteEventsCmd extends BaseCmd {
         return ids;
     }
 
-    public Date getOlderThan() {
-        return olderThan;
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public Date getStartDate() {
+        return startDate;
     }
 
     public String getType() {
@@ -90,8 +99,10 @@ public class DeleteEventsCmd extends BaseCmd {
 
     @Override
     public void execute() {
-        if(ids == null && type == null && olderThan == null) {
+        if(ids == null && type == null && endDate == null) {
             throw new InvalidParameterValueException("either ids, type or enddate must be specified");
+        } else if (startDate != null && endDate == null) {
+            throw new InvalidParameterValueException("enddate must be specified with startdate parameter");
         }
         boolean result = _mgr.deleteEvents(this);
         if (result) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/engine/schema/src/com/cloud/alert/dao/AlertDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/alert/dao/AlertDao.java b/engine/schema/src/com/cloud/alert/dao/AlertDao.java
index fda814d..1aa1fe0 100755
--- a/engine/schema/src/com/cloud/alert/dao/AlertDao.java
+++ b/engine/schema/src/com/cloud/alert/dao/AlertDao.java
@@ -27,7 +27,7 @@ public interface AlertDao extends GenericDao<AlertVO, Long> {
     // This is for backward compatibility
     AlertVO getLastAlert(short type, long dataCenterId, Long podId);
 
-    public boolean deleteAlert(List<Long> Ids, String type, Date olderThan, Long zoneId);
-    public boolean archiveAlert(List<Long> Ids, String type, Date olderThan, Long zoneId);
+    public boolean deleteAlert(List<Long> Ids, String type, Date startDate, Date endDate, Long zoneId);
+    public boolean archiveAlert(List<Long> Ids, String type, Date startDate, Date endDate, Long zoneId);
     public List<AlertVO> listOlderAlerts(Date oldTime);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java b/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java
index 18115a5..7c0a562 100755
--- a/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java
+++ b/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java
@@ -41,7 +41,8 @@ public class AlertDaoImpl extends GenericDaoBase<AlertVO, Long> implements Alert
         AlertSearchByIdsAndType = createSearchBuilder();
         AlertSearchByIdsAndType.and("id", AlertSearchByIdsAndType.entity().getId(), Op.IN);
         AlertSearchByIdsAndType.and("type", AlertSearchByIdsAndType.entity().getType(), Op.EQ);
-        AlertSearchByIdsAndType.and("createdDateL", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.LT);
+        AlertSearchByIdsAndType.and("createdDateB", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.BETWEEN);
+        AlertSearchByIdsAndType.and("createdDateL", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.LTEQ);
         AlertSearchByIdsAndType.and("data_center_id", AlertSearchByIdsAndType.entity().getDataCenterId(), Op.EQ);
         AlertSearchByIdsAndType.and("archived", AlertSearchByIdsAndType.entity().getArchived(), Op.EQ);
         AlertSearchByIdsAndType.done();
@@ -89,7 +90,7 @@ public class AlertDaoImpl extends GenericDaoBase<AlertVO, Long> implements Alert
     }
 
     @Override
-    public boolean archiveAlert(List<Long> Ids, String type, Date olderThan, Long zoneId) {
+    public boolean archiveAlert(List<Long> Ids, String type, Date startDate, Date endDate, Long zoneId) {
         SearchCriteria<AlertVO> sc = AlertSearchByIdsAndType.create();
 
         if (Ids != null) {
@@ -101,8 +102,10 @@ public class AlertDaoImpl extends GenericDaoBase<AlertVO, Long> implements Alert
         if(zoneId != null) {
             sc.setParameters("data_center_id", zoneId);
         }
-        if(olderThan != null) {
-            sc.setParameters("createdDateL", olderThan);
+        if (startDate != null && endDate != null) {
+            sc.setParameters("createdDateB", startDate, endDate);
+        } else if (endDate != null) {
+            sc.setParameters("createdDateL", endDate);
         }
         sc.setParameters("archived", false);
 
@@ -112,20 +115,22 @@ public class AlertDaoImpl extends GenericDaoBase<AlertVO, Long> implements Alert
             result = false;
             return result;
         }
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        for (AlertVO alert : alerts) {
-            alert = lockRow(alert.getId(), true);
-            alert.setArchived(true);
-            update(alert.getId(), alert);
-            txn.commit();
+        if (alerts != null && !alerts.isEmpty()) {
+            Transaction txn = Transaction.currentTxn();
+            txn.start();
+            for (AlertVO alert : alerts) {
+                alert = lockRow(alert.getId(), true);
+                alert.setArchived(true);
+                update(alert.getId(), alert);
+                txn.commit();
+            }
+            txn.close();
         }
-        txn.close();
         return result;
     }
 
     @Override
-    public boolean deleteAlert(List<Long> ids, String type, Date olderThan, Long zoneId) {
+    public boolean deleteAlert(List<Long> ids, String type, Date startDate, Date endDate, Long zoneId) {
         SearchCriteria<AlertVO> sc = AlertSearchByIdsAndType.create();
 
         if (ids != null) {
@@ -137,8 +142,10 @@ public class AlertDaoImpl extends GenericDaoBase<AlertVO, Long> implements Alert
         if(zoneId != null) {
             sc.setParameters("data_center_id", zoneId);
         }
-        if(olderThan != null) {
-            sc.setParameters("createdDateL", olderThan);
+        if (startDate != null && endDate != null) {
+            sc.setParameters("createdDateB", startDate, endDate);
+        } else if (endDate != null) {
+            sc.setParameters("createdDateL", endDate);
         }
         sc.setParameters("archived", false);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/engine/schema/src/com/cloud/event/dao/EventDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/event/dao/EventDao.java b/engine/schema/src/com/cloud/event/dao/EventDao.java
index 9454ce7..c50451b 100644
--- a/engine/schema/src/com/cloud/event/dao/EventDao.java
+++ b/engine/schema/src/com/cloud/event/dao/EventDao.java
@@ -31,7 +31,7 @@ public interface EventDao extends GenericDao<EventVO, Long> {
 
     EventVO findCompletedEvent(long startId);
 
-    public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date olderThan, List<Long> accountIds);
+    public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date startDate, Date endDate, List<Long> accountIds);
 
     public void archiveEvents(List<EventVO> events);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java b/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java
index cefe107..e5615db 100644
--- a/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java
+++ b/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java
@@ -51,7 +51,8 @@ public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements Event
         ToArchiveOrDeleteEventSearch.and("id", ToArchiveOrDeleteEventSearch.entity().getId(), Op.IN);
         ToArchiveOrDeleteEventSearch.and("type", ToArchiveOrDeleteEventSearch.entity().getType(), Op.EQ);
         ToArchiveOrDeleteEventSearch.and("accountIds", ToArchiveOrDeleteEventSearch.entity().getAccountId(), Op.IN);
-        ToArchiveOrDeleteEventSearch.and("createDateL", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.LT);
+        ToArchiveOrDeleteEventSearch.and("createdDateB", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.BETWEEN);
+        ToArchiveOrDeleteEventSearch.and("createdDateL", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.LTEQ);
         ToArchiveOrDeleteEventSearch.and("archived", ToArchiveOrDeleteEventSearch.entity().getArchived(), Op.EQ);
         ToArchiveOrDeleteEventSearch.done();
     }
@@ -80,7 +81,7 @@ public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements Event
     }
 
     @Override
-    public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date olderThan, List<Long> accountIds) {
+    public List<EventVO> listToArchiveOrDeleteEvents(List<Long> ids, String type, Date startDate, Date endDate, List<Long> accountIds) {
         SearchCriteria<EventVO> sc = ToArchiveOrDeleteEventSearch.create();
         if (ids != null) {
             sc.setParameters("id", ids.toArray(new Object[ids.size()]));
@@ -88,8 +89,10 @@ public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements Event
         if (type != null) {
             sc.setParameters("type", type);
         }
-        if (olderThan != null) {
-            sc.setParameters("createDateL", olderThan);
+        if (startDate != null && endDate != null) {
+            sc.setParameters("createdDateB", startDate, endDate);
+        } else if (endDate != null) {
+            sc.setParameters("createdDateL", endDate);
         }
         if (accountIds != null && !accountIds.isEmpty()) {
             sc.setParameters("accountIds", accountIds.toArray(new Object[accountIds.size()]));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index b7d08e2..b886256 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -49,6 +49,9 @@ import org.apache.cloudstack.api.InternalIdentity;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.Validate;
+import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
+import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
+import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
 import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd;
 import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
@@ -381,7 +384,11 @@ public class ApiDispatcher {
                 // This piece of code is for maintaining backward compatibility
                 // and support both the date formats(Bug 9724)
                 // Do the date messaging for ListEventsCmd only
-                if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd || cmdObj instanceof ArchiveEventsCmd) {
+                if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd
+                        || cmdObj instanceof ArchiveEventsCmd
+                        || cmdObj instanceof ArchiveAlertsCmd
+                        || cmdObj instanceof DeleteAlertsCmd
+                        ) {
                     boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString());
                     if (isObjInNewDateFormat) {
                         DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT;
@@ -396,8 +403,6 @@ public class ApiDispatcher {
                                 date = messageDate(date, 0, 0, 0);
                             } else if (field.getName().equals("endDate")) {
                                 date = messageDate(date, 23, 59, 59);
-                            } else if (field.getName().equals("olderThan")) {
-                                date = messageDate(date, 0, 0, 0);
                             }
                             field.set(cmdObj, date);
                         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 7795bb3..a0b9daa 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -848,7 +848,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
         }
 
-        List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds);
+        List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
         ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
         _accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEvents);
 
@@ -875,7 +875,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds);
         }
 
-        List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds);
+        List<EventVO> events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds);
         ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]);
         _accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEvents);
 
@@ -2236,14 +2236,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     @Override
     public boolean archiveAlerts(ArchiveAlertsCmd cmd) {
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), null);
-        boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getOlderThan(), zoneId);
+        boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId);
         return result;
     }
 
     @Override
     public boolean deleteAlerts(DeleteAlertsCmd cmd) {
         Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), null);
-        boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getOlderThan(), zoneId);
+        boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId);
         return result;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/server/test/com/cloud/alert/AlertControlsUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/alert/AlertControlsUnitTest.java b/server/test/com/cloud/alert/AlertControlsUnitTest.java
index c1e4c54..2b30246 100644
--- a/server/test/com/cloud/alert/AlertControlsUnitTest.java
+++ b/server/test/com/cloud/alert/AlertControlsUnitTest.java
@@ -53,8 +53,8 @@ public class AlertControlsUnitTest extends TestCase {
         _mgmtServer._alertDao = _alertDao;
         _mgmtServer._accountMgr = _accountMgr;
         doReturn(3L).when(_accountMgr).checkAccessAndSpecifyAuthority(any(Account.class), anyLong());
-        when(_alertDao.archiveAlert(anyList(), anyString(), any(Date.class), anyLong())).thenReturn(true);
-        when(_alertDao.deleteAlert(anyList(), anyString(), any(Date.class), anyLong())).thenReturn(true);
+        when(_alertDao.archiveAlert(anyList(), anyString(), any(Date.class), any(Date.class), anyLong())).thenReturn(true);
+        when(_alertDao.deleteAlert(anyList(), anyString(), any(Date.class), any(Date.class), anyLong())).thenReturn(true);
     }
 
     @After
@@ -72,12 +72,12 @@ public class AlertControlsUnitTest extends TestCase {
     protected void archiveAlerts() {
         // archive alerts
         String msg = "Archive Alerts: TEST FAILED";
-        assertNotNull(msg, _mgmtServer._alertDao.archiveAlert(null, "system alert",null, 2L));
+        assertNotNull(msg, _mgmtServer._alertDao.archiveAlert(null, "system alert",null, null, 2L));
     }
 
     protected void deleteAlerts() {
         // delete alerts
         String msg = "Delete Alerts: TEST FAILED";
-        assertNotNull(msg, _mgmtServer._alertDao.deleteAlert(null, "system alert",null, 2L));
+        assertNotNull(msg, _mgmtServer._alertDao.deleteAlert(null, "system alert",null, null, 2L));
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429e6bd4/server/test/com/cloud/event/EventControlsUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/event/EventControlsUnitTest.java b/server/test/com/cloud/event/EventControlsUnitTest.java
index e2a86cd..f9003a9 100644
--- a/server/test/com/cloud/event/EventControlsUnitTest.java
+++ b/server/test/com/cloud/event/EventControlsUnitTest.java
@@ -57,7 +57,7 @@ public class EventControlsUnitTest extends TestCase{
         _mgmtServer._eventDao = _eventDao;
         _mgmtServer._accountMgr = _accountMgr;
         doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class));
-        when(_eventDao.listToArchiveOrDeleteEvents(anyList(), anyString(), any(Date.class), anyList())).thenReturn(_events);
+        when(_eventDao.listToArchiveOrDeleteEvents(anyList(), anyString(), any(Date.class), any(Date.class), anyList())).thenReturn(_events);
     }
 
     @After