|
20 | 20 | import no.java.submit.service.TimelineService; |
21 | 21 | import no.java.submit.util.UserHelper; |
22 | 22 | import org.eclipse.microprofile.config.inject.ConfigProperty; |
| 23 | +import org.jboss.resteasy.reactive.ClientWebApplicationException; |
23 | 24 |
|
24 | 25 | import java.util.ArrayList; |
25 | 26 | import java.util.Collections; |
@@ -67,12 +68,17 @@ public TemplateInstance all() { |
67 | 68 | @Path("{sessionId}") |
68 | 69 | public TemplateInstance view(@PathParam("sessionId") String sessionId, @Context SecurityIdentity securityIdentity) { |
69 | 70 | var email = UserHelper.getEmail(securityIdentity); |
70 | | - var session = talksService.getSession(email, sessionId); |
71 | 71 |
|
72 | | - if (!session.containsEmail(email)) |
73 | | - throw new NotAllowedException("Not allowed to view this session"); |
| 72 | + try { |
| 73 | + var session = talksService.getSession(email, sessionId); |
74 | 74 |
|
75 | | - return talk.data("session", session); |
| 75 | + if (!session.containsEmail(email)) |
| 76 | + throw new NotAuthorizedException("Not allowed to view this session"); |
| 77 | + |
| 78 | + return talk.data("session", session); |
| 79 | + } catch (ClientWebApplicationException e) { |
| 80 | + throw new NotAuthorizedException("Not allowed to view this session", e); |
| 81 | + } |
76 | 82 | } |
77 | 83 |
|
78 | 84 | @GET |
@@ -135,18 +141,22 @@ public Object newSessionPost(SessionForm form, @Context SecurityIdentity securit |
135 | 141 | public TemplateInstance editSession(@PathParam("sessionId") String sessionId, @Context SecurityIdentity securityIdentity) { |
136 | 142 | var email = UserHelper.getEmail(securityIdentity); |
137 | 143 |
|
138 | | - var session = talksService.getSession(email, sessionId); |
| 144 | + try { |
| 145 | + var session = talksService.getSession(email, sessionId); |
139 | 146 |
|
140 | | - if (!session.containsEmail(email)) |
141 | | - throw new NotAllowedException("Not allowed to view this session"); |
| 147 | + if (!session.containsEmail(email)) |
| 148 | + throw new NotAuthorizedException("Not allowed to view this session"); |
142 | 149 |
|
143 | | - if (!conferenceService.current().id.equals(session.conferenceId)) |
144 | | - throw new NotFoundException(); |
| 150 | + if (!conferenceService.current().id.equals(session.conferenceId)) |
| 151 | + throw new NotFoundException(); |
145 | 152 |
|
146 | | - return sessionForm |
147 | | - .data("form", SessionForm.parse(session)) |
148 | | - .data("val", Collections.emptyMap()) |
149 | | - .data("sessionId", sessionId); |
| 153 | + return sessionForm |
| 154 | + .data("form", SessionForm.parse(session)) |
| 155 | + .data("val", Collections.emptyMap()) |
| 156 | + .data("sessionId", sessionId); |
| 157 | + } catch (ClientWebApplicationException e) { |
| 158 | + throw new NotAuthorizedException("Not allowed to view this session", e); |
| 159 | + } |
150 | 160 | } |
151 | 161 |
|
152 | 162 | @POST |
|
0 commit comments