mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1661: properties and aspects no longer appear in /comments listing.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133552 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -423,6 +423,7 @@
|
||||
<property name="commentService" ref="CommentService" />
|
||||
<property name="contentService" ref="ContentService" />
|
||||
<property name="typeConstraint" ref="nodeTypeConstraint" />
|
||||
<property name="people" ref="people"/>
|
||||
</bean>
|
||||
|
||||
<bean id="Comments" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
|
@@ -29,6 +29,8 @@ import org.alfresco.rest.api.model.Comment;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author steveglover
|
||||
@@ -39,5 +41,5 @@ public interface Comments
|
||||
public Comment createComment(String nodeId, Comment comment);
|
||||
public Comment updateComment(String nodeId, Comment comment);
|
||||
public void deleteComment(String nodeId, String commentNodeId);
|
||||
public CollectionWithPagingInfo<Comment> getComments(String nodeId, Paging paging);
|
||||
public CollectionWithPagingInfo<Comment> getComments(String nodeId, Paging paging, List<String> include);
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.NoSuchPersonException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface People
|
||||
{
|
||||
String DEFAULT_USER = "-me-";
|
||||
@@ -45,11 +47,21 @@ public interface People
|
||||
NodeRef getAvatar(String personId);
|
||||
|
||||
/**
|
||||
* Get a person. This included a full representation of the person.
|
||||
*
|
||||
* @throws NoSuchPersonException if personId does not exist
|
||||
*/
|
||||
Person getPerson(final String personId);
|
||||
|
||||
/**
|
||||
* Get a person, specifying optional includes as required.
|
||||
*
|
||||
* @param personId
|
||||
* @param include
|
||||
* @return
|
||||
*/
|
||||
Person getPerson(String personId, List<String> include);
|
||||
|
||||
/**
|
||||
* Create a person.
|
||||
*
|
||||
|
@@ -25,39 +25,38 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.impl;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.forum.CommentService;
|
||||
import org.alfresco.rest.api.Comments;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.People;
|
||||
import org.alfresco.rest.api.model.Comment;
|
||||
import org.alfresco.rest.api.model.Person;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.TypeConstraint;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.forum.CommentService;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.rest.api.Comments;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.Comment;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.TypeConstraint;
|
||||
import static org.alfresco.rest.api.People.PARAM_INCLUDE_ASPECTNAMES;
|
||||
import static org.alfresco.rest.api.People.PARAM_INCLUDE_PROPERTIES;
|
||||
|
||||
/**
|
||||
* Centralises access to comment services and maps between representations.
|
||||
@@ -67,11 +66,15 @@ import org.alfresco.util.TypeConstraint;
|
||||
*/
|
||||
public class CommentsImpl implements Comments
|
||||
{
|
||||
private static final List<String> INCLUDE_FULL_PERSON = Arrays.asList(
|
||||
PARAM_INCLUDE_ASPECTNAMES,
|
||||
PARAM_INCLUDE_PROPERTIES);;
|
||||
private Nodes nodes;
|
||||
private NodeService nodeService;
|
||||
private CommentService commentService;
|
||||
private ContentService contentService;
|
||||
private TypeConstraint typeConstraint;
|
||||
private People people;
|
||||
|
||||
public void setTypeConstraint(TypeConstraint typeConstraint)
|
||||
{
|
||||
@@ -98,7 +101,12 @@ public class CommentsImpl implements Comments
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
private Comment toComment(NodeRef nodeRef, NodeRef commentNodeRef)
|
||||
public void setPeople(People people)
|
||||
{
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
private Comment toComment(NodeRef nodeRef, NodeRef commentNodeRef, List<String> include)
|
||||
{
|
||||
Map<QName, Serializable> nodeProps = nodeService.getProperties(commentNodeRef);
|
||||
|
||||
@@ -115,6 +123,11 @@ public class CommentsImpl implements Comments
|
||||
boolean canEdit = map.get(CommentService.CAN_EDIT);
|
||||
boolean canDelete = map.get(CommentService.CAN_DELETE);
|
||||
|
||||
Person createdBy = people.getPerson((String) nodeProps.get(ContentModel.PROP_CREATOR), include);
|
||||
nodeProps.put(Comment.PROP_COMMENT_CREATED_BY, createdBy);
|
||||
|
||||
Person modifiedBy = people.getPerson((String) nodeProps.get(ContentModel.PROP_MODIFIER), include);
|
||||
nodeProps.put(Comment.PROP_COMMENT_MODIFIED_BY, modifiedBy);
|
||||
|
||||
Comment comment = new Comment(commentNodeRef.getId(), nodeProps, canEdit, canDelete);
|
||||
return comment;
|
||||
@@ -132,7 +145,7 @@ public class CommentsImpl implements Comments
|
||||
try
|
||||
{
|
||||
NodeRef commentNode = commentService.createComment(nodeRef, comment.getTitle(), comment.getContent(), false);
|
||||
return toComment(nodeRef, commentNode);
|
||||
return toComment(nodeRef, commentNode, INCLUDE_FULL_PERSON);
|
||||
}
|
||||
catch(IllegalArgumentException e)
|
||||
{
|
||||
@@ -157,7 +170,7 @@ public class CommentsImpl implements Comments
|
||||
}
|
||||
|
||||
commentService.updateComment(commentNodeRef, title, content);
|
||||
return toComment(nodeRef, commentNodeRef);
|
||||
return toComment(nodeRef, commentNodeRef, INCLUDE_FULL_PERSON);
|
||||
}
|
||||
catch(IllegalArgumentException e)
|
||||
{
|
||||
@@ -165,7 +178,7 @@ public class CommentsImpl implements Comments
|
||||
}
|
||||
}
|
||||
|
||||
public CollectionWithPagingInfo<Comment> getComments(String nodeId, Paging paging)
|
||||
public CollectionWithPagingInfo<Comment> getComments(String nodeId, Paging paging, List<String> include)
|
||||
{
|
||||
final NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
|
||||
@@ -186,7 +199,7 @@ public class CommentsImpl implements Comments
|
||||
@Override
|
||||
public Comment get(int index)
|
||||
{
|
||||
return toComment(nodeRef, page.get(index));
|
||||
return toComment(nodeRef, page.get(index), include);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -303,6 +303,7 @@ public class PeopleImpl implements People
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a full representation of a person.
|
||||
*
|
||||
* @throws NoSuchPersonException
|
||||
* if personId does not exist
|
||||
@@ -318,6 +319,14 @@ public class PeopleImpl implements People
|
||||
return person;
|
||||
}
|
||||
|
||||
public Person getPerson(String personId, List<String> include)
|
||||
{
|
||||
personId = validatePerson(personId);
|
||||
Person person = getPersonWithProperties(personId, include);
|
||||
|
||||
return person;
|
||||
}
|
||||
|
||||
public CollectionWithPagingInfo<Person> getPeople(final Parameters parameters)
|
||||
{
|
||||
Paging paging = parameters.getPaging();
|
||||
|
@@ -45,14 +45,16 @@ import org.alfresco.service.namespace.QName;
|
||||
public class Comment
|
||||
{
|
||||
public static final QName PROP_COMMENT_CONTENT = QName.createQName("RestApi", "commentContent");
|
||||
public static final QName PROP_COMMENT_CREATED_BY = QName.createQName("RestApi", "createdBy");
|
||||
public static final QName PROP_COMMENT_MODIFIED_BY = QName.createQName("RestApi", "modifiedBy");
|
||||
|
||||
private String id;
|
||||
private String title;
|
||||
private String content;
|
||||
private Date createdAt;
|
||||
private String createdBy;
|
||||
private Person createdBy;
|
||||
private Date modifiedAt;
|
||||
private String modifiedBy;
|
||||
private Person modifiedBy;
|
||||
private Boolean edited;
|
||||
|
||||
// permissions
|
||||
@@ -118,14 +120,12 @@ public class Comment
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
@EmbeddedEntityResource(propertyName = "createdBy", entityResource = PeopleEntityResource.class)
|
||||
public String getCreatedBy()
|
||||
public Person getCreatedBy()
|
||||
{
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
@EmbeddedEntityResource(propertyName = "modifiedBy", entityResource = PeopleEntityResource.class)
|
||||
public String getModifiedBy()
|
||||
public Person getModifiedBy()
|
||||
{
|
||||
return modifiedBy;
|
||||
}
|
||||
@@ -156,11 +156,14 @@ public class Comment
|
||||
this.edited = Boolean.valueOf(diff >= 100); // logic is consistent with existing (Javascript) comments implementation
|
||||
}
|
||||
|
||||
this.createdBy = (String)nodeProps.get(ContentModel.PROP_CREATOR);
|
||||
this.modifiedBy = (String)nodeProps.get(ContentModel.PROP_MODIFIER);
|
||||
|
||||
this.content = (String)nodeProps.get(PROP_COMMENT_CONTENT);
|
||||
nodeProps.remove(PROP_COMMENT_CONTENT);
|
||||
|
||||
this.createdBy = (Person) nodeProps.get(PROP_COMMENT_CREATED_BY);
|
||||
nodeProps.remove(PROP_COMMENT_CREATED_BY);
|
||||
|
||||
this.modifiedBy = (Person) nodeProps.get(PROP_COMMENT_MODIFIED_BY);
|
||||
nodeProps.remove(PROP_COMMENT_MODIFIED_BY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -42,8 +42,9 @@ import java.util.Map;
|
||||
* @author steveglover
|
||||
*
|
||||
*/
|
||||
public class Person
|
||||
public class Person implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected String userName;
|
||||
protected Boolean enabled;
|
||||
protected NodeRef avatarId;
|
||||
|
@@ -93,7 +93,7 @@ public class NodeCommentsRelation implements RelationshipResourceAction.Read<Com
|
||||
@WebApiDescription(title = "Returns a paged list of comments for the document/folder identified by nodeId, sorted chronologically with the newest first.")
|
||||
public CollectionWithPagingInfo<Comment> readAll(String nodeId, Parameters parameters)
|
||||
{
|
||||
return comments.getComments(nodeId, parameters.getPaging());
|
||||
return comments.getComments(nodeId, parameters.getPaging(), parameters.getInclude());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user