diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/CreateExperimentExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/CreateExperimentExecutor.java
index b59adb3a500f75b97bfe70bae9647b754fea9cdd..35e2a146e935e958d580452acda25b7227088c79 100644
--- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/CreateExperimentExecutor.java
+++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/experiment/CreateExperimentExecutor.java
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
 import org.springframework.stereotype.Component;
 
 import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext;
@@ -36,6 +37,7 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentPer
 import ch.ethz.sis.openbis.generic.shared.api.v3.exceptions.UnauthorizedObjectAccessException;
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
 import ch.systemsx.cisd.openbis.generic.server.authorization.validator.ProjectByIdentiferValidator;
+import ch.systemsx.cisd.openbis.generic.server.business.bo.DataAccessExceptionTranslator;
 import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory;
 import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
@@ -90,22 +92,29 @@ public class CreateExperimentExecutor implements ICreateExperimentExecutor
     @Override
     public List<ExperimentPermId> create(IOperationContext context, List<ExperimentCreation> creations)
     {
-        List<ExperimentPermId> result = new LinkedList<ExperimentPermId>();
-
-        for (ExperimentCreation creation : creations)
+        try
         {
-            context.pushContextDescription(ExperimentContextDescription.creating(creation));
+            List<ExperimentPermId> result = new LinkedList<ExperimentPermId>();
 
-            ExperimentPE experiment = createExperimentPE(context, creation);
-            daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment, context.getSession().tryGetPerson());
-            createAttachmentExecutor.create(context, experiment, creation.getAttachments());
-            addTagToEntityExecutor.add(context, experiment, creation.getTagIds());
-            result.add(new ExperimentPermId(experiment.getPermId()));
+            for (ExperimentCreation creation : creations)
+            {
+                context.pushContextDescription(ExperimentContextDescription.creating(creation));
 
-            context.popContextDescription();
-        }
+                ExperimentPE experiment = createExperimentPE(context, creation);
+                daoFactory.getExperimentDAO().createOrUpdateExperiment(experiment, context.getSession().tryGetPerson());
+                createAttachmentExecutor.create(context, experiment, creation.getAttachments());
+                addTagToEntityExecutor.add(context, experiment, creation.getTagIds());
+                result.add(new ExperimentPermId(experiment.getPermId()));
+
+                context.popContextDescription();
+            }
 
-        return result;
+            return result;
+        } catch (DataAccessException e)
+        {
+            DataAccessExceptionTranslator.throwException(e, "Experiment", EntityKind.EXPERIMENT);
+            return null;
+        }
     }
 
     private ExperimentPE createExperimentPE(IOperationContext context, ExperimentCreation experimentCreation)
diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/CreateSampleExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/CreateSampleExecutor.java
index ab2f6b0327ddc455e2044f4965444cc58be27b4b..5f907a559a7f0cf5f21672cbe7779c36c6360e6b 100644
--- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/CreateSampleExecutor.java
+++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/CreateSampleExecutor.java
@@ -25,7 +25,9 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataAccessException;
 import org.springframework.stereotype.Component;
 
 import ch.ethz.sis.openbis.generic.server.api.v3.executor.IOperationContext;
@@ -33,11 +35,17 @@ import ch.ethz.sis.openbis.generic.server.api.v3.executor.attachment.ICreateAtta
 import ch.ethz.sis.openbis.generic.server.api.v3.executor.property.IUpdateEntityPropertyExecutor;
 import ch.ethz.sis.openbis.generic.server.api.v3.executor.tag.IAddTagToEntityExecutor;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.sample.SampleCreation;
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.sample.SampleIdentifier;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.sample.SamplePermId;
+import ch.ethz.sis.openbis.generic.shared.api.v3.exceptions.UnauthorizedObjectAccessException;
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.generic.server.authorization.validator.SampleByIdentiferValidator;
+import ch.systemsx.cisd.openbis.generic.server.business.bo.DataAccessExceptionTranslator;
 import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory;
 import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFactory;
+import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
 import ch.systemsx.cisd.openbis.generic.shared.util.RelationshipUtils;
 
 /**
@@ -99,38 +107,44 @@ public class CreateSampleExecutor implements ICreateSampleExecutor
     @Override
     public List<SamplePermId> create(IOperationContext context, List<SampleCreation> creations)
     {
-        List<SamplePermId> permIdsAll = new LinkedList<SamplePermId>();
-        Map<SampleCreation, SamplePE> samplesAll = new LinkedHashMap<SampleCreation, SamplePE>();
-
-        int batchSize = 1000;
-        for (int batchStart = 0; batchStart < creations.size(); batchStart += batchSize)
+        try
         {
-            List<SampleCreation> creationsBatch = creations.subList(batchStart, Math.min(batchStart + batchSize, creations.size()));
-            createSamples(context, creationsBatch, permIdsAll, samplesAll);
+            List<SamplePermId> permIdsAll = new LinkedList<SamplePermId>();
+            Map<SampleCreation, SamplePE> samplesAll = new LinkedHashMap<SampleCreation, SamplePE>();
 
-            for (SampleCreation creation : creationsBatch)
+            int batchSize = 1000;
+            for (int batchStart = 0; batchStart < creations.size(); batchStart += batchSize)
             {
-                SamplePE sample = samplesAll.get(creation);
-                createAttachmentExecutor.create(context, sample, creation.getAttachments());
-                addTagToEntityExecutor.add(context, sample, creation.getTagIds());
+                List<SampleCreation> creationsBatch = creations.subList(batchStart, Math.min(batchStart + batchSize, creations.size()));
+                createSamples(context, creationsBatch, permIdsAll, samplesAll);
+
+                for (SampleCreation creation : creationsBatch)
+                {
+                    SamplePE sample = samplesAll.get(creation);
+                    createAttachmentExecutor.create(context, sample, creation.getAttachments());
+                    addTagToEntityExecutor.add(context, sample, creation.getTagIds());
+                }
+
+                daoFactory.getSessionFactory().getCurrentSession().flush();
+                daoFactory.getSessionFactory().getCurrentSession().clear();
             }
 
+            reloadSamples(samplesAll);
+
+            setSampleRelatedSamplesExecutor.set(context, samplesAll);
+            verifySampleExecutor.verify(context, samplesAll.values());
+
             daoFactory.getSessionFactory().getCurrentSession().flush();
             daoFactory.getSessionFactory().getCurrentSession().clear();
+            return permIdsAll;
+        } catch (DataAccessException e)
+        {
+            DataAccessExceptionTranslator.throwException(e, "Sample", EntityKind.SAMPLE);
+            return null;
         }
-
-        reloadSamples(samplesAll);
-
-        setSampleRelatedSamplesExecutor.set(context, samplesAll);
-        verifySampleExecutor.verify(context, samplesAll.values());
-
-        daoFactory.getSessionFactory().getCurrentSession().flush();
-        daoFactory.getSessionFactory().getCurrentSession().clear();
-
-        return permIdsAll;
     }
 
-    private void createSamples(IOperationContext context, List<SampleCreation> creationsBatch, 
+    private void createSamples(IOperationContext context, List<SampleCreation> creationsBatch,
             List<SamplePermId> permIdsAll, Map<SampleCreation, SamplePE> samplesAll)
     {
         Map<SampleCreation, SamplePE> batchMap = new LinkedHashMap<SampleCreation, SamplePE>();
@@ -157,6 +171,12 @@ public class CreateSampleExecutor implements ICreateSampleExecutor
         for (Map.Entry<SampleCreation, SamplePE> batchEntry : batchMap.entrySet())
         {
             SamplePE sample = batchEntry.getValue();
+
+            if (false == new SampleByIdentiferValidator().doValidation(context.getSession().tryGetPerson(), sample))
+            {
+                throw new UnauthorizedObjectAccessException(new SampleIdentifier(sample.getIdentifier()));
+            }
+
             Map<String, String> properties = batchEntry.getKey().getProperties();
             updateEntityPropertyExecutor.update(context, sample, sample.getEntityType(), properties);
         }
@@ -168,11 +188,13 @@ public class CreateSampleExecutor implements ICreateSampleExecutor
 
     private SamplePE createSamplePE(IOperationContext context, SampleCreation sampleCreation)
     {
-        if (sampleCreation.getCode() == null)
+        if (StringUtils.isEmpty(sampleCreation.getCode()))
         {
-            throw new UserFailureException("No code for sample provided");
+            throw new UserFailureException("Code cannot be empty.");
         }
-        
+
+        SampleIdentifierFactory.assertValidCode(sampleCreation.getCode());
+
         SamplePE sample = new SamplePE();
         sample.setCode(sampleCreation.getCode());
         String createdPermId = daoFactory.getPermIdDAO().createPermId();
diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/SetSampleTypeExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/SetSampleTypeExecutor.java
index 4794d9e29e27dbaa3f06b38693683749152b6c26..1a69428aba8c4eeb9687169b45282a3fbb725d7c 100644
--- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/SetSampleTypeExecutor.java
+++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/SetSampleTypeExecutor.java
@@ -68,7 +68,7 @@ public class SetSampleTypeExecutor implements ISetSampleTypeExecutor
 
             if (creation.getTypeId() == null)
             {
-                throw new UserFailureException("No type for sample provided");
+                throw new UserFailureException("Type id cannot be null.");
             } else
             {
                 EntityTypePE type = typeMap.get(creation.getTypeId());
diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateExperimentTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateExperimentTest.java
index 32f3e994ceb6e237f5a8cf4eba61dbde1aaac126..1d18ef8e8ae60e7825c8e9e4f9beef5a060c36c0 100644
--- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateExperimentTest.java
+++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateExperimentTest.java
@@ -74,6 +74,28 @@ public class CreateExperimentTest extends AbstractExperimentTest
             }, "Code cannot be empty", ExperimentContextDescription.creating(experiment));
     }
 
+    @Test
+    public void testCreateExperimentWithExistingCode()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final ExperimentCreation experiment = new ExperimentCreation();
+        experiment.setCode("EXPERIMENT_WITH_EXISTING_CODE");
+        experiment.setTypeId(new EntityTypePermId("SIRNA_HCS"));
+        experiment.setProjectId(new ProjectIdentifier("/CISD/NEMO"));
+
+        v3api.createExperiments(sessionToken, Arrays.asList(experiment));
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createExperiments(sessionToken, Arrays.asList(experiment));
+                }
+            }, "Experiment already exists in the database and needs to be unique", ExperimentContextDescription.creating(experiment));
+    }
+
     @Test
     public void testCreateExperimentWithIncorrectCode()
     {
@@ -307,7 +329,7 @@ public class CreateExperimentTest extends AbstractExperimentTest
     }
 
     @Test
-    public void testCreateExperimentWithIncorrectPropertyValue()
+    public void testCreateExperimentWithIncorrectDatePropertyValue()
     {
         final String sessionToken = v3api.login(TEST_USER, PASSWORD);
 
diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateSampleTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateSampleTest.java
index ede10d329ddee1e3f884d8da9184a69c0b074708..a787c72064304d9602cc11e3ec87204b8edc5770 100644
--- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateSampleTest.java
+++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/api/v3/CreateSampleTest.java
@@ -17,6 +17,7 @@
 package ch.ethz.sis.openbis.systemtest.api.v3;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.fail;
 
 import java.util.ArrayList;
@@ -40,6 +41,8 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.tag.Tag;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.sample.SampleFetchOptions;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.CreationId;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.entitytype.EntityTypePermId;
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.entitytype.IEntityTypeId;
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentIdentifier;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.ExperimentPermId;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.experiment.IExperimentId;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.sample.ISampleId;
@@ -59,6 +62,477 @@ import ch.systemsx.cisd.common.test.AssertionUtil;
 public class CreateSampleTest extends AbstractSampleTest
 {
 
+    @Test
+    public void testCreateSampleWithoutCode()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+        final SampleCreation sample = sampleCreation(null);
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(sample));
+                }
+            }, "Code cannot be empty");
+    }
+
+    @Test
+    public void testCreateSampleWithExistingCode()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation sample = sampleCreation("SAMPLE_WITH_EXISTING_CODE");
+        v3api.createSamples(sessionToken, Arrays.asList(sample));
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(sample));
+                }
+            }, "Insert/Update of sample (code: SAMPLE_WITH_EXISTING_CODE) failed because sample with the same code already exists");
+    }
+
+    @Test
+    public void testCreateSampleWithIncorrectCode()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+        final SampleCreation sample = sampleCreation("?!*");
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(sample));
+                }
+            }, "The code '?!*' contains illegal characters");
+    }
+
+    @Test
+    public void testCreateSampleWithoutType()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation sample = new SampleCreation();
+        sample.setCode("SAMPLE_WITHOUT_TYPE");
+        sample.setSpaceId(new SpacePermId("CISD"));
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(sample));
+                }
+            }, "Type id cannot be null");
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentType()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final IEntityTypeId typeId = new EntityTypePermId("IDONTEXIST");
+        final SampleCreation sample = new SampleCreation();
+        sample.setTypeId(typeId);
+        sample.setCode("SAMPLE_WITH_NONEXISTENT_TYPE");
+        sample.setSpaceId(new SpacePermId("CISD"));
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(sample));
+                }
+            }, typeId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentPropertyCode()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SAMPLE_WITH_NONEXISTENT_PROPERTY_CODE");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(new SpacePermId("CISD"));
+        creation.setProperty("NONEXISTENT_PROPERTY_CODE", "any value");
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(creation));
+                }
+            }, "Property type with code 'NONEXISTENT_PROPERTY_CODE' does not exist");
+    }
+
+    @Test
+    public void testCreateSampleWithIncorrectVocabularyPropertyValue()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SAMPLE_WITH_INCORRECT_PROPERTY_VALUE");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(new SpacePermId("CISD"));
+        creation.setProperty("ORGANISM", "NON_EXISTENT_ORGANISM");
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(creation));
+                }
+            }, "Vocabulary value 'NON_EXISTENT_ORGANISM' is not valid. It must exist in 'ORGANISM' controlled vocabulary");
+    }
+
+    @Test
+    public void testCreateSampleWithoutMandatoryPropertyValue()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SAMPLE_WITH_EMPTY_MANDATORY_PROPERTY");
+        creation.setTypeId(new EntityTypePermId("CONTROL_LAYOUT"));
+        creation.setSpaceId(new SpacePermId("CISD"));
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Arrays.asList(creation));
+                }
+            }, "Value of mandatory property '$PLATE_GEOMETRY' not specified");
+    }
+
+    @Test
+    public void testCreateSampleWithoutSpaceButWithExperiment()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SHARED_SAMPLE_TEST");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setExperimentId(new ExperimentIdentifier("/CISD/NEMO/EXP1"));
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, "Shared samples cannot be attached to experiments");
+    }
+
+    @Test
+    public void testCreateSampleWithoutSpaceAsAdminUser()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SHARED_SAMPLE_TEST");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+
+        List<SamplePermId> permIds = v3api.createSamples(sessionToken, Collections.singletonList(creation));
+
+        SampleFetchOptions fetchOptions = new SampleFetchOptions();
+        fetchOptions.fetchSpace();
+
+        Map<ISampleId, Sample> map = v3api.mapSamples(sessionToken, permIds, fetchOptions);
+        Sample sample = map.values().iterator().next();
+
+        assertEquals(sample.getCode(), "SHARED_SAMPLE_TEST");
+        assertNull(sample.getSpace());
+    }
+
+    @Test
+    public void testCreateSampleWithoutSpaceAsSpaceUser()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SHARED_SAMPLE_TEST");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, new SampleIdentifier("/SHARED_SAMPLE_TEST"));
+    }
+
+    @Test
+    public void testCreateSampleWithUnauthorizedSpace()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISpaceId spaceId = new SpacePermId("CISD");
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("UNAUTHORIZED_SPACE");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(spaceId);
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, spaceId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentSpace()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISpaceId spaceId = new SpacePermId("IDONTEXIST");
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("NONEXISTENT_SPACE");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(spaceId);
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, spaceId);
+    }
+
+    @Test
+    public void testCreateSampleWithInconsistentSpace()
+    {
+        final String sessionToken = v3api.login(TEST_USER, PASSWORD);
+
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("SAMPLE_WITH_INCONSISTENT_SPACE");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(new SpacePermId("TEST-SPACE"));
+        creation.setExperimentId(new ExperimentIdentifier("/CISD/NEMO/EXP1"));
+
+        assertUserFailureException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, "Sample space must be the same as experiment space");
+    }
+
+    @Test
+    public void testCreateSampleWithUnauthorizedExperiment()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final IExperimentId experimentId = new ExperimentPermId("200811050951882-1028");
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("UNAUTHORIZED_EXPERIMENT");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(new SpacePermId("TEST-SPACE"));
+        creation.setExperimentId(experimentId);
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, experimentId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentExperiment()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final IExperimentId experimentId = new ExperimentPermId("IDONTEXIST");
+        final SampleCreation creation = new SampleCreation();
+        creation.setCode("NONEXISTENT_EXPERIMENT");
+        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
+        creation.setSpaceId(new SpacePermId("TEST-SPACE"));
+        creation.setExperimentId(experimentId);
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, experimentId);
+    }
+
+    @Test
+    public void testCreateSampleWithUnauthorizedParent()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId parentId = createCisdSample("PARENT_SAMPLE");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_PARENT");
+        creation.setParentIds(Collections.singletonList(parentId));
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, parentId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentParent()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId parentId = new SamplePermId("IDONTEXIST");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_PARENT");
+        creation.setParentIds(Collections.singletonList(parentId));
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, parentId);
+    }
+
+    @Test
+    public void testCreateSampleWithUnauthorizedChild()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId childId = createCisdSample("CHILD_SAMPLE");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_CHILD");
+        creation.setChildIds(Collections.singletonList(childId));
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, childId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentChild()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId childId = new SamplePermId("IDONTEXIST");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_CHILD");
+        creation.setChildIds(Collections.singletonList(childId));
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, childId);
+    }
+
+    @Test
+    public void testCreateSampleWithUnauthorizedContainer()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId containerId = createCisdSample("CONTAINER_SAMPLE");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_CONTAINER");
+        creation.setContainerId(containerId);
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, containerId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonExistentContainer()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId containerId = new SamplePermId("IDONTEXIST");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_CONTAINER");
+        creation.setContainerId(containerId);
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, containerId);
+    }
+
+    @Test
+    public void testCreateSampleWithUnauthorizedContained()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId containedId = createCisdSample("CONTAINED_SAMPLE");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_CONTAINED");
+        creation.setContainedIds(Collections.singletonList(containedId));
+
+        assertUnauthorizedObjectAccessException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, containedId);
+    }
+
+    @Test
+    public void testCreateSampleWithNonexistentContained()
+    {
+        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
+
+        final ISampleId containedId = new SamplePermId("IDONTEXIST");
+        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_CONTAINED");
+        creation.setContainedIds(Collections.singletonList(containedId));
+
+        assertObjectNotFoundException(new IDelegatedAction()
+            {
+                @Override
+                public void execute()
+                {
+                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
+                }
+            }, containedId);
+    }
+
     @DataProvider(name = "tf-ft-tt")
     Object[][] getDataProviderForRelationTest()
     {
@@ -475,259 +949,6 @@ public class CreateSampleTest extends AbstractSampleTest
         }
     }
 
-    @Test
-    public void testCreateSampleWithoutCode()
-    {
-        String sessionToken = v3api.login(TEST_USER, PASSWORD);
-        SampleCreation sample = sampleCreation(null);
-        try
-        {
-            v3api.createSamples(sessionToken, Arrays.asList(sample));
-            fail("Expected user failure exception");
-        } catch (UserFailureException ufe)
-        {
-            AssertionUtil.assertContains("No code for sample provided", ufe.getMessage());
-        }
-    }
-
-    @Test
-    public void testCreateSampleWithUnauthorizedSpace()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISpaceId spaceId = new SpacePermId("CISD");
-        final SampleCreation creation = new SampleCreation();
-        creation.setCode("UNAUTHORIZED_SPACE");
-        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
-        creation.setSpaceId(spaceId);
-
-        assertUnauthorizedObjectAccessException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, spaceId);
-    }
-
-    @Test
-    public void testCreateSampleWithNonexistentSpace()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISpaceId spaceId = new SpacePermId("IDONTEXIST");
-        final SampleCreation creation = new SampleCreation();
-        creation.setCode("NONEXISTENT_SPACE");
-        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
-        creation.setSpaceId(spaceId);
-
-        assertObjectNotFoundException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, spaceId);
-    }
-
-    @Test
-    public void testCreateSampleWithUnauthorizedExperiment()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final IExperimentId experimentId = new ExperimentPermId("200811050951882-1028");
-        final SampleCreation creation = new SampleCreation();
-        creation.setCode("UNAUTHORIZED_EXPERIMENT");
-        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
-        creation.setSpaceId(new SpacePermId("TEST-SPACE"));
-        creation.setExperimentId(experimentId);
-
-        assertUnauthorizedObjectAccessException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, experimentId);
-    }
-
-    @Test
-    public void testCreateSampleWithNonexistentExperiment()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final IExperimentId experimentId = new ExperimentPermId("IDONTEXIST");
-        final SampleCreation creation = new SampleCreation();
-        creation.setCode("NONEXISTENT_EXPERIMENT");
-        creation.setTypeId(new EntityTypePermId("CELL_PLATE"));
-        creation.setSpaceId(new SpacePermId("TEST-SPACE"));
-        creation.setExperimentId(experimentId);
-
-        assertObjectNotFoundException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, experimentId);
-    }
-
-    @Test
-    public void testCreateSampleWithUnauthorizedParent()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId parentId = createCisdSample("PARENT_SAMPLE");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_PARENT");
-        creation.setParentIds(Collections.singletonList(parentId));
-
-        assertUnauthorizedObjectAccessException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, parentId);
-    }
-
-    @Test
-    public void testCreateSampleWithNonexistentParent()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId parentId = new SamplePermId("IDONTEXIST");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_PARENT");
-        creation.setParentIds(Collections.singletonList(parentId));
-
-        assertObjectNotFoundException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, parentId);
-    }
-
-    @Test
-    public void testCreateSampleWithUnauthorizedChild()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId childId = createCisdSample("CHILD_SAMPLE");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_CHILD");
-        creation.setChildIds(Collections.singletonList(childId));
-
-        assertUnauthorizedObjectAccessException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, childId);
-    }
-
-    @Test
-    public void testCreateSampleWithNonexistentChild()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId childId = new SamplePermId("IDONTEXIST");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_CHILD");
-        creation.setChildIds(Collections.singletonList(childId));
-
-        assertObjectNotFoundException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, childId);
-    }
-
-    @Test
-    public void testCreateSampleWithUnauthorizedContainer()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId containerId = createCisdSample("CONTAINER_SAMPLE");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_CONTAINER");
-        creation.setContainerId(containerId);
-
-        assertUnauthorizedObjectAccessException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, containerId);
-    }
-
-    @Test
-    public void testCreateSampleWithNonExistentContainer()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId containerId = new SamplePermId("IDONTEXIST");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_CONTAINER");
-        creation.setContainerId(containerId);
-
-        assertObjectNotFoundException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, containerId);
-    }
-
-    @Test
-    public void testCreateSampleWithUnauthorizedContained()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId containedId = createCisdSample("CONTAINED_SAMPLE");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_UNAUTHORIZED_CONTAINED");
-        creation.setContainedIds(Collections.singletonList(containedId));
-
-        assertUnauthorizedObjectAccessException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, containedId);
-    }
-
-    @Test
-    public void testCreateSampleWithNonexistentContained()
-    {
-        final String sessionToken = v3api.login(TEST_SPACE_USER, PASSWORD);
-
-        final ISampleId containedId = new SamplePermId("IDONTEXIST");
-        final SampleCreation creation = sampleCreation("TEST-SPACE", "HAS_NONEXISTENT_CONTAINED");
-        creation.setContainedIds(Collections.singletonList(containedId));
-
-        assertObjectNotFoundException(new IDelegatedAction()
-            {
-                @Override
-                public void execute()
-                {
-                    v3api.createSamples(sessionToken, Collections.singletonList(creation));
-                }
-            }, containedId);
-    }
-
     private SampleCreation sampleCreation(String code)
     {
         SampleCreation sampleParent = new SampleCreation();