Skip to content

Commit

Permalink
Adjusted all code to OpenAPI Annotations - (Task #1184)
Browse files Browse the repository at this point in the history
- updated server side services

---
Task #1184: Updating to Eclipse 2024/03 and all dependencies
  • Loading branch information
PhilMFischer committed May 7, 2024
1 parent d4bf03f commit 7e9358a
Show file tree
Hide file tree
Showing 6 changed files with 695 additions and 530 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ApiErrorHelper {
public static final String INVALID_TYPE_ERROR = "Is not a valid type";
public static final String NOT_EXECUTEABLE = "Command was not executeable";
public static final String NOT_EXECUTEABLE_CODE = "500";
public static final String INVALID_TYPE_ERROR_CODE = "500";

private ApiErrorHelper() { };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public CategoryAssignmentResource(RepoModelAccessResource parentResource) {
@ApiResponse(
responseCode = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT_CODE,
description = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT
),
),
@ApiResponse(
responseCode = ApiErrorHelper.INTERNAL_SERVER_ERROR_CODE,
description = ApiErrorHelper.INTERNAL_SERVER_ERROR
Expand Down Expand Up @@ -118,6 +118,10 @@ public Response getCa(@PathParam("caUuid") @Parameter(description = "Uuid of the
responseCode = ApiErrorHelper.SUCCESSFUL_OPERATION_CODE,
description = ApiErrorHelper.SUCCESSFUL_OPERATION
),
@ApiResponse(
responseCode = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT_CODE,
description = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT
),
@ApiResponse(
responseCode = ApiErrorHelper.INTERNAL_SERVER_ERROR_CODE,
description = ApiErrorHelper.INTERNAL_SERVER_ERROR
Expand Down Expand Up @@ -148,10 +152,6 @@ public Response putCa(@Parameter(description = "CA to put", required = true) ABe
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = String.class))
),
@ApiResponse(
responseCode = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT_CODE,
description = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT
),
@ApiResponse(
responseCode = ApiErrorHelper.NOT_EXECUTEABLE_CODE,
description = ApiErrorHelper.NOT_EXECUTEABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.jetty.http.HttpStatus;

import de.dlr.sc.virsat.model.concept.types.roles.BeanDiscipline;
import de.dlr.sc.virsat.model.dvlm.roles.Discipline;
import de.dlr.sc.virsat.model.dvlm.roles.RolesFactory;
Expand All @@ -33,14 +31,24 @@
import de.dlr.sc.virsat.server.resources.ApiErrorHelper;
import de.dlr.sc.virsat.server.resources.ModelAccessResource;
import de.dlr.sc.virsat.server.resources.ModelAccessResource.RepoModelAccessResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.tags.Tag;

@Api(hidden = true, authorizations = {@Authorization(value = "basic")}, tags = {ModelAccessResource.TAG_DISCIPLINE})
@Hidden
@Tag(name = ModelAccessResource.TAG_DISCIPLINE)
@SecurityScheme(
type = SecuritySchemeType.HTTP,
name = "basicAuth",
scheme = "basic")
@SecurityRequirement(name = "basicAuth")
public class DisciplineResource {

private RepoModelAccessResource parentResource;
Expand All @@ -54,22 +62,27 @@ public DisciplineResource(RepoModelAccessResource parentResource) {
@Path("/{disciplineUuid}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(
produces = "application/json",
value = "Fetch Discipline",
httpMethod = "GET",
notes = "This service fetches a Discipline")
@ApiResponses(value = {
@ApiResponse(
code = HttpStatus.OK_200,
response = BeanDiscipline.class,
message = ApiErrorHelper.SUCCESSFUL_OPERATION),
@ApiResponse(
code = HttpStatus.BAD_REQUEST_400,
message = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT),
@ApiResponse(
code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = ApiErrorHelper.INTERNAL_SERVER_ERROR)})
public Response getDiscipline(@PathParam("disciplineUuid") @Parameter(value = "Uuid of the discipline", required = true) String disciplineUuid) {
summary = "Fetch Discipline",
method = "GET",
description = "This service fetches a Discipline.",
responses = {
@ApiResponse(
responseCode = ApiErrorHelper.SUCCESSFUL_OPERATION_CODE,
description = ApiErrorHelper.SUCCESSFUL_OPERATION,
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = BeanDiscipline.class))
),
@ApiResponse(
responseCode = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT_CODE,
description = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT
),
@ApiResponse(
responseCode = ApiErrorHelper.INTERNAL_SERVER_ERROR_CODE,
description = ApiErrorHelper.INTERNAL_SERVER_ERROR
)
})
public Response getDiscipline(@PathParam("disciplineUuid") @Parameter(description = "Uuid of the discipline", required = true) String disciplineUuid) {
try {
parentResource.synchronize();

Expand All @@ -91,18 +104,24 @@ public Response getDiscipline(@PathParam("disciplineUuid") @Parameter(value = "U
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Operation(
consumes = "application/json",
value = "Put Discipline",
httpMethod = "PUT",
notes = "This service updates an existing Discipline")
@ApiResponses(value = {
@ApiResponse(
code = HttpStatus.OK_200,
message = ApiErrorHelper.SUCCESSFUL_OPERATION),
@ApiResponse(
code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = ApiErrorHelper.INTERNAL_SERVER_ERROR)})
public Response putDiscipline(@Parameter(value = "Discipline to put", required = true) BeanDiscipline bean) {
summary = "Put Discipline",
method = "PUT",
description = "This service updates an existing Discipline.",
responses = {
@ApiResponse(
responseCode = ApiErrorHelper.SUCCESSFUL_OPERATION_CODE,
description = ApiErrorHelper.SUCCESSFUL_OPERATION
),
@ApiResponse(
responseCode = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT_CODE,
description = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT
),
@ApiResponse(
responseCode = ApiErrorHelper.INTERNAL_SERVER_ERROR_CODE,
description = ApiErrorHelper.INTERNAL_SERVER_ERROR
)
})
public Response putDiscipline(@Parameter(description = "Discipline to put", required = true) BeanDiscipline bean) {
try {
parentResource.synchronize();
return Response.status(Response.Status.OK).build();
Expand All @@ -116,21 +135,26 @@ public Response putDiscipline(@Parameter(value = "Discipline to put", required =
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
@Operation(
consumes = "application/json",
value = "Create Discipline",
httpMethod = "POST",
notes = "This service creates a new Discipline and returns the uuid")
@ApiResponses(value = {
@ApiResponse(
code = HttpStatus.OK_200,
response = String.class,
message = ApiErrorHelper.SUCCESSFUL_OPERATION),
@ApiResponse(
code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = ApiErrorHelper.NOT_EXECUTEABLE),
@ApiResponse(
code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = ApiErrorHelper.INTERNAL_SERVER_ERROR)})
summary = "Create Discipline",
method = "POST",
description = "This service creates a new Discipline and returns it.",
responses = {
@ApiResponse(
responseCode = ApiErrorHelper.SUCCESSFUL_OPERATION_CODE,
description = ApiErrorHelper.SUCCESSFUL_OPERATION,
content = @Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = String.class))
),
@ApiResponse(
responseCode = ApiErrorHelper.NOT_EXECUTEABLE_CODE,
description = ApiErrorHelper.NOT_EXECUTEABLE
),
@ApiResponse(
responseCode = ApiErrorHelper.INTERNAL_SERVER_ERROR_CODE,
description = ApiErrorHelper.INTERNAL_SERVER_ERROR
)
})
public Response createDiscipline() {
try {
parentResource.synchronize();
Expand All @@ -152,24 +176,28 @@ public Response createDiscipline() {
@Path("/{disciplineUuid}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(
produces = "application/json",
value = "Delete Discipline",
httpMethod = "DELETE",
notes = "This service deletes a Discipline")
@ApiResponses(value = {
@ApiResponse(
code = HttpStatus.OK_200,
message = ApiErrorHelper.SUCCESSFUL_OPERATION),
@ApiResponse(
code = HttpStatus.BAD_REQUEST_400,
message = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT),
@ApiResponse(
code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = ApiErrorHelper.NOT_EXECUTEABLE),
@ApiResponse(
code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = ApiErrorHelper.INTERNAL_SERVER_ERROR)})
public Response deleteDiscipline(@PathParam("disciplineUuid") @Parameter(value = "Uuid of the Discipline", required = true) String disciplineUuid) {
summary = "Delete Discipline",
method = "DELETE",
description = "This service deletes a Discipline.",
responses = {
@ApiResponse(
responseCode = ApiErrorHelper.SUCCESSFUL_OPERATION_CODE,
description = ApiErrorHelper.SUCCESSFUL_OPERATION
),
@ApiResponse(
responseCode = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT_CODE,
description = ApiErrorHelper.COULD_NOT_FIND_REQUESTED_ELEMENT
),
@ApiResponse(
responseCode = ApiErrorHelper.NOT_EXECUTEABLE_CODE,
description = ApiErrorHelper.NOT_EXECUTEABLE
),
@ApiResponse(
responseCode = ApiErrorHelper.INTERNAL_SERVER_ERROR_CODE,
description = ApiErrorHelper.INTERNAL_SERVER_ERROR
)
})
public Response deleteDiscipline(@PathParam("disciplineUuid") @Parameter(description = "Uuid of the Discipline", required = true) String disciplineUuid) {
try {
// Sync before delete
parentResource.synchronize();
Expand Down
Loading

0 comments on commit 7e9358a

Please sign in to comment.