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
10 changes: 5 additions & 5 deletions ramls/gobi-custom-mappings.raml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ traits:
validate: !include raml-util/traits/validation.raml

/gobi/orders/custom-mappings:
displayName: Acquisition methods
description: Acquisition methods APIs
displayName: Gobi Custom Mappings
description: Gobi Custom Mappings APIs
type:
collection:
exampleCollection: !include acq-models/mod-gobi/examples/orders_mapping.sample
exampleItem: !include acq-models/mod-gobi/examples/orders_mapping.sample
schemaCollection: order-mappings-view-collection
schemaItem: order-mappings
get:
description: Get list of acquisition methods
description: Get list of custom mappings
is: [
searchable: { description: "with valid searchable fields: for example code", example: "[\"value\", \"Purchase At Vendor System\", \"=\"]" },
pageable
Expand All @@ -51,8 +51,8 @@ traits:
orderType:
description: The order type
type: string
displayName: Acquisition method
description: Get, Delete or Update a specific acquisition method
displayName: Custom mapping
description: Get, Delete or Update a specific custom mapping
type:
collection-item:
exampleItem: !include acq-models/mod-gobi/examples/orders_mapping.sample
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/folio/dao/OrderMappingsDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.vertx.core.Future;
import java.util.List;
import java.util.UUID;

import io.vertx.pgclient.PgException;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.folio.gobi.exceptions.HttpException;
Expand Down Expand Up @@ -51,7 +53,13 @@ public Future<OrderMappings> save(OrderMappings orderMappings, Conn conn) {

String id = orderMappings.getId();
return conn.saveAndReturnUpdatedEntity(TABLE_NAME, id, orderMappings)
.onFailure(t -> log.error("save:: Failed to save order mapping", t));
.recover(t -> {
log.error("save:: Failed to save order mapping", t);
if (t instanceof PgException pgException && "23505".equals(pgException.getSqlState())) {
return Future.failedFuture(new HttpException(409, "Order mapping with this orderType already exists"));
}
return Future.failedFuture(t);
});
}

@Override
Expand Down