use of io.swagger.v3.oas.models.responses.ApiResponses in project atlasmap by atlasmap.
the class AtlasService method removeMappingRequest.
/**
* Remove a mapping file saved on the backend.
* @param mappingDefinitionId mapping definition ID
* @return empty response
*/
@DELETE
@Path("/mapping/{mappingDefinitionId}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Remove Mapping", description = "Remove a mapping file saved on the server")
@ApiResponses({ @ApiResponse(responseCode = "200", description = "Specified mapping file was removed successfully"), @ApiResponse(responseCode = "204", description = "Mapping file was not found") })
public Response removeMappingRequest(@Parameter(description = "Mapping ID") @PathParam("mappingDefinitionId") Integer mappingDefinitionId) {
java.nio.file.Path mappingDirPath = Paths.get(getMappingSubDirectory(mappingDefinitionId));
File mappingDirFile = mappingDirPath.toFile();
if (mappingDirFile == null || !mappingDirFile.exists()) {
return Response.noContent().build();
}
if (!mappingDirFile.isDirectory()) {
LOG.warn("Removing invalid file '{}' in a persistent directory", mappingDirFile.getAbsolutePath());
} else {
AtlasUtil.deleteDirectory(mappingDirFile);
}
return Response.ok().build();
}
use of io.swagger.v3.oas.models.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.models.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.models.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.models.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();
}
Aggregations