use of org.apache.cxf.ws.eventing.shared.faults.UnknownSubscription in project cxf by apache.
the class SubscriptionManagerImpl method renew.
@Override
public ExpirationType renew(UUID uuid, ExpirationType requestedExpiration) {
SubscriptionTicket ticket = getDatabase().findById(uuid);
if (ticket == null) {
throw new UnknownSubscription();
}
LOG.info("[subscription=" + ticket.getUuid() + "] Requested renew expiration: " + requestedExpiration.getValue());
LOG.fine("[subscription=" + ticket.getUuid() + "] Current expiration: " + ticket.getExpires().toXMLFormat());
ExpirationType response = new ExpirationType();
XMLGregorianCalendar grantedExpires;
if (DurationAndDateUtil.isDuration(requestedExpiration.getValue())) {
// duration was requested
javax.xml.datatype.Duration requestedDuration = DurationAndDateUtil.parseDuration(requestedExpiration.getValue());
javax.xml.datatype.Duration grantedDuration = requestedDuration;
LOG.info("[subscription=" + ticket.getUuid() + "] Granted renewal duration: " + grantedDuration.toString());
grantedExpires = getDatabase().findById(uuid).getExpires();
grantedExpires.add(grantedDuration);
response.setValue(grantedDuration.toString());
} else {
// end-date was requested
grantedExpires = DurationAndDateUtil.parseXMLGregorianCalendar(requestedExpiration.getValue());
LOG.info("[subscription=" + ticket.getUuid() + "] Granted expiration: " + grantedExpires.toXMLFormat());
response.setValue(grantedExpires.toXMLFormat());
}
getDatabase().findById(uuid).setExpires(grantedExpires);
return response;
}
Aggregations