Index: /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java	(revision 5563)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java	(revision 5564)
@@ -8,4 +8,5 @@
 import clarin.cmdi.componentregistry.ComponentRegistryFactory;
 import clarin.cmdi.componentregistry.ItemNotFoundException;
+import clarin.cmdi.componentregistry.RegistrySpace;
 import clarin.cmdi.componentregistry.components.CMDComponentSpec;
 import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase;
@@ -834,4 +835,5 @@
     }
     
+    
     @Test
     public void testUpdateGroupComponentAndProfile() throws Exception {
@@ -932,3 +934,135 @@
     }
 
+     @Test
+    public void testPublishGroupProfileAndComponent() throws Exception {
+
+        System.out.println("testPublishProfile");
+
+        fillUpGroupA();
+        fillUpGroupB();        
+        fillUpGroupC();
+        
+        baseRegistry.setRegistrySpace(RegistrySpace.PUBLISHED);
+        
+        FormDataMultiPart  form = createFormData(
+                RegistryTestHelper.getTestProfileContent("publishedName"),
+                "Published");
+        RegisterResponse response = getAuthenticatedResource(getResource().path(
+                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"profile-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertTrue(response.isProfile());
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"profile-1", response.getDescription().getId());
+        
+        
+        List<ProfileDescription> profiles = baseRegistry.getProfileDescriptions();
+        assertEquals(1, profiles.size());        
+        ProfileDescription profileDescription = profiles.get(0);
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"profile-1", profileDescription.getId());
+        assertEquals("link:" + ProfileDescription.PROFILE_PREFIX+"profile-1",
+                profileDescription.getHref());
+        assertEquals("Published", profileDescription.getDescription());
+        
+        
+          
+        
+        // not my profile from "my" group
+        
+        form = createFormData(
+                RegistryTestHelper.getTestProfileContent("publishedName"),
+                "Published");
+        response = getAuthenticatedResource(getResource().path(
+                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertTrue(response.isProfile());
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"Bprofile-1", response.getDescription().getId());
+      
+        profiles = baseRegistry.getProfileDescriptions();
+        assertEquals(2, profiles.size());        
+        profileDescription = profiles.get(0);
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"Bprofile-1", profileDescription.getId());
+        assertEquals("link:" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1",
+                profileDescription.getHref());
+        assertEquals("Published", profileDescription.getDescription());
+        
+        // not my profile, not my group 
+        
+       form = createFormData(
+                RegistryTestHelper.getTestProfileContent("publishedName"),
+                "Published");
+        ClientResponse cr = getAuthenticatedResource(getResource().path(
+                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                ClientResponse.class, form);
+        assertEquals(403, cr.getStatus());
+        profiles = baseRegistry.getProfileDescriptions();
+        assertEquals(2, profiles.size()); 
+        
+        /// components 
+        
+        
+        form = createFormData(
+                RegistryTestHelper.getComponentTestContentAsStream("publishedName"),
+                "Published");
+        response = getAuthenticatedResource(getResource().path(
+                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"component-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertFalse(response.isProfile());
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"component-1", response.getDescription().getId());
+        
+        
+        List<ComponentDescription> components = baseRegistry.getComponentDescriptions();
+        assertEquals(1, components.size());        
+        ComponentDescription componentDescription = components.get(0);
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"component-1", componentDescription.getId());
+        assertEquals("link:" + ComponentDescription.COMPONENT_PREFIX+"component-1",
+                componentDescription.getHref());
+        assertEquals("Published", componentDescription.getDescription());
+        
+        
+          
+        
+        // not my profile from "my" group
+        
+        
+         form = createFormData(
+                RegistryTestHelper.getComponentTestContentAsStream("publishedName"),
+                "Published");
+        response = getAuthenticatedResource(getResource().path(
+                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertFalse(response.isProfile());
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", response.getDescription().getId());
+        
+        
+        components = baseRegistry.getComponentDescriptions();
+        assertEquals(2, components.size());        
+        componentDescription = components.get(0);
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", componentDescription.getId());
+        assertEquals("link:" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1",
+                componentDescription.getHref());
+        assertEquals("Published", componentDescription.getDescription());
+        
+        
+        // not my profile, not my group 
+        
+        form = createFormData(
+                RegistryTestHelper.getComponentTestContentAsStream("publishedName"),
+                "Published");
+        cr = getAuthenticatedResource(getResource().path(
+                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                ClientResponse.class, form);
+        assertEquals(403, cr.getStatus());
+        components = baseRegistry.getComponentDescriptions();
+        assertEquals(2, components.size());  
+    }
+    
 }
Index: /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java	(revision 5563)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java	(revision 5564)
@@ -8,6 +8,9 @@
 import clarin.cmdi.componentregistry.ComponentRegistryFactory;
 import clarin.cmdi.componentregistry.ItemNotFoundException;
+import clarin.cmdi.componentregistry.RegistrySpace;
+import clarin.cmdi.componentregistry.components.CMDComponentSpec;
 import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase;
 import clarin.cmdi.componentregistry.impl.database.GroupService;
+import clarin.cmdi.componentregistry.model.BaseDescription;
 import clarin.cmdi.componentregistry.model.Comment;
 import clarin.cmdi.componentregistry.model.ComponentDescription;
@@ -22,4 +25,5 @@
 import java.text.ParseException;
 import java.util.Date;
+import java.util.List;
 import javax.ws.rs.core.MediaType;
 import javax.xml.bind.JAXBException;
@@ -224,100 +228,136 @@
     }
     
-    @Test
-    public void testUpdateGroupComponentAndProfile() throws Exception {
-
-        System.out.println("test updateGorupComponent");
+  
+    
+     @Test
+    public void testPublishGroupProfileAndComponent() throws Exception {
+
+        System.out.println("testPublishProfile");
 
         fillUpGroupA();
         fillUpGroupB();        
         fillUpGroupC();
-
+        
+        baseRegistry.setRegistrySpace(RegistrySpace.PUBLISHED);
+        
+        FormDataMultiPart  form = createFormData(
+                RegistryTestHelper.getTestProfileContent("publishedName"),
+                "Published");
+        RegisterResponse response = getAuthenticatedResource(getResource().path(
+                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"profile-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertTrue(response.isProfile());
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"profile-1", response.getDescription().getId());
+        
+        
+        List<ProfileDescription> profiles = baseRegistry.getProfileDescriptions();
+        assertEquals(1, profiles.size());        
+        ProfileDescription profileDescription = profiles.get(0);
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"profile-1", profileDescription.getId());
+        assertEquals("link:" + ProfileDescription.PROFILE_PREFIX+"profile-1",
+                profileDescription.getHref());
+        assertEquals("Published", profileDescription.getDescription());
+        
+        
+          
+        
+        // not my profile from "my" group
+        
+        form = createFormData(
+                RegistryTestHelper.getTestProfileContent("publishedName"),
+                "Published");
+        response = getAuthenticatedResource(getResource().path(
+                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertTrue(response.isProfile());
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"Bprofile-1", response.getDescription().getId());
       
-        
-        FormDataMultiPart form = createFormData(
-                RegistryTestHelper.getComponentTestContentAsStream("TESTNAME"),
-                "UPDATE DESCRIPTION!");
-        ClientResponse cResponse = getAuthenticatedResource(getResource().path(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"component-1" + "/update")).type(
-                MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-        assertEquals(ClientResponse.Status.OK.getStatusCode(),
-                cResponse.getStatus());
-        RegisterResponse response = cResponse.getEntity(RegisterResponse.class);
-        assertTrue(response.isRegistered());
+        profiles = baseRegistry.getProfileDescriptions();
+        assertEquals(2, profiles.size());        
+        profileDescription = profiles.get(0);
+        assertEquals(ProfileDescription.PROFILE_PREFIX+"Bprofile-1", profileDescription.getId());
+        assertEquals("link:" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1",
+                profileDescription.getHref());
+        assertEquals("Published", profileDescription.getDescription());
+        
+        // not my profile, not my group 
+        
+       form = createFormData(
+                RegistryTestHelper.getTestProfileContent("publishedName"),
+                "Published");
+        ClientResponse cr = getAuthenticatedResource(getResource().path(
+                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                ClientResponse.class, form);
+        assertEquals(403, cr.getStatus());
+        profiles = baseRegistry.getProfileDescriptions();
+        assertEquals(2, profiles.size()); 
+        
+        /// components 
+        
+        
+        form = createFormData(
+                RegistryTestHelper.getComponentTestContentAsStream("publishedName"),
+                "Published");
+        response = getAuthenticatedResource(getResource().path(
+                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"component-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
         assertFalse(response.isProfile());
-        assertTrue(response.isInUserSpace());
-        ComponentDescription desc = (ComponentDescription) response.getDescription();
-        assertNotNull(desc);
-        assertEquals("Test1", desc.getName());
-        assertEquals("UPDATE DESCRIPTION!", desc.getDescription());
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"component-1", response.getDescription().getId());
+        
+        
+        List<ComponentDescription> components = baseRegistry.getComponentDescriptions();
+        assertEquals(1, components.size());        
+        ComponentDescription componentDescription = components.get(0);
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"component-1", componentDescription.getId());
+        assertEquals("link:" + ComponentDescription.COMPONENT_PREFIX+"component-1",
+                componentDescription.getHref());
+        assertEquals("Published", componentDescription.getDescription());
+        
+        
+          
+        
+        // not my profile from "my" group
+        
+        
+         form = createFormData(
+                RegistryTestHelper.getComponentTestContentAsStream("publishedName"),
+                "Published");
+        response = getAuthenticatedResource(getResource().path(
+                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                RegisterResponse.class, form);
+        assertFalse(response.isInUserSpace());
+        assertFalse(response.isProfile());
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", response.getDescription().getId());
+        
+        
+        components = baseRegistry.getComponentDescriptions();
+        assertEquals(2, components.size());        
+        componentDescription = components.get(0);
+        assertEquals(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1", componentDescription.getId());
+        assertEquals("link:" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1",
+                componentDescription.getHref());
+        assertEquals("Published", componentDescription.getDescription());
+        
+        
+        // not my profile, not my group 
         
         form = createFormData(
-                RegistryTestHelper.getComponentTestContentAsStream("TESTNAME"),
-                "UPDATE DESCRIPTION!");
-        cResponse = getAuthenticatedResource(getResource().path(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1" + "/update")).type(
-                MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-        assertEquals(ClientResponse.Status.OK.getStatusCode(),
-                cResponse.getStatus());
-        response = cResponse.getEntity(RegisterResponse.class);
-        assertTrue(response.isRegistered());
-        assertFalse(response.isProfile());
-        assertTrue(response.isInUserSpace());
-        desc = (ComponentDescription) response.getDescription();
-        assertNotNull(desc);
-        assertEquals("Test1", desc.getName());
-        assertEquals("UPDATE DESCRIPTION!", desc.getDescription());
-       
-        form = createFormData(
-                RegistryTestHelper.getComponentTestContentAsStream("TESTNAME"),
-                "UPDATE DESCRIPTION!");
-        cResponse = getAuthenticatedResource(getResource().path(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1" + "/update")).type(
-                MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-        assertEquals(403, cResponse.getStatus());
-        
-        // profile
-        
-        form = createFormData(RegistryTestHelper.getTestProfileContent("TESTNAME"),
-                "UPDATE DESCRIPTION!");
-        cResponse = getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"profile-1" + "/update")).type(
-                MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-        assertEquals(ClientResponse.Status.OK.getStatusCode(),
-                cResponse.getStatus());
-        response = cResponse.getEntity(RegisterResponse.class);
-        assertTrue(response.isRegistered());
-        assertTrue(response.isProfile());
-        assertTrue(response.isInUserSpace());
-        ProfileDescription pdesc = (ProfileDescription) response.getDescription();
-        assertNotNull(pdesc);
-        assertEquals("Test1", pdesc.getName());
-        assertEquals("UPDATE DESCRIPTION!", pdesc.getDescription());
-        
-        form = createFormData(
-                RegistryTestHelper.getTestProfileContent("TESTNAME"),
-                "UPDATE DESCRIPTION!");
-        cResponse = getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1" + "/update")).type(
-                MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-        assertEquals(ClientResponse.Status.OK.getStatusCode(),
-                cResponse.getStatus());
-        response = cResponse.getEntity(RegisterResponse.class);
-        assertTrue(response.isRegistered());
-        assertTrue(response.isProfile());
-        assertTrue(response.isInUserSpace());
-        pdesc = (ProfileDescription) response.getDescription();
-        assertNotNull(pdesc);
-        assertEquals("Test1", pdesc.getName());
-        assertEquals("UPDATE DESCRIPTION!", pdesc.getDescription());
-       
-         form = createFormData(
-                RegistryTestHelper.getTestProfileContent("TESTNAME"),
-                "UPDATE DESCRIPTION!");
-        cResponse = getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1" + "/update")).type(
-                MediaType.MULTIPART_FORM_DATA).post(ClientResponse.class, form);
-        assertEquals(403, cResponse.getStatus());
-        
+                RegistryTestHelper.getComponentTestContentAsStream("publishedName"),
+                "Published");
+        cr = getAuthenticatedResource(getResource().path(
+                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1" + "/publish"))
+                .type(MediaType.MULTIPART_FORM_DATA).post(
+                ClientResponse.class, form);
+        assertEquals(403, cr.getStatus());
+        components = baseRegistry.getComponentDescriptions();
+        assertEquals(2, components.size());  
     }
 
