Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into ecs-tlr-feature
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/folio/service/CirculationSettingsService.java
#	src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java
  • Loading branch information
AntonAntonich committed Aug 19, 2024
2 parents 81c9932 + 2775310 commit faf7857
Show file tree
Hide file tree
Showing 23 changed files with 775 additions and 40 deletions.
38 changes: 37 additions & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,30 @@
}
]
},
{
"id": "print-events-storage",
"version": "1.0",
"handlers": [
{
"methods": [
"POST"
],
"pathPattern": "/print-events-storage/print-events-entry",
"permissionsRequired": [
"print-events-storage.print-events-entry.item.post"
]
},
{
"methods": [
"POST"
],
"pathPattern": "/print-events-storage/print-events-status",
"permissionsRequired": [
"print-events-storage.print-events-status.item.post"
]
}
]
},
{
"id": "_timer",
"version": "1.0",
Expand Down Expand Up @@ -677,6 +701,16 @@
}
],
"permissionSets": [
{
"permissionName": "print-events-storage.print-events-entry.item.post",
"displayName": "print events storage - save print event logs",
"description": "save print event log in storage"
},
{
"permissionName": "print-events-storage.print-events-status.item.post",
"displayName": "print-events-storage - Fetch print event status",
"description": "Fetch print event details for a batch of request Ids"
},
{
"permissionName": "check-in-storage.check-ins.collection.get",
"displayName": "Check-in storage - get check-ins collection",
Expand Down Expand Up @@ -1133,7 +1167,9 @@
"circulation-storage.circulation-settings.item.get",
"circulation-storage.circulation-settings.item.post",
"circulation-storage.circulation-settings.item.put",
"circulation-storage.circulation-settings.item.delete"
"circulation-storage.circulation-settings.item.delete",
"print-events-storage.print-events-entry.item.post",
"print-events-storage.print-events-status.item.post"
]
},
{
Expand Down
9 changes: 9 additions & 0 deletions ramls/examples/print-events-request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"requestIds": [
"059e54bb-53e5-4039-a2fb-b34358e88b0a",
"e70dcbae-30c6-47ac-94f8-4ffefd44a935"
],
"requesterId": "d51470ea-5daa-480b-a4aa-09c8c6d9940e",
"requesterName": "requester",
"printEventDate": "2024-06-25T20:00:00+05:30"
}
6 changes: 6 additions & 0 deletions ramls/examples/print-events-status-request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"requestIds" : [
"fbbbe691-d6c6-4f40-b9dd-7364ccb1518a",
"fd831be3-f05f-4b6f-b68f-1a976ea1ab0f"
]
}
7 changes: 7 additions & 0 deletions ramls/examples/print-events-status-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"requestId": "fbbbe691-d6c6-4f40-b9dd-7364ccb1518a",
"requesterId": "44642483-f4d4-4a29-a2ba-8eefcf53de16",
"requesterName": "vignesh",
"count": 2,
"printEventDate": "2024-07-04T07:07:00.000+00:00"
}
19 changes: 19 additions & 0 deletions ramls/examples/print-events-status-responses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"printEventsStatusResponses": [
{
"requestId": "fbbbe691-d6c6-4f40-b9dd-7364ccb1518a",
"requesterId": "44642483-f4d4-4a29-a2ba-8eefcf53de16",
"requesterName": "vignesh",
"count": 2,
"printEventDate": "2024-07-04T07:07:00.000+00:00"
},
{
"requestId": "fd831be3-f05f-4b6f-b68f-1a976ea1ab0f",
"requesterId": "44642483-f4d4-4a29-a2ba-8eefcf53de17",
"requesterName": "siddhu",
"count": 5,
"printEventDate": "2024-07-05T07:07:00.000+00:00"
}
],
"totalRecords": 2
}
38 changes: 38 additions & 0 deletions ramls/print-events-request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Print Events Request",
"type": "object",
"properties": {
"requestIds": {
"description": "List of request IDs",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
}
},
"requesterId": {
"description": "ID of the requester",
"type": "string",
"$ref": "raml-util/schemas/uuid.schema",
"pattern": "^(?!\\s*$).+"
},
"requesterName": {
"description": "Name of the requester",
"type": "string",
"pattern": "^(?!\\s*$).+"
},
"printEventDate": {
"description": "Date and time when the print command is executed",
"type": "string",
"format": "date-time"
}
},
"required": [
"requestIds",
"requesterId",
"requesterName",
"printEventDate"
]
}
17 changes: 17 additions & 0 deletions ramls/print-events-status-request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Print Events Request",
"type": "object",
"properties": {
"requestIds": {
"description": "List of request IDs",
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[1-5][a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$"
}
}
}
}

28 changes: 28 additions & 0 deletions ramls/print-events-status-response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Print events details",
"type": "object",
"properties": {
"requestId": {
"description": "ID of the request",
"type": "string"
},
"requesterId": {
"description": "ID of the requester",
"type": "string"
},
"requesterName": {
"description": "Name of the requester",
"type": "string"
},
"count": {
"description": "No of times the request is printed",
"type": "integer"
},
"printEventDate": {
"description": "Date and time when the print command is executed",
"type": "string",
"format": "date-time"
}
}
}
23 changes: 23 additions & 0 deletions ramls/print-events-status-responses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Collection of print events details",
"type": "object",
"properties": {
"printEventsStatusResponses": {
"description": "List of print events details",
"id": "printEvents",
"type": "array",
"items": {
"type": "object",
"$ref": "print-events-status-response.json"
}
},
"totalRecords": {
"type": "integer"
}
},
"required": [
"printEventsStatusResponses",
"totalRecords"
]
}
73 changes: 73 additions & 0 deletions ramls/print-events-storage.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#%RAML 1.0
title: Print Events Storage
version: v1.0
protocols: [ HTTP, HTTPS ]
baseUri: http://localhost:9130

documentation:
- title: Print Events Storage API
content: <b>Storage for print events</b>

types:
print-events-request: !include print-events-request.json
print-events-status-request: !include print-events-status-request.json
print-events-status-responses: !include print-events-status-responses.json
errors: !include raml-util/schemas/errors.schema

traits:
validate: !include raml-util/traits/validation.raml

/print-events-storage:
/print-events-entry:
post:
is: [validate]
description: save a print event log
body:
application/json:
type: print-events-request
responses:
201:
description: "All items have been successfully created or updated"
409:
description: "Optimistic locking version conflict"
body:
text/plain:
example: "Version error"
413:
description: "Payload too large"
body:
text/plain:
example: "Payload too large"
422:
description: "Unprocessable entity"
body:
application/json:
type: errors
500:
description: "Internal server error"
body:
text/plain:
example: "Internal server error"
/print-events-status:
post:
is: [validate]
description: Fetch batch of print event details
body:
application/json:
type: print-events-status-request
responses:
200:
description: "Requests print event details are successfully retreived"
body:
application/json:
type: print-events-status-responses
422:
description: "Unprocessable entity"
body:
application/json:
type: errors
500:
description: "Internal server error"
body:
text/plain:
example: "Internal server error"
2 changes: 1 addition & 1 deletion src/main/java/org/folio/persist/AbstractRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ public Future<RowSet<Row>> deleteById(String id) {
return postgresClient.delete(tableName, id);
}

}
}
37 changes: 37 additions & 0 deletions src/main/java/org/folio/rest/impl/PrintEventsApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.folio.rest.impl;

import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Handler;
import org.folio.rest.jaxrs.model.PrintEventsRequest;
import org.folio.rest.jaxrs.model.PrintEventsStatusRequest;
import org.folio.rest.jaxrs.resource.PrintEventsStorage;
import org.folio.service.PrintEventsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import java.util.Map;

import static io.vertx.core.Future.succeededFuture;

public class PrintEventsApi implements PrintEventsStorage {
private static final Logger LOG = LoggerFactory.getLogger(PrintEventsApi.class);

@Override
public void postPrintEventsStoragePrintEventsEntry(PrintEventsRequest printEventsRequest, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
LOG.info("postPrintEventsStoragePrintEvents:: save print events {}", printEventsRequest);
new PrintEventsService(vertxContext, okapiHeaders)
.create(printEventsRequest)
.onSuccess(response -> asyncResultHandler.handle(succeededFuture(response)))
.onFailure(throwable -> asyncResultHandler.handle(succeededFuture(PostPrintEventsStoragePrintEventsEntryResponse.respond500WithTextPlain(throwable.getMessage()))));
}

@Override
public void postPrintEventsStoragePrintEventsStatus(PrintEventsStatusRequest entity, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
LOG.info("postPrintEventsStoragePrintEventsStatus:: Fetching print event details for requestIds {}",
entity.getRequestIds());
new PrintEventsService(vertxContext, okapiHeaders)
.getPrintEventRequestDetails(entity.getRequestIds(), asyncResultHandler);
}
}
Loading

0 comments on commit faf7857

Please sign in to comment.