Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/CommentsDao.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/CommentsDao.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/CommentsDao.java	(revision 1640)
@@ -69,5 +69,5 @@
      */
     public List<Comment> getCommentsFromProfile(String profileId) throws DataAccessException {
-        return getList(SELECT_BASE + " WHERE profile_description_id = ?", profileId);
+        return getList((SELECT_BASE + " WHERE profile_description_id = ?").concat(getOrderByDate()), profileId);
     }
 
@@ -79,5 +79,4 @@
      */
     public Comment getSpecifiedCommentFromProfile(String commentId) throws DataAccessException {
-        //String select = SELECT_BASE + " WHERE " + COLUMN_ID + " = ?";
         return getFirstOrNull(SELECT_BASE + " WHERE " + COLUMN_ID + " = ?", Integer.parseInt(commentId));
     }
@@ -90,5 +89,5 @@
      */
     public List<Comment> getCommentsFromComponent(String componentId) throws DataAccessException {
-        return getList(SELECT_BASE + " WHERE component_description_id = ?", componentId);
+        return getList((SELECT_BASE + " WHERE component_description_id = ?").concat(getOrderByDate()), componentId);
     }
 
@@ -134,9 +133,7 @@
      * @throws DataAccessException
      */
-    public Number insertComment(Comment comment, String content, Number userId) throws DataAccessException {
+    public Number insertComment(Comment comment, Number userId) throws DataAccessException {
         TransactionStatus transaction = getTransaction();
         try {
-            SimpleJdbcInsert insert = new SimpleJdbcInsert(getDataSource()).withTableName(TABLE_COMMENTS).usingGeneratedKeyColumns(
-                    COLUMN_ID);
             SimpleJdbcInsert insertComment = new SimpleJdbcInsert(getDataSource()).withTableName(getTableName()).usingGeneratedKeyColumns(COLUMN_ID);
             Map<String, Object> params = new HashMap<String, Object>();
@@ -241,3 +238,11 @@
         return getFirstOrNull(SELECT_BASE + " WHERE comments = ?", aComment);
     }
+    
+    /**
+     * Sort the returned comments per date from the most recent to the oldest
+     * @return 
+     */
+        private String getOrderByDate() {
+	return " order by comment_date asc ";
+    }
 }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 1640)
@@ -233,19 +233,11 @@
     public int registerComment(Comment comment, String userId) {
         try {
-            String xml = commmentSpecToString(comment);
             // Convert principal name to user record id
             Number uid = convertUserIdInComment(comment, userId);
-            //Number uid = Integer.parseInt(userId.toString());
-            commentsDao.insertComment(comment, xml, uid);
+            commentsDao.insertComment(comment, uid);
             return 0;
         } catch (DataAccessException ex) {
             LOG.error("Database error while registering component", ex);
             return -1;
-        } catch (JAXBException ex) {
-            LOG.error("Error while registering component", ex);
-            return -2;
-        } catch (UnsupportedEncodingException ex) {
-            LOG.error("Error while registering component", ex);
-            return -3;
         }
     }
@@ -492,11 +484,4 @@
     }
 
-    private String commmentSpecToString(Comment spec) throws UnsupportedEncodingException, JAXBException {
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        MDMarshaller.marshal(spec, os);
-        String xml = os.toString("UTF-8");
-        return xml;
-    }
-
     private CMDComponentSpec getUncachedMDComponent(String id, AbstractDescriptionDao dao) {
         String xml = dao.getContent(false, id);
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/CommentResponse.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/CommentResponse.java	(revision 1640)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/CommentResponse.java	(revision 1640)
@@ -0,0 +1,27 @@
+package clarin.cmdi.componentregistry.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlRootElement(name = "commentResponse")
+
+public class CommentResponse extends ComponentRegistryResponse {
+
+    @XmlElement
+    private Comment comment;
+
+    public void setComment(Comment comment) {
+        this.comment = comment;
+    }
+
+    public Comment getComment() {
+        return comment;
+    }
+}
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/ComponentRegistryResponse.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/ComponentRegistryResponse.java	(revision 1640)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/ComponentRegistryResponse.java	(revision 1640)
@@ -0,0 +1,64 @@
+package clarin.cmdi.componentregistry.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ *
+ * @author jeafer
+ */
+@XmlRootElement(name = "response")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlSeeAlso({RegisterResponse.class, CommentResponse.class})
+public class ComponentRegistryResponse {
+
+    @XmlAttribute(required = true)
+    private Boolean registered;
+    
+    @XmlAttribute(required = true)
+    private Boolean isInUserSpace;
+    
+    @XmlElementWrapper(name = "errors", required = false)
+    @XmlElements(
+    @XmlElement(name = "error", type = String.class))
+    private List<String> errors = new ArrayList<String>();
+
+    public ComponentRegistryResponse() {
+    }
+
+    public void addError(String error) {
+        getErrors().add(error);
+    }
+
+    public List<String> getErrors() {
+        return errors;
+    }
+
+    public boolean isRegistered() {
+        return registered;
+    }
+
+    public void setErrors(List<String> errors) {
+        this.errors = errors;
+    }
+
+    public void setRegistered(boolean registered) {
+        this.registered = registered;
+    }
+
+    public void setIsInUserSpace(Boolean isInUserSpace) {
+        this.isInUserSpace = isInUserSpace;
+    }
+
+    public Boolean isInUserSpace() {
+        return isInUserSpace;
+    }
+}
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/RegisterResponse.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/RegisterResponse.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/RegisterResponse.java	(revision 1640)
@@ -1,6 +1,3 @@
 package clarin.cmdi.componentregistry.model;
-
-import java.util.ArrayList;
-import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -8,6 +5,4 @@
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -15,56 +10,14 @@
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlRootElement(name = "registerResponse")
-public class RegisterResponse {
-
-    @XmlAttribute(required = true)
-    private Boolean isInUserSpace;
+public class RegisterResponse extends ComponentRegistryResponse {
 
     @XmlAttribute(required = true)
     private Boolean isProfile;
 
-    @XmlAttribute(required = true)
-    private Boolean registered;
-
-
-    @XmlElementWrapper(name = "errors", required = false)
-    @XmlElements(@XmlElement(name = "error", type = String.class))
-    private List<String> errors = new ArrayList<String>();
-
     @XmlElement
     private AbstractDescription description;
-    @XmlElement
-    private Comment comment;
-
-
-    public void setRegistered(boolean registered) {
-        this.registered = registered;
-    }
-
-    public boolean isRegistered() {
-        return registered;
-    }
-
-    public void setErrors(List<String> errors) {
-        this.errors = errors;
-    }
-
-    public List<String> getErrors() {
-        return errors;
-    }
-
-    public void addError(String error) {
-        getErrors().add(error);
-    }
 
     public void setDescription(AbstractDescription description) {
         this.description = description;
-    }
-    
-    public void setComment(Comment comment) {
-        this.comment = comment;
-    }
-    
-    public Comment getComment() {
-        return comment;
     }
 
@@ -80,12 +33,4 @@
         this.isProfile = isProfile;
     }
-
-    public void setIsInUserSpace(Boolean isInUserSpace) {
-        this.isInUserSpace = isInUserSpace;
-    }
-
-    public Boolean isInUserSpace() {
-        return isInUserSpace;
-    }
     
 }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/CommentValidator.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/CommentValidator.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/CommentValidator.java	(revision 1640)
@@ -1,5 +1,4 @@
 package clarin.cmdi.componentregistry.rest;
 
-import clarin.cmdi.componentregistry.ComponentRegistry;
 import clarin.cmdi.componentregistry.ComponentRegistryException;
 import clarin.cmdi.componentregistry.MDMarshaller;
@@ -20,5 +19,4 @@
 class CommentValidator implements Validator {
 
-    static final String MISMATCH_ERROR = "Cannot register component as a profile or vica versa.";
     static final String COMMENT_NOT_REGISTERED_ERROR = "referenced comment is not registered or does not have a correct commentId: ";
     static final String PARSE_ERROR = "Error in validation input file. Error is: ";
@@ -36,5 +34,5 @@
      * @param description use to validate the comment with the appropriate description (profile or a component)
      */
-    public CommentValidator(InputStream input, ComponentRegistry registry, ComponentRegistry userRegistry, AbstractDescription description) {
+    public CommentValidator(InputStream input, AbstractDescription description) {
         this.input = input;
         this.description = description;
@@ -68,13 +66,13 @@
      */
     private void validateComment(Comment comment) throws ComponentRegistryException {
-        if (comment.getComment() == null) {
+        if (comment.getComment() == null | comment.getComment().isEmpty()) {
             errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "comment has to be filled in");
         }
         if (description.isProfile()) {
-            if (comment.getProfileDescriptionId() == null) {
+            if (comment.getProfileDescriptionId() == null | comment.getProfileDescriptionId().isEmpty()) {
                 errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "profileId could not be found");
             }
         } else {
-            if (comment.getComponentDescriptionId() == null) {
+            if (comment.getComponentDescriptionId() == null | comment.getComponentDescriptionId().isEmpty()) {
                 errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "componentId could not be found");
             }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 1640)
@@ -44,4 +44,5 @@
 import clarin.cmdi.componentregistry.model.ComponentDescription;
 import clarin.cmdi.componentregistry.model.ProfileDescription;
+import clarin.cmdi.componentregistry.model.CommentResponse;
 import clarin.cmdi.componentregistry.model.RegisterResponse;
 
@@ -654,8 +655,6 @@
         Comment com = createNewComment();
         com.setComponentDescriptionId("componentId");
-        //com.setUserId(userCredentials.getPrincipalName()); // Hash used to be created here, now Id is constructed by impl
-        //com.setComment(comment);
         LOG.info("Trying to register Comment: " + com);
-        return registerComment(input, registry, userspace, description, principal, new NewAction());
+        return registerComment(input, registry, userspace, description, principal);
     }
 
@@ -670,10 +669,6 @@
         ComponentRegistry registry = getRegistry(userspace, userCredentials);
         AbstractDescription description = registry.getProfileDescription(profileId);
-        //Comment com = createNewComment(); 
-        //com.setProfileDescriptionId("profileId");
-        //com.setUserId(userCredentials.getPrincipalName()); // Hash used to be created here, now Id is constructed by impl
-        //com.setComment(comment);
         LOG.info("Trying to register Comment: ");
-        return registerComment(input, registry, userspace, description, principal, new NewAction());
+        return registerComment(input, registry, userspace, description, principal);
     }
 
@@ -728,15 +723,14 @@
 
     private Response registerComment(InputStream input, ComponentRegistry registry, boolean userspace,
-            AbstractDescription description, Principal principal,
-            RegisterAction action) {
-        try {
-            CommentValidator validator = new CommentValidator(input, registry, getRegistry(true), description);
-            RegisterResponse response = new RegisterResponse();
+            AbstractDescription description, Principal principal) {
+        try {
+            CommentValidator validator = new CommentValidator(input, description);
+            CommentResponse response = new CommentResponse();
             response.setIsInUserSpace(userspace);
-            validate(response, validator);
+            validateComment(response, validator);
             if (response.getErrors().isEmpty()) {
                 Comment com = validator.getCommentSpec();
-               int returnCode = action.executeComment(com, response, registry, principal.getName());
-              // registry.registerComment(com, principal.getName());
+               //int returnCode = action.executeComment(com, response, registry, principal.getName());
+              int returnCode =  registry.registerComment(com, principal.getName());
                 if (returnCode == 0) {
                     response.setRegistered(true);
@@ -791,4 +785,14 @@
         }
     }
+    
+        private void validateComment(CommentResponse response, Validator... validators) {
+        for (Validator validator : validators) {
+            if (!validator.validate()) {
+                for (String error : validator.getErrorMessages()) {
+                    response.addError(error);
+                }
+            }
+        }
+    }
 
     /**
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/NewAction.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/NewAction.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/NewAction.java	(revision 1640)
@@ -4,5 +4,4 @@
 import clarin.cmdi.componentregistry.components.CMDComponentSpec;
 import clarin.cmdi.componentregistry.model.AbstractDescription;
-import clarin.cmdi.componentregistry.model.Comment;
 import clarin.cmdi.componentregistry.model.RegisterResponse;
 
@@ -13,9 +12,3 @@
         return registry.register(desc, spec);
     }
-
-    @Override
-    public int executeComment(Comment com, RegisterResponse response, ComponentRegistry registry, String userId) {
-        return registry.registerComment(com, userId);
-    }
-
 }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/PublishAction.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/PublishAction.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/PublishAction.java	(revision 1640)
@@ -1,5 +1,4 @@
 package clarin.cmdi.componentregistry.rest;
 
-import clarin.cmdi.componentregistry.model.Comment;
 import java.security.Principal;
 
@@ -22,9 +21,3 @@
         return registry.publish(desc, spec, principal);
     }
-
-    @Override
-    public int executeComment(Comment com, RegisterResponse response, ComponentRegistry registry, String userId) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
 }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/RegisterAction.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/RegisterAction.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/RegisterAction.java	(revision 1640)
@@ -4,5 +4,4 @@
 import clarin.cmdi.componentregistry.components.CMDComponentSpec;
 import clarin.cmdi.componentregistry.model.AbstractDescription;
-import clarin.cmdi.componentregistry.model.Comment;
 import clarin.cmdi.componentregistry.model.RegisterResponse;
 
@@ -11,5 +10,3 @@
     int execute(AbstractDescription desc, CMDComponentSpec spec, RegisterResponse response, ComponentRegistry registry);
 
-    int executeComment(Comment com, RegisterResponse response, ComponentRegistry registry, String userId);
-
 }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/UpdateAction.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/UpdateAction.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/UpdateAction.java	(revision 1640)
@@ -1,5 +1,4 @@
 package clarin.cmdi.componentregistry.rest;
 
-import clarin.cmdi.componentregistry.model.Comment;
 import java.security.Principal;
 
@@ -22,8 +21,3 @@
     }
 
-    @Override
-    public int executeComment(Comment com, RegisterResponse response, ComponentRegistry registry, String userId) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
 }
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/CommentsDaoTest.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/CommentsDaoTest.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/CommentsDaoTest.java	(revision 1640)
@@ -44,7 +44,6 @@
         Comment comment = createTestComment();
 
-        String testComment = comment.getComment();
         assertEquals(0, commentsDao.getAllComments().size());
-        Number newId = commentsDao.insertComment(comment, testComment, Integer.parseInt(TEST_COMMENT_USER_ID));
+        Number newId = commentsDao.insertComment(comment, Integer.parseInt(TEST_COMMENT_USER_ID));
         assertNotNull(newId);
       
@@ -81,6 +80,5 @@
     public void testGetComment() {
         Comment comment = createTestComment();
-        String testComment = comment.getComment();
-        commentsDao.insertComment(comment, testComment, 8);
+        commentsDao.insertComment(comment, 8);
 
         assertNotNull(commentsDao.getByComment(TEST_COMMENT_NAME));
@@ -101,8 +99,7 @@
     public void testSetDelete(){
         Comment comment = createTestComment();
-        String testComment = comment.getComment();
         int count = commentsDao.getAllComments().size();
         
-        commentsDao.insertComment(comment, testComment, 8);
+        commentsDao.insertComment(comment, 8);
 	assertEquals(count + 1, commentsDao.getAllComments().size());
 
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/CommentResponseTest.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/CommentResponseTest.java	(revision 1640)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/CommentResponseTest.java	(revision 1640)
@@ -0,0 +1,87 @@
+package clarin.cmdi.componentregistry.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import clarin.cmdi.componentregistry.MDMarshaller;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import org.junit.Test;
+
+/**
+ *
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
+ */
+public class CommentResponseTest {
+    
+    /**
+     * Test with no validate attribute should return errors 
+     * @throws Exception 
+     */
+    @Test
+    public void testRegisterError() throws Exception {
+        CommentResponse resp = new CommentResponse();
+        resp.setRegistered(false);
+        resp.setIsInUserSpace(true);
+        resp.addError("Error 1");
+        resp.addError("Error 2, <!-- to be escaped -->");
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        MDMarshaller.marshal(resp, out);
+        String expected = "";
+        expected += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        expected += "<commentResponse isInUserSpace=\"true\" registered=\"false\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        expected += "    <errors>\n";
+        expected += "        <error>Error 1</error>\n";
+        expected += "        <error>Error 2, &lt;!-- to be escaped --&gt;</error>\n";
+        expected += "    </errors>\n";
+        expected += "</commentResponse>\n";
+        assertEquals(expected, out.toString());
+
+        CommentResponse rr = MDMarshaller.unmarshal(CommentResponse.class, new ByteArrayInputStream(expected.getBytes()), null);
+        assertFalse(rr.isRegistered());
+        assertEquals(2, rr.getErrors().size());
+    }
+    
+    
+    /**
+     * Test successfully processed
+     * @throws Exception 
+     */
+    @Test
+    public void testRegisterSucces() throws Exception {
+        CommentResponse resp = new CommentResponse();
+        resp.setRegistered(true);
+        resp.setIsInUserSpace(false);
+        resp.setComment(getComment());
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        MDMarshaller.marshal(resp, out);
+        String expected = "";
+        expected += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        expected += "<commentResponse isInUserSpace=\"false\" registered=\"true\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        expected += "    <errors/>\n";
+        expected += "    <comment>\n";       
+        expected += "        <comments>Name</comments>\n";
+        expected += "        <commentDate>myDate</commentDate>\n";
+        expected += "        <profileDescriptionId>myD</profileDescriptionId>\n";       
+        expected += "        <userId>myU</userId>\n";
+        expected += "        <id>myId</id>\n";
+	expected += "    </comment>\n";
+        expected += "</commentResponse>\n";
+        assertEquals(expected, out.toString());
+
+        CommentResponse rr = MDMarshaller.unmarshal(CommentResponse.class, new ByteArrayInputStream(expected.getBytes()), null);
+        assertTrue(rr.isRegistered());
+        assertEquals("myId", rr.getComment().getId());
+    }
+    
+        private Comment getComment() {
+        Comment com = new Comment();
+        com.setComment("Name");
+        com.setId("myId");
+        com.setUserId("myU");
+        com.setProfileDescriptionId("myD");
+        com.setCommentDate("myDate");
+        return com;
+    }
+}
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/RegisterResponseTest.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/RegisterResponseTest.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/model/RegisterResponseTest.java	(revision 1640)
@@ -26,5 +26,5 @@
         String expected = "";
         expected += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
-        expected += "<registerResponse registered=\"false\" isProfile=\"true\" isInUserSpace=\"true\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        expected += "<registerResponse isProfile=\"true\" isInUserSpace=\"true\" registered=\"false\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
         expected += "    <errors>\n";
         expected += "        <error>Error 1</error>\n";
@@ -51,5 +51,5 @@
         String expected = "";
         expected += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
-        expected += "<registerResponse registered=\"true\" isProfile=\"true\" isInUserSpace=\"false\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        expected += "<registerResponse isProfile=\"true\" isInUserSpace=\"false\" registered=\"true\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
         expected += "    <errors/>\n";
         expected += "    <description xsi:type=\"profileDescription\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
@@ -82,5 +82,5 @@
         String expected = "";
         expected += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
-        expected += "<registerResponse registered=\"true\" isProfile=\"false\" isInUserSpace=\"true\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        expected += "<registerResponse isProfile=\"false\" isInUserSpace=\"true\" registered=\"true\" xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
         expected += "    <errors/>\n";
         expected += "    <description xsi:type=\"componentDescription\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/CommentValidatorTest.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/CommentValidatorTest.java	(revision 1640)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/CommentValidatorTest.java	(revision 1640)
@@ -0,0 +1,169 @@
+package clarin.cmdi.componentregistry.rest;
+
+import clarin.cmdi.componentregistry.ComponentRegistry;
+import clarin.cmdi.componentregistry.ComponentRegistryFactory;
+import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase;
+import clarin.cmdi.componentregistry.model.AbstractDescription;
+
+import clarin.cmdi.componentregistry.model.ComponentDescription;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import clarin.cmdi.componentregistry.model.ProfileDescription;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Test class for CommentValidator
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"/applicationContext.xml"})
+public class CommentValidatorTest {
+
+    @Autowired
+    private ComponentRegistryFactory componentRegistryFactory;
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
+    private ComponentRegistry publicRegistry;
+
+    @Before
+    public void init() {
+        ComponentRegistryTestDatabase.resetAndCreateAllTables(jdbcTemplate);
+        publicRegistry = componentRegistryFactory.getPublicRegistry();
+    }
+
+    /**
+     * Fully successfull comment validation
+     */
+    @Test
+    public void testValidateSucces() {
+        AbstractDescription description = ProfileDescription.createNewDescription();
+        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>myCom</comments>\n";
+        comContent += "    <commentDate></commentDate>\n";
+        comContent += "     <profileDescriptionId>" + description.getId() + "</profileDescriptionId>";
+        comContent += "    <userId>0</userId>\n";
+        comContent += "    <id>1</id>\n";
+        comContent += "</comment>\n";
+        InputStream input = new ByteArrayInputStream(comContent.getBytes());
+        CommentValidator validator = new CommentValidator(input, description);
+        assertTrue(validator.validate());
+    }
+
+    /**
+     * Test the validation of comment with componentID
+     */
+    @Test
+    public void testValidateComponent() {
+        AbstractDescription desc = ComponentDescription.createNewDescription();
+        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>myCom</comments>\n";
+        comContent += "    <commentDate></commentDate>\n";
+        comContent += "     <componentDescriptionId></componentDescriptionId>";
+        comContent += "    <userId>0</userId>\n";
+        comContent += "    <id>1</id>\n";
+        comContent += "</comment>\n";
+        InputStream input = new ByteArrayInputStream(comContent.getBytes());
+        CommentValidator validator = new CommentValidator(input, desc);
+        assertFalse(validator.validate());// missing componentId will return an error
+        assertEquals(validator.getErrorMessages().size(), 1);
+        assertTrue(validator.getErrorMessages().get(0).startsWith(CommentValidator.ILLEGAL_ATTRIBUTE_NAME_ERROR));
+
+        String commentContent = "";
+        commentContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        commentContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        commentContent += "    <comments>myCom</comments>\n";
+        commentContent += "    <commentDate></commentDate>\n";
+        commentContent += "     <componentDescriptionId>" + desc.getId() + "</componentDescriptionId>";
+        commentContent += "    <userId>0</userId>\n";
+        commentContent += "    <id>1</id>\n";
+        commentContent += "</comment>\n";
+        input = new ByteArrayInputStream(commentContent.getBytes());
+        validator = new CommentValidator(input, desc);
+        assertTrue(validator.validate()); // componentId valid, validation complete
+    }
+
+    /***
+     * Test the validation of comment with profileId
+     */
+    @Test
+    public void testValidateProfile() {
+        AbstractDescription desc = ProfileDescription.createNewDescription();
+        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>myCom</comments>\n";
+        comContent += "    <commentDate></commentDate>\n";
+        comContent += "     <profileDescriptionId></profileDescriptionId>";
+        comContent += "    <userId>0</userId>\n";
+        comContent += "    <id>1</id>\n";
+        comContent += "</comment>\n";
+        InputStream input = new ByteArrayInputStream(comContent.getBytes());
+        CommentValidator validator = new CommentValidator(input, desc);
+        assertFalse(validator.validate());// missing profileId will return an error
+        assertEquals(validator.getErrorMessages().size(), 1);
+        assertTrue(validator.getErrorMessages().get(0).startsWith(CommentValidator.ILLEGAL_ATTRIBUTE_NAME_ERROR));
+
+        String commentContent = "";
+        commentContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        commentContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        commentContent += "    <comments>myCom</comments>\n";
+        commentContent += "    <commentDate></commentDate>\n";
+        commentContent += "     <profileDescriptionId>" + desc.getId() + "</profileDescriptionId>";
+        commentContent += "    <userId>0</userId>\n";
+        commentContent += "    <id>1</id>\n";
+        commentContent += "</comment>\n";
+        input = new ByteArrayInputStream(commentContent.getBytes());
+        validator = new CommentValidator(input, desc);
+        assertTrue(validator.validate()); // profileId valid, validation complete
+    }
+
+    /**
+     * Test the validation of comment with content comments
+     * @throws Exception 
+     */
+    @Test
+    public void testValidateNoCommentContent() throws Exception {
+        AbstractDescription desc = ProfileDescription.createNewDescription();
+        String commentContent = "";
+        commentContent += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
+        commentContent += "<comment xmlns:ns2=\"http://www.w3.org/1999/xlink\">\n";
+        commentContent += "    <comments></comments>\n";
+        commentContent += "    <commentDate></commentDate>\n";
+        commentContent += "     <profileDescriptionId>" + desc.getId() + "</profileDescriptionId>";
+        commentContent += "    <userId>0</userId>\n";
+        commentContent += "    <id>1</id>\n";
+        commentContent += "</comment>\n";
+        InputStream input = new ByteArrayInputStream(commentContent.getBytes());
+        CommentValidator validator = new CommentValidator(input, desc);
+        assertFalse(validator.validate()); // missing content will return an error
+        assertTrue(validator.getErrorMessages().get(0).startsWith(CommentValidator.ILLEGAL_ATTRIBUTE_NAME_ERROR));
+
+        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>myCom</comments>\n";
+        comContent += "    <commentDate></commentDate>\n";
+        comContent += "     <profileDescriptionId>"+ desc.getId() +"</profileDescriptionId>";
+        comContent += "    <userId>0</userId>\n";
+        comContent += "    <id>1</id>\n";
+        comContent += "</comment>\n";
+        input = new ByteArrayInputStream(comContent.getBytes());
+        validator = new CommentValidator(input, desc);
+        assertTrue(validator.validate());// content comments is fill in, validation complete
+        
+    }
+}
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTest.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTest.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTest.java	(revision 1640)
@@ -32,4 +32,5 @@
 import clarin.cmdi.componentregistry.model.ComponentDescription;
 import clarin.cmdi.componentregistry.model.ProfileDescription;
+import clarin.cmdi.componentregistry.model.CommentResponse;
 import clarin.cmdi.componentregistry.model.RegisterResponse;
 
@@ -152,7 +153,7 @@
                 COMMENT_LIST_GENERICTYPE);
         assertEquals(3, response.size());
-        assertEquals("comment2", response.get(0).getComment());
+        assertEquals("COMMENT1", response.get(0).getComment());
         assertEquals("comment1", response.get(1).getComment());
-        assertEquals("COMMENT1", response.get(2).getComment());
+        assertEquals("comment2", response.get(2).getComment());
     }
 
@@ -167,7 +168,7 @@
                 COMMENT_LIST_GENERICTYPE);
         assertEquals(3, response.size());
-        assertEquals("comment3", response.get(0).getComment());
+        assertEquals("COMMENT2", response.get(0).getComment());
         assertEquals("comment4", response.get(1).getComment());
-        assertEquals("COMMENT2", response.get(2).getComment());
+        assertEquals("comment3", response.get(2).getComment());
     }
 
@@ -852,6 +853,6 @@
                 MediaType.APPLICATION_OCTET_STREAM_TYPE);
         fillUp();
-        RegisterResponse response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile1/comments").type(MediaType.MULTIPART_FORM_DATA).post(
-                RegisterResponse.class, form);
+        CommentResponse response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile1/comments").type(MediaType.MULTIPART_FORM_DATA).post(
+                CommentResponse.class, form);
         assertTrue(response.isRegistered());
         assertFalse(response.isInUserSpace());
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/MDValidatorTest.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/MDValidatorTest.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/MDValidatorTest.java	(revision 1640)
@@ -140,4 +140,5 @@
 	profileContent += "</CMD_ComponentSpec>\n";
 
+        // Ids not registered will return two errors. One for each id
 	ProfileDescription desc = ProfileDescription.createNewDescription();
 	MDValidator validator = new MDValidator(new ByteArrayInputStream(profileContent.getBytes()), desc, publicRegistry, null, publicRegistry);
@@ -147,4 +148,5 @@
 	assertTrue(validator.getErrorMessages().get(1).startsWith(MDValidator.COMPONENT_NOT_PUBLICLY_REGISTERED_ERROR));
 
+        // id1 will be added and therefore only id2 is not registered
 	RegistryTestHelper.addComponent(publicRegistry, id1);
 	validator = new MDValidator(new ByteArrayInputStream(profileContent.getBytes()), desc, publicRegistry, null, publicRegistry);
@@ -153,4 +155,5 @@
 	assertTrue(validator.getErrorMessages().get(0).startsWith(MDValidator.COMPONENT_NOT_PUBLICLY_REGISTERED_ERROR));
 
+        // id2 is added, no more errors shoud be return
 	RegistryTestHelper.addComponent(publicRegistry, id2);
 	validator = new MDValidator(new ByteArrayInputStream(profileContent.getBytes()), desc, publicRegistry, null, publicRegistry);
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 1639)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 1640)
@@ -15,10 +15,7 @@
 import clarin.cmdi.componentregistry.MDMarshaller;
 import clarin.cmdi.componentregistry.components.CMDComponentSpec;
-import clarin.cmdi.componentregistry.impl.database.UserDao;
 import clarin.cmdi.componentregistry.model.Comment;
 import clarin.cmdi.componentregistry.model.ComponentDescription;
 import clarin.cmdi.componentregistry.model.ProfileDescription;
-import clarin.cmdi.componentregistry.model.UserMapping.User;
-import java.security.Principal;
 
 /**
