Skip to content

Commit

Permalink
server: Add swagger doc for serviced 500 responses
Browse files Browse the repository at this point in the history
Either create or reuse the most (known as) accurate descriptions for
these internal (trace) server errors.

Change-Id: Ie64a0773641577080f6b8e3ca362d424ad65aeb8
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/191420
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
marco-miller authored and MatthewKhouzam committed Mar 11, 2022
1 parent 58f9e85 commit 8e00c1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Expand Up @@ -138,6 +138,7 @@ public class EndpointConstants {
static final String NOT_SUPPORTED = "Trace type not supported"; //$NON-NLS-1$
static final String NO_SUCH_EXPERIMENT = "No such experiment"; //$NON-NLS-1$
static final String PROVIDER_NOT_FOUND = "Experiment or output provider not found"; //$NON-NLS-1$
static final String TRACE_CREATION_FAILED = "Trace resource creation failed"; //$NON-NLS-1$
static final String TREE_ENTRIES = "Unique entry point for output providers, to get the tree of visible entries"; //$NON-NLS-1$

private EndpointConstants() {
Expand Down
Expand Up @@ -263,7 +263,8 @@ public Response deleteExperiment(@Parameter(description = EXP_UUID) @PathParam("
@ApiResponse(responseCode = "200", description = "The experiment was successfully created", content = @Content(schema = @Schema(implementation = IExperiment.class))),
@ApiResponse(responseCode = "204", description = "The experiment has at least one trace which hasn't been created yet", content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "400", description = INVALID_PARAMETERS, content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "409", description = "The experiment (name) already exists and both differ", content = @Content(schema = @Schema(implementation = String.class)))
@ApiResponse(responseCode = "409", description = "The experiment (name) already exists and both differ", content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "500", description = "Internal trace-server error while trying to post experiment", content = @Content(schema = @Schema(implementation = String.class)))
})
public Response postExperiment(@RequestBody(content = {
@Content(schema = @Schema(implementation = IExperimentQueryParameters.class))
Expand Down
Expand Up @@ -16,6 +16,7 @@
import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NAME_EXISTS;
import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NOT_SUPPORTED;
import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_TRACE;
import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.TRACE_CREATION_FAILED;
import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.TRACE_UUID;

import java.io.File;
Expand Down Expand Up @@ -153,6 +154,7 @@ private static Map<UUID, IResource> initTraces() {
@ApiResponse(responseCode = "404", description = NO_SUCH_TRACE, content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "406", description = CANNOT_READ, content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "409", description = NAME_EXISTS, content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "500", description = TRACE_CREATION_FAILED, content = @Content(schema = @Schema(implementation = String.class))),
@ApiResponse(responseCode = "501", description = NOT_SUPPORTED, content = @Content(schema = @Schema(implementation = String.class)))
})
public Response putTrace(@RequestBody(content = {
Expand Down Expand Up @@ -200,7 +202,7 @@ private static Response put(String path, String name, String typeID)
IResource resource = getResource(path, name);
if (!resource.exists()) {
if (!createResource(path, resource)) {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity("Trace resource creation failed").build(); //$NON-NLS-1$
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(TRACE_CREATION_FAILED).build();
}
resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, traceType);
} else {
Expand Down

0 comments on commit 8e00c1c

Please sign in to comment.