use of com.couchbase.client.java.document.SerializableDocument in project cas by apereo.
the class CouchbaseTicketRegistry method addTicket.
@Override
public void addTicket(final Ticket ticketToAdd) {
LOGGER.debug("Adding ticket [{}]", ticketToAdd);
try {
final Ticket ticket = encodeTicket(ticketToAdd);
final SerializableDocument document = SerializableDocument.create(ticket.getId(), getTimeToLive(ticketToAdd), ticket);
LOGGER.debug("Created document for ticket [{}]. Upserting into bucket [{}]", ticketToAdd, this.couchbase.bucket().name());
this.couchbase.bucket().upsert(document);
} catch (final Exception e) {
LOGGER.error("Failed adding [{}]: [{}]", ticketToAdd, e);
}
}
use of com.couchbase.client.java.document.SerializableDocument in project cas by apereo.
the class CouchbaseTicketRegistry method updateTicket.
@Override
public Ticket updateTicket(final Ticket ticket) {
LOGGER.debug("Updating ticket [{}]", ticket);
try {
final SerializableDocument document = SerializableDocument.create(ticket.getId(), getTimeToLive(ticket), ticket);
LOGGER.debug("Upserting document [{}] into couchbase bucket [{}]", document.id(), this.couchbase.bucket().name());
this.couchbase.bucket().upsert(document);
} catch (final Exception e) {
LOGGER.error("Failed updating [{}]: [{}]", ticket, e);
}
return ticket;
}
use of com.couchbase.client.java.document.SerializableDocument in project cas by apereo.
the class CouchbaseTicketRegistry method getTicket.
@Override
public Ticket getTicket(final String ticketId) {
try {
LOGGER.debug("Locating ticket id [{}]", ticketId);
final String encTicketId = encodeTicketId(ticketId);
if (encTicketId == null) {
LOGGER.debug("Ticket id [{}] could not be found", ticketId);
return null;
}
final SerializableDocument document = this.couchbase.bucket().get(encTicketId, SerializableDocument.class);
if (document != null) {
final Ticket t = (Ticket) document.content();
LOGGER.debug("Got ticket [{}] from the registry.", t);
return t;
}
LOGGER.debug("Ticket [{}] not found in the registry.", encTicketId);
return null;
} catch (final Exception e) {
LOGGER.error("Failed fetching [{}]: [{}]", ticketId, e);
return null;
}
}
Aggregations