From cfa6140cfae6fca0baf9fdb50aff8876d57f3e89 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Mon, 10 Sep 2012 08:45:25 +0000 Subject: [PATCH] BIS-180 - openBIS AS becomes unresponsive when performing batch sample updates - fix error messages SVN: 26565 --- .../openbis/generic/server/business/bo/SampleBO.java | 5 ----- .../generic/server/dataaccess/db/SampleDAOTest.java | 12 ++++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java index ab480cb0125..a0d07aa06d3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/SampleBO.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Set; import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.generic.server.business.bo.util.SampleUtils; @@ -177,10 +176,6 @@ public final class SampleBO extends AbstractSampleBusinessObject implements ISam try { getSampleDAO().createOrUpdateSample(sample, findPerson()); - } catch (final DataIntegrityViolationException ex) - { - // needed because we throw an exception in DAO instead of relying on DB constraint - throw UserFailureException.fromTemplate(ex.getMessage()); } catch (final DataAccessException ex) { throwException(ex, String.format("Sample '%s'", sample.getSampleIdentifier())); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java index 34e300e1b7a..4c1c796568e 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/SampleDAOTest.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Set; import org.hibernate.classic.Session; +import org.hibernate.exception.ConstraintViolationException; import org.springframework.dao.DataIntegrityViolationException; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -152,9 +153,7 @@ public final class SampleDAOTest extends AbstractDAOTest fail("DataIntegrityViolationException expected"); } catch (DataIntegrityViolationException e) { - assertEquals("ERROR: Insert/Update of Sample (Code: WELL1) failed because " - + "database instance sample with the same code and being the part " - + "of the same container already exists.", e.getMessage()); + assertEquals(ConstraintViolationException.class, e.getCause().getClass()); } } @@ -183,9 +182,7 @@ public final class SampleDAOTest extends AbstractDAOTest fail("DataIntegrityViolationException expected"); } catch (DataIntegrityViolationException e) { - assertEquals("ERROR: Insert/Update of Sample (Code: WELL1) failed because " - + "database instance sample of the same type with the same subcode " - + "already exists.", e.getMessage()); + assertEquals(ConstraintViolationException.class, e.getCause().getClass()); } } @@ -210,8 +207,7 @@ public final class SampleDAOTest extends AbstractDAOTest fail("DataIntegrityViolationException expected"); } catch (DataIntegrityViolationException e) { - assertEquals("ERROR: Insert/Update of Sample (Code: S_CODE) failed because " - + "database instance sample with the same code already exists.", e.getMessage()); + assertEquals(ConstraintViolationException.class, e.getCause().getClass()); } } -- GitLab