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 #24 from GenomicDataInfrastructure/issue-5/only-su…
…bmit-draft-and-returned-applications feat: Only submit applications that are in draft or returned status
- Loading branch information
Showing
18 changed files
with
439 additions
and
8 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
13 changes: 13 additions & 0 deletions
13
...ava/io/github/genomicdatainfrastructure/daam/exceptions/ApplicationNotFoundException.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,13 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.genomicdatainfrastructure.daam.exceptions; | ||
|
||
public class ApplicationNotFoundException extends RuntimeException { | ||
|
||
private static final String MESSAGE = "Application %s not found"; | ||
|
||
public ApplicationNotFoundException(Long applicationId) { | ||
super(MESSAGE.formatted(applicationId)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...thub/genomicdatainfrastructure/daam/exceptions/ApplicationNotInCorrectStateException.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,13 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.genomicdatainfrastructure.daam.exceptions; | ||
|
||
public class ApplicationNotInCorrectStateException extends RuntimeException { | ||
|
||
private static final String MESSAGE = "Application %s is not in correct state: %s"; | ||
|
||
public ApplicationNotInCorrectStateException(Long id, String state) { | ||
super(MESSAGE.formatted(id, state)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...n/java/io/github/genomicdatainfrastructure/daam/exceptions/UserNotApplicantException.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,13 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.genomicdatainfrastructure.daam.exceptions; | ||
|
||
public class UserNotApplicantException extends RuntimeException { | ||
|
||
private static final String MESSAGE = "User %s is not an applicant for application %s"; | ||
|
||
public UserNotApplicantException(Long applicationId, String userId) { | ||
super(MESSAGE.formatted(userId, applicationId)); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../io/github/genomicdatainfrastructure/daam/mappers/ApplicationNotFoundExceptionMapper.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,29 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.genomicdatainfrastructure.daam.mappers; | ||
import io.github.genomicdatainfrastructure.daam.exceptions.ApplicationNotFoundException; | ||
import io.github.genomicdatainfrastructure.daam.model.ErrorResponse; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.ext.Provider; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.ExceptionMapper; | ||
|
||
@Provider | ||
public class ApplicationNotFoundExceptionMapper implements ExceptionMapper<ApplicationNotFoundException> { | ||
|
||
@Override | ||
public Response toResponse(ApplicationNotFoundException exception) { | ||
ErrorResponse errorResponse = new ErrorResponse( | ||
"Application Not Found", | ||
Response.Status.NOT_FOUND.getStatusCode(), | ||
exception.getMessage() | ||
); | ||
|
||
return Response | ||
.status(Response.Status.NOT_FOUND) | ||
.entity(errorResponse) | ||
.type(MediaType.APPLICATION_JSON) | ||
.build(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...b/genomicdatainfrastructure/daam/mappers/ApplicationNotInCorrectStateExceptionMapper.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,30 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.genomicdatainfrastructure.daam.mappers; | ||
|
||
import io.github.genomicdatainfrastructure.daam.exceptions.ApplicationNotFoundException; | ||
import io.github.genomicdatainfrastructure.daam.exceptions.ApplicationNotInCorrectStateException; | ||
import io.github.genomicdatainfrastructure.daam.model.ErrorResponse; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.ExceptionMapper; | ||
import jakarta.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
public class ApplicationNotInCorrectStateExceptionMapper implements ExceptionMapper<ApplicationNotInCorrectStateException> { | ||
@Override | ||
public Response toResponse(ApplicationNotInCorrectStateException exception) { | ||
ErrorResponse errorResponse = new ErrorResponse( | ||
"Application Not In Correct State", | ||
Response.Status.PRECONDITION_REQUIRED.getStatusCode(), | ||
exception.getMessage() | ||
); | ||
|
||
return Response | ||
.status(Response.Status.PRECONDITION_REQUIRED) | ||
.entity(errorResponse) | ||
.type(MediaType.APPLICATION_JSON) | ||
.build(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ava/io/github/genomicdatainfrastructure/daam/mappers/UserNotApplicantExceptionMapper.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,30 @@ | ||
// SPDX-FileCopyrightText: 2024 PNED G.I.E. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.genomicdatainfrastructure.daam.mappers; | ||
|
||
import io.github.genomicdatainfrastructure.daam.exceptions.UserNotApplicantException; | ||
import io.github.genomicdatainfrastructure.daam.model.ErrorResponse; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.ext.ExceptionMapper; | ||
import jakarta.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
public class UserNotApplicantExceptionMapper implements ExceptionMapper<UserNotApplicantException> { | ||
@Override | ||
public Response toResponse(UserNotApplicantException exception) { | ||
|
||
ErrorResponse errorResponse = new ErrorResponse( | ||
"User Not Applicant", | ||
Response.Status.FORBIDDEN.getStatusCode(), | ||
exception.getMessage() | ||
); | ||
|
||
return Response | ||
.status(Response.Status.FORBIDDEN) | ||
.entity(errorResponse) | ||
.type(MediaType.APPLICATION_JSON) | ||
.build(); | ||
} | ||
} |
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
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
Oops, something went wrong.