6
6
import io .quarkus .security .Authenticated ;
7
7
import io .smallrye .common .annotation .Blocking ;
8
8
import io .smallrye .mutiny .Uni ;
9
+ import org .apache .logging .log4j .LogManager ;
10
+ import org .apache .logging .log4j .Logger ;
9
11
import org .eclipse .microprofile .jwt .JsonWebToken ;
10
12
import org .lfenergy .compas .scl .data .model .Version ;
11
13
import org .lfenergy .compas .scl .data .rest .UserInfoProperties ;
12
14
import org .lfenergy .compas .scl .data .rest .v1 .model .*;
13
15
import org .lfenergy .compas .scl .data .service .CompasSclDataService ;
14
16
import org .lfenergy .compas .scl .extensions .model .SclFileType ;
15
- import org .slf4j .Logger ;
16
- import org .slf4j .LoggerFactory ;
17
17
18
18
import javax .enterprise .context .RequestScoped ;
19
19
import javax .inject .Inject ;
28
28
@ RequestScoped
29
29
@ Path ("/scl/v1/{" + TYPE_PATH_PARAM + "}" )
30
30
public class CompasSclDataResource {
31
- private static final Logger LOGGER = LoggerFactory .getLogger (CompasSclDataResource .class );
31
+ private static final Logger LOGGER = LogManager .getLogger (CompasSclDataResource .class );
32
32
33
33
private final CompasSclDataService compasSclDataService ;
34
34
@@ -49,6 +49,7 @@ public CompasSclDataResource(CompasSclDataService compasSclDataService) {
49
49
@ Produces (MediaType .APPLICATION_XML )
50
50
public Uni <CreateResponse > create (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
51
51
@ Valid CreateRequest request ) {
52
+ LOGGER .info ("Adding new SCL File for type {} to storage." , type );
52
53
String who = jsonWebToken .getClaim (userInfoProperties .who ());
53
54
LOGGER .trace ("Username used for Who {}" , who );
54
55
@@ -62,6 +63,7 @@ public Uni<CreateResponse> create(@PathParam(TYPE_PATH_PARAM) SclFileType type,
62
63
@ Path ("/list" )
63
64
@ Produces (MediaType .APPLICATION_XML )
64
65
public Uni <ListResponse > list (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ) {
66
+ LOGGER .info ("Listing SCL Files for type {} from storage." , type );
65
67
var response = new ListResponse ();
66
68
response .setItems (compasSclDataService .list (type ));
67
69
return Uni .createFrom ().item (response );
@@ -72,6 +74,7 @@ public Uni<ListResponse> list(@PathParam(TYPE_PATH_PARAM) SclFileType type) {
72
74
@ Produces (MediaType .APPLICATION_XML )
73
75
public Uni <VersionsResponse > listVersionsByUUID (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
74
76
@ PathParam (ID_PATH_PARAM ) UUID id ) {
77
+ LOGGER .info ("Listing versions of SCL File {} for type {} from storage." , id , type );
75
78
var response = new VersionsResponse ();
76
79
response .setItems (compasSclDataService .listVersionsByUUID (type , id ));
77
80
return Uni .createFrom ().item (response );
@@ -82,6 +85,7 @@ public Uni<VersionsResponse> listVersionsByUUID(@PathParam(TYPE_PATH_PARAM) SclF
82
85
@ Produces (MediaType .APPLICATION_XML )
83
86
public Uni <GetResponse > findByUUID (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
84
87
@ PathParam (ID_PATH_PARAM ) UUID id ) {
88
+ LOGGER .info ("Retrieving latest version of SCL File {} for type {} from storage." , id , type );
85
89
var response = new GetResponse ();
86
90
response .setSclData (compasSclDataService .findByUUID (type , id ));
87
91
return Uni .createFrom ().item (response );
@@ -93,6 +97,7 @@ public Uni<GetResponse> findByUUID(@PathParam(TYPE_PATH_PARAM) SclFileType type,
93
97
public Uni <GetResponse > findByUUIDAndVersion (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
94
98
@ PathParam (ID_PATH_PARAM ) UUID id ,
95
99
@ PathParam (VERSION_PATH_PARAM ) Version version ) {
100
+ LOGGER .info ("Retrieving version {} of SCL File {} for type {} from storage." , version , id , type );
96
101
var response = new GetResponse ();
97
102
response .setSclData (compasSclDataService .findByUUID (type , id , version ));
98
103
return Uni .createFrom ().item (response );
@@ -106,6 +111,7 @@ public Uni<GetResponse> findByUUIDAndVersion(@PathParam(TYPE_PATH_PARAM) SclFile
106
111
public Uni <UpdateResponse > update (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
107
112
@ PathParam (ID_PATH_PARAM ) UUID id ,
108
113
@ Valid UpdateRequest request ) {
114
+ LOGGER .info ("Updating SCL File {} for type {} to storage." , id , type );
109
115
String who = jsonWebToken .getClaim (userInfoProperties .who ());
110
116
LOGGER .trace ("Username used for Who {}" , who );
111
117
@@ -121,6 +127,7 @@ public Uni<UpdateResponse> update(@PathParam(TYPE_PATH_PARAM) SclFileType type,
121
127
@ Produces (MediaType .APPLICATION_XML )
122
128
public Uni <Void > deleteAll (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
123
129
@ PathParam (ID_PATH_PARAM ) UUID id ) {
130
+ LOGGER .info ("Removing all versions of SCL File {} for type {} from storage." , id , type );
124
131
compasSclDataService .delete (type , id );
125
132
return Uni .createFrom ().nullItem ();
126
133
}
@@ -132,6 +139,7 @@ public Uni<Void> deleteAll(@PathParam(TYPE_PATH_PARAM) SclFileType type,
132
139
public Uni <Void > deleteVersion (@ PathParam (TYPE_PATH_PARAM ) SclFileType type ,
133
140
@ PathParam (ID_PATH_PARAM ) UUID id ,
134
141
@ PathParam (VERSION_PATH_PARAM ) Version version ) {
142
+ LOGGER .info ("Removing version {} of SCL File {} for type {} from storage." , version , id , type );
135
143
compasSclDataService .delete (type , id , version );
136
144
return Uni .createFrom ().nullItem ();
137
145
}
0 commit comments