Loading pom.xml +13 −26 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <version>2.1.0.RELEASE</version> <relativePath /> </parent> Loading @@ -13,7 +13,7 @@ <groupId>es.redmic.lib</groupId> <artifactId>broker-lib</artifactId> <packaging>jar</packaging> <version>0.6.0</version> <version>0.8.0</version> <name>broker-lib</name> <properties> Loading @@ -24,16 +24,15 @@ <java.version>1.8</java.version> <!-- REDMIC --> <redmic.exceptions.version>0.6.0</redmic.exceptions.version> <redmic.jackson-jsonschema.version>0.6.0</redmic.jackson-jsonschema.version> <redmic.exceptions.version>0.7.0</redmic.exceptions.version> <redmic.jackson-jsonschema.version>0.7.0</redmic.jackson-jsonschema.version> <redmic.jts4jackson.version>0.0.1</redmic.jts4jackson.version> <!-- OTHERS --> <avro.version>1.8.2</avro.version> <confluent.version>5.0.0</confluent.version> <kafka.version>1.1.0</kafka.version> <confluent.version>5.0.1</confluent.version> <kafka.version>2.0.1</kafka.version> <hibernate-validator.version>6.0.8.Final</hibernate-validator.version> <geotools.version>19.0</geotools.version> <jackson-datatype-jts.version>2.4</jackson-datatype-jts.version> <geotools.version>20.1</geotools.version> <!-- Version plugins --> <jacoco.version>0.8.1</jacoco.version> Loading @@ -56,13 +55,13 @@ <artifactId>jackson-jsonschema</artifactId> <version>${redmic.jackson-jsonschema.version}</version> </dependency> <!-- Others --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <scope>provided</scope> <groupId>es.redmic.lib</groupId> <artifactId>jts4jackson</artifactId> <version>${redmic.jts4jackson.version}</version> </dependency> <!-- Others --> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-joda</artifactId> Loading @@ -73,18 +72,6 @@ <artifactId>jackson-dataformat-avro</artifactId> </dependency> <dependency> <groupId>com.bedatadriven</groupId> <artifactId>jackson-datatype-jts</artifactId> <version>${jackson-datatype-jts.version}</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> Loading src/main/java/es/redmic/brokerlib/alert/AlertService.java +30 −5 Original line number Diff line number Diff line package es.redmic.brokerlib.alert; import javax.annotation.PostConstruct; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; Loading @@ -21,22 +24,44 @@ public class AlertService { @Value("${spring.profiles.active}") private String PROFILE_ACTIVE; @Value("${info.microservice.name}") private String MICROSERVICE_NAME; private String subjectDefault; @PostConstruct private void AlertServicePostConstruct() { subjectDefault = "[" + MICROSERVICE_NAME + "][" + PROFILE_ACTIVE + "]"; } @Autowired private KafkaTemplate<String, Message> kafkaTemplate; public void infoAlert(String subject, String message) { alert(subject, message, AlertType.INFO.name()); } public void warnAlert(String subject, String message) { alert(subject, message, AlertType.WARN.name()); } public void errorAlert(String subject, String message) { if (PROFILE_ACTIVE.equals("test")) ALERT_EMAIL = "test@redmic.es"; alert(subject, message, AlertType.ERROR.name()); } public void alert(String subject, String message, String type) { String subjectDefault = "[ERROR][" + PROFILE_ACTIVE + "] "; send(new Message(ALERT_EMAIL, subjectDefault + subject, message, AlertType.ERROR.name())); send(new Message(ALERT_EMAIL, subjectDefault + "[" + type + "] " + subject, message, type)); } private void send(Message message) { logger.info("sending alert='{}' to topic='{}'", message, ALERT_TOPIC); kafkaTemplate.send(ALERT_TOPIC, message); kafkaTemplate.send(ALERT_TOPIC, String.valueOf(DateTime.now().getMillis()), message); } } src/main/java/es/redmic/brokerlib/avro/common/CommonDTO.java +25 −0 Original line number Diff line number Diff line Loading @@ -19,4 +19,29 @@ public abstract class CommonDTO extends org.apache.avro.specific.SpecificRecordB public void setId(String id) { this.id = id; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CommonDTO other = (CommonDTO) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } } src/main/java/es/redmic/brokerlib/avro/common/EventTypes.java +13 −0 Original line number Diff line number Diff line Loading @@ -61,4 +61,17 @@ public abstract class EventTypes { return (eventType.equals(EventTypes.CREATED.toString()) || eventType.equals(EventTypes.UPDATED.toString()) || eventType.equals(EventTypes.DELETED.toString())); } /** * Función que identifica si el contenido de un evento puede ser modificado * * @param eventType * tipo de evento * @return true si el tipo coincide con finales de ciclo y no borrado, false en * caso contrario **/ protected static boolean isUpdatable(String eventType) { return (isSnapshot(eventType) && !eventType.equals(EventTypes.DELETED.toString())); } } src/main/java/es/redmic/brokerlib/avro/geodata/common/FeatureDTO.java +4 −3 Original line number Diff line number Diff line Loading @@ -3,20 +3,21 @@ package es.redmic.brokerlib.avro.geodata.common; import javax.validation.Valid; import javax.validation.constraints.NotNull; import com.bedatadriven.jackson.datatype.jts.JtsModule; import org.locationtech.jts.geom.Geometry; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.ObjectMapper; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaIgnore; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull; import com.vividsolutions.jts.geom.Geometry; import es.redmic.brokerlib.avro.common.CommonDTO; import es.redmic.brokerlib.avro.geodata.utils.GeoJSONFeatureType; import es.redmic.jts4jackson.module.JTSModule; public abstract class FeatureDTO<TProperties extends PropertiesBaseDTO, TGeometry extends Geometry> extends CommonDTO { @JsonIgnore protected ObjectMapper mapper = new ObjectMapper().registerModules(new JtsModule()); protected ObjectMapper mapper = new ObjectMapper().registerModule(new JTSModule()); private String uuid; Loading Loading
pom.xml +13 −26 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <version>2.1.0.RELEASE</version> <relativePath /> </parent> Loading @@ -13,7 +13,7 @@ <groupId>es.redmic.lib</groupId> <artifactId>broker-lib</artifactId> <packaging>jar</packaging> <version>0.6.0</version> <version>0.8.0</version> <name>broker-lib</name> <properties> Loading @@ -24,16 +24,15 @@ <java.version>1.8</java.version> <!-- REDMIC --> <redmic.exceptions.version>0.6.0</redmic.exceptions.version> <redmic.jackson-jsonschema.version>0.6.0</redmic.jackson-jsonschema.version> <redmic.exceptions.version>0.7.0</redmic.exceptions.version> <redmic.jackson-jsonschema.version>0.7.0</redmic.jackson-jsonschema.version> <redmic.jts4jackson.version>0.0.1</redmic.jts4jackson.version> <!-- OTHERS --> <avro.version>1.8.2</avro.version> <confluent.version>5.0.0</confluent.version> <kafka.version>1.1.0</kafka.version> <confluent.version>5.0.1</confluent.version> <kafka.version>2.0.1</kafka.version> <hibernate-validator.version>6.0.8.Final</hibernate-validator.version> <geotools.version>19.0</geotools.version> <jackson-datatype-jts.version>2.4</jackson-datatype-jts.version> <geotools.version>20.1</geotools.version> <!-- Version plugins --> <jacoco.version>0.8.1</jacoco.version> Loading @@ -56,13 +55,13 @@ <artifactId>jackson-jsonschema</artifactId> <version>${redmic.jackson-jsonschema.version}</version> </dependency> <!-- Others --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <scope>provided</scope> <groupId>es.redmic.lib</groupId> <artifactId>jts4jackson</artifactId> <version>${redmic.jts4jackson.version}</version> </dependency> <!-- Others --> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-joda</artifactId> Loading @@ -73,18 +72,6 @@ <artifactId>jackson-dataformat-avro</artifactId> </dependency> <dependency> <groupId>com.bedatadriven</groupId> <artifactId>jackson-datatype-jts</artifactId> <version>${jackson-datatype-jts.version}</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> Loading
src/main/java/es/redmic/brokerlib/alert/AlertService.java +30 −5 Original line number Diff line number Diff line package es.redmic.brokerlib.alert; import javax.annotation.PostConstruct; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.kafka.core.KafkaTemplate; Loading @@ -21,22 +24,44 @@ public class AlertService { @Value("${spring.profiles.active}") private String PROFILE_ACTIVE; @Value("${info.microservice.name}") private String MICROSERVICE_NAME; private String subjectDefault; @PostConstruct private void AlertServicePostConstruct() { subjectDefault = "[" + MICROSERVICE_NAME + "][" + PROFILE_ACTIVE + "]"; } @Autowired private KafkaTemplate<String, Message> kafkaTemplate; public void infoAlert(String subject, String message) { alert(subject, message, AlertType.INFO.name()); } public void warnAlert(String subject, String message) { alert(subject, message, AlertType.WARN.name()); } public void errorAlert(String subject, String message) { if (PROFILE_ACTIVE.equals("test")) ALERT_EMAIL = "test@redmic.es"; alert(subject, message, AlertType.ERROR.name()); } public void alert(String subject, String message, String type) { String subjectDefault = "[ERROR][" + PROFILE_ACTIVE + "] "; send(new Message(ALERT_EMAIL, subjectDefault + subject, message, AlertType.ERROR.name())); send(new Message(ALERT_EMAIL, subjectDefault + "[" + type + "] " + subject, message, type)); } private void send(Message message) { logger.info("sending alert='{}' to topic='{}'", message, ALERT_TOPIC); kafkaTemplate.send(ALERT_TOPIC, message); kafkaTemplate.send(ALERT_TOPIC, String.valueOf(DateTime.now().getMillis()), message); } }
src/main/java/es/redmic/brokerlib/avro/common/CommonDTO.java +25 −0 Original line number Diff line number Diff line Loading @@ -19,4 +19,29 @@ public abstract class CommonDTO extends org.apache.avro.specific.SpecificRecordB public void setId(String id) { this.id = id; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CommonDTO other = (CommonDTO) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } }
src/main/java/es/redmic/brokerlib/avro/common/EventTypes.java +13 −0 Original line number Diff line number Diff line Loading @@ -61,4 +61,17 @@ public abstract class EventTypes { return (eventType.equals(EventTypes.CREATED.toString()) || eventType.equals(EventTypes.UPDATED.toString()) || eventType.equals(EventTypes.DELETED.toString())); } /** * Función que identifica si el contenido de un evento puede ser modificado * * @param eventType * tipo de evento * @return true si el tipo coincide con finales de ciclo y no borrado, false en * caso contrario **/ protected static boolean isUpdatable(String eventType) { return (isSnapshot(eventType) && !eventType.equals(EventTypes.DELETED.toString())); } }
src/main/java/es/redmic/brokerlib/avro/geodata/common/FeatureDTO.java +4 −3 Original line number Diff line number Diff line Loading @@ -3,20 +3,21 @@ package es.redmic.brokerlib.avro.geodata.common; import javax.validation.Valid; import javax.validation.constraints.NotNull; import com.bedatadriven.jackson.datatype.jts.JtsModule; import org.locationtech.jts.geom.Geometry; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.ObjectMapper; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaIgnore; import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaNotNull; import com.vividsolutions.jts.geom.Geometry; import es.redmic.brokerlib.avro.common.CommonDTO; import es.redmic.brokerlib.avro.geodata.utils.GeoJSONFeatureType; import es.redmic.jts4jackson.module.JTSModule; public abstract class FeatureDTO<TProperties extends PropertiesBaseDTO, TGeometry extends Geometry> extends CommonDTO { @JsonIgnore protected ObjectMapper mapper = new ObjectMapper().registerModules(new JtsModule()); protected ObjectMapper mapper = new ObjectMapper().registerModule(new JTSModule()); private String uuid; Loading