Skip to content

Commit 96f1dbf

Browse files
author
Dennis Labordus
committed
Added logging on endpoints.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 48ec5d8 commit 96f1dbf

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasCommonResource.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import javax.enterprise.context.RequestScoped;
1818
import javax.inject.Inject;
1919
import javax.ws.rs.GET;
20-
import javax.ws.rs.HeaderParam;
2120
import javax.ws.rs.Path;
2221
import javax.ws.rs.Produces;
2322
import javax.ws.rs.core.MediaType;
@@ -41,8 +40,8 @@ public class CompasCommonResource {
4140
@GET
4241
@Path("/type/list")
4342
@Produces(MediaType.APPLICATION_XML)
44-
public Uni<TypeListResponse> list(@HeaderParam("Authorization") String authHeader) {
45-
LOGGER.trace("Authorization Header '{}'", authHeader);
43+
public Uni<TypeListResponse> list() {
44+
LOGGER.info("Retrieving list of the types of SCL Files");
4645

4746
// Retrieve the roles the logged-in user has.
4847
var roles = jsonWebToken.getGroups();
@@ -61,9 +60,8 @@ public Uni<TypeListResponse> list(@HeaderParam("Authorization") String authHeade
6160
@GET
6261
@Path("/userinfo")
6362
@Produces(MediaType.APPLICATION_XML)
64-
public Uni<UserInfoResponse> getUserInfo(@HeaderParam("Authorization") String authHeader) {
65-
LOGGER.trace("Authorization Header '{}'", authHeader);
66-
63+
public Uni<UserInfoResponse> getUserInfo() {
64+
LOGGER.info("Retrieving user information about {}", jsonWebToken.getName());
6765
var response = new UserInfoResponse();
6866
response.setName(jsonWebToken.getClaim(userInfoProperties.name()));
6967
response.setSessionWarning(userInfoProperties.sessionWarning());

app/src/main/java/org/lfenergy/compas/scl/data/rest/v1/CompasSclDataResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public CompasSclDataResource(CompasSclDataService compasSclDataService) {
4949
@Produces(MediaType.APPLICATION_XML)
5050
public Uni<CreateResponse> create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
5151
@Valid CreateRequest request) {
52+
LOGGER.info("Adding new SCL File for type {} to storage.", type);
5253
String who = jsonWebToken.getClaim(userInfoProperties.who());
5354
LOGGER.trace("Username used for Who {}", who);
5455

@@ -62,6 +63,7 @@ public Uni<CreateResponse> create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
6263
@Path("/list")
6364
@Produces(MediaType.APPLICATION_XML)
6465
public Uni<ListResponse> list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
66+
LOGGER.info("Listing SCL Files for type {} from storage.", type);
6567
var response = new ListResponse();
6668
response.setItems(compasSclDataService.list(type));
6769
return Uni.createFrom().item(response);
@@ -72,6 +74,7 @@ public Uni<ListResponse> list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
7274
@Produces(MediaType.APPLICATION_XML)
7375
public Uni<VersionsResponse> listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
7476
@PathParam(ID_PATH_PARAM) UUID id) {
77+
LOGGER.info("Listing versions of SCL File {} for type {} from storage.", id, type);
7578
var response = new VersionsResponse();
7679
response.setItems(compasSclDataService.listVersionsByUUID(type, id));
7780
return Uni.createFrom().item(response);
@@ -82,6 +85,7 @@ public Uni<VersionsResponse> listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclF
8285
@Produces(MediaType.APPLICATION_XML)
8386
public Uni<GetResponse> findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
8487
@PathParam(ID_PATH_PARAM) UUID id) {
88+
LOGGER.info("Retrieving latest version of SCL File {} for type {} from storage.", id, type);
8589
var response = new GetResponse();
8690
response.setSclData(compasSclDataService.findByUUID(type, id));
8791
return Uni.createFrom().item(response);
@@ -93,6 +97,7 @@ public Uni<GetResponse> findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
9397
public Uni<GetResponse> findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
9498
@PathParam(ID_PATH_PARAM) UUID id,
9599
@PathParam(VERSION_PATH_PARAM) Version version) {
100+
LOGGER.info("Retrieving version {} of SCL File {} for type {} from storage.", version, id, type);
96101
var response = new GetResponse();
97102
response.setSclData(compasSclDataService.findByUUID(type, id, version));
98103
return Uni.createFrom().item(response);
@@ -106,6 +111,7 @@ public Uni<GetResponse> findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFile
106111
public Uni<UpdateResponse> update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
107112
@PathParam(ID_PATH_PARAM) UUID id,
108113
@Valid UpdateRequest request) {
114+
LOGGER.info("Updating SCL File {} for type {} to storage.", id, type);
109115
String who = jsonWebToken.getClaim(userInfoProperties.who());
110116
LOGGER.trace("Username used for Who {}", who);
111117

@@ -121,6 +127,7 @@ public Uni<UpdateResponse> update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
121127
@Produces(MediaType.APPLICATION_XML)
122128
public Uni<Void> deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
123129
@PathParam(ID_PATH_PARAM) UUID id) {
130+
LOGGER.info("Removing all versions of SCL File {} for type {} from storage.", id, type);
124131
compasSclDataService.delete(type, id);
125132
return Uni.createFrom().nullItem();
126133
}
@@ -132,6 +139,7 @@ public Uni<Void> deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
132139
public Uni<Void> deleteVersion(@PathParam(TYPE_PATH_PARAM) SclFileType type,
133140
@PathParam(ID_PATH_PARAM) UUID id,
134141
@PathParam(VERSION_PATH_PARAM) Version version) {
142+
LOGGER.info("Removing version {} of SCL File {} for type {} from storage.", version, id, type);
135143
compasSclDataService.delete(type, id, version);
136144
return Uni.createFrom().nullItem();
137145
}

0 commit comments

Comments
 (0)