Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java	(revision 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java	(revision 1639)
@@ -32,7 +32,4 @@
      */
     List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException;
-
-    
-    //List<Comment> getComments() throws ComponentRegistryException;
     
     /**
@@ -48,5 +45,4 @@
 
     CMDComponentSpec getMDComponent(String id) throws ComponentRegistryException;
-    //CMDComponentSpec getMDComment(String id) throws ComponentRegistryException;
 
     /**
@@ -56,6 +52,10 @@
     int register(AbstractDescription desc, CMDComponentSpec spec);
 
-    
-    int registerComment(Comment comment, Comment spec);
+    /**
+     * 
+     * @param comment
+     * @return -1 if comment could not be registered
+     */
+    int registerComment(Comment comment, String userId);
     /**
      * 
@@ -105,6 +105,4 @@
 	    DeleteFailedException;
 
-    
-    //void deleteMDComment(String commentId, Principal principal)throws IOException, UserUnauthorizedException, ComponentRegistryException, DeleteFailedException;
     /**
      * 
@@ -147,13 +145,45 @@
     
     
+    /**
+     * 
+     * @param profileId
+     * @return List of comments fro a specific profile
+     * @throws ComponentRegistryException 
+     */
     List<Comment> getCommentsInProfile(String profileId) throws ComponentRegistryException;
     
-    
-    
+    /**
+     * 
+     * @param commentId
+     * @return a specific comment from a profile
+     * @throws ComponentRegistryException 
+     */
     Comment getSpecifiedCommentInProfile(String commentId) throws ComponentRegistryException;
     
+    /**
+     * 
+     * @param componentId
+     * @return List of comments from a specific component
+     * @throws ComponentRegistryException 
+     */
     List<Comment> getCommentsInComponent(String componentId) throws ComponentRegistryException;
+    
+    /**
+     * 
+     * @param commentId
+     * @return a specific comment from a component
+     * @throws ComponentRegistryException 
+     */
     Comment getSpecifiedCommentInComponent(String commentId) throws ComponentRegistryException;
 
+    /**
+     * 
+     * @param commentId
+     * @param principal
+     * @throws IOException
+     * @throws ComponentRegistryException
+     * @throws UserUnauthorizedException
+     * @throws DeleteFailedException 
+     */
     public void deleteComment(String commentId, Principal principal)throws IOException,  ComponentRegistryException, UserUnauthorizedException,
 	    DeleteFailedException;;
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/ComponentRegistryImplBase.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/ComponentRegistryImplBase.java	(revision 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/ComponentRegistryImplBase.java	(revision 1639)
@@ -56,17 +56,4 @@
         return result;
     }
-
-//    public List<Comment> getUsageInComments(String componentId) throws ComponentRegistryException {
-//        List<Comment> result = new ArrayList<Comment>();
-//        for (Comment comment : getComments()) {
-//            CMDComponentSpec myComment = getMDComment(comment.getId());
-//            if (myComment != null && findComponentId(componentId, myComment.getCMDComponent())) {
-//            result.add(comment);
-//            System.out.println("get unsage in comments : " + myComment + "\n");
-//            }
-//        }
-//        
-//        return result;
-//    }
 
     /**
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/CommentsDao.java	(revision 1639)
@@ -1,6 +1,2 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 package clarin.cmdi.componentregistry.impl.database;
 
@@ -12,5 +8,4 @@
 import java.sql.Timestamp;
 import java.text.ParseException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -29,5 +24,5 @@
 /**
  *
- * @author jeafer
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
  */
 public class CommentsDao extends ComponentRegistryDao<Comment> {
@@ -45,4 +40,13 @@
     }
 
+    protected String getCMDIdColumn() {
+        return COLUMN_ID;
+    }
+
+    /**
+     * Get the list of all the comments available in the database
+     * The distinction between profile or component is not treated in this method
+     * @return list of Comments 
+     */
     public List<Comment> getAllComments() throws DataAccessException {
         return getList(SELECT_BASE);
@@ -50,5 +54,5 @@
 
     /**
-     *
+     * Look for a specified Comment through its id
      * @param id Database record id (key)
      * @return Comment, if it exists
@@ -60,7 +64,7 @@
 
     /**
-     * @param id Database record id (key)
-     * Method to retrieve comments from profiles
-     * @return  Comments, comments_date, user_id and id
+     * Retrieve the comments related to a certain profile
+     * @param id Database record id (fkey)
+     * @return list of Comments
      */
     public List<Comment> getCommentsFromProfile(String profileId) throws DataAccessException {
@@ -68,4 +72,10 @@
     }
 
+    /**
+     * Retrieve a specific comment related to a profile
+     * @param id Database record id (key)
+     * @return Comment
+     * @throws DataAccessException 
+     */
     public Comment getSpecifiedCommentFromProfile(String commentId) throws DataAccessException {
         //String select = SELECT_BASE + " WHERE " + COLUMN_ID + " = ?";
@@ -74,19 +84,21 @@
 
     /**
-     * @param id Database record id (key)
-     * Method to retrieve comments from components
-     * @return  Comments, comments_date, user_id and id
-     */
-    public Comment getSpecifiedCommentFromComponent(String commentId) throws DataAccessException {
-        //String select = SELECT_BASE + " WHERE " + COLUMN_ID + " =  ?";
-        return getFirstOrNull(SELECT_BASE + " WHERE " + COLUMN_ID + " =  ?", Integer.parseInt(commentId));
-    }
-
+     * Retrieve the comments related to a certain component
+     * @param id Database record id (fkey)
+     * @return list of Comments
+     * @throws DataAccessException 
+     */
     public List<Comment> getCommentsFromComponent(String componentId) throws DataAccessException {
         return getList(SELECT_BASE + " WHERE component_description_id = ?", componentId);
     }
 
-    public Comment getByComment(String aComment) throws DataAccessException {
-        return getFirstOrNull(SELECT_BASE + " WHERE comments = ?", aComment);
+    /**
+     * Retrieve a specific comment related to a component
+     * @param id Database record id (key)
+     * @return Comment
+     * @throws DataAccessException 
+     */
+    public Comment getSpecifiedCommentFromComponent(String commentId) throws DataAccessException {
+        return getFirstOrNull(SELECT_BASE + " WHERE " + COLUMN_ID + " =  ?", Integer.parseInt(commentId));
     }
 
@@ -105,5 +117,6 @@
         if (owner.isEmpty()) {
             return null;
-        } else {
+        }
+        {
             return owner.get(0);
         }
@@ -113,4 +126,9 @@
      *
      * @param comment
+     *              the comment to be inserted
+     * @param content
+     *              
+     * @param userId
+     *              the id of the user
      * @return Record id of the inserted comment
      * @throws DataAccessException
@@ -121,9 +139,7 @@
             SimpleJdbcInsert insert = new SimpleJdbcInsert(getDataSource()).withTableName(TABLE_COMMENTS).usingGeneratedKeyColumns(
                     COLUMN_ID);
-            //Number contentId = insert.executeAndReturnKey(Collections.singletonMap("content", (Object) content));
-
             SimpleJdbcInsert insertComment = new SimpleJdbcInsert(getDataSource()).withTableName(getTableName()).usingGeneratedKeyColumns(COLUMN_ID);
             Map<String, Object> params = new HashMap<String, Object>();
-            putInsertComment(params, comment, content, userId);
+            putInsertComment(params, comment, userId);
 
             Number id = insertComment.executeAndReturnKey(params);
@@ -136,12 +152,18 @@
     }
 
-    protected void putInsertComment(Map<String, Object> params, Comment comment, String contentId, Number userId) throws DataAccessException {
-        // SimpleJdbcInsert insert = new SimpleJdbcInsert(getDataSource()).withTableName(TABLE_COMMENTS).usingGeneratedKeyColumns(
-        //         COLUMN_ID);
+    /**
+     * 
+     * @param params
+     * @param comment
+     * @param contentId
+     * @param userId
+     * @throws DataAccessException 
+     */
+    protected void putInsertComment(Map<String, Object> params, Comment comment, Number userId) throws DataAccessException {
         params.put("comments", comment.getComment());
         params.put("comment_date", extractTimestamp(comment));
         params.put("component_description_id", comment.getComponentDescriptionId());
         params.put("profile_description_id", comment.getProfileDescriptionId());
-        params.put("user_id", comment.getUserId());
+        params.put("user_id", userId);
     }
 
@@ -165,29 +187,15 @@
         }
     };
-//    protected String getTableName() {
-//        throw new UnsupportedOperationException("Not supported yet.");
-//    }
-//
-//    
-//    protected String getCMDIdColumn() {
-//        throw new UnsupportedOperationException("Not supported yet.");
-//    }
-//
-//    String getContent(boolean b, String id) {
-//        throw new UnsupportedOperationException("Not yet implemented");
-//    }
-//
-//    boolean isPublic(String cmdId) {
-//        throw new UnsupportedOperationException("Not yet implemented");
-//    }
-//
-//    boolean isInUserSpace(String cmdId, Number userId) {
-//        throw new UnsupportedOperationException("Not yet implemented");
-//    }
-
-    public void deleteComment(Comment com, boolean isDeleted) throws DataAccessException {
+
+    /**
+     * Method that will delete a comment from the database based on its id
+     * @param com
+     *           comment to be deleted
+     * @throws DataAccessException 
+     */
+    public void deleteComment(Comment com) throws DataAccessException {
         TransactionStatus transaction = getTransaction();
-        Number dbId = getDbId(Integer.parseInt(com.getId()));
-        StringBuilder delete = new StringBuilder("DELETE ").append(getTableName());
+        Number dbId = Integer.parseInt(com.getId());
+        StringBuilder delete = new StringBuilder("DELETE FROM ").append(getTableName());
         delete.append(" WHERE " + COLUMN_ID + " = ?");
         getSimpleJdbcTemplate().update(delete.toString(), dbId);
@@ -195,36 +203,14 @@
     }
 
-    public Number getDbId(Number cmdId) {
+    /**
+     * Retrieve comment Id From a comment
+     * @param cmdId
+     * @return query for database access to id
+     */
+    public Number getDbId(String cmdId) {
         StringBuilder query = new StringBuilder("SELECT " + COLUMN_ID + " FROM ").append(getTableName());
-        query.append(" WHERE ").append(getDbId(cmdId)).append(" = ?");
+        query.append(" WHERE ").append(COLUMN_ID).append(" = ?");
         return getSimpleJdbcTemplate().queryForInt(query.toString(), cmdId);
     }
-//    public Comment getDbId(Number cmId) {
-//        return getFirstOrNull(getSelectStatement("WHERE id=?"), cmId);
-//    }
-//
-//    private StringBuilder getSelectStatement(String... where) throws DataAccessException {
-//        StringBuilder select = new StringBuilder("SELECT ").append(getCommentColumnList());
-//        select.append(" FROM ").append(getTableName());
-//        if (where.length > 0) {
-//            select.append(" ");
-//            for (String str : where) {
-//                select.append(" ").append(str);
-//            }
-//        }
-//        return select;
-//    }
-//
-//    protected StringBuilder getCommentColumnList() {
-//
-//        StringBuilder sb = new StringBuilder();
-//        sb.append(getOrderByColumn());
-//        sb.append(",comment,comment_date,user_id,");
-//        return sb;
-//    }
-//
-//    private String getOrderByColumn() {
-//        return "name";
-//    }
 
     private Timestamp extractTimestamp(Comment comment) {
@@ -245,3 +231,13 @@
         return txManager.getTransaction(txDefinition);
     }
+
+    /**
+     * Method use for tests that will select comments based on the content
+     * @param aComment
+     * @return list of Comments
+     * @throws DataAccessException 
+     */
+    public Comment getByComment(String aComment) throws DataAccessException {
+        return getFirstOrNull(SELECT_BASE + " WHERE comments = ?", aComment);
+    }
 }
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 1639)
@@ -61,5 +61,4 @@
     @Autowired
     private CommentsDao commentsDao;
-    //private CMDComponentSpecCache commentsCache;
 
     /**
@@ -230,11 +229,12 @@
         }
     }
-    
-    @Override
-    public int registerComment(Comment comment, Comment spec){
-        try {
-            String xml = commmentSpecToString(spec);
+
+    @Override
+    public int registerComment(Comment comment, String userId) {
+        try {
+            String xml = commmentSpecToString(comment);
             // Convert principal name to user record id
-            Number uid = convertUserIdInComment(comment);
+            Number uid = convertUserIdInComment(comment, userId);
+            //Number uid = Integer.parseInt(userId.toString());
             commentsDao.insertComment(comment, xml, uid);
             return 0;
@@ -276,9 +276,19 @@
         return uid;
     }
-    
-        private Number convertUserIdInComment(Comment comment) throws DataAccessException {
+
+    /**
+     * Calling service sets user id to principle. Our task is to convert this to
+     * an id for later reference. If none is set and this is a user's workspace,
+     * set from that user's id.
+     * 
+     * @param comment
+     *            Comment containing principle name as userId
+     * @return Id (from database)
+     * @throws DataAccessException
+     */
+    private Number convertUserIdInComment(Comment comment, String uId) throws DataAccessException {
         Number uid = null;
         if (comment.getUserId() != null) {
-            User user = userDao.getByPrincipalName(comment.getUserId());
+            User user = userDao.getByPrincipalName(uId);
             if (user != null) {
                 uid = user.getId();
@@ -449,5 +459,4 @@
         return description.isProfile() ? profileDescriptionDao : componentDescriptionDao;
     }
-    
 
     /**
@@ -476,18 +485,4 @@
     }
 
-        private Number getIdForCommentDescription(Comment comment) throws IllegalArgumentException {
-        Number dbId = null;
-        try {
-            dbId = commentsDao.getDbId(Integer.parseInt(comment.getId()));
-        } catch (DataAccessException ex) {
-            LOG.error("Error getting dbId for comment with id " + comment.getId(), ex);
-        }
-        if (dbId == null) {
-            throw new IllegalArgumentException("Could not get database Id for description");
-        } else {
-            return dbId;
-        }
-    }
-    
     private String componentSpecToString(CMDComponentSpec spec) throws UnsupportedEncodingException, JAXBException {
         ByteArrayOutputStream os = new ByteArrayOutputStream();
@@ -496,6 +491,6 @@
         return xml;
     }
-    
-        private String commmentSpecToString(Comment spec) throws UnsupportedEncodingException, JAXBException {
+
+    private String commmentSpecToString(Comment spec) throws UnsupportedEncodingException, JAXBException {
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         MDMarshaller.marshal(spec, os);
@@ -542,10 +537,10 @@
     }
 
-        private boolean isOwnerOfComment(Comment desc, String principalName) {
-        String owner = commentsDao.getOwnerPrincipalName(getIdForCommentDescription(desc));
+    private boolean isOwnerOfComment(Comment com, String principalName) {
+        String owner = commentsDao.getOwnerPrincipalName(Integer.parseInt(com.getId()));
         return owner != null // If owner is null, no one can be owner
                 && principalName.equals(owner);
     }
-    
+
     private void checkAge(AbstractDescription desc, Principal principal) throws DeleteFailedException {
         if (isPublic() && !configuration.isAdminUser(principal)) {
@@ -594,16 +589,15 @@
 
     @Override
-    public void deleteComment(String commentId, Principal principal) throws IOException, 
-    ComponentRegistryException, UserUnauthorizedException, DeleteFailedException {
-
-            Comment com = commentsDao.getById(commentId);        
-            if (com!= null) {
+    public void deleteComment(String commentId, Principal principal) throws IOException,
+            ComponentRegistryException, UserUnauthorizedException, DeleteFailedException {
+        Comment com = commentsDao.getById(commentId);
+        if (com != null) {
             try {
-                    checkAuthorisationComment(com, principal);
-                    commentsDao.deleteComment(com, true);
-                } catch (DataAccessException ex) {
-                    throw new DeleteFailedException("Database access error while trying to delete component", ex);
-                }
-            }
-        }
-    }
+                checkAuthorisationComment(com, principal);
+                commentsDao.deleteComment(com);
+            } catch (DataAccessException ex) {
+                throw new DeleteFailedException("Database access error while trying to delete component", ex);
+            }
+        }
+    }
+}
Index: /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/Comment.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/Comment.java	(revision 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/Comment.java	(revision 1639)
@@ -1,6 +1,2 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 package clarin.cmdi.componentregistry.model;
 
@@ -8,10 +4,7 @@
 import clarin.cmdi.componentregistry.IdSequence;
 import java.text.ParseException;
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import org.apache.commons.lang.time.DateFormatUtils;
@@ -20,93 +13,91 @@
 /**
  *
- * @author jeafer
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
  */
 @XmlRootElement(name = "comment")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class Comment {
-        @XmlElement(name = "Comment_Type")
-    protected List<Comment> commentType;
-        private String comments;
-        private String commentDate;
-        private String componentDescriptionId;
-        private String profileDescriptionId;
-        private String userId;
-        private String id;
 
-        
-        public List<Comment> getComments() {
-        if (commentType == null) {
-            commentType = new ArrayList<Comment>();
-        }
-        return this.commentType;
+    private String comments;
+    private String commentDate;
+    private String componentDescriptionId;
+    private String profileDescriptionId;
+    private String userId;
+    private String id;
+
+    public void setComment(String comment) {
+        this.comments = comment;
     }
-        
-        public void setComment(String comment) {
-            this.comments = comment;
-        }
 
-        public String getComment() {
-            return comments;
-        }
+    public String getComment() {
+        return comments;
+    }
 
-        public void setCommentDate(String commentDate) {
-            this.commentDate = commentDate;
-        }
+    public void setCommentDate(String commentDate) {
+        this.commentDate = commentDate;
+    }
 
-        public String getCommentDate() {
-            return commentDate;
-        }
+    public String getCommentDate() {
+        return commentDate;
+    }
 
-        public void setId(String commentId) {
-            this.id = commentId;
-        }
+    public void setId(String commentId) {
+        this.id = commentId;
+    }
 
-        public String getId() {
-            return id;
-        }
+    public String getId() {
+        return id;
+    }
 
-        public String getComponentDescriptionId() {
-            return componentDescriptionId;
-        }
+    public String getComponentDescriptionId() {
+        return componentDescriptionId;
+    }
 
-        public void setComponentDescriptionId(String ComponentDescriptionId) {
-            this.componentDescriptionId = ComponentDescriptionId;
-        }
+    public void setComponentDescriptionId(String ComponentDescriptionId) {
+        this.componentDescriptionId = ComponentDescriptionId;
+    }
 
-        public void setProfileDescriptionId(String profileDescriptionId) {
-            this.profileDescriptionId = profileDescriptionId;
-        }
+    public void setProfileDescriptionId(String profileDescriptionId) {
+        this.profileDescriptionId = profileDescriptionId;
+    }
 
-        public String getProfileDescriptionId() {
-            return profileDescriptionId;
-        }
+    public String getProfileDescriptionId() {
+        return profileDescriptionId;
+    }
 
-        public void setUserId(String userId) {
-            this.userId = userId;
-        }
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
 
-        public String getUserId() {
-            return userId;
-        }
+    public String getUserId() {
+        return userId;
+    }
 
-        public static String createNewDate() {
-            return createNewDate(new Date().getTime());
-        }
+    public static Date getDate(String registrationDate) throws ParseException {
+        return DateUtils.parseDate(registrationDate, new String[]{DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()});
+    }
 
-        public static Date getDate(String registrationDate) throws ParseException {
-            return DateUtils.parseDate(registrationDate, new String[]{DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()});
-        }
+    /*
+     * Helper method to set the Date
+     */
+    public static String createNewDate() {
+        return createNewDate(new Date().getTime());
+    }
+    
+    /*
+     * Helper method to set the Date in the same format
+     * @param time, long that contains the time to be set 
+     */
 
-        public static String createNewDate(long time) {
-            return DateFormatUtils.formatUTC(time, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern());
-        }
-        
-            public static Comment createANewComment() {
-	String descriptionId = ComponentRegistry.REGISTRY_ID+ "p_" + IdSequence.get();
-	Comment com = new Comment();
-        com.setComment("Actual");
-        com.setProfileDescriptionId(descriptionId);        
-	com.setCommentDate(createNewDate());
-	return com;
+    public static String createNewDate(long time) {
+        return DateFormatUtils.formatUTC(time, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern());
     }
+
+    public static Comment createANewComment() {
+        String Id = ComponentRegistry.REGISTRY_ID + IdSequence.get();
+        Comment com = new Comment();
+        com.setId(Id);
+        com.setCommentDate(createNewDate());
+        return com;
     }
+}
Index: mponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComValidator.java
===================================================================
--- /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComValidator.java	(revision 1638)
+++ 	(revision )
@@ -1,142 +1,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package clarin.cmdi.componentregistry.rest;
-
-import clarin.cmdi.componentregistry.ComponentRegistry;
-import clarin.cmdi.componentregistry.ComponentRegistryException;
-import clarin.cmdi.componentregistry.MDMarshaller;
-import clarin.cmdi.componentregistry.components.AttributeListType.Attribute;
-import clarin.cmdi.componentregistry.components.CMDComponentSpec;
-import clarin.cmdi.componentregistry.model.AbstractDescription;
-import clarin.cmdi.componentregistry.model.Comment;
-import clarin.cmdi.componentregistry.model.ComponentDescription;
-import clarin.cmdi.componentregistry.model.ProfileDescription;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import javax.xml.bind.JAXBException;
-
-/**
- *
- * @author jeafer
- */
-class ComValidator 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: ";
-    static final String COMMENT_NOT_PUBLICLY_REGISTERED_ERROR = "referenced comment cannot be found in the published comments: ";
-    static final String COMPONENT_REGISTRY_EXCEPTION_ERROR = "An exception occurred while accessing the component registry: ";
-    static final String ILLEGAL_ATTRIBUTE_NAME_ERROR = "Illegal attribute name: ";
-    static final Collection<String> ILLEGAL_ATTRIBUTE_NAMES = Collections.unmodifiableCollection(Arrays.asList("ref", "CommentId"));
-    private List<String> errorMessages = new ArrayList<String>();
-    private Comment spec = null;
-    private final InputStream input;
-    private final Comment comment;
-    private final ComponentRegistry registry;
-    private final ComponentRegistry userRegistry;
-    private final AbstractDescription descriptionId;
-
-    /**
-     * 
-     * @param input In order to validate the input is consumed. So use @see getCMDComponentSpec to get the parsed CMDComponentSpec.
-     * @param desc
-     * @param registry (registry you currently used) 
-     * @param userRegistry can be null, We get user registry as well so we can give nice error messages if needed. Can be the same as @param registry
-     */
-    public ComValidator(InputStream input, Comment comment, ComponentRegistry registry, ComponentRegistry userRegistry, AbstractDescription descriptionId) {
-        this.input = input;
-        this.comment = comment;
-        this.registry = registry;
-        this.userRegistry = userRegistry;
-        this.descriptionId = descriptionId;
-    }
-
-    @Override
-    public List<String> getErrorMessages() {
-        return errorMessages;
-    }
-
-    @Override
-    public boolean validate() {
-        try {
-            spec = MDMarshaller.unmarshal(Comment.class, input, null);
-        } catch (JAXBException e) {
-            errorMessages.add(PARSE_ERROR + e);
-        }
-        if (errorMessages.isEmpty()) {
-            try {
-                validateComment(spec.getComments());
-            } catch (ComponentRegistryException e) {
-                errorMessages.add(COMPONENT_REGISTRY_EXCEPTION_ERROR + e);
-            }
-        }
-        return errorMessages.isEmpty();
-    }
-
-    private void validateComment(List<Comment> comment) throws ComponentRegistryException {
-        for (Comment commentType : comment) {
-            validateDescribedComments(commentType);
-            validateComment(commentType.getComments());//Recursion
-        }
-    }
-
-    private void validateDescribedComments(Comment comment) throws ComponentRegistryException {
-        checkPublicComments(comment);
-        checkLegalAttributes(comment);
-    }
-
-    private void checkPublicComments(Comment comment) throws ComponentRegistryException {
-        if (isDefinedInSeparateFile(comment)) {
-            String id = comment.getId();
-            String profileId = comment.getProfileDescriptionId();
-            String componentId = comment.getComponentDescriptionId();
-            Comment registeredComment = null;
-            if (descriptionId.isProfile()) {
-                if (descriptionId != null) {
-                    registeredComment = registry.getSpecifiedCommentInProfile(profileId);
-                    if (registeredComment == null) {
-                        String error = comment.getId();
-                        errorMessages.add(COMMENT_NOT_PUBLICLY_REGISTERED_ERROR + error);
-                    }
-                }
-            } else { //User registry, can link to components from public registry and the user's registry
-                if (descriptionId != null) {
-                    registeredComment = registry.getSpecifiedCommentInComponent(componentId);
-                    if (registeredComment == null) {
-                        errorMessages.add(COMMENT_NOT_REGISTERED_ERROR + comment.getId());
-                    }
-
-                }
-            }
-        }
-    }
-
-    private boolean isDefinedInSeparateFile(Comment comment) {
-        return comment.getComment() == null;
-    }
-
-    private void checkLegalAttributes(Comment comment) {
-        if (comment.getComment() == null) {
-            errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "comment has to be filled in");
-        }
-        if (descriptionId.isProfile()) {
-            if (comment.getProfileDescriptionId() == null) {
-                errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "profileId could not be found");
-            }
-        } else {
-            if (comment.getComponentDescriptionId() == null) {
-                errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "componentId could not be found");
-            }
-        }
-    }
-    
-        public Comment getCommentSpec() {
-	return spec;
-    }
-}
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/CommentValidator.java	(revision 1639)
@@ -1,25 +1,44 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 package clarin.cmdi.componentregistry.rest;
 
+import clarin.cmdi.componentregistry.ComponentRegistry;
+import clarin.cmdi.componentregistry.ComponentRegistryException;
+import clarin.cmdi.componentregistry.MDMarshaller;
+import clarin.cmdi.componentregistry.model.AbstractDescription;
 import clarin.cmdi.componentregistry.model.Comment;
+import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
-import org.apache.commons.lang.StringUtils;
+import javax.xml.bind.JAXBException;
 
 /**
- *
- * @author jeafer
+ * Implementation of Validator
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
  */
-class CommentValidator implements Validator{
-    private final Comment com;
+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: ";
+    static final String COMMENT_NOT_PUBLICLY_REGISTERED_ERROR = "referenced comment cannot be found in the published comments: ";
+    static final String COMPONENT_REGISTRY_EXCEPTION_ERROR = "An exception occurred while accessing the component registry: ";
+    static final String ILLEGAL_ATTRIBUTE_NAME_ERROR = "Illegal attribute name: ";
+    static final Collection<String> ILLEGAL_ATTRIBUTE_NAMES = Collections.unmodifiableCollection(Arrays.asList("ref", "CommentId"));
     private List<String> errorMessages = new ArrayList<String>();
+    private Comment com = null;
+    private final InputStream input;
+    private final AbstractDescription description;
 
-    public CommentValidator(Comment com) {
-        this.com = com;
+    /*
+     * @param input In order to validate the input is consumed. So use @see getCommentSpec to get the parsed CommentSpec.
+     * @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) {
+        this.input = input;
+        this.description = description;
     }
-    
+
     @Override
     public List<String> getErrorMessages() {
@@ -29,17 +48,40 @@
     @Override
     public boolean validate() {
-        if (!isOk(com.getUserId(), com.getComment(), com.getCommentDate())) {
-            errorMessages.add("Fields are not filled in correctly");
+        try {
+            com = MDMarshaller.unmarshal(Comment.class, input, null);
+        } catch (JAXBException e) {
+            errorMessages.add(PARSE_ERROR + e);
+        }
+        if (errorMessages.isEmpty()) {
+            try {
+                validateComment(com);
+            } catch (ComponentRegistryException e) {
+                errorMessages.add(COMPONENT_REGISTRY_EXCEPTION_ERROR + e);
+            }
         }
         return errorMessages.isEmpty();
     }
-    
-    private boolean isOk(String... fields) {
-        boolean isOk = true;
-        for (String field : fields) {
-            isOk &= StringUtils.isNotBlank(field);
+
+    /*
+     * Method that check wether a comment is valid (good attributes)
+     * @param comment, the comment to be validated
+     */
+    private void validateComment(Comment comment) throws ComponentRegistryException {
+        if (comment.getComment() == null) {
+            errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "comment has to be filled in");
         }
-        return isOk;
+        if (description.isProfile()) {
+            if (comment.getProfileDescriptionId() == null) {
+                errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "profileId could not be found");
+            }
+        } else {
+            if (comment.getComponentDescriptionId() == null) {
+                errorMessages.add(ILLEGAL_ATTRIBUTE_NAME_ERROR + "componentId could not be found");
+            }
+        }
     }
-    
+
+    public Comment getCommentSpec() {
+        return com;
+    }
 }
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 1639)
@@ -507,5 +507,5 @@
             return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build();
         }
-        LOG.info("Profile with id: " + commentId + " deleted.");
+        LOG.info("Comment with id: " + commentId + " deleted.");
         return Response.ok().build();
     }
@@ -532,5 +532,5 @@
             return Response.serverError().status(Status.UNAUTHORIZED).entity("" + e.getMessage()).build();
         }
-        LOG.info("Profile with id: " + commentId + " deleted.");
+        LOG.info("Comment with id: " + commentId + " deleted.");
         return Response.ok().build();
     }
@@ -647,29 +647,33 @@
     @Consumes("multipart/form-data")
     public Response registerCommentInComponent(@FormDataParam(DATA_FORM_FIELD) InputStream input, @FormDataParam(NAME_FORM_FIELD) String comment,
-            @FormDataParam("componentId") AbstractDescription componentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) {
+            @PathParam("componentId") String componentId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
         Principal principal = checkAndGetUserPrincipal();
         UserCredentials userCredentials = getUserCredentials(principal);
+        ComponentRegistry registry = getRegistry(userspace, userCredentials);
+        AbstractDescription description = registry.getComponentDescription(componentId);
         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);
+        //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, com, userCredentials, userspace, componentId, new NewAction());
-    }
-    
-        @POST
+        return registerComment(input, registry, userspace, description, principal, new NewAction());
+    }
+
+    @POST
     @Path("/profiles/{profileId}/comments")
     @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     @Consumes("multipart/form-data")
-    public Response registerCommentInProfile(@FormDataParam(DATA_FORM_FIELD) InputStream input, @FormDataParam(NAME_FORM_FIELD) String comment,
-            @FormDataParam("profileId") AbstractDescription profileId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) {
+    public Response registerCommentInProfile(@FormDataParam(DATA_FORM_FIELD) InputStream input,
+            @PathParam("profileId") String profileId, @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
         Principal principal = checkAndGetUserPrincipal();
         UserCredentials userCredentials = getUserCredentials(principal);
-        Comment com = createNewComment();
-        com.setComponentDescriptionId("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: " + com);
-        return registerComment(input, com, userCredentials, userspace, profileId, new NewAction());
+        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());
     }
 
@@ -723,18 +727,16 @@
     }
 
-    private Response registerComment(InputStream input, Comment com, UserCredentials userCredentials, boolean userspace,
-            AbstractDescription descriptionId,
+    private Response registerComment(InputStream input, ComponentRegistry registry, boolean userspace,
+            AbstractDescription description, Principal principal,
             RegisterAction action) {
         try {
-            ComponentRegistry registry = getRegistry(userspace, userCredentials);
-            CommentValidator commentValidator = new CommentValidator(com);
-            ComValidator validator = new ComValidator(input, com, registry, getRegistry(true), descriptionId
-            );
+            CommentValidator validator = new CommentValidator(input, registry, getRegistry(true), description);
             RegisterResponse response = new RegisterResponse();
             response.setIsInUserSpace(userspace);
-            validate(response, commentValidator, validator);
+            validate(response, validator);
             if (response.getErrors().isEmpty()) {
-                Comment spec = validator.getCommentSpec();
-                int returnCode = action.executeComment(com, spec, response, registry);
+                Comment com = validator.getCommentSpec();
+               int returnCode = action.executeComment(com, response, registry, principal.getName());
+              // registry.registerComment(com, principal.getName());
                 if (returnCode == 0) {
                     response.setRegistered(true);
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/NewAction.java	(revision 1639)
@@ -15,6 +15,6 @@
 
     @Override
-    public int executeComment(Comment com, Comment spec, RegisterResponse response, ComponentRegistry registry) {
-        return registry.registerComment(com, spec);
+    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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/PublishAction.java	(revision 1639)
@@ -24,5 +24,5 @@
 
     @Override
-    public int executeComment(Comment com, Comment spec, RegisterResponse response, ComponentRegistry registry) {
+    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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/RegisterAction.java	(revision 1639)
@@ -11,5 +11,5 @@
     int execute(AbstractDescription desc, CMDComponentSpec spec, RegisterResponse response, ComponentRegistry registry);
 
-    int executeComment(Comment com, Comment 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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/UpdateAction.java	(revision 1639)
@@ -23,5 +23,5 @@
 
     @Override
-    public int executeComment(Comment com, Comment spec, RegisterResponse response, ComponentRegistry registry) {
+    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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/CommentsDaoTest.java	(revision 1639)
@@ -1,5 +1,4 @@
 package clarin.cmdi.componentregistry.impl.database;
 
-import clarin.cmdi.componentregistry.model.Comment;
 import clarin.cmdi.componentregistry.model.Comment;
 import java.util.List;
@@ -18,5 +17,5 @@
 /**
  *
- * @author jeafer
+ * @author jean-charles FerriÃšres <jean-charles.ferrieres@mpi.nl>
  */
 @RunWith(SpringJUnit4ClassRunner.class)
@@ -44,13 +43,4 @@
     public void testInsertComment() {
         Comment comment = createTestComment();
-
-
-
-
-        //testComment.setId(TEST_COMMENT_ID);
-        
-        //comment.setUserId("1");
-        //testComment.setComponentDescriptionId("A component1");
-        //testComment.setProfileDescriptionId("A profile1");
 
         String testComment = comment.getComment();
@@ -117,5 +107,5 @@
 	assertEquals(count + 1, commentsDao.getAllComments().size());
 
-        commentsDao.deleteComment(comment, true);
+        commentsDao.deleteComment(comment);
         assertEquals(count, commentsDao.getAllComments().size());
         
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTest.java	(revision 1639)
@@ -76,7 +76,9 @@
         RegistryTestHelper.addComponent(getTestRegistry(), "component2");
         RegistryTestHelper.addComponent(getTestRegistry(), "component1");
-        RegistryTestHelper.addComment(getTestRegistry(), "comment2");
-        RegistryTestHelper.addComment(getTestRegistry(), "comment1");
-        
+        RegistryTestHelper.addComment(getTestRegistry(), "comment2", "profile1", "JUnit@test.com");
+        RegistryTestHelper.addComment(getTestRegistry(), "comment1", "profile1", "JUnit@test.com");
+        RegistryTestHelper.addComment(getTestRegistry(), "comment3", "component1", "JUnit@test.com");
+        RegistryTestHelper.addComment(getTestRegistry(), "comment4", "component1", "JUnit@test.com");
+
     }
 
@@ -143,14 +145,97 @@
     public void testGetRegisteredCommentsInProfile() throws Exception {
         fillUp();
-        RegistryTestHelper.addComment(getTestRegistry(), "COMMENT1");
-        List<Comment> response = getResource().path("/registry/profiles/clarin.eu:cr1:profile1/comments").accept(MediaType.APPLICATION_XML).
+        RegistryTestHelper.addComment(getTestRegistry(), "COMMENT1", "profile1", "JUnit@test.com");
+        List<Comment> response = getResource().path("/registry/profiles/profile1/comments/").accept(MediaType.APPLICATION_XML).
                 get(COMMENT_LIST_GENERICTYPE);
-        assertEquals(0, response.size());
-        response = getResource().path("/registry/components/clarin.eu:cr1:profile1/comments").accept(MediaType.APPLICATION_JSON).get(
+        assertEquals(3, response.size());
+        response = getResource().path("/registry/profiles/profile1/comments").accept(MediaType.APPLICATION_JSON).get(
                 COMMENT_LIST_GENERICTYPE);
         assertEquals(3, response.size());
-        assertEquals("comment1", response.get(0).getComment());
-        assertEquals("comment2", response.get(1).getComment());
+        assertEquals("comment2", response.get(0).getComment());
+        assertEquals("comment1", response.get(1).getComment());
         assertEquals("COMMENT1", response.get(2).getComment());
+    }
+
+    @Test
+    public void testGetRegisteredCommentsInComponent() throws Exception {
+        fillUp();
+        RegistryTestHelper.addComment(getTestRegistry(), "COMMENT2", "component1", "JUnit@test.com");
+        List<Comment> response = getResource().path("/registry/components/component1/comments/").accept(MediaType.APPLICATION_XML).
+                get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(3, response.size());
+        response = getResource().path("/registry/components/component1/comments").accept(MediaType.APPLICATION_JSON).get(
+                COMMENT_LIST_GENERICTYPE);
+        assertEquals(3, response.size());
+        assertEquals("comment3", response.get(0).getComment());
+        assertEquals("comment4", response.get(1).getComment());
+        assertEquals("COMMENT2", response.get(2).getComment());
+    }
+
+    @Test
+    public void testGetSpecifiedCommentInComponent() throws Exception {
+        fillUp();
+        Comment comment = getResource().path("/registry/components/component1/comments/2").accept(MediaType.APPLICATION_JSON).get(Comment.class);
+        assertNotNull(comment);
+        assertEquals("comment3", comment.getComment());
+        assertEquals("2", comment.getId());
+        comment = getResource().path("/registry/components/component1/comments/3").accept(MediaType.APPLICATION_JSON).get(Comment.class);
+        assertNotNull(comment);
+        assertEquals("comment4", comment.getComment());
+        assertEquals("3", comment.getId());
+        assertEquals("component1", comment.getComponentDescriptionId());
+    }
+
+    @Test
+    public void testGetSpecifiedCommentInProfile() throws Exception {
+        fillUp();
+        Comment comment = getResource().path("/registry/profiles/profile1/comments/0").accept(MediaType.APPLICATION_JSON).get(Comment.class);
+        assertNotNull(comment);
+        assertEquals("comment2", comment.getComment());
+        assertEquals("0", comment.getId());
+        comment = getResource().path("/registry/profiles/profile1/comments/1").accept(MediaType.APPLICATION_JSON).get(Comment.class);
+        assertNotNull(comment);
+        assertEquals("comment1", comment.getComment());
+        assertEquals("1", comment.getId());
+        assertEquals("profile1", comment.getProfileDescriptionId());
+    }
+    
+    @Test
+    public void testDeleteCommentFromComponent() throws Exception {
+        fillUp();
+        List<Comment> comments = getResource().path("/registry/components/component1/comments").get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(2, comments.size());
+        Comment aComment = getResource().path("/registry/components/component1/comments/2").get(Comment.class);
+        assertNotNull(aComment);
+        ClientResponse response = getAuthenticatedResource("/registry/components/component1/comments/2").delete(ClientResponse.class);
+        assertEquals(200, response.getStatus());
+        
+        comments = getResource().path("/registry/components/component1/comments/").get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(1, comments.size());
+        
+        response = getAuthenticatedResource("/registry/components/component1/comments/3").delete(ClientResponse.class);
+        assertEquals(200, response.getStatus());
+        
+        comments = getResource().path("/registry/components/component1/comments").get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(0, comments.size());
+    }
+    
+        @Test
+    public void testDeleteCommentFromProfile() throws Exception {
+        fillUp();
+        List<Comment> comments = getResource().path("/registry/profiles/profile1/comments").get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(2, comments.size());
+        Comment aComment = getResource().path("/registry/profiles/profile1/comments/0").get(Comment.class);
+        assertNotNull(aComment);
+        ClientResponse response = getAuthenticatedResource("/registry/profiles/profile1/comments/0").delete(ClientResponse.class);
+        assertEquals(200, response.getStatus());
+        
+        comments = getResource().path("/registry/profiles/profile1/comments/").get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(1, comments.size());
+        
+        response = getAuthenticatedResource("/registry/profiles/profile1/comments/1").delete(ClientResponse.class);
+        assertEquals(200, response.getStatus());
+        
+        comments = getResource().path("/registry/profiles/profile1/comments").get(COMMENT_LIST_GENERICTYPE);
+        assertEquals(0, comments.size());
     }
 
@@ -769,13 +854,11 @@
         RegisterResponse response = getAuthenticatedResource("/registry/profiles/clarin.eu:cr1:profile1/comments").type(MediaType.MULTIPART_FORM_DATA).post(
                 RegisterResponse.class, form);
+        assertTrue(response.isRegistered());
         assertFalse(response.isInUserSpace());
-        Comment comment = (Comment) response.getComment();
+        Comment comment = response.getComment();
         assertNotNull(comment);
-        assertEquals("CommentTest1", comment.getComment());
+        assertEquals("Actual", comment.getComment());
         assertEquals(expectedUserId("JUnit@test.com"), comment.getUserId());
-        assertTrue(comment.getId().startsWith(ComponentRegistry.REGISTRY_ID + "p_"));
         assertNotNull(comment.getCommentDate());
-        String url = getResource().getUriBuilder().build().toString();
-        assertEquals(url + "registry/profiles/{clarin.eu:cr1:p_1297242111880}/comments/" + comment.getId(), 1);
     }
 
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 1638)
+++ /ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 1639)
@@ -15,7 +15,10 @@
 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;
 
 /**
@@ -181,32 +184,23 @@
     }
 
-    public static Comment addComment(ComponentRegistry testRegistry, String id) throws ParseException, JAXBException {
-        return addComment(testRegistry, id, RegistryTestHelper.getCommentTestContent());
-    }
-
-//    public static Comment addComment(ComponentRegistry testRegistry, String id, String content) throws ParseException,
-//            JAXBException {
-//        return addComment(testRegistry, id, new ByteArrayInputStream(content.getBytes()));
-//    }
-
-    private static Comment addComment(ComponentRegistry testRegistry, String id, InputStream content) throws ParseException,
-            JAXBException {
-        Comment com = Comment.createANewComment();
-        com.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());
-        com.setId(id);
-        com.setComment("Test Comment");
+    public static Comment addComment(ComponentRegistry testRegistry, String id, String descriptionId, String principal) throws ParseException, JAXBException {
+        return addComment(testRegistry, RegistryTestHelper.getTestCommentContent(id, descriptionId), principal);
+    }
+
+    private static Comment addComment(ComponentRegistry testRegistry, InputStream content, String principal) throws ParseException,
+            JAXBException {
         Comment spec = MDMarshaller.unmarshal(Comment.class, content, null);
-        testRegistry.registerComment(com, spec);
-        return com;
-    }
-
-    public static String getCommentTestContentString(String commentName) {
+        testRegistry.registerComment(spec, principal);
+        return spec;
+    }
+
+    public static String getCommentTestContentString(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>myDate</commentDate>\n";
-        comContent += "    <profileDescriptionId>profile1</profileDescriptionId>\n";
-        comContent += "    <userId>8</userId>\n";
+        comContent += "    <comments>" + commentName + "</comments>\n";
+        comContent += "    <commentDate>" + Comment.createNewDate() + "</commentDate>\n";
+        comContent += "    <profileDescriptionId>" + profileId + "</profileDescriptionId>\n";
+        comContent += "    <userId>0</userId>\n";
         comContent += "    <id>1</id>\n";
         comContent += "</comment>\n";
@@ -214,14 +208,31 @@
     }
 
-    public static InputStream getTestCommentContent(String content) {
-        return new ByteArrayInputStream(getCommentTestContentString(content).getBytes());
-    }
-
-    public static String getCommentTestContent(String commentName) {
-        return getCommentTestContentString("Actual");
+    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>" + Comment.createNewDate() + "</commentDate>\n";
+        comContent += "     <componentDescriptionId>" + componentId + "</componentDescriptionId>";
+        comContent += "    <userId>0</userId>\n";
+        comContent += "    <id>1</id>\n";
+        comContent += "</comment>\n";
+        return comContent;
+    }
+
+    public static InputStream getTestCommentContent(String content, String descriptionId) {
+        if (descriptionId.contains("profile")) {
+            return new ByteArrayInputStream(getCommentTestContentString(content, descriptionId).getBytes());
+        } else {
+            return new ByteArrayInputStream(getCommentTestContentStringForComponent(content, descriptionId).getBytes());
+        }
+    }
+
+    public static String getCommentTestContent(String commentId, String descriptionId) {
+        return getCommentTestContentString(commentId, descriptionId);
     }
 
     public static InputStream getCommentTestContent() {
-        return getTestCommentContent("Actual");
+        return getTestCommentContent("Actual", "profile1");
     }
 
