From 569390d96ef6c23d9bd1654bf5288f52865af647 Mon Sep 17 00:00:00 2001 From: Dominik Mizyn Date: Thu, 13 Jun 2019 16:15:00 +0200 Subject: FunctionalMenuItem DB constraints fix Add @Digits to secure Long type fields Issue-ID: PORTAL-626 Change-Id: I59080c9103369d96a42c574356f0635265335d0a Signed-off-by: Dominik Mizyn --- .../portal/domain/FunctionalMenuItemWithAppID.java | 6 +++++- .../portalapp/portal/transport/FunctionalMenuItem.java | 17 ++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'ecomp-portal-BE-common/src/main/java/org') diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java index e321512a..9900827f 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java @@ -44,6 +44,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Transient; +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.Digits; import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; @@ -68,10 +70,11 @@ public class FunctionalMenuItemWithAppID{ @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "MENU_ID") + @Digits(integer = 11, fraction = 0) public Long menuId; @Column(name = "COLUMN_NUM") - @Max(value = 99) + @Digits(integer = 2, fraction = 0) @NotNull public Integer column; @@ -82,6 +85,7 @@ public class FunctionalMenuItemWithAppID{ public String text; @Column(name = "PARENT_MENU_ID") + @Digits(integer = 11, fraction = 0) public Integer parentMenuId; @Column(name = "URL") diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java index 6848d6ae..14ad2f4c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java @@ -47,6 +47,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; +import javax.validation.constraints.Digits; import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; @@ -61,30 +62,32 @@ public class FunctionalMenuItem implements Serializable { private static final long serialVersionUID = 1L; @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) + @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "MENU_ID") + @Digits(integer = 11, fraction = 0) public Long menuId; - + @Column(name = "COLUMN_NUM") - @Max(value = 99) + @Digits(integer = 2, fraction = 0) @NotNull public Integer column; - + @Column(name = "TEXT") @Max(value = 100) @SafeHtml @NotNull public String text; - + @Column(name = "PARENT_MENU_ID") + @Digits(integer = 11, fraction = 0) public Integer parentMenuId; - + @Column(name = "URL") @Max(value = 128) @SafeHtml @NotNull public String url; - + @Column(name="ACTIVE_YN") @Max(value = 1) @SafeHtml -- cgit 1.2.3-korg