From 24fa8fb193c3131b63ceab3968381e93ea0b4921 Mon Sep 17 00:00:00 2001
From: jakubs <jakubs>
Date: Mon, 14 Jan 2013 16:33:49 +0000
Subject: [PATCH] SP-207 BIS-124 disallow adding contained data sets to
 non-container data sets

SVN: 28086
---
 .../cisd/openbis/generic/server/business/bo/DataBO.java    | 4 ++++
 .../openbis/systemtest/UpdateDataSetContainmentTest.java   | 7 ++++---
 2 files changed, 8 insertions(+), 3 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 7d4a2d9871f..a655d4db873 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
@@ -661,6 +661,10 @@ public class DataBO extends AbstractDataSetBusinessObject implements IDataBO
         if (modifiedContainedDatasetCodesOrNull == null)
         {
             return; // contained data sets were not changed
+        } else if (modifiedContainedDatasetCodesOrNull.length > 0 && false == data.isContainer())
+        {
+            throw new UserFailureException("Data set '" + data.getCode()
+                    + " is not a container data set, and cannot contain other data sets.");
         } else
         {
             final List<DataPE> currentComponents =
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java
index 0ffd7aaa38c..d5c98acc362 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java
@@ -98,7 +98,7 @@ public class UpdateDataSetContainmentTest extends BaseTest
         perform(anUpdateOf(component1).withContainer(component2));
     }
 
-    @Test(expectedExceptions = UserFailureException.class, groups = "broken")
+    @Test(expectedExceptions = UserFailureException.class)
     public void dataSetWithComponentTypeCannotHaveComponents() throws Exception
     {
         ExternalData component1 = create(aDataSet().inSample(sample));
@@ -164,8 +164,9 @@ public class UpdateDataSetContainmentTest extends BaseTest
         perform(anUpdateOf(dataset).withComponent(dataset));
     }
 
-    @Test(groups = "broken")
-    public void subcomponentsAreAllowed() throws Exception
+    @Test(expectedExceptions =
+        { UserFailureException.class })
+    public void subcomponentsAreNotAllowed() throws Exception
     {
         ExternalData component = create(aDataSet().inSample(sample));
         ExternalData container =
-- 
GitLab