Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 5559)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 5560)
@@ -278,6 +278,4 @@
     public List<Comment> getCommentsInProfile(String profileId) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         try {
-            //Olha was here
-            //if (componentDao.isInRegistry(profileId, getUserId())) {
             if (this.canCurrentUserAccessDescription(profileId)) {
                 final List<Comment> commentsFromProfile = commentsDao.getCommentsFromItem(profileId);
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 5559)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 5560)
@@ -524,6 +524,6 @@
         LOG.debug("Comments of component with id {} are requested.", commentId);
         try {
-
-            return this.getBaseRegistry().getSpecifiedCommentInComponent(componentId, commentId);
+            Comment result = this.getBaseRegistry().getSpecifiedCommentInComponent(componentId, commentId);
+            return result;
         } catch (ComponentRegistryException e) {
             response.sendError(Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getMessage());
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 5559)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 5560)
@@ -23,4 +23,5 @@
 import clarin.cmdi.componentregistry.model.ComponentDescription;
 import clarin.cmdi.componentregistry.model.ProfileDescription;
+import clarin.cmdi.componentregistry.persistence.jpa.CommentsDao;
 
 import java.io.BufferedReader;
@@ -28,4 +29,5 @@
 import java.io.FileOutputStream;
 import java.io.InputStreamReader;
+import java.util.Date;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,293 +40,333 @@
 
     private static MDMarshaller marshaller;
+    
+   
+            
 
     @Autowired
     public void setMarshaller(MDMarshaller marshaller) {
-	RegistryTestHelper.marshaller = marshaller;
-    }
-    
-   
+        RegistryTestHelper.marshaller = marshaller;
+    }
 
     public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException {
-	return addComponent(testRegistry, id, getComponentTestContent(), isPublic);
-    }
-    
-    
+        return addComponent(testRegistry, id, getComponentTestContent(), isPublic);
+    }
+
     public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, String content, boolean isPublic) throws ParseException,
-	    JAXBException, UnsupportedEncodingException {
-	return addComponent(testRegistry, id, new ByteArrayInputStream(content.getBytes("UTF-8")), isPublic);
+            JAXBException, UnsupportedEncodingException {
+        return addComponent(testRegistry, id, new ByteArrayInputStream(content.getBytes("UTF-8")), isPublic);
     }
 
     private static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
-	    JAXBException {
-	ComponentDescription desc = ComponentDescription.createNewDescription();
-	desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
+            JAXBException {
+        ComponentDescription desc = ComponentDescription.createNewDescription();
+        desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
         desc.setUserId(DummyPrincipal.DUMMY_PRINCIPAL.getName());
-	desc.setName(id);
-	desc.setDescription("Test Description");
-	desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
-	desc.setHref("link:" + desc.getId());
+        desc.setName(id);
+        desc.setDescription("Test Description");
+        desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
+        desc.setHref("link:" + desc.getId());
         desc.setPublic(isPublic);
-	CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
-	testRegistry.register(desc, spec);
-	return desc;
-    }
-    
+        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
+        testRegistry.register(desc, spec);
+        return desc;
+    }
+
     public static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException {
-	return addComponentAnotherPrincipal(testRegistry, id, getComponentTestContent(), isPublic);
-    }
-
-     private static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
-	    JAXBException {
-	ComponentDescription desc = ComponentDescription.createNewDescription();
-	desc.setCreatorName("AnotherPrincipal");
+        return addComponentAnotherPrincipal(testRegistry, id, getComponentTestContent(), isPublic);
+    }
+
+    private static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
+            JAXBException {
+        ComponentDescription desc = ComponentDescription.createNewDescription();
+        desc.setCreatorName("AnotherPrincipal");
         desc.setUserId("AnotherPrincipal");
         desc.setDbUserId(2);
-	desc.setName(id);
-	desc.setDescription("Test Description");
-	desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
-	desc.setHref("link:" + desc.getId());
+        desc.setName(id);
+        desc.setDescription("Test Description");
+        desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
+        desc.setHref("link:" + desc.getId());
         desc.setPublic(isPublic);
-	CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
-	testRegistry.register(desc, spec);
-	return desc;
+        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
+        testRegistry.register(desc, spec);
+        return desc;
     }
 
     public static String getProfileTestContentString() {
-	return getProfileTestContentString("Actor");
+        return getProfileTestContentString("Actor");
     }
 
     private static String getProfileTestContentString(String name) {
-	String profileContent = "";
-	profileContent += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-	profileContent += "<CMD_ComponentSpec isProfile=\"true\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
-	profileContent += "    xsi:noNamespaceSchemaLocation=\"general-component-schema.xsd\">\n";
-	profileContent += "    <Header />\n";
-	profileContent += "    <CMD_Component name=\"" + name + "\" CardinalityMin=\"0\" CardinalityMax=\"unbounded\">\n";
-	profileContent += "        <AttributeList>\n";
-	profileContent += "            <Attribute>\n";
-	profileContent += "                <Name>Name</Name>\n";
-	profileContent += "                <Type>string</Type>\n";
-	profileContent += "            </Attribute>\n";
-	profileContent += "        </AttributeList>\n";
-	profileContent += "        <CMD_Element name=\"Age\">\n";
-	profileContent += "            <ValueScheme>\n";
-	profileContent += "                <pattern>[23][0-9]</pattern>\n";
-	profileContent += "            </ValueScheme>\n";
-	profileContent += "        </CMD_Element>\n";
-	profileContent += "    </CMD_Component>\n";
-	profileContent += "</CMD_ComponentSpec>\n";
-	return profileContent;
+        String profileContent = "";
+        profileContent += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        profileContent += "<CMD_ComponentSpec isProfile=\"true\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        profileContent += "    xsi:noNamespaceSchemaLocation=\"general-component-schema.xsd\">\n";
+        profileContent += "    <Header />\n";
+        profileContent += "    <CMD_Component name=\"" + name + "\" CardinalityMin=\"0\" CardinalityMax=\"unbounded\">\n";
+        profileContent += "        <AttributeList>\n";
+        profileContent += "            <Attribute>\n";
+        profileContent += "                <Name>Name</Name>\n";
+        profileContent += "                <Type>string</Type>\n";
+        profileContent += "            </Attribute>\n";
+        profileContent += "        </AttributeList>\n";
+        profileContent += "        <CMD_Element name=\"Age\">\n";
+        profileContent += "            <ValueScheme>\n";
+        profileContent += "                <pattern>[23][0-9]</pattern>\n";
+        profileContent += "            </ValueScheme>\n";
+        profileContent += "        </CMD_Element>\n";
+        profileContent += "    </CMD_Component>\n";
+        profileContent += "</CMD_ComponentSpec>\n";
+        return profileContent;
     }
 
     public static InputStream getTestProfileContent() {
-	return getTestProfileContent("Actor");
+        return getTestProfileContent("Actor");
     }
 
     public static InputStream getTestProfileContent(String name) {
-	return new ByteArrayInputStream(getProfileTestContentString(name).getBytes());
+        return new ByteArrayInputStream(getProfileTestContentString(name).getBytes());
     }
 
     public static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException, ItemNotFoundException {
-	return addProfile(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic);
+        return addProfile(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic);
     }
 
     public static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, String content, boolean isPublic) throws ParseException,
-	    JAXBException, ItemNotFoundException {
-	return addProfile(testRegistry, id, new ByteArrayInputStream(content.getBytes()), isPublic);
-    }
-    
-    
+            JAXBException, ItemNotFoundException {
+        return addProfile(testRegistry, id, new ByteArrayInputStream(content.getBytes()), isPublic);
+    }
 
     private static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
-	    JAXBException, ItemNotFoundException {
-	ProfileDescription desc = ProfileDescription.createNewDescription();
-	desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
-	desc.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());
-	desc.setName(id);
-	desc.setDescription("Test Description");
-	desc.setId(ProfileDescription.PROFILE_PREFIX + id);
-	desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
+            JAXBException, ItemNotFoundException {
+        ProfileDescription desc = ProfileDescription.createNewDescription();
+        desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
+        desc.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());
+        desc.setName(id);
+        desc.setDescription("Test Description");
+        desc.setId(ProfileDescription.PROFILE_PREFIX + id);
+        desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
         desc.setPublic(isPublic);
-	CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
-	testRegistry.register(desc, spec);
-	return desc;
-    }
-    
+        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
+        testRegistry.register(desc, spec);
+        return desc;
+    }
+
     public static ProfileDescription addProfileAnotherPrincipal(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException, ItemNotFoundException {
-	return addProfileAnotherPrincipal(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic);
-    }
-    
+        return addProfileAnotherPrincipal(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic);
+    }
+
     private static ProfileDescription addProfileAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
-	    JAXBException, ItemNotFoundException {
-	ProfileDescription desc = ProfileDescription.createNewDescription();
-	desc.setCreatorName("AnotherPrincipal");
-	desc.setUserId("AnotherPrincipal");
+            JAXBException, ItemNotFoundException {
+        ProfileDescription desc = ProfileDescription.createNewDescription();
+        desc.setCreatorName("AnotherPrincipal");
+        desc.setUserId("AnotherPrincipal");
         desc.setDbUserId(2);
-	desc.setName(id);
-	desc.setDescription("Test Description");
-	desc.setId(ProfileDescription.PROFILE_PREFIX + id);
-	desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
+        desc.setName(id);
+        desc.setDescription("Test Description");
+        desc.setId(ProfileDescription.PROFILE_PREFIX + id);
+        desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
         desc.setPublic(isPublic);
-	CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
-	testRegistry.register(desc, spec);
-	return desc;
+        CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
+        testRegistry.register(desc, spec);
+        return desc;
     }
 
     public static CMDComponentSpec getTestProfile() throws JAXBException {
-	return marshaller.unmarshal(CMDComponentSpec.class, getTestProfileContent(), marshaller.getCMDComponentSchema());
+        return marshaller.unmarshal(CMDComponentSpec.class, getTestProfileContent(), marshaller.getCMDComponentSchema());
     }
 
     public static String getComponentTestContentString() {
-	return getComponentTestContentString("Access");
+        return getComponentTestContentString("Access");
     }
 
     public static InputStream getComponentTestContent() {
-	return getComponentTestContentAsStream("Access");
+        return getComponentTestContentAsStream("Access");
     }
 
     public static String getComponentTestContentString(String componentName) {
-	String compContent = "";
-	compContent += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-	compContent += "\n";
-	compContent += "<CMD_ComponentSpec isProfile=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
-	compContent += "    xsi:noNamespaceSchemaLocation=\"../../general-component-schema.xsd\">\n";
-	compContent += "    \n";
-	compContent += "    <Header/>\n";
-	compContent += "    \n";
-	compContent += "    <CMD_Component name=\"" + componentName + "\" CardinalityMin=\"1\" CardinalityMax=\"1\">\n";
-	compContent += "        <CMD_Element name=\"Availability\" ValueScheme=\"string\" />\n";
-	compContent += "        <CMD_Element name=\"Date\">\n";
-	compContent += "            <ValueScheme>\n";
-	compContent += "                <!-- matching dates of the pattern yyyy-mm-dd (ISO 8601); this only matches dates from the years 1000 through 2999 and does allow some invalid dates (e.g. February, the 30th) -->\n";
-	compContent += "                <pattern>(1|2)\\d{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])</pattern>                \n";
-	compContent += "            </ValueScheme>\n";
-	compContent += "        </CMD_Element>\n";
-	compContent += "        <CMD_Element name=\"Owner\" ValueScheme=\"string\" />\n";
-	compContent += "        <CMD_Element name=\"Publisher\" ValueScheme=\"string\" />\n";
-	compContent += "    </CMD_Component>\n";
-	compContent += "\n";
-	compContent += "</CMD_ComponentSpec>\n";
-	return compContent;
+        String compContent = "";
+        compContent += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+        compContent += "\n";
+        compContent += "<CMD_ComponentSpec isProfile=\"false\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
+        compContent += "    xsi:noNamespaceSchemaLocation=\"../../general-component-schema.xsd\">\n";
+        compContent += "    \n";
+        compContent += "    <Header/>\n";
+        compContent += "    \n";
+        compContent += "    <CMD_Component name=\"" + componentName + "\" CardinalityMin=\"1\" CardinalityMax=\"1\">\n";
+        compContent += "        <CMD_Element name=\"Availability\" ValueScheme=\"string\" />\n";
+        compContent += "        <CMD_Element name=\"Date\">\n";
+        compContent += "            <ValueScheme>\n";
+        compContent += "                <!-- matching dates of the pattern yyyy-mm-dd (ISO 8601); this only matches dates from the years 1000 through 2999 and does allow some invalid dates (e.g. February, the 30th) -->\n";
+        compContent += "                <pattern>(1|2)\\d{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])</pattern>                \n";
+        compContent += "            </ValueScheme>\n";
+        compContent += "        </CMD_Element>\n";
+        compContent += "        <CMD_Element name=\"Owner\" ValueScheme=\"string\" />\n";
+        compContent += "        <CMD_Element name=\"Publisher\" ValueScheme=\"string\" />\n";
+        compContent += "    </CMD_Component>\n";
+        compContent += "\n";
+        compContent += "</CMD_ComponentSpec>\n";
+        return compContent;
     }
 
     public static String getStringFromStream(InputStream largeProfileStream) throws IOException {
-	try {
-	    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(largeProfileStream));
-	    StringBuilder profileStringBuilder = new StringBuilder();
-	    String line;
-	    while (null != (line = bufferedReader.readLine())) {
-		profileStringBuilder.append(line);
-	    }
-	    return profileStringBuilder.toString();
-	} finally {
-	    largeProfileStream.close();
-	}
+        try {
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(largeProfileStream));
+            StringBuilder profileStringBuilder = new StringBuilder();
+            String line;
+            while (null != (line = bufferedReader.readLine())) {
+                profileStringBuilder.append(line);
+            }
+            return profileStringBuilder.toString();
+        } finally {
+            largeProfileStream.close();
+        }
     }
     ///////////////////////////////////////////////////////
 
     public static String getLargeProfileContent() throws IOException {
-	InputStream largeProfileStream = RegistryTestHelper.class.getResourceAsStream("/xml/largeProfile.xml");
-	return getStringFromStream(largeProfileStream);
+        InputStream largeProfileStream = RegistryTestHelper.class.getResourceAsStream("/xml/largeProfile.xml");
+        return getStringFromStream(largeProfileStream);
     }
 
     //////////////////////
     public static CMDComponentSpec getComponentFromString(String contentString) throws JAXBException {
-	return marshaller.unmarshal(CMDComponentSpec.class, getComponentContentAsStream(contentString), marshaller.getCMDComponentSchema());
+        return marshaller.unmarshal(CMDComponentSpec.class, getComponentContentAsStream(contentString), marshaller.getCMDComponentSchema());
     }
 
     public static InputStream getComponentContentAsStream(String content) {
-	return new ByteArrayInputStream(content.getBytes());
+        return new ByteArrayInputStream(content.getBytes());
     }
 
     public static InputStream getComponentTestContentAsStream(String componentName) {
-	return getComponentContentAsStream(getComponentTestContentString(componentName));
+        return getComponentContentAsStream(getComponentTestContentString(componentName));
     }
 
     public static CMDComponentSpec getTestComponent() throws JAXBException {
-	return marshaller.unmarshal(CMDComponentSpec.class, getComponentTestContent(), marshaller.getCMDComponentSchema());
+        return marshaller.unmarshal(CMDComponentSpec.class, getComponentTestContent(), marshaller.getCMDComponentSchema());
     }
 
     public static CMDComponentSpec getTestComponent(String name) throws JAXBException {
-	return marshaller.unmarshal(CMDComponentSpec.class, getComponentTestContentAsStream(name), marshaller.getCMDComponentSchema());
+        return marshaller.unmarshal(CMDComponentSpec.class, getComponentTestContentAsStream(name), marshaller.getCMDComponentSchema());
     }
 
     public static String getXml(CMDComponentSpec componentSpec) throws JAXBException, UnsupportedEncodingException {
-	ByteArrayOutputStream os = new ByteArrayOutputStream();
-	marshaller.marshal(componentSpec, os);
-	String xml = os.toString();
-	try {
-	    os.close();
-	} catch (IOException ex) {
-	}
-	return xml;
-    }
-
-    public static Comment addComment(ComponentRegistry testRegistry, String id, String descriptionId, String principal) throws ParseException, JAXBException, ComponentRegistryException, ItemNotFoundException,UserUnauthorizedException {
-	return addComment(testRegistry, RegistryTestHelper.getTestCommentContent(id, descriptionId), principal);
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        marshaller.marshal(componentSpec, os);
+        String xml = os.toString();
+        try {
+            os.close();
+        } catch (IOException ex) {
+        }
+        return xml;
+    }
+
+    public static Comment addComment(ComponentRegistry testRegistry, String id, String descriptionId, String principal) throws ParseException, JAXBException, ComponentRegistryException, ItemNotFoundException, UserUnauthorizedException {
+        return addComment(testRegistry, RegistryTestHelper.getTestCommentContent(id, descriptionId), principal);
     }
 
     private static Comment addComment(ComponentRegistry testRegistry, InputStream content, String principal) throws ParseException,
-	    JAXBException,
-	    ComponentRegistryException, ItemNotFoundException,UserUnauthorizedException {
-	Comment spec = marshaller.unmarshal(Comment.class, content, null);
-	testRegistry.registerComment(spec, principal);
-	return spec;
+            JAXBException,
+            ComponentRegistryException, ItemNotFoundException, UserUnauthorizedException {
+        Comment spec = marshaller.unmarshal(Comment.class, content, null);
+        testRegistry.registerComment(spec, principal);
+        return spec;
+    }
+    
+    public Comment addCommentBypassAuthorisation(CommentsDao commentsDao, String id, String descriptionId, String principal) throws ParseException, JAXBException, ComponentRegistryException, ItemNotFoundException, UserUnauthorizedException {
+        return addCommentBypassAuthorisation(commentsDao, RegistryTestHelper.getTestCommentContent(id, descriptionId), principal);
+    }
+
+
+    private Comment addCommentBypassAuthorisation(CommentsDao commentsDao, InputStream content, String principal) throws ParseException,
+            JAXBException,
+            ComponentRegistryException, ItemNotFoundException, UserUnauthorizedException {
+        Comment comment = marshaller.unmarshal(Comment.class, content, null);
+        comment.setCommentDate(new Date());
+        comment.setUserId(2);
+        commentsDao.saveAndFlush(comment);
+        return comment;
     }
 
     public static String getCommentTestContentStringForProfile(String commentName, String profileId) {
-	String comContent = "";
-	comContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
-	comContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
-	comContent += "    <comments>" + commentName + "</comments>\n";
-	comContent += "    <commentDate>" + DatesHelper.createNewDate() + "</commentDate>\n";
-	comContent += "    <componentId>" + profileId + "</componentId>\n";
-	comContent += "    <userName>J. Unit</userName>\n";
-	comContent += "</comment>\n";
-	return comContent;
+        String comContent = "";
+        comContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        comContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        comContent += "    <comments>" + commentName + "</comments>\n";
+        comContent += "    <commentDate>" + DatesHelper.createNewDate() + "</commentDate>\n";
+        comContent += "    <componentId>" + profileId + "</componentId>\n";
+        comContent += "    <userName>JUnit@test.com</userName>\n";
+        comContent += "</comment>\n";
+        return comContent;
+    }
+    
+     public static String getanotherPrincipalCommentTestContentStringForProfile(String commentName, String profileId) {
+        String comContent = "";
+        comContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        comContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        comContent += "    <comments>" + commentName + "</comments>\n";
+        comContent += "    <commentDate>" + DatesHelper.createNewDate() + "</commentDate>\n";
+        comContent += "    <componentId>" + profileId + "</componentId>\n";
+        comContent += "    <userName>anotherPrincipal</userName>\n";
+        comContent += "</comment>\n";
+        return comContent;
     }
 
     public static String getCommentTestContentStringForComponent(String commentName, String componentId) {
-	String comContent = "";
-	comContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
-	comContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
-	comContent += "    <comments>" + commentName + "</comments>\n";
-	comContent += "    <commentDate>" + DatesHelper.createNewDate() + "</commentDate>\n";
-	comContent += "     <componentId>" + componentId + "</componentId>";
-	comContent += "    <userName>J. Unit</userName>\n";
-	comContent += "</comment>\n";
-	return comContent;
+        String comContent = "";
+        comContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        comContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        comContent += "    <comments>" + commentName + "</comments>\n";
+        comContent += "    <commentDate>" + DatesHelper.createNewDate() + "</commentDate>\n";
+        comContent += "     <componentId>" + componentId + "</componentId>";
+        comContent += "    <userName>JUnit@test.com</userName>\n";
+        comContent += "</comment>\n";
+        return comContent;
+    }
+    
+     public static String getAnotherPrincipalCommentTestContentStringForComponent(String commentName, String componentId) {
+        String comContent = "";
+        comContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        comContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        comContent += "    <comments>" + commentName + "</comments>\n";
+        comContent += "    <commentDate>" + DatesHelper.createNewDate() + "</commentDate>\n";
+        comContent += "     <componentId>" + componentId + "</componentId>";
+        comContent += "    <userName>anotherPrincipal</userName>\n";
+        comContent += "</comment>\n";
+        return comContent;
     }
 
     public static InputStream getTestCommentContent(String content, String descriptionId) {
-	if (descriptionId.contains("profile")) {
-	    return new ByteArrayInputStream(getCommentTestContentStringForProfile(content, descriptionId).getBytes());
-	} else {
-	    return new ByteArrayInputStream(getCommentTestContentStringForComponent(content, descriptionId).getBytes());
-	}
+        if (descriptionId.contains("profile")) {
+            return new ByteArrayInputStream(getCommentTestContentStringForProfile(content, descriptionId).getBytes());
+        } else {
+            return new ByteArrayInputStream(getCommentTestContentStringForComponent(content, descriptionId).getBytes());
+        }
     }
 
     public static String getCommentTestContent(String commentId, String descriptionId) {
-	return getCommentTestContentStringForProfile(commentId, descriptionId);
+        return getCommentTestContentStringForProfile(commentId, descriptionId);
     }
 
     public static InputStream getCommentTestContent() {
-	return getTestCommentContent("Actual", ProfileDescription.PROFILE_PREFIX+"profile1");
-    }
-
-    /**
-     * Testing a big xsd string is a bit hard, so doing a best effort by checking the xs:element which represent the nested components used
-     * in a profile/component
+        return getTestCommentContent("Actual", ProfileDescription.PROFILE_PREFIX + "profile1");
+    }
+
+    /**
+     * Testing a big xsd string is a bit hard, so doing a best effort by
+     * checking the xs:element which represent the nested components used in a
+     * profile/component
      */
     public static boolean hasComponent(String xsd, String name, String min, String max) {
-	Pattern pattern = Pattern.compile("<xs:element name=\"" + name + "\" minOccurs=\"" + min + "\" maxOccurs=\"" + max + "\">");
-	Matcher matcher = pattern.matcher(xsd);
-	return matcher.find() && !matcher.find(); //find only one
+        Pattern pattern = Pattern.compile("<xs:element name=\"" + name + "\" minOccurs=\"" + min + "\" maxOccurs=\"" + max + "\">");
+        Matcher matcher = pattern.matcher(xsd);
+        return matcher.find() && !matcher.find(); //find only one
     }
 
     /**
      *
-     * @param bytes is an array of bytes to be written in the file filename (from scratch!)
-     * @param filename is the name of the file where the array "bytes" is to be written to
+     * @param bytes is an array of bytes to be written in the file filename
+     * (from scratch!)
+     * @param filename is the name of the file where the array "bytes" is to be
+     * written to
      * @throws IOException
      * @throws JAXBException
@@ -332,11 +374,11 @@
     public static void writeBytesToFile(byte[] bytes, String filename) throws IOException, JAXBException {
 
-	File file = new File(filename);
-	FileOutputStream fop = new FileOutputStream(file);
-
-	fop.write(bytes);
-
-	fop.flush();
-	fop.close();
+        File file = new File(filename);
+        FileOutputStream fop = new FileOutputStream(file);
+
+        fop.write(bytes);
+
+        fop.flush();
+        fop.close();
 
 
@@ -345,5 +387,6 @@
     /**
      *
-     * @param str is a string which is to be written into the filename (from scratch!)
+     * @param str is a string which is to be written into the filename (from
+     * scratch!)
      * @param filename is a filename where the string is to be written to
      * @throws IOException
@@ -352,5 +395,5 @@
     public static void writeStringToFile(String str, String filename) throws IOException, JAXBException {
 
-	writeBytesToFile(str.getBytes(), filename);
+        writeBytesToFile(str.getBytes(), filename);
 
 
@@ -359,5 +402,6 @@
     /**
      *
-     * @param os is an output stream which is to be written into the filename (from scratch!)
+     * @param os is an output stream which is to be written into the filename
+     * (from scratch!)
      * @param filename is a filename where the stream is to be written to
      * @throws IOException
@@ -366,5 +410,5 @@
     public static void writeStreamToFile(ByteArrayOutputStream os, String filename) throws IOException, JAXBException {
 
-	writeBytesToFile(os.toByteArray(), filename);
+        writeBytesToFile(os.toByteArray(), filename);
 
 
@@ -373,5 +417,6 @@
     /**
      *
-     * @param cdesc is a component which is to be written into the filename (from scratch!)
+     * @param cdesc is a component which is to be written into the filename
+     * (from scratch!)
      * @param filename is a filename where the component is to be written to
      * @throws IOException
@@ -381,8 +426,8 @@
 
 
-	ByteArrayOutputStream os = new ByteArrayOutputStream();
-	marshaller.marshal(cdesc, os);
-
-	writeStreamToFile(os, filename);
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        marshaller.marshal(cdesc, os);
+
+        writeStreamToFile(os, filename);
 
     }
@@ -391,19 +436,20 @@
      * opens a temporary sub-directory dirName in /target/
      *
-     * @param dirName is the name of the temporary subdirectory which is to be opened
+     * @param dirName is the name of the temporary subdirectory which is to be
+     * opened
      * @return the absolute part for this directory
      */
     public static String openTestDir(String dirName) {
 
-	File testDir = new File("target/" + dirName);
-
-
-	testDir.mkdir();
-
-	System.out.println(dirName);
-	//String retval = new File(testDir, dirName).getAbsolutePath();
-	String retval = new File(testDir, "/").getAbsolutePath();
-
-	return (retval);
+        File testDir = new File("target/" + dirName);
+
+
+        testDir.mkdir();
+
+        System.out.println(dirName);
+        //String retval = new File(testDir, dirName).getAbsolutePath();
+        String retval = new File(testDir, "/").getAbsolutePath();
+
+        return (retval);
 
     }
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 5559)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java	(revision 5560)
@@ -17,4 +17,5 @@
 import clarin.cmdi.componentregistry.model.ProfileDescription;
 import clarin.cmdi.componentregistry.model.RegistryUser;
+import clarin.cmdi.componentregistry.persistence.jpa.CommentsDao;
 import clarin.cmdi.componentregistry.persistence.jpa.UserDao;
 import com.sun.jersey.api.client.ClientResponse;
@@ -22,5 +23,4 @@
 import java.util.List;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
 import javax.xml.bind.JAXBException;
 import org.junit.Before;
@@ -46,4 +46,6 @@
     @Autowired 
     private UserDao userDao;
+    @Autowired 
+    private CommentsDao commentsDao;
     
     private ComponentRegistry baseRegistry;
@@ -507,4 +509,5 @@
         fillUpGroupC();
 
+        // lists
         
         List<ProfileDescription> response = this.getAuthenticatedResource(getResource()
@@ -534,4 +537,5 @@
         assertEquals(403, clientResponse.getStatus());
         
+        // particular components and profiles
         
         CMDComponentSpec component = this.getAuthenticatedResource(getResource()
@@ -570,4 +574,109 @@
         
     }
+    
+   @Test
+    public void testGetGroupComments() throws Exception {
+
+        System.out.println("test getGroupComments");
+
+        fillUpGroupA();
+        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");
+         
+          
+                // lists 
+        
+        List<Comment> response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        
+    
+        ClientResponse clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+         clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+        // particular comments
+        
+       Comment responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/1"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+      
+        assertEquals(1, Long.parseLong(responseComment.getId()));
+        
+        responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/2"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+       
+        assertEquals(2, Long.parseLong(responseComment.getId()));
+        
+       responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/3"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+        assertEquals(3, Long.parseLong(responseComment.getId()));
+        
+        responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/4"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+        assertEquals(4, Long.parseLong(responseComment.getId()));
+       
+        clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1/comments/6"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+         clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1/comments/5"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.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 5559)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java	(revision 5560)
@@ -7,20 +7,25 @@
 import clarin.cmdi.componentregistry.ComponentRegistry;
 import clarin.cmdi.componentregistry.ComponentRegistryFactory;
-import clarin.cmdi.componentregistry.impl.database.ComponentRegistryBeanFactory;
+import clarin.cmdi.componentregistry.ItemNotFoundException;
 import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase;
+import clarin.cmdi.componentregistry.impl.database.GroupService;
 import clarin.cmdi.componentregistry.model.Comment;
 import clarin.cmdi.componentregistry.model.ComponentDescription;
+import clarin.cmdi.componentregistry.model.Ownership;
 import clarin.cmdi.componentregistry.model.ProfileDescription;
+import clarin.cmdi.componentregistry.model.RegistryUser;
+import clarin.cmdi.componentregistry.persistence.jpa.CommentsDao;
+import clarin.cmdi.componentregistry.persistence.jpa.UserDao;
 import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.multipart.FormDataMultiPart;
+import java.text.ParseException;
 import java.util.List;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
+import javax.xml.bind.JAXBException;
 import org.junit.Before;
-import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 import static org.junit.Assert.*;
+import org.junit.Test;
 
 /**
@@ -29,11 +34,16 @@
  */
 public class SanboxTest extends ComponentRegistryRestServiceTestCase {
-
+    
     @Autowired
     private ComponentRegistryFactory componentRegistryFactory;
-    @Autowired
-    private ComponentRegistryBeanFactory componentRegistryBeanFactory;
+    
     @Autowired
     private JdbcTemplate jdbcTemplate;
+    @Autowired 
+    private GroupService groupService;
+    @Autowired 
+    private UserDao userDao;
+     @Autowired 
+    private CommentsDao commentsDao;
     private ComponentRegistry baseRegistry;
 
@@ -45,7 +55,5 @@
     }
 
-    private String expectedUserId(String principal) {
-        return getUserDao().getByPrincipalName(principal).getId().toString();
-    }
+   
     private ComponentDescription component1;
     private ComponentDescription component2;
@@ -94,62 +102,212 @@
                 "JUnit@test.com");
     }
-
+    
+     protected void createAntherUserRecord() {
+	RegistryUser user = new RegistryUser();
+	user.setName("Another database test user");
+	user.setPrincipalName("anotherPrincipal");
+	userDao.save(user);
+    }
+     
+    private void MakeGroupA(){
+        groupService.createNewGroup("group A", DummyPrincipal.DUMMY_PRINCIPAL.getName());
+    }
+    
+     private void fillUpGroupA() throws ParseException, JAXBException, ItemNotFoundException{
+         
+        MakeGroupA();
+        
+        RegistryTestHelper.addProfile(baseRegistry, "profile-1", false);
+        RegistryTestHelper.addComponent(baseRegistry, "component-1", false);
+        RegistryTestHelper.addComponent(baseRegistry, "component-2", false);
+        
+        Ownership ownership = new Ownership();
+        ownership.setComponentId(ProfileDescription.PROFILE_PREFIX+"profile-1");
+        ownership.setGroupId(1);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"component-1");
+        ownership.setGroupId(1);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"component-2");
+        ownership.setGroupId(1);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+    }
+     
+     
+    
+    private void MakeGroupB() throws ItemNotFoundException{
+        createAntherUserRecord();
+        groupService.createNewGroup("group B", "anotherPrincipal");
+        groupService.makeMember(DummyPrincipal.DUMMY_PRINCIPAL.getName(), "group B");
+    }
+    
+     private void MakeGroupC() throws ItemNotFoundException{
+        groupService.createNewGroup("group C", "anotherPrincipal");
+    }
+    
+     private void fillUpGroupB() throws ParseException, JAXBException, ItemNotFoundException{
+         
+        MakeGroupB();
+        
+        RegistryTestHelper.addProfile(baseRegistry, "Bprofile-1", false);
+        RegistryTestHelper.addComponent(baseRegistry, "Bcomponent-1", false);
+        RegistryTestHelper.addComponent(baseRegistry, "Bcomponent-2", false);
+        
+        Ownership ownership = new Ownership();
+        ownership.setComponentId(ProfileDescription.PROFILE_PREFIX+"Bprofile-1");
+        ownership.setGroupId(2);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1");
+        ownership.setGroupId(2);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Bcomponent-2");
+        ownership.setGroupId(2);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+    }
+     
+     private void fillUpGroupC() throws ParseException, JAXBException, ItemNotFoundException{
+         
+        MakeGroupC();
+        
+        RegistryTestHelper.addProfileAnotherPrincipal(baseRegistry, "Cprofile-1", false);
+        RegistryTestHelper.addComponentAnotherPrincipal(baseRegistry, "Ccomponent-1", false);
+        RegistryTestHelper.addComponentAnotherPrincipal(baseRegistry, "Ccomponent-2", false);
+        
+        Ownership ownership = new Ownership();
+        ownership.setComponentId(ProfileDescription.PROFILE_PREFIX+"Cprofile-1");
+        ownership.setGroupId(3);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1");
+        ownership.setGroupId(3);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+        ownership.setComponentId(ComponentDescription.COMPONENT_PREFIX+"Ccomponent-2");
+        ownership.setGroupId(3);
+        ownership.setUserId(0);
+        groupService.addOwnership(ownership);
+        
+    }
+    
+ 
+    
     @Test
-    public void testDeleteCommentFromPublicProfile() throws Exception {
-
-        System.out.println("testDeleteCommentFromPublicProfile");
-
-        fillUpPublicItems();
-
-        List<Comment> comments = this.getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile1/comments")).get(COMMENT_LIST_GENERICTYPE);
-        assertEquals(2, comments.size());
-        Comment aComment = this.getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile1/comments/" + profile1Comment1.getId())).get(Comment.class);
-        assertNotNull(aComment);
-
-        // Try to delete from other profile
-        ClientResponse response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile2/comments/9999").delete(ClientResponse.class);
-        assertEquals(404, response.getStatus());
-        // Delete from correct profile
-        response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile1/comments/" + profile1Comment1.getId()).delete(ClientResponse.class);
-        assertEquals(200, response.getStatus());
-
-        comments = this.getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile1/comments/")).get(COMMENT_LIST_GENERICTYPE);
-        assertEquals(1, comments.size());
-
-        response = getAuthenticatedResource(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile1/comments/" + profile1Comment2.getId()).delete(ClientResponse.class);
-        assertEquals(200, response.getStatus());
-
-        comments = this.getAuthenticatedResource(getResource().path(
-                "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX
-                + "profile1/comments")).get(COMMENT_LIST_GENERICTYPE);
-        assertEquals(0, comments.size());
-    }
-
-    private FormDataMultiPart createFormData(Object content) {
-        return createFormData(content, "My Test");
-    }
-
-    private FormDataMultiPart createFormData(Object content, String description) {
-        FormDataMultiPart form = new FormDataMultiPart();
-        form.field(IComponentRegistryRestService.DATA_FORM_FIELD, content,
-                MediaType.APPLICATION_OCTET_STREAM_TYPE);
-        form.field(IComponentRegistryRestService.NAME_FORM_FIELD, "Test1");
-        form.field(IComponentRegistryRestService.DESCRIPTION_FORM_FIELD,
-                description);
-        form.field(IComponentRegistryRestService.DOMAIN_FORM_FIELD, "My domain");
-        form.field(IComponentRegistryRestService.GROUP_FORM_FIELD, "TestGroup");
-        return form;
-    }
+    public void testGetGroupComments() throws Exception {
+
+        System.out.println("test getGroupComments");
+
+        fillUpGroupA();
+        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");
+         
+          
+                // lists 
+        
+        List<Comment> response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(COMMENT_LIST_GENERICTYPE);        
+        assertEquals(1, response.size());
+        
+        
+    
+        ClientResponse clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+         clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+        // particular comments
+        
+       Comment responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1" + "/comments/1"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+      
+        assertEquals(1, Long.parseLong(responseComment.getId()));
+        
+        responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1" + "/comments/2"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+       
+        assertEquals(2, Long.parseLong(responseComment.getId()));
+        
+       responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1" + "/comments/3"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+        assertEquals(3, Long.parseLong(responseComment.getId()));
+        
+        responseComment = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1" + "/comments/4"))
+                .accept(MediaType.APPLICATION_XML)
+                .get(Comment.class);        
+        assertNotNull(responseComment);
+        assertEquals(4, Long.parseLong(responseComment.getId()));
+       
+        clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1/comments/6"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+         clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1/comments/5"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+    }
+
 }
