Skip to content

Commit

Permalink
refactor: don't use TimTransmorgrifier to buildEncodings
Browse files Browse the repository at this point in the history
Standardizing on the ObjectMapper provided in the app context will reduce variability and decrease risk of unintended differences in serdes behavior
  • Loading branch information
mcook42 committed Dec 27, 2024
1 parent 7a58bce commit fd715ab
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import us.dot.its.jpo.ode.context.AppContext;
import us.dot.its.jpo.ode.kafka.topics.Asn1CoderTopics;
import us.dot.its.jpo.ode.kafka.topics.JsonTopics;
import us.dot.its.jpo.ode.model.Asn1Encoding;
import us.dot.its.jpo.ode.model.Asn1Encoding.EncodingRule;
import us.dot.its.jpo.ode.model.OdeAsdPayload;
import us.dot.its.jpo.ode.model.OdeAsn1Data;
Expand All @@ -52,7 +53,6 @@
import us.dot.its.jpo.ode.traveler.TimTransmogrifier;
import us.dot.its.jpo.ode.uper.SupportedMessageType;
import us.dot.its.jpo.ode.util.CodecUtils;
import us.dot.its.jpo.ode.util.JsonUtils.JsonUtilsException;
import us.dot.its.jpo.ode.util.XmlUtils;
import us.dot.its.jpo.ode.util.XmlUtils.XmlUtilsException;

Expand Down Expand Up @@ -276,8 +276,7 @@ private String signTimWithExpiration(String encodedTIM, JSONObject metadataJson)
* @return a String containing the fully crafted ASD message in XML format. Returns null if the
* message could not be constructed due to exceptions.
*/
private String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) throws JsonProcessingException, ParseException,
JsonUtilsException {
private String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg) throws JsonProcessingException, ParseException {
SDW sdw = request.getSdw();
SNMP snmp = request.getSnmp();
DdsAdvisorySituationData asd;
Expand Down Expand Up @@ -339,11 +338,10 @@ private String packageSignedTimIntoAsd(ServiceRequest request, String signedMsg)
return outputXml;
}

private ArrayNode buildEncodings() throws JsonUtilsException {
private ArrayNode buildEncodings() throws JsonProcessingException {
ArrayNode encodings = mapper.createArrayNode();
encodings.add(TimTransmogrifier.buildEncodingNode(ADVISORY_SITUATION_DATA_STRING,
ADVISORY_SITUATION_DATA_STRING,
EncodingRule.UPER));
var encoding = new Asn1Encoding(ADVISORY_SITUATION_DATA_STRING, ADVISORY_SITUATION_DATA_STRING, EncodingRule.UPER);
encodings.add(mapper.readTree(mapper.writeValueAsString(encoding)));
return encodings;
}

Expand Down

0 comments on commit fd715ab

Please sign in to comment.