Skip to content

Commit

Permalink
Fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
HoussemNasri committed Oct 9, 2024
1 parent 250f21f commit 54c2718
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> emailOpt) {
@JsonDeserialize(using = JCardObjectDeserializer.class)
public record JCardObject(String fn, Optional<String> emailOpt) {

public jCardObject {
public JCardObject {
Preconditions.checkNotNull(fn);
Preconditions.checkNotNull(emailOpt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

public class jCardObjectDeserializer extends StdDeserializer<jCardObject> {
public class JCardObjectDeserializer extends StdDeserializer<JCardObject> {
private static final String FN = "fn";
private static final String EMAIL = "email";
private static final Set<String> SUPPORTED_PROPERTY_NAMES = Set.of(FN, EMAIL);
private static final int PROPERTY_NAME_INDEX = 0;
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);

Expand All @@ -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<String, String> collectJCardProperties(Iterator<JsonNode> propertiesIterator) {
return Iterators.toStream(propertiesIterator)
.map(jCardObjectDeserializer::getPropertyKeyValuePair)
.map(JCardObjectDeserializer::getPropertyKeyValuePair)
.filter(pair -> pair != ImmutablePair.<String, String>nullPair())
.collect(Collectors.toMap(Pair::getKey, Pair::getValue));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -123,7 +123,7 @@ private Mono<Void> 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<MailAddress> contactMailAddressOpt = jCardObject.emailOpt()
Expand Down

0 comments on commit 54c2718

Please sign in to comment.