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
Hello
<shameless plug>
I think you are looking for alfSetPermissions.sh from alfresco-shell-tools
</shameless plug>
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
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.