From 54c2718d34799ceaaa9d8e2e3944755d5ba843b7 Mon Sep 17 00:00:00 2001 From: HoussemNasri Date: Wed, 9 Oct 2024 11:46:22 +0100 Subject: [PATCH] Fix checkstyle --- .../jmap/contact/ContactAddedRabbitMqMessage.java | 2 +- .../contact/{jCardObject.java => JCardObject.java} | 6 +++--- ...eserializer.java => JCardObjectDeserializer.java} | 12 ++++++------ .../james/jmap/contact/OpenPaasContactsConsumer.java | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) rename tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/{jCardObject.java => JCardObject.java} (84%) rename tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/{jCardObjectDeserializer.java => JCardObjectDeserializer.java} (87%) diff --git a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/ContactAddedRabbitMqMessage.java b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/ContactAddedRabbitMqMessage.java index 131ca1fafb..7ba49b0907 100644 --- a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/ContactAddedRabbitMqMessage.java +++ b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/ContactAddedRabbitMqMessage.java @@ -1,5 +1,5 @@ package com.linagora.tmail.james.jmap.contact; public record ContactAddedRabbitMqMessage(String bookId, String bookName, String contactId, - String userId, jCardObject vcard) { + String userId, JCardObject vcard) { } diff --git a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/jCardObject.java b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/JCardObject.java similarity index 84% rename from tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/jCardObject.java rename to tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/JCardObject.java index abd037da57..ac5650c823 100644 --- a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/jCardObject.java +++ b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/JCardObject.java @@ -5,10 +5,10 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.common.base.Preconditions; -@JsonDeserialize(using = jCardObjectDeserializer.class) -public record jCardObject(String fn, Optional emailOpt) { +@JsonDeserialize(using = JCardObjectDeserializer.class) +public record JCardObject(String fn, Optional emailOpt) { - public jCardObject { + public JCardObject { Preconditions.checkNotNull(fn); Preconditions.checkNotNull(emailOpt); } diff --git a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/jCardObjectDeserializer.java b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/JCardObjectDeserializer.java similarity index 87% rename from tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/jCardObjectDeserializer.java rename to tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/JCardObjectDeserializer.java index f62e440918..6bac3e1eb8 100644 --- a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/jCardObjectDeserializer.java +++ b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/JCardObjectDeserializer.java @@ -16,7 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -public class jCardObjectDeserializer extends StdDeserializer { +public class JCardObjectDeserializer extends StdDeserializer { private static final String FN = "fn"; private static final String EMAIL = "email"; private static final Set SUPPORTED_PROPERTY_NAMES = Set.of(FN, EMAIL); @@ -24,16 +24,16 @@ public class jCardObjectDeserializer extends StdDeserializer { private static final int PROPERTIES_ARRAY_INDEX = 1; private static final int TEXT_PROPERTY_VALUE_INDEX = 3; - public jCardObjectDeserializer() { + public JCardObjectDeserializer() { this(null); } - protected jCardObjectDeserializer(Class vc) { + protected JCardObjectDeserializer(Class vc) { super(vc); } @Override - public jCardObject deserialize(JsonParser p, DeserializationContext ctxt) + public JCardObject deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonNode node = p.getCodec().readTree(p); @@ -45,12 +45,12 @@ public jCardObject deserialize(JsonParser p, DeserializationContext ctxt) throw new RuntimeException("The FN field is required according to specification."); } - return new jCardObject(jCardProperties.get(FN), getOptionalFromMap(jCardProperties, EMAIL)); + return new JCardObject(jCardProperties.get(FN), getOptionalFromMap(jCardProperties, EMAIL)); } private static Map collectJCardProperties(Iterator propertiesIterator) { return Iterators.toStream(propertiesIterator) - .map(jCardObjectDeserializer::getPropertyKeyValuePair) + .map(JCardObjectDeserializer::getPropertyKeyValuePair) .filter(pair -> pair != ImmutablePair.nullPair()) .collect(Collectors.toMap(Pair::getKey, Pair::getValue)); } diff --git a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/OpenPaasContactsConsumer.java b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/OpenPaasContactsConsumer.java index c7f7549815..6660f08a6b 100644 --- a/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/OpenPaasContactsConsumer.java +++ b/tmail-backend/jmap/extensions/src/main/java/com/linagora/tmail/james/jmap/contact/OpenPaasContactsConsumer.java @@ -3,6 +3,11 @@ import static org.apache.james.backends.rabbitmq.Constants.DURABLE; import static org.apache.james.backends.rabbitmq.Constants.EMPTY_ROUTING_KEY; +import java.io.Closeable; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Optional; + import jakarta.inject.Inject; import jakarta.inject.Named; import jakarta.mail.internet.AddressException; @@ -21,11 +26,6 @@ import com.linagora.tmail.james.jmap.EmailAddressContactInjectKeys; import com.rabbitmq.client.BuiltinExchangeType; -import java.io.Closeable; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Optional; - import reactor.core.Disposable; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -123,7 +123,7 @@ private Mono handleMessage(ContactAddedRabbitMqMessage contactAddedMessage return openPaasRestClient.getUserById(openPaasOwnerId) .map(OpenPaasUserResponse::preferredEmail) .mapNotNull(ownerEmail -> { - jCardObject jCardObject = contactAddedMessage.vcard(); + JCardObject jCardObject = contactAddedMessage.vcard(); String contactFullname = jCardObject.fn(); Optional contactMailAddressOpt = jCardObject.emailOpt()