@Test public void testPackageSignedTimIntoAsd() { testAsn1CommandManager.packageSignedTimIntoAsd(injectableOdeTravelerInputData.getRequest(), "message"); }
public String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) { SDW sdw = request.getSdw(); SNMP snmp = request.getSnmp(); DdsAdvisorySituationData asd = null; byte sendToRsu = request.getRsus() != null ? DdsAdvisorySituationData.RSU : DdsAdvisorySituationData.NONE; byte distroType = (byte) (DdsAdvisorySituationData.IP | sendToRsu); String outputXml = null; try { if (null != snmp) { asd = new DdsAdvisorySituationData() .setAsdmDetails(snmp.getDeliverystart(), snmp.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } else { asd = new DdsAdvisorySituationData() .setAsdmDetails(sdw.getDeliverystart(), sdw.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } OdeMsgPayload payload = null; ObjectNode dataBodyObj = JsonUtils.newNode(); ObjectNode asdObj = JsonUtils.toObjectNode(asd.toJson()); ObjectNode admDetailsObj = (ObjectNode) asdObj.findValue("asdmDetails"); admDetailsObj.remove("advisoryMessage"); admDetailsObj.put("advisoryMessage", signedMsg); dataBodyObj.set(ADVISORY_SITUATION_DATA_STRING, asdObj); payload = new OdeAsdPayload(asd); ObjectNode payloadObj = JsonUtils.toObjectNode(payload.toJson()); payloadObj.set(AppContext.DATA_STRING, dataBodyObj); OdeMsgMetadata metadata = new OdeMsgMetadata(payload); ObjectNode metaObject = JsonUtils.toObjectNode(metadata.toJson()); ObjectNode requestObj = JsonUtils.toObjectNode(JsonUtils.toJson(request, false)); requestObj.remove("tim"); metaObject.set("request", requestObj); ArrayNode encodings = buildEncodings(); ObjectNode enc = XmlUtils.createEmbeddedJsonArrayForXmlConversion(AppContext.ENCODINGS_STRING, encodings); metaObject.set(AppContext.ENCODINGS_STRING, enc); ObjectNode message = JsonUtils.newNode(); message.set(AppContext.METADATA_STRING, metaObject); message.set(AppContext.PAYLOAD_STRING, payloadObj); ObjectNode root = JsonUtils.newNode(); root.set(AppContext.ODE_ASN1_DATA, message); outputXml = XmlUtils.toXmlStatic(root); outputXml = outputXml.replace("<ObjectNode>", ""); outputXml = outputXml.replace("</ObjectNode>", ""); } catch (ParseException | JsonUtilsException | XmlUtilsException e) { logger.error("Parsing exception thrown while populating ASD structure: {}", e); } logger.debug("Fully crafted ASD to be encoded: {}", outputXml); return outputXml; }
Asn1CommandManager { public String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) { SDW sdw = request.getSdw(); SNMP snmp = request.getSnmp(); DdsAdvisorySituationData asd = null; byte sendToRsu = request.getRsus() != null ? DdsAdvisorySituationData.RSU : DdsAdvisorySituationData.NONE; byte distroType = (byte) (DdsAdvisorySituationData.IP | sendToRsu); String outputXml = null; try { if (null != snmp) { asd = new DdsAdvisorySituationData() .setAsdmDetails(snmp.getDeliverystart(), snmp.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } else { asd = new DdsAdvisorySituationData() .setAsdmDetails(sdw.getDeliverystart(), sdw.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } OdeMsgPayload payload = null; ObjectNode dataBodyObj = JsonUtils.newNode(); ObjectNode asdObj = JsonUtils.toObjectNode(asd.toJson()); ObjectNode admDetailsObj = (ObjectNode) asdObj.findValue("asdmDetails"); admDetailsObj.remove("advisoryMessage"); admDetailsObj.put("advisoryMessage", signedMsg); dataBodyObj.set(ADVISORY_SITUATION_DATA_STRING, asdObj); payload = new OdeAsdPayload(asd); ObjectNode payloadObj = JsonUtils.toObjectNode(payload.toJson()); payloadObj.set(AppContext.DATA_STRING, dataBodyObj); OdeMsgMetadata metadata = new OdeMsgMetadata(payload); ObjectNode metaObject = JsonUtils.toObjectNode(metadata.toJson()); ObjectNode requestObj = JsonUtils.toObjectNode(JsonUtils.toJson(request, false)); requestObj.remove("tim"); metaObject.set("request", requestObj); ArrayNode encodings = buildEncodings(); ObjectNode enc = XmlUtils.createEmbeddedJsonArrayForXmlConversion(AppContext.ENCODINGS_STRING, encodings); metaObject.set(AppContext.ENCODINGS_STRING, enc); ObjectNode message = JsonUtils.newNode(); message.set(AppContext.METADATA_STRING, metaObject); message.set(AppContext.PAYLOAD_STRING, payloadObj); ObjectNode root = JsonUtils.newNode(); root.set(AppContext.ODE_ASN1_DATA, message); outputXml = XmlUtils.toXmlStatic(root); outputXml = outputXml.replace("<ObjectNode>", ""); outputXml = outputXml.replace("</ObjectNode>", ""); } catch (ParseException | JsonUtilsException | XmlUtilsException e) { logger.error("Parsing exception thrown while populating ASD structure: {}", e); } logger.debug("Fully crafted ASD to be encoded: {}", outputXml); return outputXml; } }
Asn1CommandManager { public String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) { SDW sdw = request.getSdw(); SNMP snmp = request.getSnmp(); DdsAdvisorySituationData asd = null; byte sendToRsu = request.getRsus() != null ? DdsAdvisorySituationData.RSU : DdsAdvisorySituationData.NONE; byte distroType = (byte) (DdsAdvisorySituationData.IP | sendToRsu); String outputXml = null; try { if (null != snmp) { asd = new DdsAdvisorySituationData() .setAsdmDetails(snmp.getDeliverystart(), snmp.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } else { asd = new DdsAdvisorySituationData() .setAsdmDetails(sdw.getDeliverystart(), sdw.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } OdeMsgPayload payload = null; ObjectNode dataBodyObj = JsonUtils.newNode(); ObjectNode asdObj = JsonUtils.toObjectNode(asd.toJson()); ObjectNode admDetailsObj = (ObjectNode) asdObj.findValue("asdmDetails"); admDetailsObj.remove("advisoryMessage"); admDetailsObj.put("advisoryMessage", signedMsg); dataBodyObj.set(ADVISORY_SITUATION_DATA_STRING, asdObj); payload = new OdeAsdPayload(asd); ObjectNode payloadObj = JsonUtils.toObjectNode(payload.toJson()); payloadObj.set(AppContext.DATA_STRING, dataBodyObj); OdeMsgMetadata metadata = new OdeMsgMetadata(payload); ObjectNode metaObject = JsonUtils.toObjectNode(metadata.toJson()); ObjectNode requestObj = JsonUtils.toObjectNode(JsonUtils.toJson(request, false)); requestObj.remove("tim"); metaObject.set("request", requestObj); ArrayNode encodings = buildEncodings(); ObjectNode enc = XmlUtils.createEmbeddedJsonArrayForXmlConversion(AppContext.ENCODINGS_STRING, encodings); metaObject.set(AppContext.ENCODINGS_STRING, enc); ObjectNode message = JsonUtils.newNode(); message.set(AppContext.METADATA_STRING, metaObject); message.set(AppContext.PAYLOAD_STRING, payloadObj); ObjectNode root = JsonUtils.newNode(); root.set(AppContext.ODE_ASN1_DATA, message); outputXml = XmlUtils.toXmlStatic(root); outputXml = outputXml.replace("<ObjectNode>", ""); outputXml = outputXml.replace("</ObjectNode>", ""); } catch (ParseException | JsonUtilsException | XmlUtilsException e) { logger.error("Parsing exception thrown while populating ASD structure: {}", e); } logger.debug("Fully crafted ASD to be encoded: {}", outputXml); return outputXml; } Asn1CommandManager(OdeProperties odeProperties); }
Asn1CommandManager { public String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) { SDW sdw = request.getSdw(); SNMP snmp = request.getSnmp(); DdsAdvisorySituationData asd = null; byte sendToRsu = request.getRsus() != null ? DdsAdvisorySituationData.RSU : DdsAdvisorySituationData.NONE; byte distroType = (byte) (DdsAdvisorySituationData.IP | sendToRsu); String outputXml = null; try { if (null != snmp) { asd = new DdsAdvisorySituationData() .setAsdmDetails(snmp.getDeliverystart(), snmp.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } else { asd = new DdsAdvisorySituationData() .setAsdmDetails(sdw.getDeliverystart(), sdw.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } OdeMsgPayload payload = null; ObjectNode dataBodyObj = JsonUtils.newNode(); ObjectNode asdObj = JsonUtils.toObjectNode(asd.toJson()); ObjectNode admDetailsObj = (ObjectNode) asdObj.findValue("asdmDetails"); admDetailsObj.remove("advisoryMessage"); admDetailsObj.put("advisoryMessage", signedMsg); dataBodyObj.set(ADVISORY_SITUATION_DATA_STRING, asdObj); payload = new OdeAsdPayload(asd); ObjectNode payloadObj = JsonUtils.toObjectNode(payload.toJson()); payloadObj.set(AppContext.DATA_STRING, dataBodyObj); OdeMsgMetadata metadata = new OdeMsgMetadata(payload); ObjectNode metaObject = JsonUtils.toObjectNode(metadata.toJson()); ObjectNode requestObj = JsonUtils.toObjectNode(JsonUtils.toJson(request, false)); requestObj.remove("tim"); metaObject.set("request", requestObj); ArrayNode encodings = buildEncodings(); ObjectNode enc = XmlUtils.createEmbeddedJsonArrayForXmlConversion(AppContext.ENCODINGS_STRING, encodings); metaObject.set(AppContext.ENCODINGS_STRING, enc); ObjectNode message = JsonUtils.newNode(); message.set(AppContext.METADATA_STRING, metaObject); message.set(AppContext.PAYLOAD_STRING, payloadObj); ObjectNode root = JsonUtils.newNode(); root.set(AppContext.ODE_ASN1_DATA, message); outputXml = XmlUtils.toXmlStatic(root); outputXml = outputXml.replace("<ObjectNode>", ""); outputXml = outputXml.replace("</ObjectNode>", ""); } catch (ParseException | JsonUtilsException | XmlUtilsException e) { logger.error("Parsing exception thrown while populating ASD structure: {}", e); } logger.debug("Fully crafted ASD to be encoded: {}", outputXml); return outputXml; } Asn1CommandManager(OdeProperties odeProperties); void depositToSdw(String asdBytes); Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg); String sendForSignature(String message); String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg); static ArrayNode buildEncodings(); String getDepositTopic(); void setDepositTopic(String depositTopic); }
Asn1CommandManager { public String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) { SDW sdw = request.getSdw(); SNMP snmp = request.getSnmp(); DdsAdvisorySituationData asd = null; byte sendToRsu = request.getRsus() != null ? DdsAdvisorySituationData.RSU : DdsAdvisorySituationData.NONE; byte distroType = (byte) (DdsAdvisorySituationData.IP | sendToRsu); String outputXml = null; try { if (null != snmp) { asd = new DdsAdvisorySituationData() .setAsdmDetails(snmp.getDeliverystart(), snmp.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } else { asd = new DdsAdvisorySituationData() .setAsdmDetails(sdw.getDeliverystart(), sdw.getDeliverystop(), distroType, null) .setServiceRegion(GeoRegionBuilder.ddsGeoRegion(sdw.getServiceRegion())).setTimeToLive(sdw.getTtl()) .setGroupID(sdw.getGroupID()).setRecordID(sdw.getRecordId()); } OdeMsgPayload payload = null; ObjectNode dataBodyObj = JsonUtils.newNode(); ObjectNode asdObj = JsonUtils.toObjectNode(asd.toJson()); ObjectNode admDetailsObj = (ObjectNode) asdObj.findValue("asdmDetails"); admDetailsObj.remove("advisoryMessage"); admDetailsObj.put("advisoryMessage", signedMsg); dataBodyObj.set(ADVISORY_SITUATION_DATA_STRING, asdObj); payload = new OdeAsdPayload(asd); ObjectNode payloadObj = JsonUtils.toObjectNode(payload.toJson()); payloadObj.set(AppContext.DATA_STRING, dataBodyObj); OdeMsgMetadata metadata = new OdeMsgMetadata(payload); ObjectNode metaObject = JsonUtils.toObjectNode(metadata.toJson()); ObjectNode requestObj = JsonUtils.toObjectNode(JsonUtils.toJson(request, false)); requestObj.remove("tim"); metaObject.set("request", requestObj); ArrayNode encodings = buildEncodings(); ObjectNode enc = XmlUtils.createEmbeddedJsonArrayForXmlConversion(AppContext.ENCODINGS_STRING, encodings); metaObject.set(AppContext.ENCODINGS_STRING, enc); ObjectNode message = JsonUtils.newNode(); message.set(AppContext.METADATA_STRING, metaObject); message.set(AppContext.PAYLOAD_STRING, payloadObj); ObjectNode root = JsonUtils.newNode(); root.set(AppContext.ODE_ASN1_DATA, message); outputXml = XmlUtils.toXmlStatic(root); outputXml = outputXml.replace("<ObjectNode>", ""); outputXml = outputXml.replace("</ObjectNode>", ""); } catch (ParseException | JsonUtilsException | XmlUtilsException e) { logger.error("Parsing exception thrown while populating ASD structure: {}", e); } logger.debug("Fully crafted ASD to be encoded: {}", outputXml); return outputXml; } Asn1CommandManager(OdeProperties odeProperties); void depositToSdw(String asdBytes); Map<String, String> sendToRsus(ServiceRequest request, String encodedMsg); String sendForSignature(String message); String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg); static ArrayNode buildEncodings(); String getDepositTopic(); void setDepositTopic(String depositTopic); static final String ADVISORY_SITUATION_DATA_STRING; }