}
}
protected GetSubscriptionResults buildGetSubscriptionResults(Subscription subscription, Date endPoint)
throws DispositionReportFaultMessage, DatatypeConfigurationException {
GetSubscriptionResults getSubscriptionResults = null;
Duration duration = TypeConvertor.convertStringToDuration(subscription.getNotificationInterval());
Date startPoint = subscription.getLastNotified();
Date nextDesiredNotificationDate = null;
if (startPoint==null) startPoint = subscription.getCreateDate();
nextDesiredNotificationDate = new Date(startPoint.getTime());
duration.addTo(nextDesiredNotificationDate);
//nextDesiredNotificationDate = lastTime + the Interval Duration, which should be:
//AFTER the lastNotified time and BEFORE the endTime (current time). If it is
//after the endTime, then the user does not want a notification yet, so we accumulate.
if (subscription.getLastNotified()==null || nextDesiredNotificationDate.after(startPoint) && nextDesiredNotificationDate.before(endPoint)) {
getSubscriptionResults = new GetSubscriptionResults();
CoveragePeriod period = new CoveragePeriod();
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTimeInMillis(startPoint.getTime());
period.setStartPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
calendar.setTimeInMillis(endPoint.getTime());
period.setEndPoint(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
if (log.isDebugEnabled()) log.debug("Period " + period.getStartPoint() + " " + period.getEndPoint());
getSubscriptionResults.setCoveragePeriod(period);
} else {
log.debug("Client does not yet want a notification. The next desidered notification Date " + nextDesiredNotificationDate + ". The current interval ["
+ startPoint + " , " + endPoint + "] therefore skipping this notification cycle.");
if (desiredDate==null || nextDesiredNotificationDate.getTime() < desiredDate.getTime()) {
desiredDate = nextDesiredNotificationDate;