Skip to content

Commit

Permalink
[REST] Check a label is provided when creating a new semantic tag (#3734
Browse files Browse the repository at this point in the history
)

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored Aug 16, 2023
1 parent aef57ed commit 5f8658d
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,19 @@ public Response getTagAndSubTags(final @Context Request request,
@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();

Expand Down

0 comments on commit 5f8658d

Please sign in to comment.