Skip to content
Snippets Groups Projects
Unverified Commit 4ff3d2ec authored by Martin Weise's avatar Martin Weise
Browse files

Updated the table service

parent 8c563039
No related branches found
No related tags found
2 merge requests!81New stable release,!47Resolve "Show error messages from response"
Showing
with 82 additions and 127 deletions
...@@ -62,16 +62,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -62,16 +62,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.GET, "/api/container/**/database/**/table/**/export/**").permitAll() .antMatchers(HttpMethod.GET, "/api/container/**/database/**/table/**/export/**").permitAll()
.antMatchers(HttpMethod.GET, "/api/container/**/database/query/**").permitAll() .antMatchers(HttpMethod.GET, "/api/container/**/database/query/**").permitAll()
.antMatchers(HttpMethod.GET, "/api/container/**/database/**/query/**").permitAll() .antMatchers(HttpMethod.GET, "/api/container/**/database/**/query/**").permitAll()
.antMatchers("/v2/api-docs", .antMatchers("/v3/api-docs/**",
"/configuration/ui", "/swagger-ui/**",
"/swagger-resources", "/swagger-ui.html").permitAll()
"/configuration/security",
"/swagger-ui.html",
"/webjars/**",
"/swagger-resources/configuration/ui",
"/swagger-ui.html",
"/v3/api-docs/**",
"/swagger-ui/**").permitAll()
/* insert endpoint */ /* insert endpoint */
.antMatchers(HttpMethod.POST, "/api/container/**/database/**/table/**/data").permitAll() .antMatchers(HttpMethod.POST, "/api/container/**/database/**/table/**/data").permitAll()
/* our private endpoints */ /* our private endpoints */
......
...@@ -193,17 +193,6 @@ ...@@ -193,17 +193,6 @@
<artifactId>mapstruct</artifactId> <artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version> <version>${mapstruct.version}</version>
</dependency> </dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.4.21</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -7,12 +7,10 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea ...@@ -7,12 +7,10 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.oas.annotations.EnableOpenApi;
@SpringBootApplication @SpringBootApplication
@EnableJpaAuditing @EnableJpaAuditing
@EnableOpenApi
@EnableTransactionManagement @EnableTransactionManagement
@EnableElasticsearchRepositories(basePackages = {"at.tuwien.repository.elastic"}) @EnableElasticsearchRepositories(basePackages = {"at.tuwien.repository.elastic"})
@EnableJpaRepositories(basePackages = {"at.tuwien.repository.jpa"}) @EnableJpaRepositories(basePackages = {"at.tuwien.repository.jpa"})
......
package at.tuwien.config; package at.tuwien.config;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import java.util.Collections;
@Configuration @Configuration
@EnableOpenApi
public class SwaggerConfig { public class SwaggerConfig {
@Bean @Bean
public Docket tableApi() { public OpenAPI springShopOpenAPI() {
return new Docket(DocumentationType.SWAGGER_2) return new OpenAPI()
.apiInfo(apiInfo()) .info(new Info()
.select() .title("Database Repository Table Service API")
.paths(PathSelectors.ant("/api/**")) .contact(new Contact()
.build(); .name("Prof. Andreas Rauber")
.email("andreas.rauber@tuwien.ac.at"))
.description("Service that manages the tables")
.version("v1.1.0-alpha")
.license(new License()
.name("Apache 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0")))
.externalDocs(new ExternalDocumentation()
.description("Wiki Documentation")
.url("https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/wikis"));
} }
private ApiInfo apiInfo() { @Bean
return new ApiInfo("FDA-Table-Service API", public GroupedOpenApi publicApi() {
"Service API for table service", return GroupedOpenApi.builder()
"1.0", .group("table-service")
null, .pathsToMatch("/api/**")
new Contact("Ao.Univ.Prof. Andreas Rauber", "http://www.ifs.tuwien.ac.at/~andi/", "rauber@ifs.tuwien.ac.at"), .build();
"API license",
null,
Collections.emptyList());
} }
} }
...@@ -6,11 +6,8 @@ import at.tuwien.exception.*; ...@@ -6,11 +6,8 @@ import at.tuwien.exception.*;
import at.tuwien.mapper.TableMapper; import at.tuwien.mapper.TableMapper;
import at.tuwien.service.MessageQueueService; import at.tuwien.service.MessageQueueService;
import at.tuwien.service.TableService; import at.tuwien.service.TableService;
import at.tuwien.service.impl.RabbitMqService; import io.swagger.v3.oas.annotations.Operation;
import at.tuwien.service.impl.TableServiceImpl; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -43,11 +40,7 @@ public class TableEndpoint { ...@@ -43,11 +40,7 @@ public class TableEndpoint {
@GetMapping @GetMapping
@Transactional(readOnly = true) @Transactional(readOnly = true)
@ApiOperation(value = "List all tables", notes = "Lists the tables in the metadata database for this database.") @Operation(summary = "List tables")
@ApiResponses({
@ApiResponse(code = 200, message = "All tables are listed."),
@ApiResponse(code = 401, message = "Not authorized to list all tables."),
})
public ResponseEntity<List<TableBriefDto>> findAll(@NotNull @PathVariable("id") Long id, public ResponseEntity<List<TableBriefDto>> findAll(@NotNull @PathVariable("id") Long id,
@NotNull @PathVariable("databaseId") Long databaseId) @NotNull @PathVariable("databaseId") Long databaseId)
throws DatabaseNotFoundException { throws DatabaseNotFoundException {
...@@ -60,15 +53,7 @@ public class TableEndpoint { ...@@ -60,15 +53,7 @@ public class TableEndpoint {
@PostMapping @PostMapping
@Transactional @Transactional
@PreAuthorize("hasRole('ROLE_RESEARCHER')") @PreAuthorize("hasRole('ROLE_RESEARCHER')")
@ApiOperation(value = "Create a table", notes = "Creates a new table for a database, requires a running container.") @Operation(summary = "Create table", security = @SecurityRequirement(name = "bearerAuth"))
@ApiResponses({
@ApiResponse(code = 201, message = "The table was created."),
@ApiResponse(code = 400, message = "The creation form contains invalid data."),
@ApiResponse(code = 401, message = "Not authorized to create a tables."),
@ApiResponse(code = 404, message = "The database does not exist."),
@ApiResponse(code = 405, message = "The container is not running."),
@ApiResponse(code = 409, message = "The table name already exists."),
})
public ResponseEntity<TableBriefDto> create(@NotNull @PathVariable("id") Long id, public ResponseEntity<TableBriefDto> create(@NotNull @PathVariable("id") Long id,
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
@NotNull @Valid @RequestBody TableCreateDto createDto) @NotNull @Valid @RequestBody TableCreateDto createDto)
...@@ -84,12 +69,7 @@ public class TableEndpoint { ...@@ -84,12 +69,7 @@ public class TableEndpoint {
@GetMapping("/{tableId}") @GetMapping("/{tableId}")
@Transactional(readOnly = true) @Transactional(readOnly = true)
@ApiOperation(value = "Get information about table", notes = "Lists the information of a table from the metadata database for this database.") @Operation(summary = "Find some table")
@ApiResponses({
@ApiResponse(code = 200, message = "All tables are listed."),
@ApiResponse(code = 401, message = "Not authorized to list all tables."),
@ApiResponse(code = 404, message = "Table not found in metadata database."),
})
public ResponseEntity<TableDto> findById(@NotNull @PathVariable("id") Long id, public ResponseEntity<TableDto> findById(@NotNull @PathVariable("id") Long id,
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
@NotNull @PathVariable("tableId") Long tableId) @NotNull @PathVariable("tableId") Long tableId)
...@@ -101,29 +81,17 @@ public class TableEndpoint { ...@@ -101,29 +81,17 @@ public class TableEndpoint {
@PutMapping("/{tableId}") @PutMapping("/{tableId}")
@Transactional @Transactional
@PreAuthorize("hasRole('ROLE_RESEARCHER')") @PreAuthorize("hasRole('ROLE_RESEARCHER')")
@ApiOperation(value = "Update a table", notes = "Update a table in the database.") @Operation(summary = "Update some table", security = @SecurityRequirement(name = "bearerAuth"))
@ApiResponses({
@ApiResponse(code = 200, message = "Updated the table."),
@ApiResponse(code = 400, message = "The update form contains invalid data."),
@ApiResponse(code = 401, message = "Not authorized to update tables."),
@ApiResponse(code = 404, message = "The table is not found in database."),
})
public ResponseEntity<TableBriefDto> update(@NotNull @PathVariable("id") Long id, public ResponseEntity<TableBriefDto> update(@NotNull @PathVariable("id") Long id,
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
@NotNull @PathVariable("tableId") Long tableId) { @NotNull @PathVariable("tableId") Long tableId) {
// TODO
return ResponseEntity.unprocessableEntity().body(new TableBriefDto()); return ResponseEntity.unprocessableEntity().body(new TableBriefDto());
} }
@DeleteMapping("/{tableId}") @DeleteMapping("/{tableId}")
@Transactional @Transactional
@PreAuthorize("hasRole('ROLE_DEVELOPER') or hasRole('ROLE_DATA_STEWARD')") @PreAuthorize("hasRole('ROLE_DEVELOPER') or hasRole('ROLE_DATA_STEWARD')")
@ApiOperation(value = "Delete a table", notes = "Delete a table in the database.") @Operation(summary = "Delete some table", security = @SecurityRequirement(name = "bearerAuth"))
@ApiResponses({
@ApiResponse(code = 200, message = "Deleted the table."),
@ApiResponse(code = 401, message = "Not authorized to delete tables."),
@ApiResponse(code = 404, message = "The table is not found in database."),
})
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public void delete(@NotNull @PathVariable("id") Long id, public void delete(@NotNull @PathVariable("id") Long id,
@NotNull @PathVariable("databaseId") Long databaseId, @NotNull @PathVariable("databaseId") Long databaseId,
......
...@@ -7,24 +7,27 @@ import org.springframework.http.HttpStatus; ...@@ -7,24 +7,27 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest; import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
@ControllerAdvice @ControllerAdvice
public class ApiExceptionHandler extends ResponseEntityExceptionHandler { public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler({AmqpException.class}) @ResponseStatus(HttpStatus.NOT_ACCEPTABLE)
public ResponseEntity<Object> handle(AmqpException e, WebRequest request) { @ExceptionHandler(AmqpException.class)
public ResponseEntity<ApiErrorDto> handle(AmqpException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.BAD_REQUEST) .status(HttpStatus.NOT_ACCEPTABLE)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
.code("error.database.queue") .code("error.database.queue")
.build(); .build();
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({ArbitraryPrimaryKeysException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<Object> handle(ArbitraryPrimaryKeysException e, WebRequest request) { @ExceptionHandler(ArbitraryPrimaryKeysException.class)
public ResponseEntity<ApiErrorDto> handle(ArbitraryPrimaryKeysException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.BAD_REQUEST) .status(HttpStatus.BAD_REQUEST)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -33,8 +36,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -33,8 +36,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({ContainerNotFoundException.class}) @ResponseStatus(HttpStatus.NOT_FOUND)
public ResponseEntity<Object> handle(ContainerNotFoundException e, WebRequest request) { @ExceptionHandler(ContainerNotFoundException.class)
public ResponseEntity<ApiErrorDto> handle(ContainerNotFoundException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.NOT_FOUND) .status(HttpStatus.NOT_FOUND)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -43,8 +47,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -43,8 +47,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({DatabaseConnectionException.class}) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ResponseEntity<Object> handle(DatabaseConnectionException e, WebRequest request) { @ExceptionHandler(DatabaseConnectionException.class)
public ResponseEntity<ApiErrorDto> handle(DatabaseConnectionException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.METHOD_NOT_ALLOWED) .status(HttpStatus.METHOD_NOT_ALLOWED)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -53,8 +58,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -53,8 +58,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({DatabaseNotFoundException.class}) @ResponseStatus(HttpStatus.NOT_FOUND)
public ResponseEntity<Object> handle(DatabaseNotFoundException e, WebRequest request) { @ExceptionHandler(DatabaseNotFoundException.class)
public ResponseEntity<ApiErrorDto> handle(DatabaseNotFoundException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.NOT_FOUND) .status(HttpStatus.NOT_FOUND)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -63,8 +69,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -63,8 +69,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({DataProcessingException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<Object> handle(DataProcessingException e, WebRequest request) { @ExceptionHandler(DataProcessingException.class)
public ResponseEntity<ApiErrorDto> handle(DataProcessingException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.BAD_REQUEST) .status(HttpStatus.BAD_REQUEST)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -73,8 +80,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -73,8 +80,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({FileStorageException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<Object> handle(FileStorageException e, WebRequest request) { @ExceptionHandler(FileStorageException.class)
public ResponseEntity<ApiErrorDto> handle(FileStorageException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.BAD_REQUEST) .status(HttpStatus.BAD_REQUEST)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -83,8 +91,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -83,8 +91,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({ImageNotSupportedException.class}) @ResponseStatus(HttpStatus.CONFLICT)
public ResponseEntity<Object> handle(ImageNotSupportedException e, WebRequest request) { @ExceptionHandler(ImageNotSupportedException.class)
public ResponseEntity<ApiErrorDto> handle(ImageNotSupportedException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.CONFLICT) .status(HttpStatus.CONFLICT)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -93,18 +102,20 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -93,18 +102,20 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({PaginationException.class}) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ResponseEntity<Object> handle(PaginationException e, WebRequest request) { @ExceptionHandler(PaginationException.class)
public ResponseEntity<ApiErrorDto> handle(PaginationException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.CONFLICT) .status(HttpStatus.METHOD_NOT_ALLOWED)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
.code("error.database.pagination") .code("error.database.pagination")
.build(); .build();
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({TableMalformedException.class}) @ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<Object> handle(TableMalformedException e, WebRequest request) { @ExceptionHandler(TableMalformedException.class)
public ResponseEntity<ApiErrorDto> handle(TableMalformedException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.BAD_REQUEST) .status(HttpStatus.BAD_REQUEST)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -113,8 +124,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -113,8 +124,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({TableNameExistsException.class}) @ResponseStatus(HttpStatus.CONFLICT)
public ResponseEntity<Object> handle(TableNameExistsException e, WebRequest request) { @ExceptionHandler(TableNameExistsException.class)
public ResponseEntity<ApiErrorDto> handle(TableNameExistsException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.CONFLICT) .status(HttpStatus.CONFLICT)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
...@@ -123,8 +135,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler { ...@@ -123,8 +135,9 @@ public class ApiExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus()); return new ResponseEntity<>(response, new HttpHeaders(), response.getStatus());
} }
@ExceptionHandler({TableNotFoundException.class}) @ResponseStatus(HttpStatus.NOT_FOUND)
public ResponseEntity<Object> handle(TableNotFoundException e, WebRequest request) { @ExceptionHandler(TableNotFoundException.class)
public ResponseEntity<ApiErrorDto> handle(TableNotFoundException e, WebRequest request) {
final ApiErrorDto response = ApiErrorDto.builder() final ApiErrorDto response = ApiErrorDto.builder()
.status(HttpStatus.NOT_FOUND) .status(HttpStatus.NOT_FOUND)
.message(e.getLocalizedMessage()) .message(e.getLocalizedMessage())
......
...@@ -30,6 +30,6 @@ eureka: ...@@ -30,6 +30,6 @@ eureka:
instance.hostname: fda-table-service instance.hostname: fda-table-service
client.serviceUrl.defaultZone: http://localhost:9090/eureka/ client.serviceUrl.defaultZone: http://localhost:9090/eureka/
fda: fda:
ready.path: ./readyalhost:9090/eureka/ ready.path: ./ready
gateway.endpoint: http://localhost:9095 gateway.endpoint: http://localhost:9095
elastic.endpoint: fda-search-service:9200 elastic.endpoint: localhost:9200
\ No newline at end of file \ No newline at end of file
...@@ -58,16 +58,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -58,16 +58,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.authorizeRequests() http.authorizeRequests()
/* our public endpoints */ /* our public endpoints */
.antMatchers(HttpMethod.GET, "/api/container/**/database/**/table/**").permitAll() .antMatchers(HttpMethod.GET, "/api/container/**/database/**/table/**").permitAll()
.antMatchers("/v2/api-docs", .antMatchers("/v3/api-docs/**",
"/configuration/ui", "/swagger-ui/**",
"/swagger-resources", "/swagger-ui.html").permitAll()
"/configuration/security",
"/swagger-ui.html",
"/webjars/**",
"/swagger-resources/configuration/ui",
"/swagger-ui.html",
"/v3/api-docs/**",
"/swagger-ui/**").permitAll()
/* our private endpoints */ /* our private endpoints */
.anyRequest().authenticated(); .anyRequest().authenticated();
/* add JWT token filter */ /* add JWT token filter */
......
...@@ -3,7 +3,7 @@ package at.tuwien.exception; ...@@ -3,7 +3,7 @@ package at.tuwien.exception;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(code = HttpStatus.BAD_REQUEST) @ResponseStatus(code = HttpStatus.METHOD_NOT_ALLOWED)
public class PaginationException extends Exception { public class PaginationException extends Exception {
public PaginationException(String msg) { public PaginationException(String msg) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment