use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.
the class AtlasService method resetMappingById.
/**
* Removes the mapping file and catalogs related to specified ID.
* @param mappingDefinitionId mapping definition ID
* @return empty response
*/
@DELETE
@Path("/mapping/RESET/{mappingDefinitionId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Remove Mapping by ID", description = "Remove mapping file and catalogs related to specified ID")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Mapping file and Catalogs were removed successfully"), @ApiResponse(responseCode = "204", description = "Unable to remove mapping file and Catalogs for the specified ID") })
public Response resetMappingById(@Parameter(description = "Mapping ID") @PathParam("mappingDefinitionId") Integer mappingDefinitionId) {
LOG.debug("resetMappingById {} ", mappingDefinitionId);
java.nio.file.Path mappingFolderPath = Paths.get(getMappingSubDirectory(mappingDefinitionId));
File mappingFolderFile = mappingFolderPath.toFile();
if (mappingFolderFile == null || !mappingFolderFile.exists()) {
return Response.ok().build();
}
if (!mappingFolderFile.isDirectory()) {
LOG.warn("{} is not a directory - removing anyway", mappingFolderFile.getAbsolutePath());
}
AtlasUtil.deleteDirectory(mappingFolderFile);
return Response.ok().build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.
the class AtlasService method listLibraryClasses.
/**
* Retrieves a list of available Java library class names from uploaded JARs.
* @param uriInfo URI info
* @return class names
*/
@GET
@Path("/library/list")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List Library Classes", description = "Retrieves a list of available Java library class names from uploaded JARs.")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "ArrayList<String>")), description = "Return a list of loadable class names"))
public Response listLibraryClasses(@Context UriInfo uriInfo) {
ArrayList<String> classNames;
try {
classNames = libraryLoader.getLibraryClassNames();
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.error("Library class retrieval error.", e);
}
throw new WebApplicationException("Error retrieving class names from uploaded JARs.");
}
byte[] serialized = toJson(classNames);
if (LOG.isDebugEnabled()) {
LOG.debug(new String(serialized));
}
return Response.ok().entity(serialized).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.
the class AtlasService method listFieldActions.
/**
* Retrieves a list of available field action.
* @param uriInfo URI info
* @return {@link ActionDetails} serialized to JSON
*/
@GET
@Path("/fieldActions")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List FieldActions", description = "Retrieves a list of available field action")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ActionDetails.class)), description = "Return a list of field action detail"))
public Response listFieldActions(@Context UriInfo uriInfo) {
ActionDetails details = new ActionDetails();
if (atlasContextFactory == null || atlasContextFactory.getFieldActionService() == null) {
return Response.ok().entity(toJson(details)).build();
}
details.getActionDetail().addAll(atlasContextFactory.getFieldActionService().listActionDetails());
byte[] serialized = toJson(details);
if (LOG.isDebugEnabled()) {
LOG.debug(new String(serialized));
}
return Response.ok().entity(serialized).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project atlasmap by atlasmap.
the class JsonService method inspect.
/**
* Inspect a JSON schema or instance and return a Document object.
* @param requestIn request
* @return {@link JsonInspectionResponse}
*/
@POST
@Path("/inspect")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Inspect JSON", description = "Inspect a JSON schema or instance and return a Document object")
@RequestBody(description = "JsonInspectionRequest object", content = @Content(schema = @Schema(implementation = JsonInspectionRequest.class)))
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = JsonInspectionResponse.class)), description = "Return a Document object represented by JsonDocument"))
public Response inspect(InputStream requestIn) {
JsonInspectionRequest request = fromJson(requestIn, JsonInspectionRequest.class);
long startTime = System.currentTimeMillis();
JsonInspectionResponse response = new JsonInspectionResponse();
JsonDocument d = null;
try {
if (request.getType() == null || request.getJsonData() == null) {
response.setErrorMessage("Json data and Instance or Schema inspection type must be specified in request");
} else {
JsonInspectionService s = new JsonInspectionService();
String jsonData = cleanJsonData(request.getJsonData());
if (!validJsonData(jsonData)) {
response.setErrorMessage("Invalid json payload specified");
} else {
switch(request.getType()) {
case INSTANCE:
d = s.inspectJsonDocument(jsonData);
break;
case SCHEMA:
d = s.inspectJsonSchema(jsonData);
break;
default:
response.setErrorMessage("Unsupported inspection type: " + request.getType());
break;
}
}
}
} catch (Exception e) {
LOG.error("Error inspecting json: " + e.getMessage(), e);
response.setErrorMessage(e.getMessage());
} finally {
response.setExecutionTime(System.currentTimeMillis() - startTime);
}
AtlasUtil.excludeNotRequestedFields(d, request.getInspectPaths());
response.setJsonDocument(d);
return Response.ok().entity(toJson(response)).build();
}
use of io.swagger.v3.oas.annotations.responses.ApiResponses in project oxTrust by GluuFederation.
the class ClientWebResource method removeScopeToClient.
@DELETE
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.SCOPES + ApiConstants.SCOPE_INUM_PARAM_PATH)
@Operation(summary = "Remove OIDC client scope", description = "Remove an existing scope from client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response removeScopeToClient(@PathParam(ApiConstants.INUM) @NotNull String inum, @PathParam(ApiConstants.SCOPE_INUM) @NotNull String sinum) {
log(logger, "remove scope to client");
try {
OxAuthClient client = clientService.getClientByInum(inum);
Scope scope = scopeService.getScopeByInum(sinum);
Objects.requireNonNull(client);
Objects.requireNonNull(scope);
if (client != null && scope != null) {
List<String> scopes = new ArrayList<String>(client.getOxAuthScopes());
scopes.remove(scopeService.getDnForScope(scope.getInum()));
client.setOxAuthScopes(scopes);
clientService.updateClient(client);
return Response.ok(scopes).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
Aggregations