From 0d104065d732786efb932a9559e0282425244961 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Mon, 11 Jul 2011 20:04:01 +0000 Subject: [PATCH] [LMS-2368] fixed error message translation when modifying data set throws DB exception SVN: 22078 --- .../openbis/generic/server/business/bo/DataBO.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBO.java index e13c669478f..5ce11efde0e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/DataBO.java @@ -25,6 +25,8 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import org.springframework.dao.DataAccessException; + import ch.rinn.restrictions.Friend; import ch.systemsx.cisd.common.collections.CollectionUtils; import ch.systemsx.cisd.common.exceptions.UserFailureException; @@ -530,7 +532,13 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO private void validateAndSave() { - getDataDAO().validateAndSaveUpdatedEntity(data); + try + { + getDataDAO().validateAndSaveUpdatedEntity(data); + } catch (final DataAccessException ex) + { + throwException(ex, String.format("Data Set '%s'", data.getCode())); + } } private void updateParents(String[] modifiedParentDatasetCodesOrNull) @@ -593,7 +601,9 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO return; } else if (componentCodes.contains(data.getCode())) { - throw new UserFailureException("Data set '" + data.getCode() + throw new UserFailureException( + "Data set '" + + data.getCode() + "' cannot contain itself as a component neither directly nor via subordinate components."); } -- GitLab