mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #762 from inoshperera/master
adding default values for timestamp
This commit is contained in:
commit
53f8c7e188
@ -83,6 +83,10 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
||||
long timestamp = 0;
|
||||
boolean isIfModifiedSinceSet = false;
|
||||
boolean isSinceSet = false;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("getActivities since: " + since + " , offset: " + offset + " ,limit: " + limit + " ," +
|
||||
"ifModifiedSince: " + ifModifiedSince);
|
||||
}
|
||||
RequestValidationUtil.validatePaginationParameters(offset, limit);
|
||||
if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) {
|
||||
Date ifSinceDate;
|
||||
@ -112,14 +116,32 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
|
||||
timestamp = sinceTimestamp / 1000;
|
||||
}
|
||||
|
||||
if (timestamp == 0) {
|
||||
//If timestamp is not sent by the user, a default value is set, that is equal to current time-12 hours.
|
||||
long time = System.currentTimeMillis() / 1000;
|
||||
timestamp = time - 42300;
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("getActivities final timestamp " + timestamp);
|
||||
}
|
||||
|
||||
List<Activity> activities;
|
||||
ActivityList activityList = new ActivityList();
|
||||
DeviceManagementProviderService dmService;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Calling database to get activities.");
|
||||
}
|
||||
dmService = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
activities = dmService.getActivitiesUpdatedAfter(timestamp, limit, offset);
|
||||
activityList.setList(activities);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Calling database to get activity count.");
|
||||
}
|
||||
int count = dmService.getActivityCountUpdatedAfter(timestamp);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Activity count: " + count);
|
||||
}
|
||||
activityList.setCount(count);
|
||||
if (activities == null || activities.size() == 0) {
|
||||
if (isIfModifiedSinceSet) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user