From 1554e9feca8146fe89014efd4b8021e10d4000bc Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Sun, 17 Mar 2013 11:29:39 +0000
Subject: [PATCH] Add capabilities DELETE_SPACE and UPDATE_SPACE.

SVN: 28623
---
 .../openbis/generic/server/CommonServer.java  | 18 ++++---
 .../predicate/SpaceUpdatesPredicate.java      | 48 +++++++++++++++++
 .../authorization/AuthorizationTestCase.java  | 54 ++++++++++++++-----
 .../authorization/PredicateExecutorTest.java  |  2 +-
 .../authorization/RoleWithIdentifierTest.java | 10 ++--
 ...AbstractTechIdCollectionPredicateTest.java | 44 +++++++++++++++
 .../AbstractTechIdPredicateTest.java          |  2 +-
 .../predicate/DataSetCodePredicateTest.java   |  2 +-
 ...DataSetUpdatesCollectionPredicateTest.java |  4 +-
 .../ListSampleCriteriaPredicateTest.java      |  2 +-
 .../predicate/NewSamplePredicateTest.java     |  2 +-
 .../predicate/ProjectPredicateTest.java       |  2 +-
 .../SampleOwnerIdentifierPredicateTest.java   |  2 +-
 .../SampleUpdatesCollectionPredicateTest.java |  4 +-
 .../SpaceIdentifierPredicateTest.java         |  6 +--
 15 files changed, 164 insertions(+), 38 deletions(-)
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceUpdatesPredicate.java

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java
index f5bc1c90958..f2435b3e31d 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java
@@ -75,6 +75,7 @@ import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SampleTec
 import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SampleTechIdPredicate;
 import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SampleUpdatesPredicate;
 import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SpaceIdentifierPredicate;
+import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SpaceUpdatesPredicate;
 import ch.systemsx.cisd.openbis.generic.server.authorization.validator.DeletionValidator;
 import ch.systemsx.cisd.openbis.generic.server.authorization.validator.ExperimentByIdentiferValidator;
 import ch.systemsx.cisd.openbis.generic.server.authorization.validator.ExpressionValidator;
@@ -481,14 +482,17 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt
 
     @Override
     @RolesAllowed(RoleWithHierarchy.INSTANCE_ADMIN)
-    public void updateSpace(final String sessionToken, final ISpaceUpdates updates)
+    @Capability("UPDATE_SPACE")
+    public void updateSpace(final String sessionToken,
+            @AuthorizationGuard(guardClass = SpaceUpdatesPredicate.class)
+            final ISpaceUpdates updates)
     {
         assert sessionToken != null : "Unspecified session token";
         assert updates != null : "Unspecified updates";
 
         final Session session = getSession(sessionToken);
-        final ISpaceBO groupBO = businessObjectFactory.createSpaceBO(session);
-        groupBO.update(updates);
+        final ISpaceBO spaceBO = businessObjectFactory.createSpaceBO(session);
+        spaceBO.update(updates);
     }
 
     @Override
@@ -2074,15 +2078,16 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt
 
     @Override
     @RolesAllowed(RoleWithHierarchy.INSTANCE_ADMIN)
+    @Capability("DELETE_SPACE")
     public void deleteSpaces(String sessionToken,
             @AuthorizationGuard(guardClass = SpaceTechIdCollectionPredicate.class)
             List<TechId> spaceIds, String reason)
     {
         Session session = getSession(sessionToken);
-        ISpaceBO groupBO = businessObjectFactory.createSpaceBO(session);
+        ISpaceBO spaceBO = businessObjectFactory.createSpaceBO(session);
         for (TechId id : spaceIds)
         {
-            groupBO.deleteByTechId(id, reason);
+            spaceBO.deleteByTechId(id, reason);
         }
     }
 
@@ -2642,7 +2647,8 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt
     {
         List<EntityTypePE> types = new ArrayList<EntityTypePE>();
         if ((entityKind.equals(EntityKind.SAMPLE) || entityKind.equals(EntityKind.DATA_SET) || entityKind
-                .equals(EntityKind.MATERIAL)) && EntityType.isDefinedInFileEntityTypeCode(type))
+                .equals(EntityKind.MATERIAL))
+                && EntityType.isDefinedInFileEntityTypeCode(type))
         {
             types.addAll(getDAOFactory().getEntityTypeDAO(
                     DtoConverters.convertEntityKind(entityKind)).listEntityTypes());
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceUpdatesPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceUpdatesPredicate.java
new file mode 100644
index 00000000000..1c06d5fe594
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceUpdatesPredicate.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2013 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.generic.server.authorization.predicate;
+
+import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.AbstractTechIdPredicate.SpaceTechIdPredicate;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISpaceUpdates;
+
+/**
+ * A predicate for {@link ISpaceUpdates}.
+ * 
+ * @author Bernd Rinn
+ */
+public class SpaceUpdatesPredicate extends DelegatedPredicate<TechId, ISpaceUpdates>
+{
+
+    public SpaceUpdatesPredicate()
+    {
+        super(new SpaceTechIdPredicate());
+    }
+
+    @Override
+    public TechId tryConvert(ISpaceUpdates value)
+    {
+        return new TechId(value.getId());
+    }
+
+    @Override
+    public String getCandidateDescription()
+    {
+        return "space update";
+    }
+
+}
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationTestCase.java
index 57e0783642e..14ea73ece76 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationTestCase.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/AuthorizationTestCase.java
@@ -66,7 +66,7 @@ public class AuthorizationTestCase extends AssertJUnit
 
     protected static final String SPACE_CODE = "G1";
 
-    protected static final String ANOTHER_GROUP_CODE = "G2";
+    protected static final String ANOTHER_SPACE_CODE = "G2";
 
     protected Mockery context;
 
@@ -76,7 +76,7 @@ public class AuthorizationTestCase extends AssertJUnit
      * Creates a role with level {@link RoleLevel#SPACE} with specified role code for specified
      * space.
      */
-    protected RoleWithIdentifier createGroupRole(RoleCode roleCode, SpaceIdentifier spaceIdentifier)
+    protected RoleWithIdentifier createSpaceRole(RoleCode roleCode, SpaceIdentifier spaceIdentifier)
     {
         SpacePE groupPE = new SpacePE();
         groupPE.setCode(spaceIdentifier.getSpaceCode());
@@ -175,12 +175,12 @@ public class AuthorizationTestCase extends AssertJUnit
     }
 
     /**
-     * Creates a space with code {@link #ANOTHER_GROUP_CODE} and database instance with code
+     * Creates a space with code {@link #ANOTHER_SPACE_CODE} and database instance with code
      * {@link #ANOTHER_INSTANCE_CODE}.
      */
     protected SpacePE createAnotherSpace()
     {
-        return createSpace(ANOTHER_GROUP_CODE, createAnotherDatabaseInstance());
+        return createSpace(ANOTHER_SPACE_CODE, createAnotherDatabaseInstance());
     }
 
     /**
@@ -196,13 +196,13 @@ public class AuthorizationTestCase extends AssertJUnit
     /**
      * Creates a space with specified group code and database instance.
      */
-    protected SpacePE createSpace(final String groupCode,
+    protected SpacePE createSpace(final String spaceCode,
             final DatabaseInstancePE databaseInstancePE)
     {
-        final SpacePE group = new SpacePE();
-        group.setCode(groupCode);
-        group.setDatabaseInstance(databaseInstancePE);
-        return group;
+        final SpacePE space = new SpacePE();
+        space.setCode(spaceCode);
+        space.setDatabaseInstance(databaseInstancePE);
+        return space;
     }
 
     /**
@@ -323,7 +323,35 @@ public class AuthorizationTestCase extends AssertJUnit
     }
 
     /**
-     * Creates a list of roles which contains a group role for a USER and group defined by code
+     * Creates a list of roles which contains an instance admin role for database instance
+     * {@link AuthorizationTestCase#ANOTHER_INSTANCE_CODE}.
+     */
+    protected List<RoleWithIdentifier> createAnotherInstanceAdminRole()
+    {
+        final List<RoleWithIdentifier> list = new ArrayList<RoleWithIdentifier>();
+        final RoleWithIdentifier databaseInstanceRole =
+                createInstanceRole(RoleCode.ADMIN, new DatabaseInstanceIdentifier(
+                        ANOTHER_INSTANCE_CODE));
+        list.add(databaseInstanceRole);
+        return list;
+    }
+
+    /**
+     * Creates a list of roles which contains a space admin role for space
+     * {@link AuthorizationTestCase#ANOTHER_SPACE_CODE}.
+     */
+    protected List<RoleWithIdentifier> createAnotherSpaceAdminRole()
+    {
+        final List<RoleWithIdentifier> list = new ArrayList<RoleWithIdentifier>();
+        final RoleWithIdentifier spaceRole =
+                createSpaceRole(RoleCode.USER, new SpaceIdentifier(ANOTHER_INSTANCE_CODE,
+                        ANOTHER_SPACE_CODE));
+        list.add(spaceRole);
+        return list;
+    }
+
+    /**
+     * Creates a list of roles which contains a space role for a USER and group defined by code
      * {@link #SPACE_CODE} and database instance {@link AuthorizationTestCase#INSTANCE_CODE}. If
      * <code>withInstanceRole == true</code> the list contains in addition an instance role for a
      * ADMIN and database instance defined by {@link #ANOTHER_INSTANCE_CODE}.
@@ -331,9 +359,9 @@ public class AuthorizationTestCase extends AssertJUnit
     protected List<RoleWithIdentifier> createRoles(final boolean withInstanceRole)
     {
         final List<RoleWithIdentifier> list = new ArrayList<RoleWithIdentifier>();
-        final RoleWithIdentifier groupRole =
-                createGroupRole(RoleCode.USER, new SpaceIdentifier(INSTANCE_CODE, SPACE_CODE));
-        list.add(groupRole);
+        final RoleWithIdentifier spaceRole =
+                createSpaceRole(RoleCode.USER, new SpaceIdentifier(INSTANCE_CODE, SPACE_CODE));
+        list.add(spaceRole);
         if (withInstanceRole)
         {
             final RoleWithIdentifier databaseInstanceRole =
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/PredicateExecutorTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/PredicateExecutorTest.java
index c302e76fb53..e3495d0b485 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/PredicateExecutorTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/PredicateExecutorTest.java
@@ -57,7 +57,7 @@ public final class PredicateExecutorTest extends AuthorizationTestCase
 
     private List<RoleWithIdentifier> createAllowedRoles()
     {
-        return Collections.singletonList(createGroupRole(RoleCode.USER, new SpaceIdentifier("DB1",
+        return Collections.singletonList(createSpaceRole(RoleCode.USER, new SpaceIdentifier("DB1",
                 "3V")));
     }
 
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/RoleWithIdentifierTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/RoleWithIdentifierTest.java
index 52ba1d24d62..010ecb70cb4 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/RoleWithIdentifierTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/RoleWithIdentifierTest.java
@@ -47,10 +47,10 @@ public final class RoleWithIdentifierTest extends AuthorizationTestCase
     {
         final RoleWithHierarchy role = RoleWithHierarchy.valueOf(RoleLevel.SPACE, RoleCode.ADMIN);
         RoleWithIdentifier roleWithCode =
-                createGroupRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, "CISD"));
+                createSpaceRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, "CISD"));
         assertEquals(role, roleWithCode.getRole());
         roleWithCode =
-                createGroupRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, ""));
+                createSpaceRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, ""));
         assertEquals(role, roleWithCode.getRole());
     }
 
@@ -60,9 +60,9 @@ public final class RoleWithIdentifierTest extends AuthorizationTestCase
         final Set<RoleWithHierarchy> singleton =
                 Collections.singleton(RoleWithHierarchy.valueOf(RoleLevel.SPACE, RoleCode.ADMIN));
         final List<RoleWithIdentifier> list = new ArrayList<RoleWithIdentifier>();
-        list.add(createGroupRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, "CISD")));
-        list.add(createGroupRole(RoleCode.USER, new SpaceIdentifier(INSTANCE_IDENTIFIER, "3V")));
-        list.add(createGroupRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, "IMSB")));
+        list.add(createSpaceRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, "CISD")));
+        list.add(createSpaceRole(RoleCode.USER, new SpaceIdentifier(INSTANCE_IDENTIFIER, "3V")));
+        list.add(createSpaceRole(RoleCode.ADMIN, new SpaceIdentifier(INSTANCE_IDENTIFIER, "IMSB")));
         list.add(createInstanceRole(RoleCode.ETL_SERVER, INSTANCE_IDENTIFIER));
         DefaultAccessController.retainMatchingRoleWithIdentifiers(list, singleton);
         assertEquals(2, list.size());
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdCollectionPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdCollectionPredicateTest.java
index 4a1c656c3ae..9050c0334c3 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdCollectionPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdCollectionPredicateTest.java
@@ -59,6 +59,50 @@ public class AbstractTechIdCollectionPredicateTest extends AuthorizationTestCase
         context.assertIsSatisfied();
     }
 
+    @Test
+    public void testSpaceTechIdCollectionPredicateSucceedsForInstanceAdmin()
+    {
+        SpaceTechIdCollectionPredicate predicate = new SpaceTechIdCollectionPredicate();
+        prepareProvider(INSTANCE_CODE, createDatabaseInstance(), createSpaces());
+        final List<TechId> techIds = TechId.createList(1L, 2L);
+        context.checking(new Expectations()
+            {
+                {
+                    one(provider).getDistinctSpacesByEntityIds(SpaceOwnerKind.SPACE, techIds);
+                    will(returnValue(new HashSet<SpacePE>(Arrays.asList(createAnotherSpace()))));
+                }
+            });
+        predicate.init(provider);
+
+        Status result =
+                predicate.evaluate(createPerson(), createAnotherInstanceAdminRole(), techIds);
+
+        assertTrue(result.toString(), result.isOK());
+        context.assertIsSatisfied();
+    }
+
+    @Test
+    public void testSpaceTechIdCollectionPredicateSucceedsForSpaceAdmin()
+    {
+        SpaceTechIdCollectionPredicate predicate = new SpaceTechIdCollectionPredicate();
+        prepareProvider(INSTANCE_CODE, createDatabaseInstance(), createSpaces());
+        final List<TechId> techIds = TechId.createList(1L, 2L);
+        context.checking(new Expectations()
+            {
+                {
+                    one(provider).getDistinctSpacesByEntityIds(SpaceOwnerKind.SPACE, techIds);
+                    will(returnValue(new HashSet<SpacePE>(Arrays.asList(createAnotherSpace()))));
+                }
+            });
+        predicate.init(provider);
+
+        Status result =
+                predicate.evaluate(createPerson(), createAnotherSpaceAdminRole(), techIds);
+
+        assertTrue(result.toString(), result.isOK());
+        context.assertIsSatisfied();
+    }
+
     @Test
     public void testSpaceTechIdCollectionPredicateFails()
     {
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdPredicateTest.java
index bf947fa983e..5188ed84230 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/AbstractTechIdPredicateTest.java
@@ -122,7 +122,7 @@ public final class AbstractTechIdPredicateTest extends AuthorizationTestCase
         final AbstractTechIdPredicate predicate = createPredicate();
         final DatabaseInstancePE homeDatabaseInstance = createDatabaseInstance();
         final List<SpacePE> groups = createSpaces();
-        final SpacePE anotherGroup = createSpace(ANOTHER_GROUP_CODE, homeDatabaseInstance);
+        final SpacePE anotherGroup = createSpace(ANOTHER_SPACE_CODE, homeDatabaseInstance);
         groups.add(anotherGroup);
         prepareProvider(groups, anotherGroup, ENTITY_KIND, TECH_ID);
         predicate.init(provider);
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetCodePredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetCodePredicateTest.java
index f69a2951996..c001cd40442 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetCodePredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetCodePredicateTest.java
@@ -57,7 +57,7 @@ public class DataSetCodePredicateTest extends AuthorizationTestCase
     public void testWithOneInvalidGroup()
     {
         final DataSetAccessPE accessData =
-                DataSetAccessPE.createDataSetAccessPEForTest("1", "d1", ANOTHER_GROUP_CODE,
+                DataSetAccessPE.createDataSetAccessPEForTest("1", "d1", ANOTHER_SPACE_CODE,
                         "global_" + ANOTHER_INSTANCE_CODE, ANOTHER_INSTANCE_CODE);
         context.checking(new Expectations()
             {
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicateTest.java
index d0c491e4aaf..e55e8b3182a 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicateTest.java
@@ -96,7 +96,7 @@ public class DataSetUpdatesCollectionPredicateTest extends AuthorizationTestCase
         DataSetUpdatesDTO ds1 = new DataSetUpdatesDTO();
         ds1.setDatasetId(new TechId(42L));
         ds1.setExperimentIdentifierOrNull(ExperimentIdentifierFactory.parse("/"
-                + ANOTHER_GROUP_CODE + "/P/E"));
+                + ANOTHER_SPACE_CODE + "/P/E"));
         ds1.setSampleIdentifierOrNull(SampleIdentifierFactory.parse("/" + SPACE_CODE + "/S"));
         prepareProvider(createDatabaseInstance(), createSpaces());
         DataSetUpdatesCollectionPredicate predicate = new DataSetUpdatesCollectionPredicate();
@@ -117,7 +117,7 @@ public class DataSetUpdatesCollectionPredicateTest extends AuthorizationTestCase
         ds1.setExperimentIdentifierOrNull(ExperimentIdentifierFactory.parse("/" + SPACE_CODE
                 + "/P/E"));
         ds1.setSampleIdentifierOrNull(SampleIdentifierFactory
-                .parse("/" + ANOTHER_GROUP_CODE + "/S"));
+                .parse("/" + ANOTHER_SPACE_CODE + "/S"));
         prepareProvider(createDatabaseInstance(), createSpaces());
         DataSetUpdatesCollectionPredicate predicate = new DataSetUpdatesCollectionPredicate();
         predicate.init(provider);
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ListSampleCriteriaPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ListSampleCriteriaPredicateTest.java
index fda1d667e52..5789794c8ac 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ListSampleCriteriaPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ListSampleCriteriaPredicateTest.java
@@ -87,7 +87,7 @@ public class ListSampleCriteriaPredicateTest extends AuthorizationTestCase
         prepareProvider(createAnotherDatabaseInstance(), createSpaces());
         predicate.init(provider);
         final ListSampleCriteria criteria = new ListSampleCriteria();
-        criteria.setSpaceCode(ANOTHER_GROUP_CODE);
+        criteria.setSpaceCode(ANOTHER_SPACE_CODE);
         criteria.setIncludeSpace(true);
         assertTrue(predicate.doEvaluation(createPerson(), createRoles(false), criteria).isError());
         context.assertIsSatisfied();
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/NewSamplePredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/NewSamplePredicateTest.java
index cd193caa456..e80495beb2f 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/NewSamplePredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/NewSamplePredicateTest.java
@@ -99,7 +99,7 @@ public class NewSamplePredicateTest extends AuthorizationTestCase
     {
         NewSamplePredicate predicate = new NewSamplePredicate();
         SampleType sampleType = new SampleType();
-        SpaceIdentifier groupIdentifier = new SpaceIdentifier(INSTANCE_CODE, ANOTHER_GROUP_CODE);
+        SpaceIdentifier groupIdentifier = new SpaceIdentifier(INSTANCE_CODE, ANOTHER_SPACE_CODE);
         SampleIdentifier sampleIdentifier = new SampleIdentifier(groupIdentifier, "s1");
         NewSample sample =
                 NewSample.createWithParent(sampleIdentifier.toString(), sampleType, "container",
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectPredicateTest.java
index c65ad0247e7..856c891e357 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectPredicateTest.java
@@ -61,7 +61,7 @@ public class ProjectPredicateTest extends AuthorizationTestCase
     public void testHaveNoAccessToProject()
     {
         ProjectPredicate predicate = new ProjectPredicate();
-        Project project = new Project(ANOTHER_GROUP_CODE, "XXX");
+        Project project = new Project(ANOTHER_SPACE_CODE, "XXX");
 
         context.checking(new Expectations()
             {
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleOwnerIdentifierPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleOwnerIdentifierPredicateTest.java
index c760e53e00f..9b50ff38a02 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleOwnerIdentifierPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleOwnerIdentifierPredicateTest.java
@@ -123,7 +123,7 @@ public class SampleOwnerIdentifierPredicateTest extends AuthorizationTestCase
         List<RoleWithIdentifier> roles = createRoles(false);
         SampleOwnerIdentifier identifier =
                 new SampleOwnerIdentifier(new SpaceIdentifier(ANOTHER_INSTANCE_CODE,
-                        ANOTHER_GROUP_CODE));
+                        ANOTHER_SPACE_CODE));
         prepareProvider(ANOTHER_INSTANCE_CODE, createAnotherDatabaseInstance(), createSpaces());
         predicate.init(provider);
 
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicateTest.java
index d5e51444c30..f0d1f439e49 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicateTest.java
@@ -111,7 +111,7 @@ public class SampleUpdatesCollectionPredicateTest extends AuthorizationTestCase
                 new SampleUpdatesDTO(new TechId(42L), null, null, null, 0, null, null, null);
         SampleUpdatesDTO sampleWithIdAndExperiment =
                 new SampleUpdatesDTO(new TechId(43L), null, ExperimentIdentifierFactory.parse("/"
-                        + ANOTHER_GROUP_CODE + "/B/E"), null, 0, null, null, null);
+                        + ANOTHER_SPACE_CODE + "/B/E"), null, 0, null, null, null);
         SampleUpdatesDTO sampleWithIdAndIdentifer =
                 new SampleUpdatesDTO(new TechId(44L), null, null, null, 0,
                         SampleIdentifierFactory.parse("/" + SPACE_CODE + "/S1"), null, null);
@@ -138,7 +138,7 @@ public class SampleUpdatesCollectionPredicateTest extends AuthorizationTestCase
                         + SPACE_CODE + "/B/E"), null, 0, null, null, null);
         SampleUpdatesDTO sampleWithIdAndIdentifer =
                 new SampleUpdatesDTO(new TechId(44L), null, null, null, 0,
-                        SampleIdentifierFactory.parse("/" + ANOTHER_GROUP_CODE + "/S1"), null, null);
+                        SampleIdentifierFactory.parse("/" + ANOTHER_SPACE_CODE + "/S1"), null, null);
         prepareProvider(createDatabaseInstance(), createSpaces());
         SampleUpdatesCollectionPredicate predicate = new SampleUpdatesCollectionPredicate();
         predicate.init(provider);
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceIdentifierPredicateTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceIdentifierPredicateTest.java
index 3571f870901..cdb7c6a5098 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceIdentifierPredicateTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SpaceIdentifierPredicateTest.java
@@ -114,7 +114,7 @@ public final class SpaceIdentifierPredicateTest extends AuthorizationTestCase
         predicate.init(provider);
         final Status evaluation =
                 predicate.doEvaluation(createPerson(), createRoles(false), new SpaceIdentifier(
-                        ANOTHER_INSTANCE_CODE, ANOTHER_GROUP_CODE));
+                        ANOTHER_INSTANCE_CODE, ANOTHER_SPACE_CODE));
         assertEquals(StatusFlag.ERROR, evaluation.getFlag());
         assertEquals("User 'megapixel' does not have enough privileges.", evaluation
                 .tryGetErrorMessage());
@@ -127,12 +127,12 @@ public final class SpaceIdentifierPredicateTest extends AuthorizationTestCase
         final DatabaseInstancePE homeDatabaseInstance = createDatabaseInstance();
         final SpaceIdentifierPredicate predicate = new SpaceIdentifierPredicate();
         final List<SpacePE> groups = createSpaces();
-        groups.add(createSpace(ANOTHER_GROUP_CODE, homeDatabaseInstance));
+        groups.add(createSpace(ANOTHER_SPACE_CODE, homeDatabaseInstance));
         prepareProvider(INSTANCE_CODE, createDatabaseInstance(), groups);
         predicate.init(provider);
         final Status evaluation =
                 predicate.doEvaluation(createPerson(), createRoles(false), new SpaceIdentifier(
-                        INSTANCE_CODE, ANOTHER_GROUP_CODE));
+                        INSTANCE_CODE, ANOTHER_SPACE_CODE));
         assertEquals(StatusFlag.ERROR, evaluation.getFlag());
         assertEquals("User 'megapixel' does not have enough privileges.", evaluation
                 .tryGetErrorMessage());
-- 
GitLab