Hi there, In refactoring ListEventsCmd api, I ran into the following code which is a mystery to me, hope that somebody can explain here:
if ((entryTime != null) && (duration != null)) { if (entryTime <= duration) { throw new InvalidParameterValueException("Entry time must be greater than duration"); } Calendar calMin = Calendar.getInstance(); Calendar calMax = Calendar.getInstance(); calMin.add(Calendar.SECOND, -entryTime); calMax.add(Calendar.SECOND, -duration); Date minTime = calMin.getTime(); Date maxTime = calMax.getTime(); sc.setParameters("state", com.cloud.event.Event.State.Completed); sc.setParameters("startId", 0); sc.setParameters("createDate", minTime, maxTime); List<EventJoinVO> startedEvents = _eventJoinDao.searchAllEvents(sc, searchFilter); List<EventJoinVO> pendingEvents = new ArrayList<EventJoinVO>(); for (EventVO event : startedEvents) { EventVO completedEvent = _eventDao.findCompletedEvent(event.getId()); if (completedEvent == null) { pendingEvents.add(event); } } return pendingEvents; } I have several questions here: 1. What are entryTime and duration parameters here? Based on API doc, here are description on these two cmd parameters: entryTime: the time the event is entered duration: the duration of the event But from code, it seems that they are both Integer type. So not sure how to understand the entryTime and duration here, contradictory to my English understanding. 2. In the code above, why must we have "Entry time must be greater than duration"? 3. When user provides entryTime and duration parameters in the search, what kind of events are we supposed to return here? I don't quite understand the pendingEvents list we are constructing here. Thanks -min