use of org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket 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;
}
use of org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket in project cxf by apache.
the class AbstractSubscriptionManager method getStatusOp.
@Override
public GetStatusResponse getStatusOp(GetStatus body) {
String uuid = retrieveSubscriptionUUID();
LOG.info("received GetStatus message for UUID=" + uuid);
SubscriptionTicket ticket = obtainTicketFromDatabaseOrThrowFault(uuid);
GetStatusResponse response = new GetStatusResponse();
response.setGrantedExpires(DurationAndDateUtil.toExpirationTypeContainingGregorianCalendar(ticket.getExpires()));
return response;
}
use of org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket in project cxf by apache.
the class SubscriptionManagerImpl method subscribe.
@Override
public SubscriptionTicketGrantingResponse subscribe(DeliveryType delivery, EndpointReferenceType endTo, ExpirationType expires, FilterType filter, FormatType format) {
SubscriptionTicket ticket = new SubscriptionTicket();
SubscriptionTicketGrantingResponse response = new SubscriptionTicketGrantingResponse();
grantSubscriptionManagerReference(ticket, response);
processDelivery(delivery, ticket, response);
processEndTo(endTo, ticket, response);
processExpiration(expires, ticket, response);
processFilters(filter, ticket, response);
processFormat(format, ticket, response);
getDatabase().addTicket(ticket);
return response;
}
Aggregations