use of org.openecard.ws.schema.StatusChange in project open-ecard by ecsec.
the class WaitForChangeAction method execute.
@Override
public BindingResult execute(RequestBody body, Map<String, String> parameters, Headers headers, List<Attachment> attachments) {
BindingResult response;
try {
WaitForChangeRequest statusRequest = WaitForChangeRequest.convert(parameters);
StatusChange status = eventHandler.next(statusRequest.getSessionIdentifier());
response = new WaitForChangeResponse(status);
} catch (StatusException e) {
response = new BindingResult(BindingResultCode.WRONG_PARAMETER);
response.setResultMessage(e.getMessage());
} catch (Exception e) {
response = new BindingResult(BindingResultCode.INTERNAL_ERROR);
LOG.error(e.getMessage(), e);
}
return response;
}
use of org.openecard.ws.schema.StatusChange in project open-ecard by ecsec.
the class EventHandler method signalEvent.
@Override
public void signalEvent(EventType eventType, EventObject eventData) {
ConnectionHandleType connectionHandle = eventData.getHandle();
for (Map.Entry<String, LinkedBlockingQueue<StatusChange>> entry : eventQueues.entrySet()) {
try {
LinkedBlockingQueue<StatusChange> queue = entry.getValue();
StatusChange statusChange = new StatusChange();
statusChange.setAction(eventType.getEventTypeIdentifier());
statusChange.setConnectionHandle(connectionHandle);
queue.put(statusChange);
} catch (InterruptedException ignore) {
}
}
}
use of org.openecard.ws.schema.StatusChange in project open-ecard by ecsec.
the class EventHandler method next.
/**
* @param session
* @return a StatusChange containing the new status, or null if no eventQueue for the given session exists or if
* interrupted
*/
public StatusChange next(String session) {
// String session = statusChangeRequest.getSessionIdentifier();
StatusChange handle = null;
LinkedBlockingQueue<StatusChange> queue = eventQueues.get(session);
if (queue == null) {
LOG.error("No queue found for session {}", session);
return null;
}
do {
try {
timers.get(session).reschedule(deleteDelay);
handle = eventQueues.get(session).poll(30, TimeUnit.SECONDS);
LOG.debug("WaitForChange event pulled from event queue.");
} catch (InterruptedException ex) {
return null;
}
} while (handle == null);
return handle;
}
Aggregations