Search in sources :

Example 1 with UnknownSubscription

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ExpirationType(org.apache.cxf.ws.eventing.ExpirationType) SubscriptionTicket(org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket) UnknownSubscription(org.apache.cxf.ws.eventing.shared.faults.UnknownSubscription)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 ExpirationType (org.apache.cxf.ws.eventing.ExpirationType)1 SubscriptionTicket (org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket)1 UnknownSubscription (org.apache.cxf.ws.eventing.shared.faults.UnknownSubscription)1