@Override public void handleMessage(Message theMessage) throws MessagingException { if (!(theMessage.getPayload() instanceof ResourceDeliveryMessage)) { ourLog.warn("Unexpected payload type: {}", theMessage.getPayload()); return; } String subscriptionId = "(unknown?)"; try { ResourceDeliveryMessage msg = (ResourceDeliveryMessage) theMessage.getPayload(); subscriptionId = msg.getSubscription().getIdElement(myFhirContext).getValue(); ActiveSubscription updatedSubscription = mySubscriptionRegistry.get(msg.getSubscription().getIdElement(myFhirContext).getIdPart()); if (updatedSubscription != null) { msg.setSubscription(updatedSubscription.getSubscription()); } handleMessage(msg); } catch (Exception e) { String msg = "Failure handling subscription payload for subscription: " + subscriptionId; ourLog.error(msg, e); throw new MessagingException(theMessage, msg, e); } }
private IIdType bindSimple(WebSocketSession theSession, String theBindString) { IdType id = new IdType(theBindString); if (!id.hasIdPart() || !id.isIdPartValid()) { try { String message = "Invalid bind request - No ID included"; ourLog.warn(message); theSession.close(new CloseStatus(CloseStatus.PROTOCOL_ERROR.getCode(), message)); } catch (IOException e) { handleFailure(e); } return null; } if (id.hasResourceType() == false) { id = id.withResourceType("Subscription"); } try { ActiveSubscription activeSubscription = mySubscriptionRegistry.get(id.getIdPart()); myState = new BoundStaticSubscipriptionState( theSession, activeSubscription); } catch (ResourceNotFoundException e) { try { String message = "Invalid bind request - Unknown subscription: " + id.getValue(); ourLog.warn(message); theSession.close(new CloseStatus(CloseStatus.PROTOCOL_ERROR.getCode(), message)); } catch (IOException e1) { handleFailure(e); } return null; } return id; }