コード例 #1
0
 private static void setTopic(SubscribeEventType event, ResourceType resource) {
   String topic = null;
   try {
     LOG.debug("######## BEGIN TOPIC EXTRACTION ########");
     JAXBElement<TopicExpressionType> jbElement =
         (JAXBElement<TopicExpressionType>)
             event.getMessage().getSubscribe().getFilter().getAny().get(0);
     TopicExpressionType topicExpression = jbElement.getValue();
     topic = (String) topicExpression.getContent().get(0);
     LOG.debug("Topic extracted: " + topic);
   } catch (Throwable t) {
     LOG.error("Error extracting the topic: " + t.getMessage(), t);
   }
   if (NullChecker.isNotNullish(topic)) {
     if (LOG.isDebugEnabled()) {
       LOG.debug(
           "Adding topic ("
               + topic
               + ") as attribute ("
               + ATTRIBUTE_ID_TOPIC
               + ") and type: "
               + Constants.DataTypeString);
     }
     AttributeHelper attrHelper = new AttributeHelper();
     resource
         .getAttribute()
         .add(attrHelper.attributeFactory(ATTRIBUTE_ID_TOPIC, Constants.DataTypeString, topic));
   }
 }
コード例 #2
0
  public static CheckPolicyRequestType transformSubscribeToCheckPolicy(SubscribeEventType event) {
    CheckPolicyRequestType genericPolicyRequest = new CheckPolicyRequestType();
    RequestType request = new RequestType();
    if (InboundOutboundChecker.isInbound(event.getDirection())) {
      request.setAction(ActionHelper.actionFactory(ActionInValue));
    }
    if (InboundOutboundChecker.isOutbound(event.getDirection())) {
      request.setAction(ActionHelper.actionFactory(ActionOutValue));
    }

    SubjectHelper subjHelp = new SubjectHelper();
    SubjectType subject =
        subjHelp.subjectFactory(event.getSendingHomeCommunity(), event.getMessage().getAssertion());
    request.getSubject().add(subject);

    AdhocQueryRequest adhocReq = new AdhocQueryRequest();
    AdhocQueryType adhocQuery = null;
    adhocQuery = getAdhocQuery(event.getMessage().getSubscribe());
    adhocReq.setAdhocQuery(adhocQuery);
    String patId = AdhocQueryTransformHelper.extractPatientIdentifierId(adhocReq);
    String assignAuth =
        AdhocQueryTransformHelper.extractPatientIdentifierAssigningAuthority(adhocReq);

    ResourceType resource = new ResourceType();
    AttributeHelper attrHelper = new AttributeHelper();

    if (NullChecker.isNotNullish(assignAuth)) {
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientAssigningAuthorityAttributeId, Constants.DataTypeString, assignAuth));
    }

    if (NullChecker.isNotNullish(patId)) {
      String sStrippedPatientId = PatientIdFormatUtil.parsePatientId(patId);
      LOG.debug("transformSubscribeToCheckPolicy: sStrippedPatientId = " + sStrippedPatientId);
      resource
          .getAttribute()
          .add(
              attrHelper.attributeFactory(
                  PatientIdAttributeId, Constants.DataTypeString, sStrippedPatientId));
    }

    setTopic(event, resource);

    request.getResource().add(resource);

    AssertionHelper assertHelp = new AssertionHelper();
    assertHelp.appendAssertionDataToRequest(request, event.getMessage().getAssertion());

    genericPolicyRequest.setRequest(request);
    genericPolicyRequest.setAssertion(event.getMessage().getAssertion());
    return genericPolicyRequest;
  }