Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 5566)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 5567)
@@ -1183,5 +1183,5 @@
             Principal principal = checkAndGetUserPrincipal();
             UserCredentials userCredentials = getUserCredentials(principal);
-            ComponentDescription desc = createNewComponentDescription();
+            ComponentDescription desc = this.createNewComponentDescription();
             desc.setCreatorName(userCredentials.getDisplayName());
             desc.setUserId(userCredentials.getPrincipalName()); // Hash used to
Index: /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 5566)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 5567)
@@ -351,4 +351,6 @@
         return getTestCommentContent("Actual", ProfileDescription.PROFILE_PREFIX + "profile1");
     }
+    
+  
 
     /**
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 5566)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java	(revision 5567)
@@ -13,4 +13,5 @@
 import clarin.cmdi.componentregistry.impl.database.GroupService;
 import clarin.cmdi.componentregistry.model.Comment;
+import clarin.cmdi.componentregistry.model.CommentResponse;
 import clarin.cmdi.componentregistry.model.ComponentDescription;
 import clarin.cmdi.componentregistry.model.Group;
@@ -35,4 +36,5 @@
 import static org.junit.Assert.*;
 import org.junit.Test;
+import org.springframework.util.Assert;
 
 /**
@@ -1215,3 +1217,81 @@
         
     }
+      
+       @Test
+    public void testRegisterCommentInGroup() throws Exception {
+
+        System.out.println("testRegisterCommmentInGroup");
+
+        
+        fillUpGroupB();        
+        fillUpGroupC();
+
+        FormDataMultiPart form = new FormDataMultiPart();        
+        String id = ProfileDescription.PROFILE_PREFIX + "Bprofile-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForProfile("comment1", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        CommentResponse response = getAuthenticatedResource(
+                "/registry/profiles/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(CommentResponse.class, form);
+        assertTrue(response.isRegistered());
+        assertTrue(response.isInUserSpace());
+        Comment comment = response.getComment();
+        assertNotNull(comment);
+        assertEquals("comment1", comment.getComment());
+        assertEquals("Database test user", comment.getUserName());
+        Assert.notNull(comment.getCommentDate());
+        assertEquals(1, Long.parseLong(comment.getId()));
+
+        // User id should not be serialized!
+        assertEquals(0, comment.getUserId());
+        
+        
+        form = new FormDataMultiPart();        
+        id = ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForComponent("comment2", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        response = getAuthenticatedResource(
+                "/registry/components/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(CommentResponse.class, form);
+        assertTrue(response.isRegistered());
+        assertTrue(response.isInUserSpace());
+        comment = response.getComment();
+        assertNotNull(comment);
+        assertEquals("comment2", comment.getComment());
+        assertEquals("Database test user", comment.getUserName());
+        Assert.notNull(comment.getCommentDate());
+        assertEquals(2, Long.parseLong(comment.getId()));
+
+        // User id should not be serialized!
+        assertEquals(0, comment.getUserId());
+        
+        // not my group
+        
+        form = new FormDataMultiPart();        
+        id = ProfileDescription.PROFILE_PREFIX + "Cprofile-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForProfile("comment3", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        ClientResponse cresponse = getAuthenticatedResource(
+                "/registry/profiles/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(ClientResponse.class, form);
+        assertEquals(403, cresponse.getStatus());
+
+        form = new FormDataMultiPart();        
+        id = ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForComponent("comment4", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        cresponse = getAuthenticatedResource(
+                "/registry/components/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(ClientResponse.class, form);
+        assertEquals(403, cresponse.getStatus());
+    }
+
 }
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 5566)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java	(revision 5567)
@@ -14,4 +14,5 @@
 import clarin.cmdi.componentregistry.model.BaseDescription;
 import clarin.cmdi.componentregistry.model.Comment;
+import clarin.cmdi.componentregistry.model.CommentResponse;
 import clarin.cmdi.componentregistry.model.ComponentDescription;
 import clarin.cmdi.componentregistry.model.Ownership;
@@ -34,4 +35,5 @@
 import static org.junit.Assert.*;
 import org.junit.Test;
+import org.springframework.util.Assert;
 
 /**
@@ -232,67 +234,81 @@
    
     
-    @Test  
-    public void testDeleteCommentFromGroupComponentAndProfile() throws Exception {
-
-        System.out.println("test deleteCommentFromGroupComponent");
-
-        
-        fillUpGroupA();
+    @Test
+    public void testRegisterCommentInGroup() throws Exception {
+
+        System.out.println("testRegisterCommmentInGroup");
+
+        
         fillUpGroupB();        
         fillUpGroupC();
-        
-         RegistryTestHelper.addComment(baseRegistry, "COMMENTc1",  ComponentDescription.COMPONENT_PREFIX + "component-1",
-                "JUnit@test.com");
-        RegistryTestHelper.addComment(baseRegistry, "COMMENTp1",  ProfileDescription.PROFILE_PREFIX + "profile-1",
-                "JUnit@test.com");
-        RegistryTestHelper.addComment(baseRegistry, "COMMENTBc1",  ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1",
-                "anotherPrincipal");
-        RegistryTestHelper.addComment(baseRegistry, "COMMENTBp1",  ProfileDescription.PROFILE_PREFIX + "Bprofile-1",
-                "anotherPrincipal");
-       (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCc1",  ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1",
-                "anotherPrincipal");
-       (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCp1",  ProfileDescription.PROFILE_PREFIX + "Cprofile-1","anotherPrincipal");
-         
-        ClientResponse response = getAuthenticatedResource(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1/comments/1").delete(
-                ClientResponse.class);
-        assertEquals(200, response.getStatus());
+
+        FormDataMultiPart form = new FormDataMultiPart();        
+        String id = ProfileDescription.PROFILE_PREFIX + "Bprofile-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForProfile("comment1", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        CommentResponse response = getAuthenticatedResource(
+                "/registry/profiles/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(CommentResponse.class, form);
+        assertTrue(response.isRegistered());
+        assertTrue(response.isInUserSpace());
+        Comment comment = response.getComment();
+        assertNotNull(comment);
+        assertEquals("comment1", comment.getComment());
+        assertEquals("Database test user", comment.getUserName());
+        Assert.notNull(comment.getCommentDate());
+        assertEquals(1, Long.parseLong(comment.getId()));
+
+        // User id should not be serialized!
+        assertEquals(0, comment.getUserId());
+        
+        
+        form = new FormDataMultiPart();        
+        id = ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForComponent("comment2", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
         response = getAuthenticatedResource(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1/comments/1").get(
-                ClientResponse.class);
-        assertEquals(404, response.getStatus());
-        
-        response = getAuthenticatedResource(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1/comments/3").delete(
-                ClientResponse.class);
-        assertEquals(403, response.getStatus());
-        
-        
-        response = getAuthenticatedResource(
-                "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1/comments/5").delete(
-                ClientResponse.class);
-        assertEquals(403, response.getStatus());
-
-       
-       response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1/comments/2").delete(
-                ClientResponse.class);
-        assertEquals(200, response.getStatus());
-        response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1/comments/2").get(
-                ClientResponse.class);
-        assertEquals(404, response.getStatus());
-        
-        response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1/comments/4").delete(
-                ClientResponse.class);
-        assertEquals(403, response.getStatus());
-        
-        
-        response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Cprofile-1/comments/6").delete(
-                ClientResponse.class);
-        assertEquals(403, response.getStatus());
-        
+                "/registry/components/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(CommentResponse.class, form);
+        assertTrue(response.isRegistered());
+        assertTrue(response.isInUserSpace());
+        comment = response.getComment();
+        assertNotNull(comment);
+        assertEquals("comment2", comment.getComment());
+        assertEquals("Database test user", comment.getUserName());
+        Assert.notNull(comment.getCommentDate());
+        assertEquals(2, Long.parseLong(comment.getId()));
+
+        // User id should not be serialized!
+        assertEquals(0, comment.getUserId());
+        
+        // not my group
+        
+        form = new FormDataMultiPart();        
+        id = ProfileDescription.PROFILE_PREFIX + "Cprofile-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForProfile("comment3", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        ClientResponse cresponse = getAuthenticatedResource(
+                "/registry/profiles/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(ClientResponse.class, form);
+        assertEquals(403, cresponse.getStatus());
+
+        
+        
+        form = new FormDataMultiPart();        
+        id = ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1";
+        form.field(IComponentRegistryRestService.DATA_FORM_FIELD,
+                RegistryTestHelper.getCommentTestContentStringForComponent("comment4", id),
+                MediaType.APPLICATION_OCTET_STREAM_TYPE);
+        cresponse = getAuthenticatedResource(
+                "/registry/components/" + id + "/comments").type(
+                MediaType.MULTIPART_FORM_DATA)
+                .post(ClientResponse.class, form);
+        assertEquals(403, cresponse.getStatus());
     }
 
