Skip to content

Commit

Permalink
JAVACLIENT-176: Add permissions on Comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinleturc committed Dec 5, 2018
1 parent 1c286b2 commit 72c7c96
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,7 @@ public void itCanHandleComplexProperties() {

// Here we are using a sub class DataSet of Document which let the dev implementing business logic.
roles = singletonList("BenchmarkIndicator");
fields = singletonList(
new Field("string", "description", roles, "columnName", "sqlTypeHint", "name"));
fields = singletonList(new Field("string", "description", roles, "columnName", "sqlTypeHint", "name"));
DataSet dataset = new DataSet(document.getId());
dataset.setFields(fields);

Expand Down Expand Up @@ -940,6 +939,31 @@ public void itCanManageAnnotationReplies() {
}
}

@Test
public void itCanRetrieveCommentPermissions() {
assumeTrue("itCanManageAnnotations works only since Nuxeo 10.3",
// TODO change the version to LTS
nuxeoClient.getServerVersion().isGreaterThan(new NuxeoVersion(10, 3, 0, true)));
Document file = nuxeoClient.repository().fetchDocumentByPath(FOLDER_2_FILE);
CommentAdapter commentAdapter = file.adapter(CommentAdapter::new);

String commentText = "Just a little comment";
Instant date = Instant.now();

// create comment
Comment comment = newComment(commentText, date, "COMMENT_ID_001");
comment = commentAdapter.create(comment);

// assert its permissions
assertEquals(
Arrays.asList("Write", "WriteVersion", "ReadProperties", "ReadCanCollect", "ReadSecurity", "Remove",
"ReadVersion", "Read", "WriteLifeCycle", "Everything", "Moderate", "Version", "ReadChildren",
"AddChildren", "Comment", "ReadLifeCycle", "RemoveChildren", "DataVisualization",
"ReviewParticipant", "Unlock", "CanAskForPublishing", "RestrictedRead", "ReadWrite",
"ReadRemove", "Browse", "WriteProperties", "WriteSecurity", "ManageWorkflows"),
comment.getPermissions());
}

private Annotation newAnnotation(String annotationText, String entityId) {
Annotation annotation = new Annotation();
annotation.setAuthor(LOGIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.nuxeo.client.objects.comment;

import java.time.Instant;
import java.util.List;
import java.util.Set;

import org.nuxeo.client.objects.Entity;
Expand Down Expand Up @@ -52,6 +53,9 @@ public class Comment extends Entity {

protected String entity;

// given by server
protected List<String> permissions; // NOSONAR

/**
* Protected constructor to extend Comment type.
*/
Expand Down Expand Up @@ -134,4 +138,8 @@ public String getEntity() {
public void setEntity(String entity) {
this.entity = entity;
}

public List<String> getPermissions() {
return permissions;
}
}

0 comments on commit 72c7c96

Please sign in to comment.