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

Cannot use @NotNull with Principal

parent ecab2507
No related branches found
No related tags found
2 merge requests!400Need assets path,!396Cannot use @NotNull with Principal
Showing
with 54 additions and 86 deletions
......@@ -6,6 +6,8 @@ author: Martin Weise
#### Features
* Fixed a bug where validation of missing `Principal` object in Java services caused a 400 error instead of a 401 error
in [#512](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/512).
* Refactored internal Java-based testing data that improves test consistency
in [#510](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/issues/510).
* Added automated dashboard generation for all public databases where each view has an overview of its data and
......
No preview for this file type
......@@ -469,11 +469,11 @@ public class SubsetEndpoint extends RestEndpoint {
public ResponseEntity<QueryDto> persist(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("queryId") UUID queryId,
@NotNull @Valid @RequestBody QueryPersistDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
RemoteUnavailableException, DatabaseNotFoundException, QueryStorePersistException,
DatabaseUnavailableException, QueryNotFoundException, UserNotFoundException, MetadataServiceException {
log.debug("endpoint persist query, databaseId={}, queryId={}, data.persist={}, principal.name={}", databaseId,
queryId, data.getPersist(), principal.getName());
log.debug("endpoint persist query, databaseId={}, queryId={}, data.persist={}", databaseId, queryId,
data.getPersist());
final DatabaseDto database = cacheService.getDatabase(databaseId);
if (!isSystem(principal)) {
cacheService.getAccess(databaseId, getId(principal));
......
......@@ -364,7 +364,7 @@ public class TableEndpoint extends RestEndpoint {
public ResponseEntity<Void> insertRawTuple(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@Valid @RequestBody TupleDto data,
@NotNull Principal principal,
Principal principal,
@RequestHeader("Authorization") String authorization)
throws DatabaseUnavailableException, RemoteUnavailableException, TableNotFoundException,
TableMalformedException, QueryMalformedException, NotAllowedException, StorageUnavailableException,
......@@ -418,7 +418,7 @@ public class TableEndpoint extends RestEndpoint {
public ResponseEntity<Void> updateRawTuple(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@Valid @RequestBody TupleUpdateDto data,
@NotNull Principal principal,
Principal principal,
@RequestHeader("Authorization") String authorization)
throws DatabaseUnavailableException, RemoteUnavailableException, TableNotFoundException,
TableMalformedException, QueryMalformedException, NotAllowedException, MetadataServiceException,
......@@ -473,7 +473,7 @@ public class TableEndpoint extends RestEndpoint {
public ResponseEntity<Void> deleteRawTuple(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@Valid @RequestBody TupleDeleteDto data,
@NotNull Principal principal,
Principal principal,
@RequestHeader("Authorization") String authorization)
throws DatabaseUnavailableException, RemoteUnavailableException, TableNotFoundException,
TableMalformedException, QueryMalformedException, NotAllowedException, MetadataServiceException,
......@@ -643,7 +643,7 @@ public class TableEndpoint extends RestEndpoint {
public ResponseEntity<Void> importDataset(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@Valid @RequestBody ImportDto data,
@NotNull Principal principal,
Principal principal,
@RequestHeader("Authorization") String authorization)
throws RemoteUnavailableException, TableNotFoundException, NotAllowedException, MetadataServiceException,
StorageNotFoundException, MalformedException, StorageUnavailableException, QueryMalformedException,
......
[
{
"id": "1",
"value": "235",
"site": "LAA",
"timestamp": "2025-03-09T11:00:00Z"
},
{
"id": "2",
"value": "44",
"site": "Vienna",
"timestamp": "2025-03-08T12:34:34Z"
}
]
......@@ -95,7 +95,7 @@ public class AccessEndpoint extends AbstractEndpoint {
public ResponseEntity<DatabaseAccessDto> create(@NotNull @PathVariable("databaseId") UUID databaseId,
@PathVariable("userId") UUID userId,
@Valid @RequestBody CreateAccessDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DataServiceException, DataServiceConnectionException, DatabaseNotFoundException, UserNotFoundException,
AccessNotFoundException, SearchServiceException, SearchServiceConnectionException,
DashboardServiceException, DashboardServiceConnectionException {
......@@ -159,12 +159,12 @@ public class AccessEndpoint extends AbstractEndpoint {
public ResponseEntity<Void> update(@NotNull @PathVariable("databaseId") UUID databaseId,
@PathVariable("userId") UUID userId,
@Valid @RequestBody CreateAccessDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DataServiceException, DataServiceConnectionException, DatabaseNotFoundException, UserNotFoundException,
AccessNotFoundException, SearchServiceException, SearchServiceConnectionException,
DashboardServiceException, DashboardServiceConnectionException {
log.debug("endpoint modify database access, databaseId={}, userId={}, access.type={}, principal.name={}",
databaseId, userId, data.getType(), principal.getName());
log.debug("endpoint modify database access, databaseId={}, userId={}, access.type={}", databaseId, userId,
data.getType());
final Database database = databaseService.findById(databaseId);
if (!database.getOwner().getId().equals(getId(principal))) {
log.error("Failed to update access: not owner");
......@@ -212,10 +212,9 @@ public class AccessEndpoint extends AbstractEndpoint {
})
public ResponseEntity<DatabaseAccessDto> find(@NotNull @PathVariable("databaseId") UUID databaseId,
@PathVariable("userId") UUID userId,
@NotNull Principal principal) throws DatabaseNotFoundException,
Principal principal) throws DatabaseNotFoundException,
UserNotFoundException, AccessNotFoundException, NotAllowedException {
log.debug("endpoint get database access, databaseId={}, userId={}, principal.name={}", databaseId, userId,
principal.getName());
log.debug("endpoint get database access, databaseId={}, userId={}", databaseId, userId);
if (!userId.equals(getId(principal))) {
if (!hasRole(principal, "check-foreign-database-access")) {
log.error("Failed to find access: foreign user");
......@@ -267,7 +266,7 @@ public class AccessEndpoint extends AbstractEndpoint {
})
public ResponseEntity<Void> revoke(@NotNull @PathVariable("databaseId") UUID databaseId,
@PathVariable("userId") UUID userId,
@NotNull Principal principal) throws NotAllowedException, DataServiceException,
Principal principal) throws NotAllowedException, DataServiceException,
DataServiceConnectionException, DatabaseNotFoundException, UserNotFoundException, AccessNotFoundException,
SearchServiceException, SearchServiceConnectionException, DashboardServiceException,
DashboardServiceConnectionException {
......
......@@ -163,7 +163,7 @@ public class DatabaseEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<DatabaseBriefDto> create(@Valid @RequestBody CreateDatabaseDto data,
@NotNull Principal principal) throws DataServiceException,
Principal principal) throws DataServiceException,
DataServiceConnectionException, UserNotFoundException, DatabaseNotFoundException,
ContainerNotFoundException, SearchServiceException, SearchServiceConnectionException,
ContainerQuotaException, DashboardServiceException, DashboardServiceConnectionException {
......@@ -222,7 +222,7 @@ public class DatabaseEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<DatabaseBriefDto> refreshTableMetadata(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull Principal principal) throws DataServiceException,
Principal principal) throws DataServiceException,
DataServiceConnectionException, DatabaseNotFoundException, SearchServiceException,
SearchServiceConnectionException, NotAllowedException, MalformedException, TableNotFoundException {
log.debug("endpoint refresh database metadata, databaseId={}", databaseId);
......@@ -270,10 +270,10 @@ public class DatabaseEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<DatabaseBriefDto> refreshViewMetadata(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull Principal principal) throws DataServiceException,
Principal principal) throws DataServiceException,
DataServiceConnectionException, DatabaseNotFoundException, SearchServiceException,
SearchServiceConnectionException, NotAllowedException, ViewNotFoundException {
log.debug("endpoint refresh database metadata, databaseId={}, principal.name={}", databaseId, principal.getName());
log.debug("endpoint refresh database metadata, databaseId={}", databaseId);
final Database database = databaseService.findById(databaseId);
if (!database.getOwner().getId().equals(getId(principal))) {
log.error("Failed to refresh database views metadata: not owner");
......@@ -324,7 +324,7 @@ public class DatabaseEndpoint extends AbstractEndpoint {
})
public ResponseEntity<DatabaseBriefDto> visibility(@NotNull @PathVariable("databaseId") UUID databaseId,
@Valid @RequestBody DatabaseModifyVisibilityDto data,
@NotNull Principal principal) throws DatabaseNotFoundException,
Principal principal) throws DatabaseNotFoundException,
NotAllowedException, SearchServiceException, SearchServiceConnectionException, DashboardServiceException,
DashboardServiceConnectionException {
log.debug("endpoint modify database visibility, databaseId={}, data={}", databaseId, data);
......@@ -381,7 +381,7 @@ public class DatabaseEndpoint extends AbstractEndpoint {
})
public ResponseEntity<DatabaseBriefDto> transfer(@NotNull @PathVariable("databaseId") UUID databaseId,
@Valid @RequestBody DatabaseTransferDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DataServiceException, DataServiceConnectionException, DatabaseNotFoundException, UserNotFoundException,
SearchServiceException, SearchServiceConnectionException {
log.debug("endpoint transfer database, databaseId={}, transferDto.id={}", databaseId, data.getId());
......@@ -437,7 +437,7 @@ public class DatabaseEndpoint extends AbstractEndpoint {
})
public ResponseEntity<DatabaseBriefDto> modifyImage(@NotNull @PathVariable("databaseId") UUID databaseId,
@Valid @RequestBody DatabaseModifyImageDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DatabaseNotFoundException, SearchServiceException, SearchServiceConnectionException,
StorageUnavailableException, StorageNotFoundException {
log.debug("endpoint modify database image, databaseId={}, data.key={}", databaseId, data.getKey());
......
......@@ -374,13 +374,13 @@ public class IdentifierEndpoint extends AbstractEndpoint {
})
public ResponseEntity<IdentifierDto> save(@NotNull @PathVariable("identifierId") UUID identifierId,
@NotNull @Valid @RequestBody IdentifierSaveDto data,
@NotNull Principal principal) throws UserNotFoundException,
Principal principal) throws UserNotFoundException,
DatabaseNotFoundException, MalformedException, NotAllowedException, DataServiceException,
DataServiceConnectionException, SearchServiceException, QueryNotFoundException,
SearchServiceConnectionException, IdentifierNotFoundException, ViewNotFoundException,
TableNotFoundException, ExternalServiceException {
log.debug("endpoint save identifier, identifierId={}, data.id={}, principal.name={}", identifierId,
data.getId(), principal.getName());
log.debug("endpoint save identifier, identifierId={}, data.id={}", identifierId,
data.getId());
final Database database = databaseService.findById(data.getDatabaseId());
final User caller = userService.findById(getId(principal));
final Identifier identifier = identifierService.find(identifierId);
......@@ -475,7 +475,7 @@ public class IdentifierEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<IdentifierDto> create(@NotNull @Valid @RequestBody CreateIdentifierDto data,
@NotNull Principal principal) throws DatabaseNotFoundException,
Principal principal) throws DatabaseNotFoundException,
UserNotFoundException, NotAllowedException, MalformedException, DataServiceConnectionException,
SearchServiceException, DataServiceException, QueryNotFoundException, SearchServiceConnectionException,
IdentifierNotFoundException, ViewNotFoundException, ExternalServiceException {
......
......@@ -95,9 +95,9 @@ public class ImageEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<ImageDto> create(@Valid @RequestBody ImageCreateDto data,
@NotNull Principal principal) throws ImageAlreadyExistsException,
Principal principal) throws ImageAlreadyExistsException,
ImageInvalidException {
log.debug("endpoint create image, data={}, principal.name={}", data, principal.getName());
log.debug("endpoint create image, data={}", data);
return ResponseEntity.status(HttpStatus.CREATED)
.body(metadataMapper.containerImageToImageDto(
imageService.create(data, principal)));
......
......@@ -104,8 +104,8 @@ public class OntologyEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = OntologyDto.class))})
})
public ResponseEntity<OntologyDto> create(@NotNull @Valid @RequestBody OntologyCreateDto data,
@NotNull Principal principal) {
log.debug("endpoint create ontology, data={}, principal.name={}", data, principal.getName());
Principal principal) {
log.debug("endpoint create ontology, data={}", data);
return ResponseEntity.status(HttpStatus.CREATED)
.body(metadataMapper.ontologyToOntologyDto(ontologyService.create(data, principal)));
}
......
......@@ -165,10 +165,9 @@ public class TableEndpoint extends AbstractEndpoint {
})
public ResponseEntity<List<EntityDto>> analyseTable(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@NotNull Principal principal)
Principal principal)
throws MalformedException, TableNotFoundException, DatabaseNotFoundException, NotAllowedException {
log.debug("endpoint analyse table semantics, databaseId={}, tableId={}, principal.name={}", databaseId, tableId,
principal);
log.debug("endpoint analyse table semantics, databaseId={}, tableId={}", databaseId, tableId);
final Database database = databaseService.findById(databaseId);
final Table table = tableService.findById(database, tableId);
if (!table.getOwner().getId().equals(getId(principal))) {
......@@ -217,11 +216,10 @@ public class TableEndpoint extends AbstractEndpoint {
})
public ResponseEntity<Void> updateStatistic(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@NotNull Principal principal)
Principal principal)
throws TableNotFoundException, DatabaseNotFoundException, SearchServiceException, NotAllowedException,
SearchServiceConnectionException, MalformedException, DataServiceException, DataServiceConnectionException {
log.debug("endpoint update table statistics, databaseId={}, tableId={}, principal.name={}", databaseId, tableId,
principal.getName());
log.debug("endpoint update table statistics, databaseId={}, tableId={}", databaseId, tableId);
final Database database = databaseService.findById(databaseId);
final Table table = tableService.findById(database, tableId);
if (!table.getOwner().getId().equals(getId(principal)) && !isSystem(principal)) {
......@@ -276,12 +274,12 @@ public class TableEndpoint extends AbstractEndpoint {
@NotNull @PathVariable("tableId") UUID tableId,
@NotNull @PathVariable("columnId") UUID columnId,
@NotNull @Valid @RequestBody ColumnSemanticsUpdateDto updateDto,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
MalformedException, DataServiceException, DataServiceConnectionException, UserNotFoundException,
TableNotFoundException, DatabaseNotFoundException, AccessNotFoundException, SearchServiceException,
SearchServiceConnectionException, OntologyNotFoundException, SemanticEntityNotFoundException {
log.debug("endpoint update table, databaseId={}, tableId={}, columnId={}, principal.name={}", databaseId,
tableId, columnId, principal.getName());
log.debug("endpoint update table, databaseId={}, tableId={}, columnId={}", databaseId,
tableId, columnId);
final Database database = databaseService.findById(databaseId);
final Table table = tableService.findById(database, tableId);
if (!hasRole(principal, "modify-foreign-table-column-semantics")) {
......@@ -325,10 +323,10 @@ public class TableEndpoint extends AbstractEndpoint {
public ResponseEntity<List<TableColumnEntityDto>> analyseTableColumn(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@NotNull @PathVariable("columnId") UUID columnId,
@NotNull Principal principal)
Principal principal)
throws MalformedException, TableNotFoundException, DatabaseNotFoundException {
log.debug("endpoint analyse table column semantics, databaseId={}, tableId={}, columnId={}, principal.name={}",
databaseId, tableId, columnId, principal.getName());
log.debug("endpoint analyse table column semantics, databaseId={}, tableId={}, columnId={}",
databaseId, tableId, columnId);
return ResponseEntity.ok()
.body(entityService.suggestByColumn(
tableService.findColumnById(
......@@ -381,13 +379,12 @@ public class TableEndpoint extends AbstractEndpoint {
})
public ResponseEntity<TableBriefDto> create(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @Valid @RequestBody CreateTableDto data,
@NotNull Principal principal) throws NotAllowedException, MalformedException,
Principal principal) throws NotAllowedException, MalformedException,
DataServiceException, DataServiceConnectionException, DatabaseNotFoundException, UserNotFoundException,
AccessNotFoundException, TableNotFoundException, TableExistsException, SearchServiceException,
SearchServiceConnectionException, OntologyNotFoundException, SemanticEntityNotFoundException,
DashboardServiceException, DashboardServiceConnectionException {
log.debug("endpoint create table, databaseId={}, data.name={}, principal.name={}", databaseId, data.getName(),
principal.getName());
log.debug("endpoint create table, databaseId={}, data.name={}", databaseId, data.getName());
final Database database = databaseService.findById(databaseId);
endpointValidator.validateOnlyAccess(database, principal, true);
endpointValidator.validateColumnCreateConstraints(data);
......@@ -439,12 +436,12 @@ public class TableEndpoint extends AbstractEndpoint {
public ResponseEntity<TableBriefDto> update(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@NotNull @Valid @RequestBody TableUpdateDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DataServiceException, DataServiceConnectionException, DatabaseNotFoundException, TableNotFoundException,
SearchServiceException, SearchServiceConnectionException, DashboardServiceException,
DashboardServiceConnectionException {
log.debug("endpoint update table, databaseId={}, data.is_public={}, data.is_schema_public={}, principal.name={}",
databaseId, data.getIsPublic(), data.getIsSchemaPublic(), principal.getName());
log.debug("endpoint update table, databaseId={}, data.is_public={}, data.is_schema_public={}",
databaseId, data.getIsPublic(), data.getIsSchemaPublic());
final Database database = databaseService.findById(databaseId);
final Table table = tableService.findById(database, tableId);
if (!table.getOwner().getId().equals(getId(principal))) {
......@@ -544,12 +541,11 @@ public class TableEndpoint extends AbstractEndpoint {
})
public ResponseEntity<Void> delete(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("tableId") UUID tableId,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DataServiceException, DataServiceConnectionException, TableNotFoundException, DatabaseNotFoundException,
SearchServiceException, SearchServiceConnectionException, DashboardServiceException,
DashboardServiceConnectionException {
log.debug("endpoint delete table, databaseId={}, tableId={}, principal.name={}", databaseId, tableId,
principal.getName());
log.debug("endpoint delete table, databaseId={}, tableId={}", databaseId, tableId);
final Database database = databaseService.findById(databaseId);
final Table table = tableService.findById(database, tableId);
/* roles */
......
......@@ -132,9 +132,9 @@ public class UserEndpoint extends AbstractEndpoint {
schema = @Schema(implementation = ApiErrorDto.class))}),
})
public ResponseEntity<UserDto> find(@NotNull @PathVariable("userId") UUID userId,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
UserNotFoundException {
log.debug("endpoint find a user, userId={}, principal.name={}", userId, principal.getName());
log.debug("endpoint find a user, userId={}", userId);
/* check */
final User user = userService.findById(userId);
if (!user.getId().equals(getId(principal)) && !hasRole(principal, "find-foreign-user")) {
......@@ -192,7 +192,7 @@ public class UserEndpoint extends AbstractEndpoint {
})
public ResponseEntity<UserBriefDto> modify(@NotNull @PathVariable("userId") UUID userId,
@NotNull @Valid @RequestBody UserUpdateDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
UserNotFoundException, AuthServiceException {
log.debug("endpoint modify a user, userId={}, data={}", userId, data);
final User user = userService.findById(userId);
......
......@@ -140,7 +140,7 @@ public class ViewEndpoint extends AbstractEndpoint {
})
public ResponseEntity<ViewBriefDto> create(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @Valid @RequestBody CreateViewDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
MalformedException, DataServiceException, DataServiceConnectionException, DatabaseNotFoundException,
UserNotFoundException, SearchServiceException, SearchServiceConnectionException, TableNotFoundException,
ImageNotFoundException, ViewExistsException, DashboardServiceException, DashboardServiceConnectionException {
......@@ -252,7 +252,7 @@ public class ViewEndpoint extends AbstractEndpoint {
})
public ResponseEntity<Void> delete(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("viewId") UUID viewId,
@NotNull Principal principal) throws NotAllowedException, DataServiceException,
Principal principal) throws NotAllowedException, DataServiceException,
DataServiceConnectionException, DatabaseNotFoundException, ViewNotFoundException, SearchServiceException,
SearchServiceConnectionException, UserNotFoundException, DashboardServiceException,
DashboardServiceConnectionException {
......@@ -308,7 +308,7 @@ public class ViewEndpoint extends AbstractEndpoint {
public ResponseEntity<ViewBriefDto> update(@NotNull @PathVariable("databaseId") UUID databaseId,
@NotNull @PathVariable("viewId") UUID viewId,
@NotNull @Valid @RequestBody ViewUpdateDto data,
@NotNull Principal principal) throws NotAllowedException,
Principal principal) throws NotAllowedException,
DataServiceConnectionException, DatabaseNotFoundException, ViewNotFoundException, SearchServiceException,
SearchServiceConnectionException, UserNotFoundException, DashboardServiceException,
DashboardServiceConnectionException {
......
[
{
"name": "",
"size": {
"min": 0,
"required": true
},
"d": {
"required": false
},
"documentation": "https://mariadb.com/kb/en/bigint/",
"quoted": false,
"buildable": true
}
]
\ No newline at end of file
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment