05-21-2018 10:59 PM
Dear friends
How can I set permission by using update Node API
Can I Do this directly by HttpClient and HttpPost methods?
PLEASE, can You give me some code example?
Thank You
05-22-2018 12:03 AM
05-22-2018 05:20 AM
Hello
<shameless plug>
I think you are looking for alfSetPermissions.sh from alfresco-shell-tools
</shameless plug>
05-22-2018 06:21 AM
Dear friends
I solve this problem by via Put Method
NameValuePair nvp = new BasicNameValuePair("include", "premissions");
builder.setScheme("http").setHost("localhost").setPort(8080).setPath("/alfresco/api/-default-/public/alfresco/versions/1/nodes/" + nodeId).setParameters(nvp);
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPut put = new HttpPut(builder.build());
String alfrescoUser = "admin";
String pass = "admin";
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(alfrescoUser, pass);
List<PermissionElementRepresentation> userPermissions = new ArrayList<PermissionElementRepresentation>();
PermissionElementRepresentation newPermission = new PermissionElementRepresentation();
newPermission.setAuthorityId("dato");
newPermission.setName("Read");
newPermission.setAccessStatus(AccessStatusEnum.ALLOWED);
userPermissions.add(newPermission);
PermissionsBodyUpdate permission = new PermissionsBodyUpdate(false, userPermissions);
NodeBodyUpdate permissionRequest = new NodeBodyUpdate(permission);
Gson gson = new Gson();
String jsonInString = gson.toJson(permissionRequest);
StringEntity se;
se = new StringEntity(jsonInString);
put.setEntity(se);
put.setHeader("Accept", "application/json");
put.setHeader("Content-type", "application/json");
put.addHeader(new BasicScheme().authenticate(creds, put, null));
HttpResponse httpResponse = httpClient.execute(put);
Thank you
Explore our Alfresco products with the links below. Use labels to filter content by product module.