|
20 | 20 | import life.qbic.projectmanagement.application.api.fair.DigitalObject; |
21 | 21 | import life.qbic.projectmanagement.application.api.fair.DigitalObjectFactory; |
22 | 22 | import life.qbic.projectmanagement.application.api.fair.ResearchProject; |
| 23 | +import life.qbic.projectmanagement.application.api.template.TemplateService; |
| 24 | +import life.qbic.projectmanagement.application.authorization.ReactiveSecurityContextUtils; |
23 | 25 | import life.qbic.projectmanagement.application.sample.SampleInformationService; |
24 | 26 | import life.qbic.projectmanagement.application.sample.SamplePreview; |
25 | 27 | import life.qbic.projectmanagement.domain.model.experiment.ExperimentId; |
@@ -58,14 +60,20 @@ public class AsyncProjectServiceImpl implements AsyncProjectService { |
58 | 60 | private final Scheduler scheduler; |
59 | 61 | private final SampleInformationService sampleInfoService; |
60 | 62 | private final DigitalObjectFactory digitalObjectFactory; |
| 63 | + private final TemplateService templateService; |
61 | 64 |
|
62 | | - public AsyncProjectServiceImpl(@Autowired ProjectInformationService projectService, |
| 65 | + public AsyncProjectServiceImpl( |
| 66 | + @Autowired ProjectInformationService projectService, |
63 | 67 | @Autowired SampleInformationService sampleInfoService, |
64 | | - @Autowired Scheduler scheduler, @Autowired DigitalObjectFactory digitalObjectFactory) { |
| 68 | + @Autowired Scheduler scheduler, |
| 69 | + @Autowired DigitalObjectFactory digitalObjectFactory, |
| 70 | + @Autowired TemplateService templateService |
| 71 | + ) { |
65 | 72 | this.projectService = Objects.requireNonNull(projectService); |
66 | 73 | this.sampleInfoService = Objects.requireNonNull(sampleInfoService); |
67 | 74 | this.scheduler = Objects.requireNonNull(scheduler); |
68 | 75 | this.digitalObjectFactory = Objects.requireNonNull(digitalObjectFactory); |
| 76 | + this.templateService = Objects.requireNonNull(templateService); |
69 | 77 | } |
70 | 78 |
|
71 | 79 | private static Retry defaultRetryStrategy() { |
@@ -239,8 +247,12 @@ public Mono<Sample> findSample(String projectId, String sampleId) { |
239 | 247 | @Override |
240 | 248 | public Mono<DigitalObject> sampleRegistrationTemplate(String projectId, String experimentId, |
241 | 249 | MimeType mimeType) { |
242 | | - |
243 | | - throw new RuntimeException("not implemented"); |
| 250 | + SecurityContext securityContext = SecurityContextHolder.getContext(); |
| 251 | + return ReactiveSecurityContextUtils.applySecurityContext(Mono.fromCallable( |
| 252 | + () -> templateService.sampleRegistrationTemplate(projectId, experimentId, mimeType))) |
| 253 | + .subscribeOn(scheduler) |
| 254 | + .transform(original -> ReactiveSecurityContextUtils.writeSecurityContext(original, |
| 255 | + securityContext)); |
244 | 256 | } |
245 | 257 |
|
246 | 258 | @Override |
|
0 commit comments