From 1e917d06e4dbdc708cdb236e64b3fc0cf62eb6fa Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Mon, 10 Jun 2024 16:55:38 +0200 Subject: [PATCH] trimming tag names --- .../main/java/org/gbif/vocabulary/restws/Application.java | 6 +++++- .../org/gbif/vocabulary/restws/resources/TagResource.java | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/Application.java b/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/Application.java index c300b478..842cd129 100644 --- a/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/Application.java +++ b/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/Application.java @@ -63,7 +63,11 @@ RequestHeaderParamUpdateFilter.class }) @ComponentScan( - basePackages = {"org.gbif.vocabulary.restws", "org.gbif.ws.remoteauth"}, + basePackages = { + "org.gbif.vocabulary.restws", + "org.gbif.ws.remoteauth", + "org.gbif.ws.server.interceptor" + }, excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE)}) @EnableConfigurationProperties({ ExportConfig.class, diff --git a/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/resources/TagResource.java b/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/resources/TagResource.java index b60eec94..24876903 100644 --- a/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/resources/TagResource.java +++ b/vocabulary-rest-ws/src/main/java/org/gbif/vocabulary/restws/resources/TagResource.java @@ -13,6 +13,7 @@ */ package org.gbif.vocabulary.restws.resources; +import org.gbif.api.annotation.Trim; import org.gbif.api.model.common.paging.Pageable; import org.gbif.api.model.common.paging.PagingResponse; import org.gbif.vocabulary.model.Tag; @@ -97,7 +98,7 @@ public Tag getTag(@PathVariable("name") String tagName) { @Docs.DefaultUnsuccessfulReadResponses @Docs.DefaultUnsuccessfulWriteResponses @PostMapping - public Tag create(@RequestBody Tag tag) { + public Tag create(@RequestBody @Trim Tag tag) { int key = tagService.create(tag); return tagService.get(key); } @@ -115,7 +116,7 @@ public Tag create(@RequestBody Tag tag) { @Docs.DefaultUnsuccessfulReadResponses @Docs.DefaultUnsuccessfulWriteResponses @PutMapping("{name}") - public Tag update(@PathVariable("name") String tagName, @RequestBody Tag tag) { + public Tag update(@PathVariable("name") String tagName, @RequestBody @Trim Tag tag) { Tag oldTag = tagService.getByName(tagName); checkArgument(oldTag != null, "Tag not found for name " + tagName); checkArgument(