mirror of https://github.com/apache/cloudstack.git
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.
This commit is contained in:
parent
47de56d665
commit
429e6bd4bb
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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()]));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue