[REST] Check a label is provided when creating a new semantic tag (#3734)

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
pull/3761/head
lolodomo 2023-08-16 17:48:09 +02:00 committed by GitHub
parent aef57edd73
commit 5f8658d0ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -189,16 +189,19 @@ public class TagResource implements RESTResource {
@Operation(operationId = "createSemanticTag", summary = "Creates a new semantic tag and adds it to the registry.", security = {
@SecurityRequirement(name = "oauth2", scopes = { "admin" }) }, responses = {
@ApiResponse(responseCode = "201", description = "Created", content = @Content(schema = @Schema(implementation = EnrichedSemanticTagDTO.class))),
@ApiResponse(responseCode = "400", description = "The tag identifier is invalid."),
@ApiResponse(responseCode = "400", description = "The tag identifier is invalid or the tag label is missing."),
@ApiResponse(responseCode = "409", description = "A tag with the same identifier already exists.") })
public Response create(
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language,
@Parameter(description = "tag data", required = true) EnrichedSemanticTagDTO data) {
final Locale locale = localeService.getLocale(language);
if (data.uid == null) {
if (data.uid == null || data.uid.isBlank()) {
return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Tag identifier is required!");
}
if (data.label == null || data.label.isBlank()) {
return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Tag label is required!");
}
String uid = data.uid.trim();