Fix constraint violation exception when creating target with whitespaces (#363)

* Added a function to validate if controller id is empty

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Changed how the controller id gets past to other methods

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Changed the way controllderId gets validated in UI and repro

- added junit test

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Fixed sonar issue

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>

* Switched to use the RegexpValidator 

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Knoblauch
2016-11-28 17:58:52 +01:00
committed by Michael Hirsch
parent a57165686e
commit b30f2bdb1f
4 changed files with 53 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.im.authentication.SpPermission;
@@ -77,6 +78,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
@Column(name = "controller_id", length = 64)
@Size(min = 1, max = 64)
@NotEmpty
@Pattern(regexp = "[.\\S]*", message = "has whitespaces which are not allowed")
private String controllerId;
@Transient