Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2025-mm-dd v4.5.0-SNAPSHOT
## 2025-mm-dd v5.0.0-SNAPSHOT
* [MODSOURCE-919](https://folio-org.atlassian.net/browse/MODSOURCE-919) Fill in permissions header during event sending to Kafka
* [MODDICORE-464](https://folio-org.atlassian.net/browse/MODDICORE-464) Add links, linking rules setter to MarcBibRecordModifier
* [MODDICORE-468](https://folio-org.atlassian.net/browse/MODDICORE-468) Upgrade to Vert.x v5.0 and RMB v36.0.0

## 2025-03-07 v4.4.0
* [MODDICORE-433](https://folio-org.atlassian.net/browse/MODDICORE-433) Add userId to event header and allow to send events with null token
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.folio</groupId>
<artifactId>data-import-processing-core</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>5.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>data-import-processing-core</name>
<organization>
Expand All @@ -23,8 +23,8 @@
<commons.lang.version>2.6</commons.lang.version>
<logger.version>2.0.17</logger.version>
<junit.version>4.13.2</junit.version>
<wiremock.version>3.12.1</wiremock.version>
<raml-module-builder.version>35.4.0</raml-module-builder.version>
<wiremock.version>3.13.2</wiremock.version>
<raml-module-builder.version>36.0.0-SNAPSHOT</raml-module-builder.version>
<sonar.exclusions>org.folio.processing.mapping.defaultmapper.**</sonar.exclusions>
<sonar.exclusions>**/OkapiConnectionParams.java</sonar.exclusions>
<sonar.coverage.exclusions>**/parameters/MappingParameters.java</sonar.coverage.exclusions>
Expand All @@ -45,7 +45,7 @@
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>4.5.14</version>
<version>5.0.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -68,7 +68,7 @@
<dependency>
<groupId>org.folio</groupId>
<artifactId>folio-kafka-wrapper</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.folio</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class EventProcessorImpl implements EventProcessor {

@Override
public CompletableFuture<DataImportEventPayload> process(DataImportEventPayload eventPayload) {
LOG.debug("process:: Processing event payload jobExecutionId: {} recordId: {}",
eventPayload.getJobExecutionId(), extractRecordId(eventPayload));
LOG.debug("process:: Processing event payload, eventType: {} jobExecutionId: {} recordId: {}",
eventPayload.getEventType(), eventPayload.getJobExecutionId(), extractRecordId(eventPayload));
CompletableFuture<DataImportEventPayload> future = new CompletableFuture<>();
try {
Optional<EventHandler> optionalEventHandler = eventHandlers.stream()
Expand Down Expand Up @@ -90,8 +90,8 @@ private void logEventProcessingTime(String eventType, long startTime, DataImport
eventType, profileType, profileId, (endTime - startTime) / 1000000L, eventPayload.getJobExecutionId(), extractRecordId(eventPayload));
}
} catch (Exception e) {
LOG.warn("logEventProcessingTime:: An Exception occurred {} jobExecutionId: {} recordId: {}",
e.getMessage(), eventPayload.getJobExecutionId(), extractRecordId(eventPayload));
LOG.warn("logEventProcessingTime:: An Exception occurred, jobExecutionId: {} recordId: {}",
eventPayload.getJobExecutionId(), extractRecordId(eventPayload), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public CompletableFuture<Boolean> match(DataImportEventPayload eventPayload) {
}
// Only one matching detail is expected in first implementation,
// in future matching will support multiple matching details combined in logic expressions
MatchDetail matchDetail = matchProfile.getMatchDetails().get(0);
MatchDetail matchDetail = matchProfile.getMatchDetails().getFirst();

Value value = matchValueReader.read(eventPayload, matchDetail);
if (value != null && value.getType().equals(Value.ValueType.STRING)) {
value = MatchIdProcessorUtil.retrieveIdFromContext(matchDetail.getExistingMatchExpression().getFields().get(0).getValue(),
value = MatchIdProcessorUtil.retrieveIdFromContext(matchDetail.getExistingMatchExpression().getFields().getFirst().getValue(),
eventPayload, (StringValue) value);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.folio.processing.matching.matcher;

import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.json.JsonArray;
Expand Down Expand Up @@ -51,7 +50,7 @@ private CompletableFuture<Boolean> processMultipleMatching(Value genericValue, M
JsonArray matchedEntities = new JsonArray();
JsonArray errors = new JsonArray();

List<Future> multipleFutures = new ArrayList<>();
List<Future<Void>> multipleFutures = new ArrayList<>();
values.forEach(v -> {
Promise<Void> promise = Promise.promise();
multipleFutures.add(promise.future());
Expand All @@ -66,16 +65,16 @@ private CompletableFuture<Boolean> processMultipleMatching(Value genericValue, M
});
});

CompositeFuture.join(multipleFutures)
Future.join(multipleFutures)
.onComplete(ar -> {
String errorsAsStringJson = errors.encode();
if (matchedEntities.size() == 0 && errors.size() == values.size()) {
if (matchedEntities.isEmpty() && errors.size() == values.size()) {
resultFuture.completeExceptionally(new MatchingException(errorsAsStringJson));
} else {
eventPayload.getContext().put(ERRORS, errorsAsStringJson);
eventPayload.getContext().put(matchDetail.getExistingRecordType().value(), matchedEntities.encode());
eventPayload.getContext().put(NOT_MATCHED_NUMBER, String.valueOf(values.size() - matchedEntities.size() - errors.size()));
resultFuture.complete(matchedEntities.size() > 0);
resultFuture.complete(!matchedEntities.isEmpty());
}
});

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/folio/rest/util/RestUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.folio.rest.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.Handler;
Expand All @@ -9,6 +8,7 @@
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpRequest;
import io.vertx.ext.web.client.HttpResponse;
Expand Down Expand Up @@ -97,9 +97,10 @@ public static <T> Future<WrappedResponse> doRequest(OkapiConnectionParams params
}
}
if (method == HttpMethod.PUT || method == HttpMethod.POST) {
request.sendBuffer(Buffer.buffer(new ObjectMapper().writeValueAsString(payload)), handleResponse(promise));
request.sendBuffer(Buffer.buffer(Json.encode(payload)))
.onComplete(handleResponse(promise));
} else {
request.send(handleResponse(promise));
request.send().onComplete(handleResponse(promise));
}
return promise.future();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void readFromJar() throws IOException, XmlPullParserException {

pom.readIt(null, "META-INF/maven/io.vertx"); // force reading from Jar
// first dependency in main pom
assertThat(pom.getModuleName(), is("vertx_parent"));
assertThat(pom.getModuleName(), is("vertx_core_aggregator"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.folio.processing.events.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.tomakehurst.wiremock.client.WireMock;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.json.EncodeException;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
Expand Down Expand Up @@ -155,22 +155,17 @@ public void shouldReturnForbiddenStatus(TestContext testContext) throws IOExcept
}

@Test
public void shouldReturnFailedFutureWhenJsonDoesntParse(TestContext testContext) throws IOException {
public void shouldReturnFailedFutureWhenJsonDoesntParse(TestContext testContext) {
Async async = testContext.async();
WireMock.stubFor(WireMock.post(PUBLISH_SERVICE_URL).willReturn(WireMock.forbidden()));

Object mockItem = mock(Object.class);
when(mockItem.toString()).thenReturn(mockItem.getClass().getName());

Promise<Event> promise = Promise.promise();
RestUtil.doRequest(params, "/pubsub/publish", HttpMethod.POST, mockItem)
.onComplete(postPublishResult -> {
if(postPublishResult.succeeded()) {
fail();
} else {
Throwable throwable = postPublishResult.cause();
Assert.assertTrue(throwable instanceof JsonProcessingException);
}
testContext.assertTrue(postPublishResult.failed());
testContext.assertTrue(postPublishResult.cause() instanceof EncodeException);
async.complete();
});
}
Expand Down
Loading