Liron Aravot has uploaded a new change for review. Change subject: core: avoid saving duplicate records when saving LUN connections ......................................................................
core: avoid saving duplicate records when saving LUN connections When adding a LUN to the db, StorageHandlingCommandBase.proceedLUNInDb() is executed. Among its other operations, this method checks if connections with the same details as the LUN connections already exists by executing Getstorage_server_connectionsByKey and if not a new connection record is being saved, otherwise the existing one is used. Getstorage_server_connectionsByKey checks if connection with the same details exists according to the iqn, connection, port, portal username and password fields - the problem is that those fields could be set and persisted with with empty string or null, which will lead to duplicate records. This patch only avoid having empty string in those fields - further patch will fix the current state in the db and will add proper contraints. Change-Id: I997ba0fbc6e984a9e6782502c6b36b1f9a1f3d8c Bug-Url: https://bugzilla.redhat.com/1173951 Signed-off-by: Liron Aravot <lara...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageServerConnections.java 1 file changed, 12 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/36212/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageServerConnections.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageServerConnections.java index 3564203..465224d 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageServerConnections.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StorageServerConnections.java @@ -80,7 +80,7 @@ } public void setiqn(String value) { - this.iqn = value; + this.iqn = getStringValueToSet(value); } private String port; @@ -90,7 +90,7 @@ } public void setport(String value) { - this.port = value; + this.port = getStringValueToSet(value); } private String portal = DEFAULT_TPGT; @@ -100,7 +100,7 @@ } public void setportal(String value) { - this.portal = value; + this.portal = getStringValueToSet(value); } private String password; @@ -110,7 +110,7 @@ } public void setpassword(String value) { - this.password = value; + this.password = getStringValueToSet(value); } private StorageType storageType; @@ -130,7 +130,7 @@ } public void setuser_name(String value) { - this.username = value; + this.username = getStringValueToSet(value); } private String mountOptions; @@ -260,4 +260,11 @@ this.nfsRetrans = nfsRetrans; } + private String getStringValueToSet(String value) { + if (value != null && value.isEmpty()) { + return null; + } + + return value; + } } -- To view, visit http://gerrit.ovirt.org/36212 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I997ba0fbc6e984a9e6782502c6b36b1f9a1f3d8c Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Aravot <lara...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches