Skip to content
Snippets Groups Projects

Resolve "Show error messages from response"

12 files
+ 115
292
Compare changes
  • Side-by-side
  • Inline

Files

@@ -3,7 +3,6 @@ package at.tuwien.endpoints;
import at.tuwien.api.database.DatabaseBriefDto;
import at.tuwien.api.database.DatabaseCreateDto;
import at.tuwien.api.database.DatabaseDto;
import at.tuwien.api.database.DatabaseModifyDto;
import at.tuwien.entities.database.Database;
import at.tuwien.exception.*;
import at.tuwien.mapper.DatabaseMapper;
@@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.security.Principal;
import java.util.List;
import java.util.stream.Collectors;
@@ -55,11 +53,10 @@ public class ContainerDatabaseEndpoint {
@PreAuthorize("hasRole('ROLE_RESEARCHER')")
@Operation(summary = "Create database", security = @SecurityRequirement(name = "bearerAuth"))
public ResponseEntity<DatabaseDto> create(@NotBlank @PathVariable("id") Long id,
@Valid @RequestBody DatabaseCreateDto createDto,
Principal principal)
@Valid @RequestBody DatabaseCreateDto createDto)
throws ImageNotSupportedException, ContainerNotFoundException, DatabaseMalformedException,
AmqpException, ContainerConnectionException, UserNotFoundException, ContainerUnauthorizedException {
final Database database = databaseService.create(id, createDto, principal);
AmqpException, ContainerConnectionException {
final Database database = databaseService.create(id, createDto);
return ResponseEntity.status(HttpStatus.CREATED)
.body(databaseMapper.databaseToDatabaseDto(database));
}
@@ -69,34 +66,18 @@ public class ContainerDatabaseEndpoint {
@Operation(summary = "List some database")
public ResponseEntity<DatabaseDto> findById(@NotBlank @PathVariable("id") Long id,
@NotBlank @PathVariable Long databaseId)
throws DatabaseNotFoundException, ContainerNotFoundException {
throws DatabaseNotFoundException {
return ResponseEntity.ok(databaseMapper.databaseToDatabaseDto(databaseService.findById(id, databaseId)));
}
@PutMapping("/{databaseId}")
@Transactional
@PreAuthorize("hasRole('ROLE_RESEARCHER')")
@Operation(summary = "Update some database", security = @SecurityRequirement(name = "bearerAuth"))
public ResponseEntity<DatabaseDto> update(@NotBlank @PathVariable("id") Long id,
@NotBlank @PathVariable Long databaseId,
@Valid @RequestBody DatabaseModifyDto metadata,
Principal principal)
throws UserNotFoundException, ContainerNotFoundException, DatabaseNotFoundException,
ContainerUnauthorizedException {
return ResponseEntity.accepted()
.body(databaseMapper.databaseToDatabaseDto(databaseService.update(id, databaseId, metadata, principal)));
}
@DeleteMapping("/{databaseId}")
@Transactional
@PreAuthorize("hasRole('ROLE_DEVELOPER') or hasRole('ROLE_DATA_STEWARD')")
@Operation(summary = "Delete some database", security = @SecurityRequirement(name = "bearerAuth"))
public ResponseEntity<?> delete(@NotBlank @PathVariable("id") Long id,
@NotBlank @PathVariable Long databaseId,
Principal principal) throws DatabaseNotFoundException,
ImageNotSupportedException, DatabaseMalformedException, AmqpException, ContainerConnectionException,
ContainerNotFoundException, ContainerUnauthorizedException {
databaseService.delete(id, databaseId, principal);
@NotBlank @PathVariable Long databaseId) throws DatabaseNotFoundException,
ImageNotSupportedException, DatabaseMalformedException, AmqpException, ContainerConnectionException {
databaseService.delete(id, databaseId);
return ResponseEntity.status(HttpStatus.ACCEPTED)
.build();
}
Loading