Skip to content

Commit

Permalink
[MODORSERS-1026] - Improved template request context
Browse files Browse the repository at this point in the history
  • Loading branch information
azizbekxm committed Apr 2, 2024
1 parent b2a135f commit 980c337
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/folio/models/TemplateProcessingRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ public static class RoutingList {
@JsonProperty
private String name;
@JsonProperty
private String note;
private String notes;

public String getName() {
return name;
}

public String getNote() {
return note;
public String getNotes() {
return notes;
}

public RoutingList setName(String name) {
this.name = name;
return this;
}

public RoutingList setNote(String note) {
this.note = note;
public RoutingList setNotes(String notes) {
this.notes = notes;
return this;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/folio/rest/core/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ public Future<JsonObject> getAsJsonObject(RequestEntry requestEntry, RequestCont

public String extractRecordId(HttpResponse<Buffer> response) {
JsonObject body = response.bodyAsJsonObject();
String id;
String id = "";
if (body != null && !body.isEmpty() && body.containsKey(ID)) {
id = body.getString(ID);
} else {
String location = response.getHeader(LOCATION);
id = location.substring(location.lastIndexOf('/') + 1);
if (location != null) {
id = location.substring(location.lastIndexOf('/') + 1);
}
}
return id;
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/folio/service/RoutingListsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class RoutingListsService {

private static final Logger log = LogManager.getLogger();
private static final UUID TEMPLATE_REQUEST_ID = UUID.fromString("9465105a-e8a1-470c-9817-142d33bc4fcd");
private static final String TEMPLATE_REQUEST_LANG = "en";
private static final String TEMPLATE_REQUEST_OUTPUT = "text/html";
private static final String ROUTING_LIST_ENDPOINT = resourcesPath(ROUTING_LISTS);
private static final String ROUTING_LIST_BY_ID_ENDPOINT = ROUTING_LIST_ENDPOINT + "/{id}";
private static final String TEMPLATE_REQUEST_ENDPOINT = resourcesPath(TEMPLATE_REQUEST);
Expand Down Expand Up @@ -68,8 +70,8 @@ private TemplateProcessingRequest createTemplateRequest(RoutingList routingList,
private TemplateProcessingRequest createBaseTemplateRequest() {
return new TemplateProcessingRequest()
.setTemplateId(TEMPLATE_REQUEST_ID)
.setLang("en")
.setOutputFormat("text/plain");
.setLang(TEMPLATE_REQUEST_LANG)
.setOutputFormat(TEMPLATE_REQUEST_OUTPUT);
}

private List<TemplateProcessingRequest.User> createUsersForContext(JsonObject users) {
Expand All @@ -88,7 +90,7 @@ private List<TemplateProcessingRequest.User> createUsersForContext(JsonObject us
private TemplateProcessingRequest.RoutingList createRoutingListForContext(RoutingList routingList) {
return new TemplateProcessingRequest.RoutingList()
.setName(routingList.getName())
.setNote(routingList.getNotes());
.setNotes(routingList.getNotes());
}

private Future<JsonObject> postTemplateRequest(TemplateProcessingRequest templateRequest, RequestContext requestContext) {
Expand Down

0 comments on commit 980c337

Please sign in to comment.