diff --git a/Dockerfile b/Dockerfile index 0b33fd4a8..0a992626d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM maven:3.5.4-jdk-8-alpine as builder +FROM maven:3.8.1-openjdk-11 as builder MAINTAINER 583114@bah.com WORKDIR /home @@ -16,7 +16,7 @@ COPY ./jpo-ode-svcs/src ./jpo-ode-svcs/src RUN mvn clean package -DskipTests -FROM openjdk:8u171-jre-alpine +FROM openjdk:11-jre-slim WORKDIR /home diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 424ad67d3..2bfdc7eb4 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,5 +1,7 @@ ## ODE Release Notes ## ----------------------- +NOTE: For release details for latest releases, please see [release notes](https://github.com/usdot-jpo-ode/jpo-ode/releases) + ### Release 1.0.8 (May 24, 2019) - Integrated odevalidator v0.0.6 - Updated test-harness (see [release notes](./qa/test-harness/README.md#release-history)) diff --git a/data/wydotLogRecords.h b/data/wydotLogRecords.h index ce92357f1..dd5b57fb1 100644 --- a/data/wydotLogRecords.h +++ b/data/wydotLogRecords.h @@ -62,8 +62,8 @@ typedef struct _location { } __attribute__((__packed__)) location; typedef struct _intersection { + int16_t intersectionId; int8_t intersectionStatus; - int32_t intersectionId; } __attribute__((__packed__)) intersection; typedef struct _driverAlertRecord { @@ -90,6 +90,7 @@ typedef struct _receivedMsgRecord { uint32_t utcTimeInSec; uint16_t msec; int8_t verificationStatus; + int8_t is_cert_present; /*ieee 1609 (acceptable values 0 = no,1 =yes)*/ uint16_t length; /* payload of length size*/ } __attribute__((__packed__)) receivedMsgRecord; diff --git a/docker-compose.yml b/docker-compose.yml index 9d598b4bf..ddbafca2e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: KAFKA_ADVERTISED_HOST_NAME: ${DOCKER_HOST_IP} KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true" - KAFKA_CREATE_TOPICS: "topic.OdeBsmPojo:1:1,topic.OdeBsmJson:1:1,topic.FilteredOdeBsmJson:1:1,topic.OdeTimJson:1:1,topic.OdeTimBroadcastJson:1:1,topic.J2735TimBroadcastJson:1:1,topic.OdeDriverAlertJson:1:1,topic.Asn1DecoderInput:1:1,topic.Asn1DecoderOutput:1:1,topic.Asn1EncoderInput:1:1,topic.Asn1EncoderOutput:1:1,topic.SDWDepositorInput:1:1,topic.OdeTIMCertExpirationTimeJson:1:1,topic.OdeRawEncodedMessageJson:1:1" + KAFKA_CREATE_TOPICS: "topic.OdeBsmPojo:1:1,topic.OdeSpatTxPojo:1:1,topic.OdeSpatPojo:1:1,topic.OdeSpatJson:1:1,topic.FilteredOdeSpatJson:1:1,topic.OdeSpatRxJson:1:1,topic.OdeSpatRxPojo:1:1,topic.OdeBsmJson:1:1,topic.FilteredOdeBsmJson:1:1,topic.OdeTimJson:1:1,topic.OdeTimBroadcastJson:1:1,topic.J2735TimBroadcastJson:1:1,topic.OdeDriverAlertJson:1:1,topic.Asn1DecoderInput:1:1,topic.Asn1DecoderOutput:1:1,topic.Asn1EncoderInput:1:1,topic.Asn1EncoderOutput:1:1,topic.SDWDepositorInput:1:1,topic.OdeTIMCertExpirationTimeJson:1:1,topic.OdeRawEncodedBSMJson:1:1,topic.OdeRawEncodedSPATJson:1:1,topic.OdeRawEncodedTIMJson:1:1" KAFKA_DELETE_TOPIC_ENABLED: "true" KAFKA_CLEANUP_POLICY: "delete" # delete old logs KAFKA_LOG_RETENTION_HOURS: 2 @@ -150,6 +150,7 @@ services: API_ENDPOINT: ${CVPEP_BSM_API_ENDPOINT} HEADER_ACCEPT: ${CVPEP_BSM_HEADER_ACCEPT} HEADER_X_API_KEY: ${CVPEP_BSM_HEADER_X_API_KEY} + DEPOSIT_GROUP: ${CVPEP_BSM_GROUP} depends_on: - kafka logging: @@ -172,6 +173,7 @@ services: API_ENDPOINT: ${RDE_BSM_API_ENDPOINT} HEADER_ACCEPT: ${RDE_BSM_HEADER_ACCEPT} HEADER_X_API_KEY: ${RDE_BSM_HEADER_X_API_KEY} + DEPOSIT_GROUP: ${RDE_BSM_GROUP} depends_on: - kafka logging: @@ -194,6 +196,7 @@ services: API_ENDPOINT: ${CVPEP_BSM_API_ENDPOINT} HEADER_ACCEPT: ${CVPEP_BSM_HEADER_ACCEPT} HEADER_X_API_KEY: ${CVPEP_BSM_HEADER_X_API_KEY} + DEPOSIT_GROUP: ${CVPEP_TIM_GROUP} depends_on: - kafka logging: @@ -216,6 +219,7 @@ services: API_ENDPOINT: ${RDE_TIM_API_ENDPOINT} HEADER_ACCEPT: ${RDE_TIM_HEADER_ACCEPT} HEADER_X_API_KEY: ${RDE_TIM_HEADER_X_API_KEY} + DEPOSIT_GROUP: ${RDE_TIM_GROUP} depends_on: - kafka logging: diff --git a/docs/Architecture.md b/docs/Architecture.md index fdf52c9f6..2ac9b4d86 100644 --- a/docs/Architecture.md +++ b/docs/Architecture.md @@ -12,7 +12,7 @@ Booz Allen Hamilton\ 8283 Greensboro Drive\ McLean, VA 22102 -_Last updated February 7, 2019_ +_Last updated June 11, 2021_ # Contents @@ -22,7 +22,7 @@ _Last updated February 7, 2019_ - [3 - System Overview](#system-overview) - [3.1 - ODE Technology Stack](#ode-technology-stack) - [3.2 - Producer Mechanisms](#producer-mechanisms) - - [3.3 - Comsumer Mechanisms](#comsumer-mechanisms) + - [3.3 - Consumer Mechanisms](#consumer-mechanisms) - [3.4 - ODE Management Console](#ode-management-console) - [4 - Architecture Pattern](#architecture-pattern) - [4.1 - Pattern Description](#pattern-description) @@ -176,7 +176,7 @@ Notation (JSON), environmental and various other system logs. -### 3.3 - Comsumer Mechanisms +### 3.3 - Consumer Mechanisms The JPO-ODE is designed to support the following mechanisms for outputting decoded BSM, Map and Signal Phase and Timing (SPaT) data as @@ -249,7 +249,7 @@ The micro-services pattern consists of three major concepts: 3. *Distributed architecture*: All the components within the architecture are fully decoupled from one other and accessed through - a messaging service. This concept is what allows mircoservices + a messaging service. This concept is what allows microservices architecture pattern achieve some of its superior scalability and deployment characteristics. diff --git a/jpo-ode-common/pom.xml b/jpo-ode-common/pom.xml index ef8a7614a..bb0278405 100644 --- a/jpo-ode-common/pom.xml +++ b/jpo-ode-common/pom.xml @@ -26,6 +26,7 @@ org.json json + 20210307 com.google.code.gson @@ -42,7 +43,6 @@ javax.xml.bind jaxb-api - 2.1 javax.websocket diff --git a/jpo-ode-core/pom.xml b/jpo-ode-core/pom.xml index a65be4c62..d0ae7e3ee 100644 --- a/jpo-ode-core/pom.xml +++ b/jpo-ode-core/pom.xml @@ -54,7 +54,6 @@ org.apache.kafka kafka-clients - 0.10.1.0 org.slf4j @@ -76,7 +75,6 @@ org.apache.kafka kafka-streams - 0.10.1.0 org.slf4j diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/context/AppContext.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/context/AppContext.java index fb3a35c3d..d41e3ab19 100644 --- a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/context/AppContext.java +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/context/AppContext.java @@ -32,6 +32,7 @@ public class AppContext { public static final String ODE_ASN1_DATA = "OdeAsn1Data"; public static final String DATA_STRING = "data"; public static final String ENCODINGS_STRING = "encodings"; + public static final String RECEIVEDMSGDETAILS_STRING = "receivedMessageDetails"; public static final String PAYLOAD_TYPE_STRING = "payloadType"; public static final String DATA_TYPE_STRING = "dataType"; public static final String SERIAL_ID_STRING = "serialId"; diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeBsmMetadata.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeBsmMetadata.java index 1d5e83a42..2fe6dec92 100644 --- a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeBsmMetadata.java +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeBsmMetadata.java @@ -19,6 +19,8 @@ public class OdeBsmMetadata extends OdeLogMetadata { private static final long serialVersionUID = -8601265839394150140L; + private String originIp; + public enum BsmSource { EV, RV, unknown } @@ -44,4 +46,12 @@ public BsmSource getBsmSource() { public void setBsmSource(BsmSource bsmSource) { this.bsmSource = bsmSource; } + + public String getOriginIp() { + return originIp; + } + + public void setOriginIp(String originIp) { + this.originIp = originIp; + } } diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatData.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatData.java new file mode 100644 index 000000000..21af1ea41 --- /dev/null +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatData.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2018 572682 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + ******************************************************************************/ +package us.dot.its.jpo.ode.model; + +public class OdeSpatData extends OdeData { + + private static final long serialVersionUID = 4944935387116447760L; + + public OdeSpatData() { + super(); + } + + public OdeSpatData(OdeMsgMetadata metadata, OdeMsgPayload payload) { + super(metadata, payload); + } + +} diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatMetadata.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatMetadata.java index a9f3f04b3..9d8c7af57 100644 --- a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatMetadata.java +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatMetadata.java @@ -11,6 +11,15 @@ public enum SpatSource { } private SpatSource spatSource; + private boolean isCertPresent; + + public boolean isCertPresent() { + return isCertPresent; + } + + public void setCertPresent(boolean isCertPresent) { + this.isCertPresent = isCertPresent; + } public OdeSpatMetadata() { super(); diff --git a/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatPayload.java b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatPayload.java new file mode 100644 index 000000000..eb6b8331d --- /dev/null +++ b/jpo-ode-core/src/main/java/us/dot/its/jpo/ode/model/OdeSpatPayload.java @@ -0,0 +1,44 @@ +package us.dot.its.jpo.ode.model; + +import us.dot.its.jpo.ode.plugin.j2735.J2735SPAT; + +/******************************************************************************* + * Copyright 2018 572682 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + ******************************************************************************/ + +public class OdeSpatPayload extends OdeMsgPayload { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public OdeSpatPayload() { + this(new J2735SPAT()); + } + + public OdeSpatPayload(J2735SPAT spat) { + super(spat); + this.setData(spat); + } + + public J2735SPAT getSpat() { + return (J2735SPAT) getData(); + } + + public void setBsm(J2735SPAT spat) { + setData(spat); + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeed.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeed.java new file mode 100644 index 000000000..f006846a2 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeed.java @@ -0,0 +1,54 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735AdvisorySpeed extends Asn1Object { + private static final long serialVersionUID = 1L; + private J2735AdvisorySpeedType type; + private Integer speed; + private J2735SpeedConfidence confidence; + private Integer distance; + private Integer classId; + + // regional + public J2735AdvisorySpeedType getType() { + return type; + } + + public void setType(J2735AdvisorySpeedType type) { + this.type = type; + } + + public Integer getSpeed() { + return speed; + } + + public void setSpeed(Integer speed) { + this.speed = speed; + } + + public J2735SpeedConfidence getConfidence() { + return confidence; + } + + public void setConfidence(J2735SpeedConfidence confidence) { + this.confidence = confidence; + } + + public Integer getDistance() { + return distance; + } + + public void setDistance(Integer distance) { + this.distance = distance; + } + + public Integer getClassId() { + return classId; + } + + public void setClassId(Integer classId) { + this.classId = classId; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeedList.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeedList.java new file mode 100644 index 000000000..1a8a3e458 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeedList.java @@ -0,0 +1,19 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import java.util.ArrayList; +import java.util.List; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735AdvisorySpeedList extends Asn1Object { + private static final long serialVersionUID = 1L; + private List advisorySpeedList = new ArrayList<>(); + + public List getAdvisorySpeedList() { + return advisorySpeedList; + } + + public void setAdvisorySpeedList(List advisorySpeedList) { + this.advisorySpeedList = advisorySpeedList; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeedType.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeedType.java new file mode 100644 index 000000000..92f5ced58 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735AdvisorySpeedType.java @@ -0,0 +1,8 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +public enum J2735AdvisorySpeedType { + NONE, + GREENWAVE, + ECODRIVE, + TRANSIT +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735ConnectionManueverAssist.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735ConnectionManueverAssist.java new file mode 100644 index 000000000..aba93dccc --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735ConnectionManueverAssist.java @@ -0,0 +1,53 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735ConnectionManueverAssist extends Asn1Object { + private static final long serialVersionUID = 1L; + private Integer connectionID; + private Integer queueLength; + private Integer availableStorageLength; + private boolean waitOnStop; + private boolean pedBicycleDetect; + + public Integer getConnectionID() { + return connectionID; + } + + public void setConnectionID(Integer connectionID) { + this.connectionID = connectionID; + } + + public Integer getQueueLength() { + return queueLength; + } + + public void setQueueLength(Integer queueLength) { + this.queueLength = queueLength; + } + + public Integer getAvailableStorageLength() { + return availableStorageLength; + } + + public void setAvailableStorageLength(Integer availableStorageLength) { + this.availableStorageLength = availableStorageLength; + } + + public boolean getWaitOnStop() { + return waitOnStop; + } + + public void setWaitOnStop(boolean waitOnStop) { + this.waitOnStop = waitOnStop; + } + + public boolean getPedBicycleDetect() { + return pedBicycleDetect; + } + + public void setPedBicycleDetect(boolean pedBicycleDetect) { + this.pedBicycleDetect = pedBicycleDetect; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735DSRCmsgID.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735DSRCmsgID.java index 7680b5207..71a23e750 100644 --- a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735DSRCmsgID.java +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735DSRCmsgID.java @@ -20,7 +20,7 @@ public enum J2735DSRCmsgID { - BasicSafetyMessage(20), TravelerInformation(31); + BasicSafetyMessage(20), TravelerInformation(31), SPATMessage(19); private int msgID; diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735EnableLaneList.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735EnableLaneList.java new file mode 100644 index 000000000..3484ba3f6 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735EnableLaneList.java @@ -0,0 +1,23 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735EnableLaneList extends Asn1Object { + private static final long serialVersionUID = 1L; + @JacksonXmlElementWrapper(useWrapping = false) + private List enabledLaneList = new ArrayList<>(); + + public List getEnabledLaneList() { + return enabledLaneList; + } + + public void setEnabledLaneList(List enabledLaneList) { + this.enabledLaneList = enabledLaneList; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionReferenceID.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionReferenceID.java new file mode 100644 index 000000000..8f566f7b4 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionReferenceID.java @@ -0,0 +1,30 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735IntersectionReferenceID extends Asn1Object { + + /** + * + */ + private static final long serialVersionUID = 1L; + private Integer region; + private Integer id; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getRegion() { + return region; + } + + public void setRegion(Integer region) { + this.region = region; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionState.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionState.java new file mode 100644 index 000000000..0c7af21b2 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionState.java @@ -0,0 +1,93 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735IntersectionState extends Asn1Object { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String name; + private J2735IntersectionReferenceID id; + private Integer revision; + private J2735IntersectionStatusObject status; + private Integer moy; + private Integer timeStamp; + private J2735EnableLaneList enabledLanes; + private J2735MovementList states; + private J2735ManeuverAssistList maneuverAssistList; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public J2735IntersectionReferenceID getId() { + return id; + } + + public void setId(J2735IntersectionReferenceID id) { + this.id = id; + } + + public Integer getRevision() { + return revision; + } + + public void setRevision(Integer revision) { + this.revision = revision; + } + + public J2735IntersectionStatusObject getStatus() { + return status; + } + + public void setStatus(J2735IntersectionStatusObject status) { + this.status = status; + } + + public Integer getMoy() { + return moy; + } + + public void setMoy(Integer moy) { + this.moy = moy; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public J2735EnableLaneList getEnabledLanes() { + return enabledLanes; + } + + public void setEnabledLanes(J2735EnableLaneList enabledLanes) { + this.enabledLanes = enabledLanes; + } + + public J2735MovementList getStates() { + return states; + } + + public void setStates(J2735MovementList states) { + this.states = states; + } + + public J2735ManeuverAssistList getManeuverAssistList() { + return maneuverAssistList; + } + + public void setManeuverAssistList(J2735ManeuverAssistList maneuverAssistList) { + this.maneuverAssistList = maneuverAssistList; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionStateList.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionStateList.java new file mode 100644 index 000000000..81430fb91 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionStateList.java @@ -0,0 +1,26 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735IntersectionStateList extends Asn1Object { + + /** + * + */ + private static final long serialVersionUID = 1L; + @JacksonXmlElementWrapper(useWrapping = false) + private List intersectionStatelist = new ArrayList<>(); + + public List getIntersectionStatelist() { + return intersectionStatelist; + } + + public void setIntersectionStatelist(List intersectionStatelist) { + this.intersectionStatelist = intersectionStatelist; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionStatusObject.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionStatusObject.java new file mode 100644 index 000000000..4e4c2957d --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735IntersectionStatusObject.java @@ -0,0 +1,19 @@ +package us.dot.its.jpo.ode.plugin.j2735; + + +public enum J2735IntersectionStatusObject { + MANUALCONTROLISENABLED, + STOPTIMEISACTIVATED, + FAILUREFLASH, + PREEMPTISACTIVE, + SIGNALPRIORITYISACTIVE, + FIXEDTIMEOPERATION, + TRAFFICDEPENDENTOPERATION, + STANDBYOPERATION, + FAILUREMODE, + OFF, + RECENTMAPMESSAGEUPDATE, + RECENTCHANGEINMAPASSIGNEDLANESIDSUSED, + NOVALIDMAPISAVAILABLEATTHISTIME, + NOVALIDSPATISAVAILABLEATTHISTIME +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735ManeuverAssistList.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735ManeuverAssistList.java new file mode 100644 index 000000000..2ac74d145 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735ManeuverAssistList.java @@ -0,0 +1,23 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735ManeuverAssistList extends Asn1Object { + private static final long serialVersionUID = 1L; + @JacksonXmlElementWrapper(useWrapping = false) + private List maneuverAssistList = new ArrayList<>(); + + public List getManeuverAssistList() { + return maneuverAssistList; + } + + public void setManeuverAssistList(List maneuverAssistList) { + this.maneuverAssistList = maneuverAssistList; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementEvent.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementEvent.java new file mode 100644 index 000000000..b90290d41 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementEvent.java @@ -0,0 +1,36 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735MovementEvent extends Asn1Object { + private static final long serialVersionUID = 1L; + private J2735MovementPhaseState eventState; + private J2735TimeChangeDetails timing; + private J2735AdvisorySpeedList speeds; + + public J2735MovementPhaseState getEventState() { + return eventState; + } + + public void setEventState(J2735MovementPhaseState eventState) { + this.eventState = eventState; + } + + public J2735TimeChangeDetails getTiming() { + return timing; + } + + public void setTiming(J2735TimeChangeDetails timing) { + this.timing = timing; + } + + public J2735AdvisorySpeedList getSpeeds() { + return speeds; + } + + public void setSpeeds(J2735AdvisorySpeedList speeds) { + this.speeds = speeds; + } + + // regional +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementEventList.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementEventList.java new file mode 100644 index 000000000..ed4da8fda --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementEventList.java @@ -0,0 +1,19 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import java.util.ArrayList; +import java.util.List; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735MovementEventList extends Asn1Object { + private static final long serialVersionUID = 1L; + private List movementEventList = new ArrayList<>(); + + public List getMovementEventList() { + return movementEventList; + } + + public void setMovementEventList(List movementEventList) { + this.movementEventList = movementEventList; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementList.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementList.java new file mode 100644 index 000000000..0847a065c --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementList.java @@ -0,0 +1,22 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735MovementList extends Asn1Object { + private static final long serialVersionUID = 1L; + @JacksonXmlElementWrapper(useWrapping = false) + private List movementList = new ArrayList<>(); + + public List getMovementList() { + return movementList; + } + + public void setMovementList(List movementList) { + this.movementList = movementList; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementPhaseState.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementPhaseState.java new file mode 100644 index 000000000..cccbf0c25 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementPhaseState.java @@ -0,0 +1,15 @@ +package us.dot.its.jpo.ode.plugin.j2735; + + +public enum J2735MovementPhaseState { + UNAVAILABLE, + DARK, + STOP_THEN_PROCEED, + STOP_AND_REMAIN, + PRE_MOVEMENT, + PERMISSIVE_MOVEMENT_ALLOWED, + PROTECTED_MOVEMENT_ALLOWED, + PERMISSIVE_CLEARANCE, + PROTECTED_CLEARANCE, + CAUTION_CONFLICTING_TRAFFIC +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementState.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementState.java new file mode 100644 index 000000000..ad2caf6cb --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735MovementState.java @@ -0,0 +1,46 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735MovementState extends Asn1Object { + private static final long serialVersionUID = 1L; + private String movementName; + private Integer signalGroup; + private J2735MovementEventList state_time_speed; + private J2735ManeuverAssistList maneuverAssistList; + + public String getMovementName() { + return movementName; + } + + public void setMovementName(String movementName) { + this.movementName = movementName; + } + + public Integer getSignalGroup() { + return signalGroup; + } + + public void setSignalGroup(Integer signalGroup) { + this.signalGroup = signalGroup; + } + + public J2735MovementEventList getState_time_speed() { + return state_time_speed; + } + + public void setState_time_speed(J2735MovementEventList state_time_speed) { + this.state_time_speed = state_time_speed; + } + + public J2735ManeuverAssistList getManeuverAssistList() { + return maneuverAssistList; + } + + public void setManeuverAssistList(J2735ManeuverAssistList maneuverAssistList) { + this.maneuverAssistList = maneuverAssistList; + } + + // regional + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735SPAT.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735SPAT.java new file mode 100644 index 000000000..ead041dbc --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735SPAT.java @@ -0,0 +1,40 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735SPAT extends Asn1Object { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private Integer timeStamp; + private String name; + private J2735IntersectionStateList intersectionStateList; + + public J2735IntersectionStateList getIntersectionStateList() { + return intersectionStateList; + } + + public void setIntersectionStateList(J2735IntersectionStateList intersectionStateList) { + this.intersectionStateList = intersectionStateList; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735TimeChangeDetails.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735TimeChangeDetails.java new file mode 100644 index 000000000..ee2e1a56a --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/J2735TimeChangeDetails.java @@ -0,0 +1,62 @@ +package us.dot.its.jpo.ode.plugin.j2735; + +import us.dot.its.jpo.ode.plugin.asn1.Asn1Object; + +public class J2735TimeChangeDetails extends Asn1Object { + private static final long serialVersionUID = 1L; + private Integer startTime; + private Integer minEndTime; + private Integer maxEndTime; + private Integer likelyTime; + private Integer confidence; + private Integer nextTime; + + public Integer getStartTime() { + return startTime; + } + + public void setStartTime(Integer startTime) { + this.startTime = startTime; + } + + public Integer getMinEndTime() { + return minEndTime; + } + + public void setMinEndTime(Integer minEndTime) { + this.minEndTime = minEndTime; + } + + public Integer getMaxEndTime() { + return maxEndTime; + } + + public void setMaxEndTime(Integer maxEndTime) { + this.maxEndTime = maxEndTime; + } + + public Integer getLikelyTime() { + return likelyTime; + } + + public void setLikelyTime(Integer likelyTime) { + this.likelyTime = likelyTime; + } + + public Integer getConfidence() { + return confidence; + } + + public void setConfidence(Integer confidence) { + this.confidence = confidence; + } + + public Integer getNextTime() { + return nextTime; + } + + public void setNextTime(Integer nextTime) { + this.nextTime = nextTime; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/AdvisorySpeedBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/AdvisorySpeedBuilder.java new file mode 100644 index 000000000..ade2bc978 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/AdvisorySpeedBuilder.java @@ -0,0 +1,82 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import org.json.JSONObject; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735AdvisorySpeed; +import us.dot.its.jpo.ode.plugin.j2735.J2735AdvisorySpeedType; +import us.dot.its.jpo.ode.plugin.j2735.J2735SpeedConfidence; + +public class AdvisorySpeedBuilder { + private AdvisorySpeedBuilder() { + throw new UnsupportedOperationException(); + } + + public static J2735AdvisorySpeed genericAdvisorySpeed(JsonNode AdvisorySpeedJson) { + J2735AdvisorySpeed advisorySpeed = new J2735AdvisorySpeed(); + if (AdvisorySpeedJson.get("type") != null) { + + String type = AdvisorySpeedJson.get("type").toString(); + JSONObject typeJson = new JSONObject(type); + String typeKey = typeJson.keys().hasNext() + ? typeJson.keys().next().toString().toLowerCase().replace("-", "_") + : ""; + + if (J2735AdvisorySpeedType.ECODRIVE.name().toLowerCase().equals(typeKey)) { + advisorySpeed.setType(J2735AdvisorySpeedType.ECODRIVE); + } else if (J2735AdvisorySpeedType.GREENWAVE.name().toLowerCase().equals(typeKey)) { + advisorySpeed.setType(J2735AdvisorySpeedType.GREENWAVE); + } else if (J2735AdvisorySpeedType.NONE.name().toLowerCase().equals(typeKey)) { + advisorySpeed.setType(J2735AdvisorySpeedType.NONE); + } else if (J2735AdvisorySpeedType.TRANSIT.name().toLowerCase().equals(typeKey)) { + advisorySpeed.setType(J2735AdvisorySpeedType.TRANSIT); + } + } + + if (AdvisorySpeedJson.get("speed") != null) { + advisorySpeed.setSpeed(AdvisorySpeedJson.get("speed").asInt()); + } + + if (AdvisorySpeedJson.get("distance") != null) { + advisorySpeed.setDistance(AdvisorySpeedJson.get("distance").asInt()); + } + + if (AdvisorySpeedJson.get("class") != null) { + advisorySpeed.setClassId(AdvisorySpeedJson.get("class").asInt()); + } + + if (AdvisorySpeedJson.get("confidence") != null) { + String confidence = AdvisorySpeedJson.get("confidence").toString(); + JSONObject confidenceJson = new JSONObject(confidence); + String confidenceKey = confidenceJson.keys().hasNext() + ? confidenceJson.keys().next().toString().toLowerCase().replace("-", "_") + : ""; + if (J2735SpeedConfidence.PREC100MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC100MS); + + } else if (J2735SpeedConfidence.UNAVAILABLE.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.UNAVAILABLE); + + } else if (J2735SpeedConfidence.PREC10MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC10MS); + + } else if (J2735SpeedConfidence.PREC5MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC5MS); + + } else if (J2735SpeedConfidence.PREC1MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC1MS); + + } else if (J2735SpeedConfidence.PREC0_1MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC0_1MS); + + } else if (J2735SpeedConfidence.PREC0_05MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC0_05MS); + + } else if (J2735SpeedConfidence.PREC0_01MS.name().toLowerCase().equals(confidenceKey)) { + advisorySpeed.setConfidence(J2735SpeedConfidence.PREC0_01MS); + } + } + return advisorySpeed; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/IntersectionStateBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/IntersectionStateBuilder.java new file mode 100644 index 000000000..9c2b8f90e --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/IntersectionStateBuilder.java @@ -0,0 +1,100 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import java.util.Iterator; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735IntersectionReferenceID; +import us.dot.its.jpo.ode.plugin.j2735.J2735IntersectionState; +import us.dot.its.jpo.ode.plugin.j2735.J2735IntersectionStatusObject; +import us.dot.its.jpo.ode.plugin.j2735.J2735ManeuverAssistList; +import us.dot.its.jpo.ode.plugin.j2735.J2735MovementList; + +public class IntersectionStateBuilder { + private IntersectionStateBuilder() { + throw new UnsupportedOperationException(); + } + + public static J2735IntersectionState genericIntersectionState(JsonNode intersectionState) { + J2735IntersectionState genericIntersectionState = new J2735IntersectionState(); + if(intersectionState.get("IntersectionState").get("name") != null) + genericIntersectionState.setName(intersectionState.get("IntersectionState").get("name").asText()); + + J2735IntersectionReferenceID id = new J2735IntersectionReferenceID(); + if(intersectionState.get("IntersectionState").get("id").get("id") != null) + id.setId(intersectionState.get("IntersectionState").get("id").get("id").asInt()); + + if(intersectionState.get("IntersectionState").get("id").get("region") != null) + id.setRegion(intersectionState.get("IntersectionState").get("id").get("region").asInt()); + + genericIntersectionState.setId(id); + + if(intersectionState.get("IntersectionState").get("revision") != null) + genericIntersectionState.setRevision(intersectionState.get("IntersectionState").get("revision").asInt()); + + if(intersectionState.get("IntersectionState").get("status") != null) + { + + Integer status = intersectionState.get("IntersectionState").get("status").asInt(); + for (J2735IntersectionStatusObject statusobj : J2735IntersectionStatusObject.values()) { + if (statusobj.ordinal() == status) { + genericIntersectionState.setStatus(J2735IntersectionStatusObject.values()[status]); + break; + } + } + } + + if (intersectionState.get("IntersectionState").get("moy") != null) + genericIntersectionState.setMoy(intersectionState.get("IntersectionState").get("moy").asInt()); + + if (intersectionState.get("IntersectionState").get("timeStamp") != null) + genericIntersectionState.setTimeStamp(intersectionState.get("IntersectionState").get("timeStamp").asInt()); + + if (intersectionState.get("IntersectionState").get("enabledLanes") != null + && intersectionState.get("IntersectionState").get("enabledLanes").get("LaneID") != null) { + if (intersectionState.get("IntersectionState").get("enabledLanes").get("LaneID").isArray()) { + Iterator elements = intersectionState.get("IntersectionState").get("enabledLanes").get("LaneID").elements(); + while (elements.hasNext()) { + genericIntersectionState.getEnabledLanes().getEnabledLaneList() + .add(elements.next().get("LaneID").asInt()); + } + } else { + genericIntersectionState.getEnabledLanes().getEnabledLaneList() + .add(intersectionState.get("IntersectionState").get("enabledLanes").get("LaneID").asInt()); + } + } + + if (intersectionState.get("IntersectionState").get("states") != null + && intersectionState.get("IntersectionState").get("states").get("MovementState") != null) { // MovementList + J2735MovementList states = new J2735MovementList(); + if (intersectionState.get("IntersectionState").get("states").get("MovementState").isArray()) { + Iterator elements = intersectionState.get("IntersectionState").get("states").get("MovementState").elements(); + while (elements.hasNext()) { + states.getMovementList().add(MovementStateBuilder.genericMovementState(elements.next())); + } + } else { + states.getMovementList().add(MovementStateBuilder.genericMovementState( + intersectionState.get("IntersectionState").get("states").get("MovementState"))); + } + genericIntersectionState.setStates(states); + } + + if (intersectionState.get("IntersectionState").get("maneuverAssistList") != null + && intersectionState.get("IntersectionState").get("maneuverAssistList").get("ConnectionManeuverAssist") != null) { // maneuverAssistList + J2735ManeuverAssistList maneuverAssistList = new J2735ManeuverAssistList(); + if (intersectionState.get("IntersectionState").get("maneuverAssistList").get("ConnectionManeuverAssist").isArray()) { + Iterator elements = intersectionState.get("maneuverAssistList").get("ConnectionManeuverAssist").elements(); + while (elements.hasNext()) { + maneuverAssistList.getManeuverAssistList() + .add(ManeuverAssistBuilder.genericManeuverAssist(elements.next())); + } + } else { + maneuverAssistList.getManeuverAssistList().add(ManeuverAssistBuilder.genericManeuverAssist( + intersectionState.get("IntersectionState").get("maneuverAssistList").get("ConnectionManueverAssist"))); + } + genericIntersectionState.setManeuverAssistList(maneuverAssistList); + } + + return genericIntersectionState; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/IntersectionStateListBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/IntersectionStateListBuilder.java new file mode 100644 index 000000000..562a25817 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/IntersectionStateListBuilder.java @@ -0,0 +1,29 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import java.util.Iterator; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735IntersectionStateList; + +public class IntersectionStateListBuilder { + private IntersectionStateListBuilder() { + throw new UnsupportedOperationException(); + } + + public static J2735IntersectionStateList genericIntersectionStateList(JsonNode intersections) { + J2735IntersectionStateList genericIntersectionStateList = new J2735IntersectionStateList(); + if (intersections.isArray()) { + Iterator elements = intersections.elements(); + while (elements.hasNext()) { + genericIntersectionStateList.getIntersectionStatelist() + .add(IntersectionStateBuilder.genericIntersectionState(elements.next())); + } + } else { + genericIntersectionStateList.getIntersectionStatelist() + .add(IntersectionStateBuilder.genericIntersectionState(intersections)); + + } + return genericIntersectionStateList; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/ManeuverAssistBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/ManeuverAssistBuilder.java new file mode 100644 index 000000000..d495c3f76 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/ManeuverAssistBuilder.java @@ -0,0 +1,32 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735ConnectionManueverAssist; + +public class ManeuverAssistBuilder { + private ManeuverAssistBuilder() { + throw new UnsupportedOperationException(); + } + + public static J2735ConnectionManueverAssist genericManeuverAssist(JsonNode maneuverAssistJson) { + J2735ConnectionManueverAssist maneuverAssist = new J2735ConnectionManueverAssist(); + if (maneuverAssistJson.get("connectionID") != null) + maneuverAssist.setConnectionID(maneuverAssistJson.get("connectionID").asInt()); + + if (maneuverAssistJson.get("queueLength") != null) + maneuverAssist.setQueueLength(maneuverAssistJson.get("queueLength").asInt()); + + if (maneuverAssistJson.get("waitOnStop") != null) + maneuverAssist.setWaitOnStop(maneuverAssistJson.get("waitOnStop").asBoolean()); + + if (maneuverAssistJson.get("availableStorageLength") != null) + maneuverAssist.setAvailableStorageLength(maneuverAssistJson.get("availableStorageLength").asInt()); + + if (maneuverAssistJson.get("pedBicycleDetect") != null) + maneuverAssist.setPedBicycleDetect(maneuverAssistJson.get("pedBicycleDetect").asBoolean()); + + return maneuverAssist; + } + +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/MovementEventBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/MovementEventBuilder.java new file mode 100644 index 000000000..2949c8cd1 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/MovementEventBuilder.java @@ -0,0 +1,99 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import java.util.Iterator; + +import org.json.JSONObject; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735AdvisorySpeedList; +import us.dot.its.jpo.ode.plugin.j2735.J2735MovementEvent; +import us.dot.its.jpo.ode.plugin.j2735.J2735MovementPhaseState; +import us.dot.its.jpo.ode.plugin.j2735.J2735TimeChangeDetails; + +public class MovementEventBuilder { + private MovementEventBuilder() { + throw new UnsupportedOperationException(); + } + + public static J2735MovementEvent genericMovementState(JsonNode movementEventJson) { + J2735MovementEvent event = new J2735MovementEvent(); + if (movementEventJson.get("eventState") != null) + { + String eventState = movementEventJson.get("eventState").toString(); + JSONObject eventStateJson = new JSONObject(eventState); + String eventStateKey = eventStateJson.keys().hasNext() + ? eventStateJson.keys().next().toString().toLowerCase().replace("-", "_") + : ""; + if (J2735MovementPhaseState.STOP_AND_REMAIN.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.STOP_AND_REMAIN); + + } else if (J2735MovementPhaseState.UNAVAILABLE.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.UNAVAILABLE); + + } else if (J2735MovementPhaseState.STOP_THEN_PROCEED.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.STOP_THEN_PROCEED); + + } else if (J2735MovementPhaseState.DARK.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.DARK); + + } else if (J2735MovementPhaseState.PRE_MOVEMENT.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.PRE_MOVEMENT); + + } else if (J2735MovementPhaseState.PERMISSIVE_MOVEMENT_ALLOWED.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.PERMISSIVE_MOVEMENT_ALLOWED); + + } else if (J2735MovementPhaseState.PROTECTED_MOVEMENT_ALLOWED.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.PROTECTED_MOVEMENT_ALLOWED); + + } else if (J2735MovementPhaseState.PERMISSIVE_CLEARANCE.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.PERMISSIVE_CLEARANCE); + + } else if (J2735MovementPhaseState.PROTECTED_CLEARANCE.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.PROTECTED_CLEARANCE); + + } else if (J2735MovementPhaseState.CAUTION_CONFLICTING_TRAFFIC.name().toLowerCase().equals(eventStateKey)) { + event.setEventState(J2735MovementPhaseState.CAUTION_CONFLICTING_TRAFFIC); + } + } + + if (movementEventJson.get("timing") != null) { + J2735TimeChangeDetails timing = new J2735TimeChangeDetails(); + if (movementEventJson.get("timing").get("minEndTime") != null) + timing.setMinEndTime(movementEventJson.get("timing").get("minEndTime").asInt()); + + if (movementEventJson.get("timing").get("startTime") != null) + timing.setStartTime(movementEventJson.get("timing").get("startTime").asInt()); + + if (movementEventJson.get("timing").get("maxEndTime") != null) + timing.setMaxEndTime(movementEventJson.get("timing").get("maxEndTime").asInt()); + + if (movementEventJson.get("timing").get("likelyTime") != null) + timing.setLikelyTime(movementEventJson.get("timing").get("likelyTime").asInt()); + + if (movementEventJson.get("timing").get("confidence") != null) + timing.setConfidence(movementEventJson.get("timing").get("confidence").asInt()); + + if (movementEventJson.get("timing").get("nextTime") != null) + timing.setNextTime(movementEventJson.get("timing").get("nextTime").asInt()); + + event.setTiming(timing); + } + + if (movementEventJson.get("speeds") != null + && movementEventJson.get("speeds").get("AdvisorySpeed") != null) { + J2735AdvisorySpeedList speeds = new J2735AdvisorySpeedList(); + if (movementEventJson.get("speeds").get("AdvisorySpeed").isArray()) { + Iterator elements = movementEventJson.get("speeds").get("AdvisorySpeed").elements(); + while (elements.hasNext()) { + speeds.getAdvisorySpeedList().add(AdvisorySpeedBuilder.genericAdvisorySpeed(elements.next())); + } + } else { + speeds.getAdvisorySpeedList().add(AdvisorySpeedBuilder + .genericAdvisorySpeed(movementEventJson.get("speeds").get("AdvisorySpeed"))); + } + event.setSpeeds(speeds); + } + return event; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/MovementStateBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/MovementStateBuilder.java new file mode 100644 index 000000000..30f0f3a2c --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/MovementStateBuilder.java @@ -0,0 +1,59 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import java.util.Iterator; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735ManeuverAssistList; +import us.dot.its.jpo.ode.plugin.j2735.J2735MovementEventList; +import us.dot.its.jpo.ode.plugin.j2735.J2735MovementState; + +public class MovementStateBuilder { + private MovementStateBuilder() { + throw new UnsupportedOperationException(); + } + + public static J2735MovementState genericMovementState(JsonNode movementStatesJson) { + J2735MovementState state = new J2735MovementState(); + if (movementStatesJson.get("movementName") != null) + state.setMovementName(movementStatesJson.get("movementName").asText()); + + if (movementStatesJson.get("signalGroup") != null) + state.setSignalGroup(movementStatesJson.get("signalGroup").asInt()); + + if (movementStatesJson.get("state-time-speed")!= null && movementStatesJson.get("state-time-speed").get("MovementEvent").isArray()) { + Iterator nestElements = movementStatesJson.get("state-time-speed").get("MovementEvent").elements(); + J2735MovementEventList state_time_speed = new J2735MovementEventList(); + while (nestElements.hasNext()) { + state_time_speed.getMovementEventList() + .add(MovementEventBuilder.genericMovementState(nestElements.next())); + } + state.setState_time_speed(state_time_speed); + } else { + J2735MovementEventList state_time_speed = new J2735MovementEventList(); + state_time_speed.getMovementEventList().add(MovementEventBuilder + .genericMovementState(movementStatesJson.get("state-time-speed").get("MovementEvent"))); + + state.setState_time_speed(state_time_speed); + } + + if(movementStatesJson.get("maneuverAssistList") != null + && movementStatesJson.get("maneuverAssistList").get("ConnectionManueverAssist") != null) + { + J2735ManeuverAssistList maneuverAssistList = new J2735ManeuverAssistList(); + if (movementStatesJson.get("maneuverAssistList").get("ConnectionManueverAssist").isArray()) { + Iterator elements = movementStatesJson.get("maneuverAssistList").get("ConnectionManueverAssist").elements(); + while (elements.hasNext()) { + maneuverAssistList.getManeuverAssistList() + .add(ManeuverAssistBuilder.genericManeuverAssist(elements.next())); + } + } else { + maneuverAssistList.getManeuverAssistList().add(ManeuverAssistBuilder.genericManeuverAssist( + movementStatesJson.get("maneuverAssistList").get("ConnectionManueverAssist"))); + } + state.setManeuverAssistList(maneuverAssistList); + } + + return state; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/SPATBuilder.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/SPATBuilder.java new file mode 100644 index 000000000..407be8e17 --- /dev/null +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/builders/SPATBuilder.java @@ -0,0 +1,33 @@ +package us.dot.its.jpo.ode.plugin.j2735.builders; + +import com.fasterxml.jackson.databind.JsonNode; + +import us.dot.its.jpo.ode.plugin.j2735.J2735SPAT; + +public class SPATBuilder { + private SPATBuilder() + { + throw new UnsupportedOperationException(); + } + public static J2735SPAT genericSPAT(JsonNode SPATMessage) { + J2735SPAT genericSPAT = new J2735SPAT(); + JsonNode timeStamp = SPATMessage.get("timeStamp"); + if(timeStamp != null) + { + genericSPAT.setTimeStamp(timeStamp.asInt()); + } + + JsonNode name = SPATMessage.get("name"); + if(name != null) + { + genericSPAT.setName(name.asText()); + } + + JsonNode intersections = SPATMessage.get("intersections"); + if(intersections != null) + { + genericSPAT.setIntersectionStateList(IntersectionStateListBuilder.genericIntersectionStateList(intersections)); + } + return genericSPAT; + } +} diff --git a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/timstorage/Position.java b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/timstorage/Position.java index 6ed35bb80..d967d33a1 100644 --- a/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/timstorage/Position.java +++ b/jpo-ode-plugins/src/main/java/us/dot/its/jpo/ode/plugin/j2735/timstorage/Position.java @@ -24,10 +24,10 @@ public class Position extends Asn1Object { private static final long serialVersionUID = 1L; - @JsonProperty("lat") + @JsonProperty("latitude") private String lat; - @JsonProperty("long") + @JsonProperty("longitude") private String llong; // TODO needs to be "long" @JsonProperty("elevation") diff --git a/jpo-ode-plugins/src/test/java/us/dot/its/jpo/ode/plugin/j2735/builders/TravelerMessageFromHumanToAsnConverterTest.java b/jpo-ode-plugins/src/test/java/us/dot/its/jpo/ode/plugin/j2735/builders/TravelerMessageFromHumanToAsnConverterTest.java index 9b12a8767..7c589e71b 100644 --- a/jpo-ode-plugins/src/test/java/us/dot/its/jpo/ode/plugin/j2735/builders/TravelerMessageFromHumanToAsnConverterTest.java +++ b/jpo-ode-plugins/src/test/java/us/dot/its/jpo/ode/plugin/j2735/builders/TravelerMessageFromHumanToAsnConverterTest.java @@ -21,6 +21,7 @@ import java.io.IOException; +import org.json.JSONException; import org.json.JSONObject; import org.json.XML; import org.junit.Before; @@ -63,8 +64,18 @@ public void testAdvisoryNodeLL() throws JsonProcessingException, IOException, Js "{\"request\":{\"rsus\":[{\"rsuIndex\":\"10\",\"rsuTarget\":\"127.0.0.2\",\"rsuUsername\":\"v3user\",\"rsuPassword\":\"password\",\"rsuRetries\":\"1\",\"rsuTimeout\":\"1000\"}],\"snmp\":{\"rsuid\":\"00000083\",\"msgid\":\"31\",\"mode\":\"1\",\"channel\":\"178\",\"interval\":\"2\",\"deliverystart\":\"2017-06-01T17:47:11-05:00\",\"deliverystop\":\"2018-01-01T17:47:11-05:15\",\"enable\":\"1\",\"status\":\"4\"}},\"tim\":{\"msgCnt\":\"1\",\"timeStamp\":309505,\"urlB\":\"null\",\"packetID\":\"EC9C236B0000000000\",\"dataFrames\":{\"TravelerDataFrame\":[{\"sspTimRights\":\"0\",\"frameType\":{\"advisory\":\"EMPTY_TAG\"},\"msgId\":{\"roadSignID\":{\"position\":{\"lat\":416784730,\"long\":-1087827750,\"elevation\":9171},\"viewAngle\":\"1010101010101010\",\"mutcdCode\":{\"warning\":\"EMPTY_TAG\"},\"crc\":\"0000\"}},\"priority\":\"0\",\"sspLocationRights\":\"3\",\"regions\":{\"GeographicalPath\":[{\"name\":\"Testing TIM\",\"laneWidth\":700,\"directionality\":{\"both\":\"EMPTY_TAG\"},\"closedPath\":\"BOOLEAN_OBJECT_FALSE\",\"description\":{\"path\":{\"scale\":\"0\",\"offset\":{\"ll\":{\"nodes\":{\"NodeLL\":[{\"delta\":{\"node-LL1\":{\"lat\":-2048,\"lon\":2047}}},{\"delta\":{\"node-LL2\":{\"lat\":-8192,\"lon\":8191}}},{\"delta\":{\"node-LL3\":{\"lat\":-32768,\"lon\":32767}}},{\"delta\":{\"node-LL4\":{\"lat\":-131072,\"lon\":131071}}},{\"delta\":{\"node-LL5\":{\"lat\":-2097152,\"lon\":2097151}}},{\"delta\":{\"node-LL6\":{\"lat\":-8388608,\"lon\":8388607}}},{\"delta\":{\"node-LL1\":{\"lat\":-2048,\"lon\":2047}}},{\"delta\":{\"node-LL2\":{\"lat\":-8192,\"lon\":8191}}},{\"delta\":{\"node-LL3\":{\"lat\":-32768,\"lon\":32767}}},{\"delta\":{\"node-LL4\":{\"lat\":-131072,\"lon\":131071}}},{\"delta\":{\"node-LL5\":{\"lat\":-2097152,\"lon\":2097151}}},{\"delta\":{\"node-LL6\":{\"lat\":-8388608,\"lon\":8388607}}},{\"delta\":{\"node-LatLon\":{\"lat\":412500807,\"lon\":-1110093847}}}]}}}}},\"direction\":\"0000000000001010\",\"id\":{\"region\":0,\"id\":33},\"anchor\":{\"lat\":412500807,\"long\":-1110093847,\"elevation\":20207}}]},\"url\":\"null\",\"sspMsgRights2\":3,\"sspMsgRights1\":2,\"duratonTime\":1,\"startYear\":2017,\"startTime\":308065,\"tcontent\":{\"advisory\":{\"SEQUENCE\":[{\"item\":{\"itis\":125}},{\"item\":{\"text\":\"some text\"}},{\"item\":{\"itis\":250}},{\"item\":{\"text\":\"98765\"}}]}}}]}}}"); assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e1) { + e1.printStackTrace(); + } catch (JsonUtilsException e1) { + e1.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + e.printStackTrace(); + } // assertEquals("string", XML.toString(timObject)); } @@ -79,8 +90,18 @@ public void testWorkzoneNodeXYWithStringLatLon() throws JsonUtilsException { "{\"request\":{\"rsus\":[{\"rsuIndex\":\"10\",\"rsuTarget\":\"127.0.0.3\",\"rsuUsername\":\"v3user\",\"rsuPassword\":\"password\",\"rsuRetries\":\"1\",\"rsuTimeout\":\"1000\"}],\"snmp\":{\"rsuid\":\"00000083\",\"msgid\":\"31\",\"mode\":\"1\",\"channel\":\"178\",\"interval\":\"2\",\"deliverystart\":\"2017-06-01T17:47:11-05:00\",\"deliverystop\":\"2018-01-01T17:47:11-05:15\",\"enable\":\"1\",\"status\":\"4\"},\"sdw\":{\"ttl\":\"oneweek\",\"serviceRegion\":{\"nwCorner\":{\"latitude\":\"44.998459\",\"longitude\":\"-111.040817\"},\"seCorner\":{\"latitude\":\"41.104674\",\"longitude\":\"-104.111312\"}}}},\"tim\":{\"msgCnt\":\"1\",\"timeStamp\":431644,\"packetID\":\"3\",\"urlB\":\"null\",\"dataFrames\":{\"TravelerDataFrame\":[{\"frameType\":{\"1\":\"EMPTY_TAG\"},\"sspTimRights\":\"1\",\"msgId\":\"roadSignID\",\"position\":{\"latitude\":\"40.573068\",\"longitude\":\"-105.049016\",\"elevation\":\"1500.8999999999999\"},\"viewAngle\":\"1111111111111111\",\"mutcd\":\"2\",\"crc\":\"0000\",\"priority\":\"5\",\"sspLocationRights\":\"1\",\"regions\":{\"GeographicalPath\":[{\"name\":\"Testing TIM\",\"laneWidth\":32700,\"directionality\":{\"both\":\"EMPTY_TAG\"},\"closedPath\":\"BOOLEAN_OBJECT_FALSE\",\"description\":{\"path\":{\"scale\":\"0\",\"offset\":{\"xy\":{\"nodes\":{\"NodeXY\":[{\"delta\":{\"node-LatLon\":{\"lon\":-1050473550,\"lat\":405724290}},\"attributes\":{\"data\":[{\"pathEndPointAngle\":123},{\"laneCrownPointCenter\":41},{\"laneCrownPointLeft\":78},{\"laneCrownPointRight\":115},{\"laneAngle\":1},{\"speedLimits\":[{\"type\":{\"maxSpeedInSchoolZoneWhenChildrenArePresent\":\"EMPTY_TAG\"},\"speed\":615},{\"type\":{\"maxSpeedInSchoolZone\":\"EMPTY_TAG\"},\"speed\":1170},{\"type\":{\"maxSpeedInConstructionZone\":\"EMPTY_TAG\"},\"speed\":615},{\"type\":{\"vehicleMinSpeed\":\"EMPTY_TAG\"},\"speed\":1170}]}],\"dWidth\":123,\"dElevation\":234}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050468440,\"lat\":405722280}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050465900,\"lat\":405721130}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050462430,\"lat\":405719100}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050459360,\"lat\":405716750}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050456740,\"lat\":405714220}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050454500,\"lat\":405711310}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050452350,\"lat\":405707240}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050451130,\"lat\":405702930}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050450870,\"lat\":405698480}}}]}}}}},\"direction\":\"1111111111111111\",\"id\":{\"region\":0,\"id\":33},\"anchor\":{\"lat\":405730680,\"long\":-1050490160,\"elevation\":15009}}]},\"url\":\"null\",\"sspMsgRights2\":1,\"sspMsgRights1\":1,\"duratonTime\":100,\"startYear\":2017,\"startTime\":420802,\"tcontent\":{\"workZone\":{\"SEQUENCE\":[{\"item\":{\"itis\":7425}}]}}}]}}}"); assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + e.printStackTrace(); + } catch (JsonUtilsException e) { + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + e.printStackTrace(); + } } @Test @@ -94,8 +115,19 @@ public void testGenericSignNodeXYWithNumericLatLon() throws JsonUtilsException { "{\"request\":{\"rsus\":[{\"rsuIndex\":\"10\",\"rsuTarget\":\"127.0.0.3\",\"rsuUsername\":\"v3user\",\"rsuPassword\":\"password\",\"rsuRetries\":\"1\",\"rsuTimeout\":\"1000\"}],\"snmp\":{\"rsuid\":\"00000083\",\"msgid\":\"31\",\"mode\":\"1\",\"channel\":\"178\",\"interval\":\"2\",\"deliverystart\":\"2017-06-01T17:47:11-05:00\",\"deliverystop\":\"2018-01-01T17:47:11-05:15\",\"enable\":\"1\",\"status\":\"4\"},\"sdw\":{\"ttl\":\"oneweek\",\"serviceRegion\":{\"nwCorner\":{\"latitude\":44.998459,\"longitude\":-111.040817},\"seCorner\":{\"latitude\":41.104674,\"longitude\":-104.111312}}}},\"tim\":{\"msgCnt\":\"1\",\"timeStamp\":431644,\"packetID\":\"3\",\"urlB\":\"null\",\"dataFrames\":{\"TravelerDataFrame\":[{\"frameType\":{\"advisory\":\"EMPTY_TAG\"},\"sspTimRights\":\"1\",\"msgId\":\"roadSignID\",\"position\":{\"latitude\":40.573068,\"longitude\":-105.049016,\"elevation\":1500.8999999999999},\"viewAngle\":\"1111111111111111\",\"mutcd\":\"2\",\"crc\":\"0000\",\"priority\":\"5\",\"sspLocationRights\":\"1\",\"regions\":{\"GeographicalPath\":[{\"name\":\"Testing TIM\",\"laneWidth\":32700,\"directionality\":{\"both\":\"EMPTY_TAG\"},\"closedPath\":\"BOOLEAN_OBJECT_FALSE\",\"description\":{\"path\":{\"scale\":\"0\",\"offset\":{\"xy\":{\"nodes\":{\"NodeXY\":[{\"delta\":{\"node-LatLon\":{\"lon\":-1050473550,\"lat\":405724290}},\"attributes\":{\"data\":[{\"pathEndPointAngle\":123},{\"laneCrownPointCenter\":41},{\"laneCrownPointLeft\":78},{\"laneCrownPointRight\":115},{\"laneAngle\":1},{\"speedLimits\":[{\"type\":{\"maxSpeedInSchoolZoneWhenChildrenArePresent\":\"EMPTY_TAG\"},\"speed\":615},{\"type\":{\"maxSpeedInSchoolZone\":\"EMPTY_TAG\"},\"speed\":1170},{\"type\":{\"maxSpeedInConstructionZone\":\"EMPTY_TAG\"},\"speed\":615},{\"type\":{\"vehicleMinSpeed\":\"EMPTY_TAG\"},\"speed\":1170}]}],\"dWidth\":123,\"dElevation\":234}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050468440,\"lat\":405722280}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050465900,\"lat\":405721130}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050462430,\"lat\":405719100}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050459360,\"lat\":405716750}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050456740,\"lat\":405714220}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050454500,\"lat\":405711310}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050452350,\"lat\":405707240}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050451130,\"lat\":405702930}}},{\"delta\":{\"node-LatLon\":{\"lon\":-1050450870,\"lat\":405698480}}}]}}}}},\"direction\":\"1111111111111111\",\"id\":{\"region\":0,\"id\":33},\"anchor\":{\"lat\":405730680,\"long\":-1050490160,\"elevation\":15009}}]},\"url\":\"null\",\"sspMsgRights2\":1,\"sspMsgRights1\":1,\"duratonTime\":100,\"startYear\":2017,\"startTime\":420802,\"tcontent\":{\"genericSign\":{\"SEQUENCE\":[{\"item\":{\"itis\":7425}}]}}}]}}}"); assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + e.printStackTrace(); + } catch (JsonUtilsException e) { + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @Test @@ -109,8 +141,21 @@ public void testGeometryUnavailable() throws JsonUtilsException { assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -125,8 +170,21 @@ public void testGeometryExitServiceForward() throws JsonUtilsException { assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -141,8 +199,21 @@ public void testGeometryAdvisoryReverse() throws JsonUtilsException { assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -156,8 +227,21 @@ public void testRoadSignIDWorkzone() throws JsonUtilsException { "{\"request\":{\"rsus\":[{\"rsuIndex\":\"10\",\"rsuTarget\":\"127.0.0.3\",\"rsuUsername\":\"v3user\",\"rsuPassword\":\"password\",\"rsuRetries\":\"1\",\"rsuTimeout\":\"1000\"}],\"snmp\":{\"rsuid\":\"00000083\",\"msgid\":\"31\",\"mode\":\"1\",\"channel\":\"178\",\"interval\":\"2\",\"deliverystart\":\"2017-06-01T17:47:11-05:00\",\"deliverystop\":\"2018-01-01T17:47:11-05:15\",\"enable\":\"1\",\"status\":\"4\"},\"sdw\":{\"ttl\":\"oneweek\",\"serviceRegion\":{\"nwCorner\":{\"latitude\":\"44.998459\",\"longitude\":\"-111.040817\"},\"seCorner\":{\"latitude\":\"41.104674\",\"longitude\":\"-104.111312\"}}}},\"tim\":{\"msgCnt\":\"2\",\"timeStamp\":309505,\"urlB\":\"null\",\"packetID\":\"EC9C236B0000000000\",\"dataFrames\":{\"TravelerDataFrame\":[{\"sspTimRights\":\"0\",\"frameType\":{\"commercialSignage\":\"EMPTY_TAG\"},\"msgId\":{\"roadSignID\":{\"position\":{\"lat\":416784730,\"long\":-1087827750,\"elevation\":9171},\"viewAngle\":\"1010101010101010\",\"mutcdCode\":{\"warning\":\"EMPTY_TAG\"},\"crc\":\"0000\"}},\"priority\":\"0\",\"sspLocationRights\":\"3\",\"regions\":{\"GeographicalPath\":[{\"name\":\"Testing TIM\",\"laneWidth\":700,\"directionality\":{\"both\":\"EMPTY_TAG\"},\"closedPath\":\"BOOLEAN_OBJECT_FALSE\",\"description\":{\"path\":{\"scale\":\"0\",\"offset\":{\"ll\":{\"nodes\":{\"NodeLL\":[{\"delta\":{\"node-LL1\":{\"lat\":-2048,\"lon\":2047}}},{\"delta\":{\"node-LL3\":{\"lat\":14568,\"lon\":30974}}},{\"delta\":{\"node-LL3\":{\"lat\":14559,\"lon\":30983}}},{\"delta\":{\"node-LL3\":{\"lat\":14563,\"lon\":30980}}},{\"delta\":{\"node-LL3\":{\"lat\":14562,\"lon\":30982}}}]}}}}},\"direction\":\"0000000000001010\",\"id\":{\"region\":0,\"id\":33},\"anchor\":{\"lat\":412500807,\"long\":-1110093847,\"elevation\":20207}}]},\"url\":\"null\",\"sspMsgRights2\":3,\"sspMsgRights1\":2,\"duratonTime\":1,\"startYear\":2017,\"startTime\":308065,\"tcontent\":{\"workZone\":{\"SEQUENCE\":[{\"item\":{\"itis\":513}}]}}}]}}}"); assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @Test @@ -171,8 +255,21 @@ public void testGeometryBothGenericSign() throws JsonUtilsException { assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -186,8 +283,21 @@ public void testPathSpeedLimit() throws JsonUtilsException { "{\"request\":{\"rsus\":[{\"rsuIndex\":\"10\",\"rsuTarget\":\"127.0.0.3\",\"rsuUsername\":\"v3user\",\"rsuPassword\":\"password\",\"rsuRetries\":\"1\",\"rsuTimeout\":\"1000\"}],\"snmp\":{\"rsuid\":\"00000083\",\"msgid\":\"31\",\"mode\":\"1\",\"channel\":\"178\",\"interval\":\"2\",\"deliverystart\":\"2017-06-01T17:47:11-05:00\",\"deliverystop\":\"2018-01-01T17:47:11-05:15\",\"enable\":\"1\",\"status\":\"4\"},\"sdw\":{\"ttl\":\"oneweek\",\"serviceRegion\":{\"nwCorner\":{\"latitude\":\"44.998459\",\"longitude\":\"-111.040817\"},\"seCorner\":{\"latitude\":\"41.104674\",\"longitude\":\"-104.111312\"}}}},\"tim\":{\"msgCnt\":\"1\",\"timeStamp\":309505,\"urlB\":\"null\",\"packetID\":\"EC9C236B0000000000\",\"dataFrames\":{\"TravelerDataFrame\":[{\"sspTimRights\":\"0\",\"frameType\":{\"advisory\":\"EMPTY_TAG\"},\"msgId\":{\"roadSignID\":{\"position\":{\"lat\":416784730,\"long\":-1087827750,\"elevation\":9171},\"viewAngle\":\"1010101010101010\",\"mutcdCode\":{\"warning\":\"EMPTY_TAG\"},\"crc\":\"0000\"}},\"priority\":\"0\",\"sspLocationRights\":\"3\",\"regions\":{\"GeographicalPath\":[{\"name\":\"Testing TIM\",\"laneWidth\":700,\"directionality\":{\"both\":\"EMPTY_TAG\"},\"closedPath\":\"BOOLEAN_OBJECT_FALSE\",\"description\":{\"path\":{\"scale\":\"0\",\"offset\":{\"ll\":{\"nodes\":{\"NodeLL\":[{\"delta\":{\"node-LL3\":{\"lat\":14506,\"lon\":31024}}},{\"delta\":{\"node-LL3\":{\"lat\":14568,\"lon\":30974}}},{\"delta\":{\"node-LL3\":{\"lat\":14559,\"lon\":30983}}},{\"delta\":{\"node-LL3\":{\"lat\":14563,\"lon\":30980}}},{\"delta\":{\"node-LL3\":{\"lat\":14562,\"lon\":30982}}}]}}}}},\"direction\":\"0000000000001010\",\"id\":{\"region\":0,\"id\":33},\"anchor\":{\"lat\":412500807,\"long\":-1110093847,\"elevation\":20207}}]},\"url\":\"null\",\"sspMsgRights2\":3,\"sspMsgRights1\":2,\"duratonTime\":1,\"startYear\":2017,\"startTime\":308065,\"tcontent\":{\"speedLimit\":{\"SEQUENCE\":[{\"item\":{\"itis\":513}}]}}}]}}}"); assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @Test @@ -262,8 +372,21 @@ public void testOldRegionWithShapePointSetWithNodeList() throws JsonUtilsExcepti assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -278,8 +401,21 @@ public void testOldRegionWithShapePointSetWithComputedLanesSmall() throws JsonUt assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -294,8 +430,21 @@ public void testOldRegionWithShapePointSetWithComputedLanesLarge() throws JsonUt assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -310,8 +459,21 @@ public void testOldRegionWithCircle() throws JsonUtilsException { assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } @@ -326,8 +488,21 @@ public void testOldRegionWithRegionPointSet() throws JsonUtilsException { assertEquals(expectedTID.toString(), inputTID.toString()); JSONObject timObject = new JSONObject(); - timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); - assertNotNull(XML.toString(timObject)); + try { + timObject.put(TravelerMessageFromHumanToAsnConverter.TRAVELER_INFORMATION, JsonUtils.toJSONObject(inputTID.toString())); + } catch (JSONException e) { + + e.printStackTrace(); + } catch (JsonUtilsException e) { + + e.printStackTrace(); + } + try { + assertNotNull(XML.toString(timObject)); + } catch (JSONException e) { + + e.printStackTrace(); + } } } diff --git a/jpo-ode-svcs/pom.xml b/jpo-ode-svcs/pom.xml index caa70f1e3..77c39b949 100644 --- a/jpo-ode-svcs/pom.xml +++ b/jpo-ode-svcs/pom.xml @@ -41,8 +41,7 @@ javax.xml.bind jaxb-api - 2.1 - + org.springframework.boot spring-boot-starter-web @@ -65,16 +64,17 @@ org.webjars webjars-locator + 0.40 org.webjars sockjs-client - 1.0.2 + 1.5.1 org.webjars stomp-websocket - 2.3.3 + 2.3.4 org.webjars @@ -103,8 +103,9 @@ org.snmp4j snmp4j - 1.10.1 - + 3.4.4 + + ${project.artifactId} diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java index f37176823..6d2d31738 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/OdeProperties.java @@ -125,7 +125,7 @@ public class OdeProperties implements EnvironmentAware { private String kafkaTopicOdeBsmTxPojo = "topic.OdeBsmTxPojo"; private String kafkaTopicOdeBsmDuringEventPojo = "topic.OdeBsmDuringEventPojo"; private String kafkaTopicFilteredOdeBsmJson = "topic.FilteredOdeBsmJson"; - private String kafkaTopicOdeRawEncodedMessageJson = "topic.OdeRawEncodedMessageJson"; + private String kafkaTopicOdeRawEncodedBSMJson = "topic.OdeRawEncodedBSMJson"; private int bsmReceiverPort = 46800; private int bsmBufferSize = 500; @@ -137,9 +137,19 @@ public class OdeProperties implements EnvironmentAware { private String kafkaTopicOdeTimBroadcastJson = "topic.OdeTimBroadcastJson"; private String kafkaTopicJ2735TimBroadcastJson = "topic.J2735TimBroadcastJson"; private String kafkaTopicFilteredOdeTimJson = "topic.FilteredOdeTimJson"; + private String kafkaTopicOdeRawEncodedTIMJson = "topic.OdeRawEncodedTIMJson"; private int timReceiverPort = 47900; private int timBufferSize = 500; - + + //SPAT + private String kafkaTopicOdeSpatTxPojo = "topic.OdeSpatTxPojo"; + private String kafkaTopicOdeSpatPojo = "topic.OdeSpatPojo"; + private String kafkaTopicOdeSpatJson = "topic.OdeSpatJson"; + private String kafkaTopicOdeSpatRxPojo = "topic.OdeSpatRxPojo"; + private String kafkaTopicOdeSpatRxJson = "topic.OdeSpatRxJson"; + private String kafkaTopicFilteredOdeSpatJson = "topic.FilteredOdeSpatJson"; + private String kafkaTopicOdeRawEncodedSPATJson = "topic.OdeRawEncodedSPATJson"; + // DriverAlerts private String kafkaTopicDriverAlertJson = "topic.OdeDriverAlertJson"; @@ -654,13 +664,96 @@ public String getKafkaTopicSignedOdeTimJsonExpiration() { public void setKafkaTopicSignedOdeTimJsonExpiration(String kafkaTopicSignedOdeTimJsonExpiration) { this.kafkaTopicSignedOdeTimJsonExpiration = kafkaTopicSignedOdeTimJsonExpiration; } + + public String getKafkaTopicOdeSpatTxPojo() { + return kafkaTopicOdeSpatTxPojo; + } + + + public void setKafkaTopicOdeSpatTxPojo(String kafkaTopicOdeSpatTxPojo) { + this.kafkaTopicOdeSpatTxPojo = kafkaTopicOdeSpatTxPojo; + } - public String getKafkaTopicOdeRawEncodedMessageJson() { - return kafkaTopicOdeRawEncodedMessageJson; - } - public void setKafkaTopicOdeRawEncodedMessageJson(String kafkaTopicOdeRawEncodedMessageJson) { - this.kafkaTopicOdeRawEncodedMessageJson = kafkaTopicOdeRawEncodedMessageJson; - } - + public String getKafkaTopicOdeSpatPojo() { + return kafkaTopicOdeSpatPojo; + } + + + public void setKafkaTopicOdeSpatPojo(String kafkaTopicOdeSpatPojo) { + this.kafkaTopicOdeSpatPojo = kafkaTopicOdeSpatPojo; + } + + + public String getKafkaTopicOdeSpatJson() { + return kafkaTopicOdeSpatJson; + } + + + public void setKafkaTopicOdeSpatJson(String kafkaTopicOdeSpatJson) { + this.kafkaTopicOdeSpatJson = kafkaTopicOdeSpatJson; + } + + + public String getKafkaTopicOdeSpatRxPojo() { + return kafkaTopicOdeSpatRxPojo; + } + + + public void setKafkaTopicOdeSpatRxPojo(String kafkaTopicOdeSpatRxPojo) { + this.kafkaTopicOdeSpatRxPojo = kafkaTopicOdeSpatRxPojo; + } + + + public String getKafkaTopicOdeSpatRxJson() { + return kafkaTopicOdeSpatRxJson; + } + + + public void setKafkaTopicOdeSpatRxJson(String kafkaTopicOdeSpatRxJson) { + this.kafkaTopicOdeSpatRxJson = kafkaTopicOdeSpatRxJson; + } + + + public String getKafkaTopicFilteredOdeSpatJson() { + return kafkaTopicFilteredOdeSpatJson; + } + + + public void setKafkaTopicFilteredOdeSpatJson(String kafkaTopicFilteredOdeSpatJson) { + this.kafkaTopicFilteredOdeSpatJson = kafkaTopicFilteredOdeSpatJson; + } + + + public String getKafkaTopicOdeRawEncodedBSMJson() { + return kafkaTopicOdeRawEncodedBSMJson; + } + + + public void setKafkaTopicOdeRawEncodedBSMJson(String kafkaTopicOdeRawEncodedBSMJson) { + this.kafkaTopicOdeRawEncodedBSMJson = kafkaTopicOdeRawEncodedBSMJson; + } + + + public String getKafkaTopicOdeRawEncodedTIMJson() { + return kafkaTopicOdeRawEncodedTIMJson; + } + + + public void setKafkaTopicOdeRawEncodedTIMJson(String kafkaTopicOdeRawEncodedTIMJson) { + this.kafkaTopicOdeRawEncodedTIMJson = kafkaTopicOdeRawEncodedTIMJson; + } + + + public String getKafkaTopicOdeRawEncodedSPATJson() { + return kafkaTopicOdeRawEncodedSPATJson; + } + + + public void setKafkaTopicOdeRawEncodedSPATJson(String kafkaTopicOdeRawEncodedSPATJson) { + this.kafkaTopicOdeRawEncodedSPATJson = kafkaTopicOdeRawEncodedSPATJson; + } + + + } diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/OdeSpatDataCreatorHelper.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/OdeSpatDataCreatorHelper.java new file mode 100644 index 000000000..42a1c0270 --- /dev/null +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/OdeSpatDataCreatorHelper.java @@ -0,0 +1,63 @@ +package us.dot.its.jpo.ode.coder; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import us.dot.its.jpo.ode.context.AppContext; +import us.dot.its.jpo.ode.model.OdeSpatData; +import us.dot.its.jpo.ode.model.OdeSpatMetadata; +import us.dot.its.jpo.ode.model.OdeSpatPayload; +import us.dot.its.jpo.ode.model.ReceivedMessageDetails; +import us.dot.its.jpo.ode.model.RxSource; +import us.dot.its.jpo.ode.plugin.j2735.builders.SPATBuilder; +import us.dot.its.jpo.ode.util.JsonUtils; +import us.dot.its.jpo.ode.util.XmlUtils; +import us.dot.its.jpo.ode.util.XmlUtils.XmlUtilsException; + +public class OdeSpatDataCreatorHelper { + + public OdeSpatDataCreatorHelper() { + } + + public static OdeSpatData createOdeSpatData(String consumedData) throws XmlUtilsException { + ObjectNode consumed = XmlUtils.toObjectNode(consumedData); + + JsonNode metadataNode = consumed.findValue(AppContext.METADATA_STRING); + if (metadataNode instanceof ObjectNode) { + ObjectNode object = (ObjectNode) metadataNode; + object.remove(AppContext.ENCODINGS_STRING); + + //Spat header file does not have a location and use predefined set required RxSource + ReceivedMessageDetails receivedMessageDetails = new ReceivedMessageDetails(); + receivedMessageDetails.setRxSource(RxSource.NA); + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode jsonNode; + try { + jsonNode = objectMapper.readTree(receivedMessageDetails.toJson()); + object.set(AppContext.RECEIVEDMSGDETAILS_STRING, jsonNode); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + OdeSpatMetadata metadata = (OdeSpatMetadata) JsonUtils.fromJson(metadataNode.toString(), OdeSpatMetadata.class); + + if(metadataNode.findValue("certPresent") != null) { + boolean isCertPresent = metadataNode.findValue("certPresent").asBoolean(); + metadata.setCertPresent(isCertPresent); + } + + if (metadata.getSchemaVersion() <= 4) { + metadata.setReceivedMessageDetails(null); + } + + OdeSpatPayload payload = new OdeSpatPayload(SPATBuilder.genericSPAT(consumed.findValue("SPAT"))); + return new OdeSpatData(metadata, payload); + } +} diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/stream/LogFileToAsn1CodecPublisher.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/stream/LogFileToAsn1CodecPublisher.java index 34e58ab5c..ac8385a94 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/stream/LogFileToAsn1CodecPublisher.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/coder/stream/LogFileToAsn1CodecPublisher.java @@ -153,7 +153,9 @@ private void publishList(XmlUtils xmlUtils, List dataList) throws JsonP publisher.publish(JsonUtils.toJson(odeData, false), publisher.getOdeProperties().getKafkaTopicDriverAlertJson()); - } else { + } + else + { if (isBsmRecord()) { logger.debug("Publishing a BSM"); } else if(isSpatRecord()) { @@ -161,11 +163,21 @@ private void publishList(XmlUtils xmlUtils, List dataList) throws JsonP }else { logger.debug("Publishing a TIM"); } - - Asn1Encoding msgEncoding = new Asn1Encoding("root", "Ieee1609Dot2Data", EncodingRule.COER); - Asn1Encoding unsecuredDataEncoding = new Asn1Encoding("unsecuredData", "MessageFrame", - EncodingRule.UPER); - msgMetadata.addEncoding(msgEncoding).addEncoding(unsecuredDataEncoding); + + if(isSpatRecord() && msgMetadata instanceof OdeSpatMetadata + && !((OdeSpatMetadata)msgMetadata).isCertPresent() ) + { + //Nothing: If Spat log file and IEEE1609Cert is not present, Skip the Ieee1609Dot2Data encoding + } + else + { + Asn1Encoding msgEncoding = new Asn1Encoding("root", "Ieee1609Dot2Data", EncodingRule.COER); + msgMetadata.addEncoding(msgEncoding); + } + + Asn1Encoding unsecuredDataEncoding = new Asn1Encoding("unsecuredData", "MessageFrame",EncodingRule.UPER); + msgMetadata.addEncoding(unsecuredDataEncoding); + publisher.publish(xmlUtils.toXml(odeData), publisher.getOdeProperties().getKafkaTopicAsn1DecoderInput()); diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/IntersectionParser.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/IntersectionParser.java index e6f95dd0d..8e24e71ca 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/IntersectionParser.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/IntersectionParser.java @@ -8,12 +8,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import us.dot.its.jpo.ode.model.OdeLogMetadata.SecurityResultCode; import us.dot.its.jpo.ode.util.CodecUtils; public class IntersectionParser extends LogFileParser { + public static final int INTERSECTION_ID_LENGTH = 2; public static final int INTERSECTION_STATUS_LENGTH = 1; - public static final int INTERSECTION_ID_LENGTH = 4; private final Logger logger = LoggerFactory.getLogger(this.getClass()); protected LogIntersection intersection; @@ -32,19 +31,19 @@ public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws F // Step 1 - parse intersection.intersectionStatus if (getStep() == 0) { - status = parseStep(bis, INTERSECTION_STATUS_LENGTH); + status = parseStep(bis, INTERSECTION_ID_LENGTH); if (status != ParserStatus.COMPLETE) return status; - intersection.setIntersectionStatus(readBuffer[0]); + intersection.setIntersectionId( + CodecUtils.bytesToShort(readBuffer, 0, INTERSECTION_ID_LENGTH, ByteOrder.LITTLE_ENDIAN)); } // Step 2 - parse intersection.intersectionId if (getStep() == 1) { - status = parseStep(bis, INTERSECTION_ID_LENGTH); + status = parseStep(bis, INTERSECTION_STATUS_LENGTH); if (status != ParserStatus.COMPLETE) return status; - intersection.setIntersectionId( - CodecUtils.bytesToInt(readBuffer, 0, INTERSECTION_ID_LENGTH, ByteOrder.LITTLE_ENDIAN)); + intersection.setIntersectionStatus(readBuffer[0]); } resetStep(); @@ -63,17 +62,10 @@ public LogIntersection getIntersection() { public void setIntersection(LogIntersection intersection) { this.intersection = intersection; } - public void setIntersection(byte code) { - try { - this.intersection.setIntersectionStatus(code); - } catch (Exception e) { - logger.error("Intersection status value error, Invalid value {}: ", - code); - } - } + @Override public void writeTo(OutputStream os) throws IOException { - os.write(CodecUtils.intToBytes(intersection.getIntersectionStatus(), ByteOrder.LITTLE_ENDIAN)); os.write(CodecUtils.intToBytes(intersection.getIntersectionId(), ByteOrder.LITTLE_ENDIAN)); + os.write(CodecUtils.intToBytes(intersection.getIntersectionStatus(), ByteOrder.LITTLE_ENDIAN)); } } diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/LogFileParser.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/LogFileParser.java index 86f0f05b4..280768e41 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/LogFileParser.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/LogFileParser.java @@ -240,11 +240,14 @@ public void updateMetadata(OdeLogMetadata metadata) { if (metadata instanceof OdeSpatMetadata) { OdeSpatMetadata odeSpatMetadata = (OdeSpatMetadata) metadata; SpatSource spatSource = SpatSource.unknown; + boolean isCertPresent = true; /*ieee 1609 (acceptable values 0 = no,1 =yes by default the Cert shall be present)*/ if (this instanceof SpatLogFileParser) { SpatLogFileParser spatLogFileParser = (SpatLogFileParser) this; spatSource = spatLogFileParser.getSpatSource(); + isCertPresent = spatLogFileParser.isCertPresent(); //update } odeSpatMetadata.setSpatSource(spatSource); + odeSpatMetadata.setCertPresent(isCertPresent); } metadata.calculateGeneratedBy(); diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/SpatLogFileParser.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/SpatLogFileParser.java index ec741f36e..f3c0a22b6 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/SpatLogFileParser.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/importer/parser/SpatLogFileParser.java @@ -12,8 +12,10 @@ public class SpatLogFileParser extends LogFileParser { private static final Logger logger = LoggerFactory.getLogger(SpatLogFileParser.class.getName()); private static final int RX_FROM_LENGTH = 1; + private static final int IS_CERT_PRESENT_LENGTH= 1; ; /*ieee 1609 (acceptable values 0 = no,1 =yes by default the Cert shall be present)*/ private SpatSource spatSource; + private boolean isCertPresent; public SpatLogFileParser() { super(); @@ -55,8 +57,15 @@ public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws F if (status != ParserStatus.COMPLETE) return status; } - + if (getStep() == 5) { + status = parseStep(bis, IS_CERT_PRESENT_LENGTH); + if (status != ParserStatus.COMPLETE) + return status; + setCertPresent(readBuffer); + } + + if (getStep() == 6) { status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; @@ -81,6 +90,23 @@ public void setSpatSource(SpatSource spatSource) { this.spatSource = spatSource; } + public boolean isCertPresent() { + return isCertPresent; + } + + public void setCertPresent(boolean isCertPresent) { + this.isCertPresent = isCertPresent; + } + + public void setCertPresent(byte[] code) { + try { + setCertPresent(code[0] == 0? false: true); + } catch (Exception e) { + logger.error("Invalid Certificate Presence indicator: {}. Valid values are {}-{} inclusive", code, 0, SpatSource.values()); + setSpatSource(SpatSource.unknown); + } + } + public void setSpatSource(byte[] code) { try { setSpatSource(SpatSource.values()[code[0]]); diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouter.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouter.java index 5fc0a9c96..40fe30ca3 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouter.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouter.java @@ -21,6 +21,7 @@ import us.dot.its.jpo.ode.OdeProperties; import us.dot.its.jpo.ode.coder.OdeBsmDataCreatorHelper; +import us.dot.its.jpo.ode.coder.OdeSpatDataCreatorHelper; import us.dot.its.jpo.ode.context.AppContext; import us.dot.its.jpo.ode.model.OdeAsn1Data; import us.dot.its.jpo.ode.model.OdeBsmData; @@ -34,57 +35,71 @@ public class Asn1DecodedDataRouter extends AbstractSubscriberProcessor { - private Logger logger = LoggerFactory.getLogger(this.getClass()); + private Logger logger = LoggerFactory.getLogger(this.getClass()); - private OdeProperties odeProperties; - private MessageProducer bsmProducer; - private MessageProducer timProducer; + private OdeProperties odeProperties; + private MessageProducer bsmProducer; + private MessageProducer timProducer; + private MessageProducer spatProducer; - public Asn1DecodedDataRouter(OdeProperties odeProps) { - super(); - this.odeProperties = odeProps; - this.bsmProducer = new MessageProducer<>(odeProps.getKafkaBrokers(), odeProps.getKafkaProducerType(), null, - OdeBsmSerializer.class.getName(), odeProperties.getKafkaTopicsDisabledSet()); - this.timProducer = MessageProducer.defaultStringMessageProducer(odeProps.getKafkaBrokers(), - odeProps.getKafkaProducerType(), odeProperties.getKafkaTopicsDisabledSet()); - } + public Asn1DecodedDataRouter(OdeProperties odeProps) { + super(); + this.odeProperties = odeProps; + this.bsmProducer = new MessageProducer<>(odeProps.getKafkaBrokers(), odeProps.getKafkaProducerType(), null, + OdeBsmSerializer.class.getName(), odeProperties.getKafkaTopicsDisabledSet()); + this.timProducer = MessageProducer.defaultStringMessageProducer(odeProps.getKafkaBrokers(), + odeProps.getKafkaProducerType(), odeProperties.getKafkaTopicsDisabledSet()); + this.spatProducer = MessageProducer.defaultStringMessageProducer(odeProps.getKafkaBrokers(), + odeProps.getKafkaProducerType(), odeProperties.getKafkaTopicsDisabledSet()); + } - @Override - public Object process(String consumedData) { - try { - JSONObject consumed = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); - int messageId = consumed.getJSONObject(AppContext.PAYLOAD_STRING).getJSONObject(AppContext.DATA_STRING) - .getJSONObject("MessageFrame").getInt("messageId"); + @Override + public Object process(String consumedData) { + try { + JSONObject consumed = XmlUtils.toJSONObject(consumedData).getJSONObject(OdeAsn1Data.class.getSimpleName()); + int messageId = consumed.getJSONObject(AppContext.PAYLOAD_STRING).getJSONObject(AppContext.DATA_STRING) + .getJSONObject("MessageFrame").getInt("messageId"); - RecordType recordType = RecordType - .valueOf(consumed.getJSONObject(AppContext.METADATA_STRING).getString("recordType")); + RecordType recordType = RecordType + .valueOf(consumed.getJSONObject(AppContext.METADATA_STRING).getString("recordType")); - if (messageId == J2735DSRCmsgID.BasicSafetyMessage.getMsgID()) { - // ODE-518/ODE-604 Demultiplex the messages to appropriate topics based on the - // "recordType" - OdeBsmData odeBsmData = OdeBsmDataCreatorHelper.createOdeBsmData(consumedData); - if (recordType == RecordType.bsmLogDuringEvent) { - bsmProducer.send(odeProperties.getKafkaTopicOdeBsmDuringEventPojo(), getRecord().key(), odeBsmData); - } else if (recordType == RecordType.rxMsg) { - bsmProducer.send(odeProperties.getKafkaTopicOdeBsmRxPojo(), getRecord().key(), odeBsmData); - } else if (recordType == RecordType.bsmTx) { - bsmProducer.send(odeProperties.getKafkaTopicOdeBsmTxPojo(), getRecord().key(), odeBsmData); - } - // Send all BSMs also to OdeBsmPojo - bsmProducer.send(odeProperties.getKafkaTopicOdeBsmPojo(), getRecord().key(), odeBsmData); - } else if (messageId == J2735DSRCmsgID.TravelerInformation.getMsgID()) { - String odeTimData = TimTransmogrifier.createOdeTimData(consumed).toString(); - if (recordType == RecordType.dnMsg) { - timProducer.send(odeProperties.getKafkaTopicOdeDNMsgJson(), getRecord().key(), odeTimData); - } else if (recordType == RecordType.rxMsg) { - timProducer.send(odeProperties.getKafkaTopicOdeTimRxJson(), getRecord().key(), odeTimData); - } - // Send all TIMs also to OdeTimJson - timProducer.send(odeProperties.getKafkaTopicOdeTimJson(), getRecord().key(), odeTimData); - } - } catch (Exception e) { - logger.error("Failed to route received data: " + consumedData, e); - } - return null; - } + if (messageId == J2735DSRCmsgID.BasicSafetyMessage.getMsgID()) { + // ODE-518/ODE-604 Demultiplex the messages to appropriate topics based on the + // "recordType" + OdeBsmData odeBsmData = OdeBsmDataCreatorHelper.createOdeBsmData(consumedData); + if (recordType == RecordType.bsmLogDuringEvent) { + bsmProducer.send(odeProperties.getKafkaTopicOdeBsmDuringEventPojo(), getRecord().key(), odeBsmData); + } else if (recordType == RecordType.rxMsg) { + bsmProducer.send(odeProperties.getKafkaTopicOdeBsmRxPojo(), getRecord().key(), odeBsmData); + } else if (recordType == RecordType.bsmTx) { + bsmProducer.send(odeProperties.getKafkaTopicOdeBsmTxPojo(), getRecord().key(), odeBsmData); + } + // Send all BSMs also to OdeBsmPojo + bsmProducer.send(odeProperties.getKafkaTopicOdeBsmPojo(), getRecord().key(), odeBsmData); + } else if (messageId == J2735DSRCmsgID.TravelerInformation.getMsgID()) { + String odeTimData = TimTransmogrifier.createOdeTimData(consumed).toString(); + if (recordType == RecordType.dnMsg) { + timProducer.send(odeProperties.getKafkaTopicOdeDNMsgJson(), getRecord().key(), odeTimData); + } else if (recordType == RecordType.rxMsg) { + timProducer.send(odeProperties.getKafkaTopicOdeTimRxJson(), getRecord().key(), odeTimData); + } + // Send all TIMs also to OdeTimJson + timProducer.send(odeProperties.getKafkaTopicOdeTimJson(), getRecord().key(), odeTimData); + } else if (messageId == J2735DSRCmsgID.SPATMessage.getMsgID()) { + String odeSpatData = OdeSpatDataCreatorHelper.createOdeSpatData(consumedData).toString(); + if (recordType == RecordType.dnMsg) { + spatProducer.send(odeProperties.getKafkaTopicOdeDNMsgJson(), getRecord().key(), odeSpatData); + } else if (recordType == RecordType.rxMsg) { + spatProducer.send(odeProperties.getKafkaTopicOdeSpatRxJson(), getRecord().key(), odeSpatData); + } else if (recordType == RecordType.spatTx) { + spatProducer.send(odeProperties.getKafkaTopicOdeSpatTxPojo(), getRecord().key(), odeSpatData); + } + // Send all SPATs also to OdeSpatJson + spatProducer.send(odeProperties.getKafkaTopicOdeSpatJson(), getRecord().key(), odeSpatData); + } + } catch (Exception e) { + logger.error("Failed to route received data: " + consumedData, e); + } + return null; + } } diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/AbstractAsn1DecodeMessageJSON.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/AbstractAsn1DecodeMessageJSON.java new file mode 100644 index 000000000..135865f5c --- /dev/null +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/AbstractAsn1DecodeMessageJSON.java @@ -0,0 +1,39 @@ +package us.dot.its.jpo.ode.services.asn1.message; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import us.dot.its.jpo.ode.coder.StringPublisher; +import us.dot.its.jpo.ode.model.OdeData; +import us.dot.its.jpo.ode.util.XmlUtils; +import us.dot.its.jpo.ode.wrapper.AbstractSubscriberProcessor; + +public abstract class AbstractAsn1DecodeMessageJSON extends AbstractSubscriberProcessor{ + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + protected StringPublisher codecPublisher; + + public AbstractAsn1DecodeMessageJSON() { + super(); + } + + public AbstractAsn1DecodeMessageJSON(StringPublisher codecPublisher) { + super(); + this.codecPublisher = codecPublisher; + } + + protected void publishEncodedMessageToAsn1Decoder(OdeData odeData) { + XmlUtils xmlUtils = new XmlUtils(); + try { + logger.info("Sending encoded message payload XML to ASN1 codec {}", xmlUtils.toXml(odeData)); + codecPublisher.publish(xmlUtils.toXml(odeData), + codecPublisher.getOdeProperties().getKafkaTopicAsn1DecoderInput()); + } catch (JsonProcessingException e) { + logger.info("Error sending encoded message payload XML to ASN1 codec {}", e.getMessage()); + e.printStackTrace(); + } + + } +} diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeBSMJSON.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeBSMJSON.java new file mode 100644 index 000000000..3a850fa47 --- /dev/null +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeBSMJSON.java @@ -0,0 +1,106 @@ +package us.dot.its.jpo.ode.services.asn1.message; + +import java.util.Set; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import us.dot.its.jpo.ode.OdeProperties; +import us.dot.its.jpo.ode.coder.StringPublisher; +import us.dot.its.jpo.ode.model.Asn1Encoding; +import us.dot.its.jpo.ode.model.Asn1Encoding.EncodingRule; +import us.dot.its.jpo.ode.model.OdeAsn1Data; +import us.dot.its.jpo.ode.model.OdeAsn1Payload; +import us.dot.its.jpo.ode.model.OdeBsmMetadata; +import us.dot.its.jpo.ode.model.OdeBsmMetadata.BsmSource; +import us.dot.its.jpo.ode.model.OdeData; +import us.dot.its.jpo.ode.model.OdeHexByteArray; +import us.dot.its.jpo.ode.model.OdeLogMetadata.RecordType; +import us.dot.its.jpo.ode.model.OdeLogMetadata.SecurityResultCode; +import us.dot.its.jpo.ode.model.OdeLogMsgMetadataLocation; +import us.dot.its.jpo.ode.model.OdeMsgPayload; +import us.dot.its.jpo.ode.model.ReceivedMessageDetails; +import us.dot.its.jpo.ode.model.RxSource; + +/*** + * Encoded message Processor + */ +public class Asn1DecodeBSMJSON extends AbstractAsn1DecodeMessageJSON { + private static final String BSMContentType = "BsmMessageContent"; + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + + public Asn1DecodeBSMJSON(OdeProperties odeProps) { + super(new StringPublisher(odeProps)); + } + + @Override + protected Object process(String consumedData) { + + OdeData odeData = null; + OdeMsgPayload payload = null; + + try { + logger.info("Consuming BSM data: {}", consumedData); + JSONObject rawJSONObject = new JSONObject(consumedData); + Set keys = rawJSONObject.keySet(); + for (Object key : keys) + { + //Send encoded BSM content to Codec service to decode BSM + if (key != null && key.toString().equals(BSMContentType)) { + /**process consumed data { "BsmMessageContent": [{ "metadata": { "utctimestamp:"2020-11-30T23:45:24.913657Z" }, "payload":"001480CF4B950C400022D2666E923D1EA6D4E28957BD55FFFFF001C758FD7E67D07F7FFF8000000002020218E1C1004A40196FBC042210115C030EF1408801021D4074CE7E1848101C5C0806E8E1A50101A84056EE8A1AB4102B840A9ADA21B9010259C08DEE1C1C560FFDDBFC070C0222210018BFCE309623120FFE9BFBB10C8238A0FFDC3F987114241610009BFB7113024780FFAC3F95F13A26800FED93FDD51202C5E0FE17BF9B31202FBAFFFEC87FC011650090019C70808440C83207873800000000001095084081C903447E31C12FC0"}]} + */ + OdeBsmMetadata metadata = null; + + JSONArray rawBSMJsonContentArray = rawJSONObject.getJSONArray(BSMContentType); + for (int i = 0; i < rawBSMJsonContentArray.length(); i++) { + JSONObject rawBSMJsonContent = (JSONObject) rawBSMJsonContentArray.get(i); + String encodedPayload = rawBSMJsonContent.get("payload").toString(); + JSONObject rawmetadata = (JSONObject) rawBSMJsonContent.get("metadata"); + logger.info("RAW BSM: {}", encodedPayload); + // construct payload + payload = new OdeAsn1Payload(new OdeHexByteArray(encodedPayload)); + + // construct metadata + metadata = new OdeBsmMetadata(payload); + metadata.setOdeReceivedAt(rawmetadata.getString("utctimestamp")); + metadata.setRecordType(RecordType.bsmTx); + metadata.setSecurityResultCode(SecurityResultCode.success); + if (rawmetadata.has("originRsu")) + metadata.setOriginIp(rawmetadata.getString("originRsu")); + + // construct metadata: receivedMessageDetails + ReceivedMessageDetails receivedMessageDetails = new ReceivedMessageDetails(); + receivedMessageDetails.setRxSource(RxSource.RV); + + // construct metadata: locationData + OdeLogMsgMetadataLocation locationData = new OdeLogMsgMetadataLocation(); + receivedMessageDetails.setLocationData(locationData); + + metadata.setReceivedMessageDetails(receivedMessageDetails); + metadata.setBsmSource(BsmSource.RV); + + Asn1Encoding unsecuredDataEncoding = new Asn1Encoding("unsecuredData", "MessageFrame", + EncodingRule.UPER); + metadata.addEncoding(unsecuredDataEncoding); + + // construct odeData + odeData = new OdeAsn1Data(metadata, payload); + + publishEncodedMessageToAsn1Decoder(odeData); + } + + } + else { + logger.error("Error received invalid key from consumed message"); + } + } + } catch (Exception e) { + logger.error("Error publishing to Asn1DecoderInput: {}", e.getMessage()); + } + return null; + } +} diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeMessageJSON.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeMessageJSON.java deleted file mode 100644 index f86702b16..000000000 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeMessageJSON.java +++ /dev/null @@ -1,207 +0,0 @@ -package us.dot.its.jpo.ode.services.asn1.message; - -import java.util.Set; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import us.dot.its.jpo.ode.OdeProperties; -import us.dot.its.jpo.ode.coder.StringPublisher; -import us.dot.its.jpo.ode.model.Asn1Encoding; -import us.dot.its.jpo.ode.model.OdeAsn1Data; -import us.dot.its.jpo.ode.model.OdeAsn1Payload; -import us.dot.its.jpo.ode.model.OdeBsmMetadata; -import us.dot.its.jpo.ode.model.OdeBsmMetadata.BsmSource; -import us.dot.its.jpo.ode.model.OdeData; -import us.dot.its.jpo.ode.model.OdeHexByteArray; -import us.dot.its.jpo.ode.model.OdeLogMetadata.RecordType; -import us.dot.its.jpo.ode.model.OdeLogMetadata.SecurityResultCode; -import us.dot.its.jpo.ode.model.OdeLogMsgMetadataLocation; -import us.dot.its.jpo.ode.model.OdeMsgPayload; -import us.dot.its.jpo.ode.model.OdeMsgMetadata; -import us.dot.its.jpo.ode.model.OdeMsgMetadata.GeneratedBy; -import us.dot.its.jpo.ode.model.OdeLogMetadata; -import us.dot.its.jpo.ode.model.OdeTimMetadata; -import us.dot.its.jpo.ode.model.OdeSpatMetadata; -import us.dot.its.jpo.ode.model.OdeSpatMetadata.SpatSource; -import us.dot.its.jpo.ode.model.ReceivedMessageDetails; -import us.dot.its.jpo.ode.model.RxSource; -import us.dot.its.jpo.ode.util.XmlUtils; -import us.dot.its.jpo.ode.model.Asn1Encoding.EncodingRule; -import us.dot.its.jpo.ode.wrapper.AbstractSubscriberProcessor; - -/*** - * Encoded message Processor - */ -public class Asn1DecodeMessageJSON extends AbstractSubscriberProcessor { - private static final String BSMContentType = "BsmMessageContent"; - private static final String TIMContentType = "TimMessageContent"; - private static final String SPATContentType = "SpatMessageContent"; - - private Logger logger = LoggerFactory.getLogger(this.getClass()); - - private StringPublisher codecPublisher; - - public Asn1DecodeMessageJSON(OdeProperties odeProps) { - super(); - this.codecPublisher = new StringPublisher(odeProps); - } - - @Override - protected Object process(String consumedData) { - - OdeData odeData = null; - OdeMsgPayload payload = null; - - try { - logger.info("Consuming data: {}", consumedData); - JSONObject rawJSONObject = new JSONObject(consumedData); - Set keys = rawJSONObject.keySet(); - for (Object key : keys) { - - //Send encoded BSM content to Codec service to decode BSM - if (key != null && key.toString().equals(BSMContentType)) { - /**process consumed data { "BsmMessageContent": [{ "metadata": { "utctimestamp:"2020-11-30T23:45:24.913657Z" }, "payload":"001480CF4B950C400022D2666E923D1EA6D4E28957BD55FFFFF001C758FD7E67D07F7FFF8000000002020218E1C1004A40196FBC042210115C030EF1408801021D4074CE7E1848101C5C0806E8E1A50101A84056EE8A1AB4102B840A9ADA21B9010259C08DEE1C1C560FFDDBFC070C0222210018BFCE309623120FFE9BFBB10C8238A0FFDC3F987114241610009BFB7113024780FFAC3F95F13A26800FED93FDD51202C5E0FE17BF9B31202FBAFFFEC87FC011650090019C70808440C83207873800000000001095084081C903447E31C12FC0"}]} - */ - OdeBsmMetadata metadata = null; - - JSONArray rawBSMJsonContentArray = rawJSONObject.getJSONArray(BSMContentType); - for (int i = 0; i < rawBSMJsonContentArray.length(); i++) { - JSONObject rawBSMJsonContent = (JSONObject) rawBSMJsonContentArray.get(i); - String encodedPayload = rawBSMJsonContent.get("payload").toString(); - JSONObject rawmetadata = (JSONObject) rawBSMJsonContent.get("metadata"); - - // construct payload - payload = new OdeAsn1Payload(new OdeHexByteArray(encodedPayload)); - - // construct metadata - metadata = new OdeBsmMetadata(payload); - metadata.setOdeReceivedAt(rawmetadata.getString("utctimestamp")); - metadata.setRecordType(RecordType.bsmTx); - metadata.setSecurityResultCode(SecurityResultCode.success); - - // construct metadata: receivedMessageDetails - ReceivedMessageDetails receivedMessageDetails = new ReceivedMessageDetails(); - receivedMessageDetails.setRxSource(RxSource.RV); - - // construct metadata: locationData - OdeLogMsgMetadataLocation locationData = new OdeLogMsgMetadataLocation(); - receivedMessageDetails.setLocationData(locationData); - - metadata.setReceivedMessageDetails(receivedMessageDetails); - metadata.setBsmSource(BsmSource.RV); - - Asn1Encoding unsecuredDataEncoding = new Asn1Encoding("unsecuredData", "MessageFrame", - EncodingRule.UPER); - metadata.addEncoding(unsecuredDataEncoding); - - // construct odeData - odeData = new OdeAsn1Data(metadata, payload); - - publishEncodedMessageToAsn1Decoder(odeData); - } - - } else if (key != null && key.toString().equals(SPATContentType)) { - /** - * process consumed data { "SpatMessageContent": [{ "metadata": { "utctimestamp: - * "2020-11-30T23:45:24.913657Z" } - * "payload":"00131A604A380583702005837800080008100000040583705043002580"}]} - */ - - OdeSpatMetadata metadata = null; - JSONArray rawSPATJsonContentArray = rawJSONObject.getJSONArray(SPATContentType); - for (int i = 0; i < rawSPATJsonContentArray.length(); i++) { - JSONObject rawSPATJsonContent = (JSONObject) rawSPATJsonContentArray.get(i); - String encodedPayload = rawSPATJsonContent.get("payload").toString(); - JSONObject rawmetadata = (JSONObject) rawSPATJsonContent.get("metadata"); - - // construct payload - payload = new OdeAsn1Payload(new OdeHexByteArray(encodedPayload)); - - // construct metadata - metadata = new OdeSpatMetadata(payload); - metadata.setOdeReceivedAt(rawmetadata.getString("utctimestamp")); - metadata.setRecordType(RecordType.spatTx); - metadata.setSecurityResultCode(SecurityResultCode.success); - - // construct metadata: receivedMessageDetails - ReceivedMessageDetails receivedMessageDetails = new ReceivedMessageDetails(); - receivedMessageDetails.setRxSource(RxSource.NA); - - // construct metadata: locationData - OdeLogMsgMetadataLocation locationData = new OdeLogMsgMetadataLocation(); - receivedMessageDetails.setLocationData(locationData); - - metadata.setReceivedMessageDetails(receivedMessageDetails); - metadata.setSpatSource(SpatSource.V2X); - - Asn1Encoding unsecuredDataEncoding = new Asn1Encoding("unsecuredData", "MessageFrame", - EncodingRule.UPER); - metadata.addEncoding(unsecuredDataEncoding); - - // construct odeData - odeData = new OdeAsn1Data(metadata, payload); - - publishEncodedMessageToAsn1Decoder(odeData); - } - } else if (key != null && key.toString().equals(TIMContentType)) { - /**process consumed data - * {"TimMessageContent":[{"metadata":{"utctimestamp":"2020-11-30T23:45:24.913657Z", "originRsu":"172.250.250.77"},"payload":"001f5520100000000000564fb69082709b898aac59717eadfffe4fca1bf0a9d828407e137131558b2e2fd581f46ffff00118b2e3b3ee6e2702c18b2e34f4e6e269ec18b2e285426e2580598b2e23b6e6e254c80420005c48"}]} - */ - OdeTimMetadata metadata = null; - - JSONArray rawTIMJsonContentArray = rawJSONObject.getJSONArray(TIMContentType); - for(int i=0;i keys = rawJSONObject.keySet(); + for (Object key : keys) { + + if (key != null && key.toString().equals(SPATContentType)) { + /** + * process consumed data { "SpatMessageContent": [{ "metadata": { "utctimestamp: + * "2020-11-30T23:45:24.913657Z" } + * "payload":"00131A604A380583702005837800080008100000040583705043002580"}]} + */ + + OdeSpatMetadata metadata = null; + JSONArray rawSPATJsonContentArray = rawJSONObject.getJSONArray(SPATContentType); + for (int i = 0; i < rawSPATJsonContentArray.length(); i++) { + JSONObject rawSPATJsonContent = (JSONObject) rawSPATJsonContentArray.get(i); + String encodedPayload = rawSPATJsonContent.get("payload").toString(); + JSONObject rawmetadata = (JSONObject) rawSPATJsonContent.get("metadata"); + logger.info("RAW SPAT: {}", encodedPayload); + // construct payload + payload = new OdeAsn1Payload(new OdeHexByteArray(encodedPayload)); + + // construct metadata + metadata = new OdeSpatMetadata(payload); + metadata.setOdeReceivedAt(rawmetadata.getString("utctimestamp")); + metadata.setRecordType(RecordType.spatTx); + metadata.setSecurityResultCode(SecurityResultCode.success); + + // construct metadata: receivedMessageDetails + ReceivedMessageDetails receivedMessageDetails = new ReceivedMessageDetails(); + receivedMessageDetails.setRxSource(RxSource.NA); + + // construct metadata: locationData + OdeLogMsgMetadataLocation locationData = new OdeLogMsgMetadataLocation(); + receivedMessageDetails.setLocationData(locationData); + + metadata.setReceivedMessageDetails(receivedMessageDetails); + metadata.setSpatSource(SpatSource.V2X); + + Asn1Encoding unsecuredDataEncoding = new Asn1Encoding("unsecuredData", "MessageFrame", + EncodingRule.UPER); + metadata.addEncoding(unsecuredDataEncoding); + + // construct odeData + odeData = new OdeAsn1Data(metadata, payload); + + publishEncodedMessageToAsn1Decoder(odeData); + } + } + else { + logger.error("Error received invalid key from consumed message"); + } + } + } catch (Exception e) { + logger.error("Error publishing to Asn1DecoderInput: {}", e.getMessage()); + } + return null; + } + +} diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeTIMJSON.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeTIMJSON.java new file mode 100644 index 000000000..672d2c2e6 --- /dev/null +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/services/asn1/message/Asn1DecodeTIMJSON.java @@ -0,0 +1,91 @@ +package us.dot.its.jpo.ode.services.asn1.message; + +import java.util.Set; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import us.dot.its.jpo.ode.OdeProperties; +import us.dot.its.jpo.ode.coder.StringPublisher; +import us.dot.its.jpo.ode.model.Asn1Encoding; +import us.dot.its.jpo.ode.model.Asn1Encoding.EncodingRule; +import us.dot.its.jpo.ode.model.OdeAsn1Data; +import us.dot.its.jpo.ode.model.OdeAsn1Payload; +import us.dot.its.jpo.ode.model.OdeData; +import us.dot.its.jpo.ode.model.OdeHexByteArray; +import us.dot.its.jpo.ode.model.OdeLogMetadata.RecordType; +import us.dot.its.jpo.ode.model.OdeMsgMetadata.GeneratedBy; +import us.dot.its.jpo.ode.model.OdeMsgPayload; +import us.dot.its.jpo.ode.model.OdeTimMetadata; + +/*** + * Encoded message Processor + */ +public class Asn1DecodeTIMJSON extends AbstractAsn1DecodeMessageJSON { + private static final String TIMContentType = "TimMessageContent"; + + private Logger logger = LoggerFactory.getLogger(this.getClass()); + + + public Asn1DecodeTIMJSON(OdeProperties odeProps) { + super(new StringPublisher(odeProps)); + } + + @Override + protected Object process(String consumedData) { + + OdeData odeData = null; + OdeMsgPayload payload = null; + + try { + logger.info("Consuming TIM data: {}", consumedData); + JSONObject rawJSONObject = new JSONObject(consumedData); + Set keys = rawJSONObject.keySet(); + for (Object key : keys) + { + if (key != null && key.toString().equals(TIMContentType)) { + /**process consumed data + * {"TimMessageContent":[{"metadata":{"utctimestamp":"2020-11-30T23:45:24.913657Z", "originRsu":"172.250.250.77"},"payload":"001f5520100000000000564fb69082709b898aac59717eadfffe4fca1bf0a9d828407e137131558b2e2fd581f46ffff00118b2e3b3ee6e2702c18b2e34f4e6e269ec18b2e285426e2580598b2e23b6e6e254c80420005c48"}]} + */ + OdeTimMetadata metadata = null; + + JSONArray rawTIMJsonContentArray = rawJSONObject.getJSONArray(TIMContentType); + for(int i=0;i asn1RawBSMJSONConsumer = MessageConsumer.defaultStringMessageConsumer( + odeProps.getKafkaBrokers(), this.getClass().getSimpleName(), asn1DecodeBSMJSON); + asn1RawBSMJSONConsumer.setName("asn1DecodeBSMJSON"); + asn1DecodeBSMJSON.start(asn1RawBSMJSONConsumer, odeProps.getKafkaTopicOdeRawEncodedBSMJson()); - MessageConsumer asn1RawMessageJSONConsumer = MessageConsumer.defaultStringMessageConsumer( - odeProps.getKafkaBrokers(), this.getClass().getSimpleName(), asn1DecodeMessageJSON); - asn1RawMessageJSONConsumer.setName("asn1DecodeMessageJSON"); + logger.info("Send encoded SPAT to ASN.1 Decoder"); + Asn1DecodeSPATJSON asn1DecodeSPATJSON = new Asn1DecodeSPATJSON(odeProps); - asn1DecodeMessageJSON.start(asn1RawMessageJSONConsumer, odeProps.getKafkaTopicOdeRawEncodedMessageJson()); - + //SPAT + MessageConsumer asn1RawSPATJSONConsumer = MessageConsumer.defaultStringMessageConsumer( + odeProps.getKafkaBrokers(), this.getClass().getSimpleName(), asn1DecodeSPATJSON); + asn1RawSPATJSONConsumer.setName("asn1DecodeSPATJSON"); + asn1DecodeSPATJSON.start(asn1RawSPATJSONConsumer, odeProps.getKafkaTopicOdeRawEncodedSPATJson()); + + logger.info("Send encoded TIM to ASN.1 Decoder"); + Asn1DecodeTIMJSON asn1DecodeTIMJSON = new Asn1DecodeTIMJSON(odeProps); + + //TIM + MessageConsumer asn1RawTIMJSONConsumer = MessageConsumer.defaultStringMessageConsumer( + odeProps.getKafkaBrokers(), this.getClass().getSimpleName(), asn1DecodeTIMJSON); + asn1RawTIMJSONConsumer.setName("asn1DecodeTIMJSON"); + asn1DecodeTIMJSON.start(asn1RawTIMJSONConsumer, odeProps.getKafkaTopicOdeRawEncodedTIMJson()); } } diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/bsm/BsmReceiver.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/bsm/BsmReceiver.java index 62e08ad57..96e630152 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/bsm/BsmReceiver.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/bsm/BsmReceiver.java @@ -79,6 +79,7 @@ public void run() { JSONObject metadataObject = new JSONObject(); metadataObject.put("utctimestamp", timestamp); + metadataObject.put("originRsu", senderIp); JSONObject messageObject = new JSONObject(); messageObject.put("metadata", metadataObject); @@ -95,7 +96,7 @@ public void run() { // Submit JSON to the OdeRawEncodedMessageJson Kafka Topic logger.debug("Publishing JSON BSM..."); - this.bsmPublisher.publish(jsonObject.toString(), this.bsmPublisher.getOdeProperties().getKafkaTopicOdeRawEncodedMessageJson()); + this.bsmPublisher.publish(jsonObject.toString(), this.bsmPublisher.getOdeProperties().getKafkaTopicOdeRawEncodedBSMJson()); } } catch (Exception e) { logger.error("Error receiving packet", e); diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/tim/TimReceiver.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/tim/TimReceiver.java index a023822a4..da4dfcb92 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/tim/TimReceiver.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/udp/tim/TimReceiver.java @@ -94,7 +94,7 @@ public void run() { // Submit JSON to the OdeRawEncodedMessageJson Kafka Topic logger.debug("Publishing JSON TIM..."); - this.timPublisher.publish(jsonObject.toString(), this.timPublisher.getOdeProperties().getKafkaTopicOdeRawEncodedMessageJson()); + this.timPublisher.publish(jsonObject.toString(), this.timPublisher.getOdeProperties().getKafkaTopicOdeRawEncodedTIMJson()); } } catch (Exception e) { logger.error("Error receiving packet", e); diff --git a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/upload/FileUploadController.java b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/upload/FileUploadController.java index 55ce09010..9770ed560 100644 --- a/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/upload/FileUploadController.java +++ b/jpo-ode-svcs/src/main/java/us/dot/its/jpo/ode/upload/FileUploadController.java @@ -72,6 +72,7 @@ public FileUploadController( // Create unfiltered exporters threadPool.submit(new StompStringExporter(odeProperties, UNFILTERED_OUTPUT_TOPIC, template, odeProperties.getKafkaTopicOdeBsmJson())); threadPool.submit(new StompStringExporter(odeProperties, UNFILTERED_OUTPUT_TOPIC, template, odeProperties.getKafkaTopicOdeTimJson())); + threadPool.submit(new StompStringExporter(odeProperties, UNFILTERED_OUTPUT_TOPIC, template, odeProperties.getKafkaTopicOdeSpatJson())); threadPool.submit(new StompStringExporter(odeProperties, UNFILTERED_OUTPUT_TOPIC, template, odeProperties.getKafkaTopicDriverAlertJson())); threadPool.submit(new StompStringExporter(odeProperties, UNFILTERED_OUTPUT_TOPIC, template, odeProperties.getKafkaTopicOdeTimBroadcastJson())); diff --git a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouterTest.java b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouterTest.java index e5b0f6510..338fd1ef7 100644 --- a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouterTest.java +++ b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1DecodedDataRouterTest.java @@ -18,6 +18,7 @@ import java.util.Set; import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.json.JSONException; import org.json.JSONObject; import org.junit.Before; import org.junit.Test; @@ -81,33 +82,41 @@ public void createMockProducers() { @Test public void testProcessBsmLogDuringEvent() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "bsmLogDuringEvent"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 2; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 0; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "bsmLogDuringEvent"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 2; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 0; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); @@ -115,33 +124,41 @@ public void testProcessBsmLogDuringEvent() throws XmlUtilsException { @Test public void testProcessRxMsgBsm() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "rxMsg"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 2; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 0; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "rxMsg"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 2; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 0; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); @@ -149,33 +166,41 @@ public void testProcessRxMsgBsm() throws XmlUtilsException { @Test public void testProcessTxMsgBsm() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "bsmTx"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 2; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 0; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "bsmTx"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 2; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 0; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); @@ -183,33 +208,41 @@ public void testProcessTxMsgBsm() throws XmlUtilsException { @Test public void testProcessDnsTim() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.TravelerInformation.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "dnMsg"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 0; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 2; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.TravelerInformation.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "dnMsg"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 0; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 2; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); @@ -217,33 +250,41 @@ public void testProcessDnsTim() throws XmlUtilsException { @Test public void testProcessRxTim() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.TravelerInformation.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "rxMsg"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 0; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 2; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.TravelerInformation.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "rxMsg"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 0; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 2; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); @@ -251,33 +292,41 @@ public void testProcessRxTim() throws XmlUtilsException { @Test public void testProcessUnsupportedTim() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.TravelerInformation.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "unsupported"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 0; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 1; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.TravelerInformation.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "unsupported"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 0; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 1; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); @@ -285,33 +334,41 @@ public void testProcessUnsupportedTim() throws XmlUtilsException { @Test public void testProcessUnsupportedBsm() throws XmlUtilsException { - new Expectations() { - - { - XmlUtils.toJSONObject(anyString); - result = mockConsumed; - - mockConsumed.getJSONObject(anyString); - result = mockConsumed; - - // mock the messageID to be BSM - mockConsumed.getInt(anyString); - result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); - - // mock the record type to be bsmLogDuringEvent - mockConsumed.getString(anyString); - result = "unsupported"; - - mockConsumerRecord.key(); - result = "testKey"; - - mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); - times = 1; - - mockTimMessageProducer.send(null, anyString, anyString); - times = 0; - } - }; + try { + new Expectations() { + + { + XmlUtils.toJSONObject(anyString); + result = mockConsumed; + + mockConsumed.getJSONObject(anyString); + result = mockConsumed; + + // mock the messageID to be BSM + mockConsumed.getInt(anyString); + result = J2735DSRCmsgID.BasicSafetyMessage.getMsgID(); + + // mock the record type to be bsmLogDuringEvent + mockConsumed.getString(anyString); + result = "unsupported"; + + mockConsumerRecord.key(); + result = "testKey"; + + mockBsmMessageProducer.send(null, anyString, (OdeBsmData) any); + times = 1; + + mockTimMessageProducer.send(null, anyString, anyString); + times = 0; + } + }; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1DecodedDataRouter.setRecord(mockConsumerRecord); testAsn1DecodedDataRouter.process("testConsumedData"); diff --git a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouterTest.java b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouterTest.java index 0ec3d25c4..2388cd01e 100644 --- a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouterTest.java +++ b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/services/asn1/Asn1EncodedDataRouterTest.java @@ -16,6 +16,7 @@ package us.dot.its.jpo.ode.services.asn1; import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; import org.junit.Test; @@ -77,66 +78,90 @@ public void testNoRsus(@Mocked JSONObject mockJSONObject) throws XmlUtilsExcepti @Test public void testSingleRsu(@Mocked JSONObject mockJSONObject) throws XmlUtilsException { - new Expectations() {{ - XmlUtils.toJSONObject(anyString); - result = mockJSONObject; - - mockJSONObject.has("request"); - result = true; - - mockJSONObject.has("rsus"); - result = true; - - mockJSONObject.get("rsus"); - //result = new JSONObject(); - }}; + try { + new Expectations() {{ + XmlUtils.toJSONObject(anyString); + result = mockJSONObject; + + mockJSONObject.has("request"); + result = true; + + mockJSONObject.has("rsus"); + result = true; + + mockJSONObject.get("rsus"); + //result = new JSONObject(); + }}; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1EncodedDataRouter.process("stringthing"); } @Test public void testRsuArray(@Mocked JSONObject mockJSONObject) throws XmlUtilsException { - new Expectations() {{ - XmlUtils.toJSONObject(anyString); - result = mockJSONObject; - - mockJSONObject.has("request"); - result = true; - - mockJSONObject.has("rsus"); - result = true; - - mockJSONObject.get("rsus"); - result = new JSONArray(); - }}; + try { + new Expectations() {{ + XmlUtils.toJSONObject(anyString); + result = mockJSONObject; + + mockJSONObject.has("request"); + result = true; + + mockJSONObject.has("rsus"); + result = true; + + mockJSONObject.get("rsus"); + result = new JSONArray(); + }}; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1EncodedDataRouter.process("stringthing"); } @Test public void testWithASD(@Mocked JSONObject mockJSONObject) throws XmlUtilsException { - new Expectations() {{ - XmlUtils.toJSONObject(anyString); - result = mockJSONObject; - - mockJSONObject.getJSONObject(AppContext.METADATA_STRING); - result = mockJSONObject; - - mockJSONObject.has(TimTransmogrifier.REQUEST_STRING); - result = true; + try { + new Expectations() {{ + XmlUtils.toJSONObject(anyString); + result = mockJSONObject; + + mockJSONObject.getJSONObject(AppContext.METADATA_STRING); + result = mockJSONObject; + + mockJSONObject.has(TimTransmogrifier.REQUEST_STRING); + result = true; - mockJSONObject.getJSONObject(TimTransmogrifier.REQUEST_STRING); - result = mockJSONObject; - - mockJSONObject.has(TimTransmogrifier.RSUS_STRING); - result = true; - times = 2; - - mockJSONObject.get(TimTransmogrifier.RSUS_STRING); - result = mockJSONObject; - times = 2; - - mockJSONObject.has(Asn1CommandManager.ADVISORY_SITUATION_DATA_STRING); - result = true; - }}; + mockJSONObject.getJSONObject(TimTransmogrifier.REQUEST_STRING); + result = mockJSONObject; + + mockJSONObject.has(TimTransmogrifier.RSUS_STRING); + result = true; + times = 2; + + mockJSONObject.get(TimTransmogrifier.RSUS_STRING); + result = mockJSONObject; + times = 2; + + mockJSONObject.has(Asn1CommandManager.ADVISORY_SITUATION_DATA_STRING); + result = true; + }}; + } catch (XmlUtilsException e) { + + e.printStackTrace(); + } catch (JSONException e) { + + e.printStackTrace(); + } testAsn1EncodedDataRouter.process("stringthing"); } diff --git a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java index 9304d7236..db3ddd30b 100644 --- a/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java +++ b/jpo-ode-svcs/src/test/java/us/dot/its/jpo/ode/upload/FileUploadIntegrationTests.java @@ -24,10 +24,10 @@ import org.junit.Ignore; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; diff --git a/pom.xml b/pom.xml index 63bd9aaec..22258856e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 1.4.1.RELEASE + 2.5.0 @@ -33,7 +33,7 @@ UTF-8 UTF-8 - 1.8 + 11 ${project.build.directory}/${project.artifactId}-${project.version} @@ -51,17 +51,26 @@ org.springframework.boot spring-boot-starter - + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-starter-test test - + + + org.codehaus.groovy + groovy-all + 3.0.8 + pom + org.jmockit jmockit - 1.40 + 1.41 test @@ -69,6 +78,12 @@ junit test + + + + log4j + log4j + @@ -99,8 +114,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + 11 + 11 @@ -123,7 +138,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19.1 + 3.0.0-M5 true diff --git a/sample.env b/sample.env index 9ebd58000..a9f3b01d4 100644 --- a/sample.env +++ b/sample.env @@ -51,6 +51,7 @@ CVPEP_BSM_K_AWS_EXPIRATION=Expiration CVPEP_BSM_API_ENDPOINT= CVPEP_BSM_HEADER_ACCEPT=application/json CVPEP_BSM_HEADER_X_API_KEY= +CVPEP_BSM_GROUP=group_cvpep_bsm RDE_BSM_BUCKET_NAME= RDE_BSM_DEPOSIT_KEY=wydot-filtered-bsm- @@ -62,7 +63,7 @@ RDE_BSM_K_AWS_EXPIRATION=Expiration RDE_BSM_API_ENDPOINT= RDE_BSM_HEADER_ACCEPT=application/json RDE_BSM_HEADER_X_API_KEY= - +RDE_BSM_GROUP=group_rde_bsm CVPEP_TIM_BUCKET_NAME= CVPEP_TIM_DEPOSIT_KEY=wydot-tim- @@ -74,6 +75,7 @@ CVPEP_TIM_K_AWS_EXPIRATION=Expiration CVPEP_TIM_API_ENDPOINT= CVPEP_TIM_HEADER_ACCEPT=application/json CVPEP_TIM_HEADER_X_API_KEY= +CVPEP_TIM_GROUP=group_cvpep_tim RDE_TIM_BUCKET_NAME= RDE_TIM_DEPOSIT_KEY=wydot-filtered-tim- @@ -85,6 +87,7 @@ RDE_TIM_K_AWS_EXPIRATION=Expiration RDE_TIM_API_ENDPOINT= RDE_TIM_HEADER_ACCEPT=application/json RDE_TIM_HEADER_X_API_KEY= +RDE_TIM_GROUP=group_rde_tim ######################### # SDW Depositor Properties