Search in sources :

Example 1 with SubscriptionTicket

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;
}
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)

Example 2 with SubscriptionTicket

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;
}
Also used : GetStatusResponse(org.apache.cxf.ws.eventing.GetStatusResponse) SubscriptionTicket(org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket)

Example 3 with SubscriptionTicket

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;
}
Also used : SubscriptionTicket(org.apache.cxf.ws.eventing.backend.database.SubscriptionTicket)

Aggregations

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