protected DataMapping findDataFlow(
      Interaction interaction, String parameterId, Direction direction)
      throws WebApplicationException {
    DataMapping ret = null;
    ApplicationContext definition = interaction.getDefinition();

    if ((null != definition) && !isEmpty(parameterId)) {
      AccessPoint outParam = findParameterDefinition(interaction, parameterId, direction);
      if (null == outParam) {
        if (InteractionDataFlowUtils.supportDataMappingIds()) {
          ret = definition.getDataMapping(direction, parameterId);
        }
      } else {
        List<DataMapping> allDataMappings = definition.getAllDataMappings();
        for (DataMapping dataMapping : allDataMappings) {
          if (outParam.equals(dataMapping.getApplicationAccessPoint())) {
            ret = dataMapping;
            break;
          }
        }
      }
    }

    if (ret == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }

    return ret;
  }
  protected AccessPoint findParameterDefinition(
      Interaction interaction, String parameterId, Direction direction)
      throws WebApplicationException {
    ApplicationContext definition = interaction.getDefinition();

    if ((null != definition) && !isEmpty(parameterId)) {
      for (AccessPoint ap : (List<AccessPoint>) definition.getAllAccessPoints()) {
        if ((direction == ap.getDirection()) && parameterId.equals(ap.getId())) {
          return ap;
        }
      }
    }

    return null;
  }