generated from GenomicDataInfrastructure/oss-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from GenomicDataInfrastructure/issue-5/submit-…
…application feat: implement submit application endpoint
- Loading branch information
Showing
6 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...main/java/io/github/genomicdatainfrastructure/daam/services/SubmitApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package io.github.genomicdatainfrastructure.daam.services; | ||
|
||
import static io.github.genomicdatainfrastructure.daam.security.PostAuthenticationFilter.USER_ID_CLAIM; | ||
import io.github.genomicdatainfrastructure.daam.remote.rems.api.RemsApplicationCommandApi; | ||
import io.github.genomicdatainfrastructure.daam.remote.rems.model.SubmitApplicationCommand; | ||
import io.quarkus.oidc.runtime.OidcJwtCallerPrincipal; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
|
||
|
||
@ApplicationScoped | ||
public class SubmitApplicationService { | ||
|
||
private final SecurityIdentity identity; | ||
private final String remsApiKey; | ||
private final RemsApplicationCommandApi remsApplicationCommandApi; | ||
|
||
@Inject | ||
public SubmitApplicationService( | ||
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey, | ||
SecurityIdentity identity, | ||
@RestClient RemsApplicationCommandApi applicationsApi | ||
) { | ||
this.remsApiKey = remsApiKey; | ||
this.identity = identity; | ||
this.remsApplicationCommandApi = applicationsApi; | ||
} | ||
|
||
public void submitApplication(String id) { | ||
var principal = (OidcJwtCallerPrincipal) identity.getPrincipal(); | ||
String userId = principal.getClaim(USER_ID_CLAIM); | ||
|
||
SubmitApplicationCommand command = SubmitApplicationCommand.builder() | ||
.applicationId(Long.valueOf(id)) | ||
.build(); | ||
|
||
remsApplicationCommandApi.apiApplicationsSubmitPost(command, remsApiKey, userId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"request": { | ||
"method": "POST", | ||
"url": "/api/applications/submit" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
}, | ||
"jsonBody": { | ||
"success": true, | ||
"application-id": 12345 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
|
||
SPDX-License-Identifier: Apache-2.0 |