11package com .objectcomputing .checkins .services .feedback_request ;
22
33import com .objectcomputing .checkins .exceptions .BadArgException ;
4+ import com .objectcomputing .checkins .security .ImpersonationController ;
45import com .objectcomputing .checkins .services .feedback_external_recipient .FeedbackExternalRecipientServices ;
56import io .micronaut .core .annotation .Nullable ;
67import io .micronaut .core .convert .format .Format ;
78import io .micronaut .http .HttpResponse ;
8- import io .micronaut .http .annotation .Body ;
9- import io .micronaut .http .annotation .Controller ;
10- import io .micronaut .http .annotation .Get ;
11- import io .micronaut .http .annotation .Put ;
9+ import io .micronaut .http .MediaType ;
10+ import io .micronaut .http .annotation .*;
1211import io .micronaut .scheduling .TaskExecutors ;
1312import io .micronaut .scheduling .annotation .ExecuteOn ;
1413import io .micronaut .security .annotation .Secured ;
1716import io .swagger .v3 .oas .annotations .tags .Tag ;
1817import jakarta .validation .Valid ;
1918import jakarta .validation .constraints .NotNull ;
19+ import org .slf4j .Logger ;
20+ import org .slf4j .LoggerFactory ;
2021
2122import java .net .URI ;
2223import java .time .LocalDate ;
@@ -32,23 +33,43 @@ public class FeedbackRequestExternalRecipientController {
3233
3334 private final FeedbackRequestServices feedbackReqServices ;
3435 private final FeedbackExternalRecipientServices feedbackExternalRecipientServices ;
36+ private static final Logger LOG = LoggerFactory .getLogger (FeedbackRequestExternalRecipientController .class );
3537
3638 public FeedbackRequestExternalRecipientController (FeedbackRequestServices feedbackRequestServices , FeedbackExternalRecipientServices feedbackExternalRecipientServices ) {
3739 this .feedbackReqServices = feedbackRequestServices ;
3840 this .feedbackExternalRecipientServices = feedbackExternalRecipientServices ;
3941 }
4042
41- @ Get ("/{?creatorId,requesteeId,recipientId,oldestDate,reviewPeriodId,templateId,externalRecipientId,requesteeIds}" )
42- public List <FeedbackRequestResponseDTO > findByValues (@ Nullable UUID creatorId , @ Nullable UUID requesteeId , @ Nullable UUID recipientId , @ Nullable @ Format ("yyyy-MM-dd" ) LocalDate oldestDate , @ Nullable UUID reviewPeriodId , @ Nullable UUID templateId , @ Nullable UUID externalRecipientId , @ Nullable List <UUID > requesteeIds ) {
43- if (externalRecipientId == null ) {
44- throw new BadArgException ("Missing required parameter: externalRecipientId" );
43+ @ Get ("/{id}" )
44+ public HttpResponse <FeedbackRequestResponseDTO > getById (UUID id ) {
45+ FeedbackRequest feedbackRequest = feedbackReqServices .getById (id );
46+ if (feedbackRequest .getExternalRecipientId () == null ) {
47+ throw new BadArgException ("This feedback request is not for an external recipient" );
4548 }
49+ return feedbackRequest == null ? HttpResponse .notFound () : HttpResponse .ok (feedbackRequestFromEntity (feedbackRequest ))
50+ .headers (headers -> headers .location (URI .create ("/feedback_request" + feedbackRequest .getId ())));
51+ }
52+
53+ @ Get ("/{?creatorId,requesteeId,recipientId,oldestDate,reviewPeriodId,templateId,externalRecipientId,requesteeIds}" )
54+ public List <FeedbackRequestResponseDTO > findByValues (@ Nullable UUID creatorId , @ Nullable UUID requesteeId , @ Nullable UUID recipientId , @ Nullable @ Format ("yyyy-MM-dd" ) LocalDate oldestDate , @ Nullable UUID reviewPeriodId , @ Nullable UUID templateId , UUID externalRecipientId , @ Nullable List <UUID > requesteeIds ) {
4655 return feedbackReqServices .findByValues (creatorId , requesteeId , recipientId , oldestDate , reviewPeriodId , templateId , externalRecipientId , requesteeIds )
4756 .stream ()
4857 .map (this ::feedbackRequestFromEntity )
4958 .toList ();
5059 }
5160
61+ @ Get ("/hello" )
62+ @ Produces (MediaType .TEXT_HTML )
63+ public String hello () {
64+ return "<html><body><h1>Hello, World!</h1></body></html>" ;
65+ }
66+
67+ @ Get ("/submitForExternalRecipient" )
68+ public HttpResponse <?> redirectToReactPage () {
69+ LOG .info ("FeedbackRequestExternalRecipientController, redirectToReactPage" );
70+ return HttpResponse .redirect (URI .create ("/feedback/submitForExternalRecipient" ));
71+ }
72+
5273 /**
5374 * Update a feedback request
5475 *
@@ -65,23 +86,6 @@ public HttpResponse<FeedbackRequestResponseDTO> update(@Body @Valid @NotNull Fee
6586 .headers (headers -> headers .location (URI .create ("/feedback_request/" + savedFeedback .getId ())));
6687 }
6788
68- /**
69- * Get feedback request by ID
70- *
71- * @param id {@link UUID} ID of the request
72- * @return {@link FeedbackRequestResponseDTO}
73- */
74- //@Secured(SecurityRule.IS_ANONYMOUS)
75- @ Get ("/{id}" )
76- public HttpResponse <FeedbackRequestResponseDTO > getById (UUID id ) {
77- FeedbackRequest feedbackRequest = feedbackReqServices .getById (id );
78- if (feedbackRequest .getExternalRecipientId () == null ) {
79- throw new BadArgException ("Missing required parameter: externalRecipientId" );
80- }
81- return feedbackRequest == null ? HttpResponse .notFound () : HttpResponse .ok (feedbackRequestFromEntity (feedbackRequest ))
82- .headers (headers -> headers .location (URI .create ("/feedback_request" + feedbackRequest .getId ())));
83- }
84-
8589 private FeedbackRequestResponseDTO feedbackRequestFromEntity (FeedbackRequest feedbackRequest ) {
8690 FeedbackRequestResponseDTO dto = new FeedbackRequestResponseDTO ();
8791 dto .setId (feedbackRequest .getId ());
0 commit comments