As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
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
Hi
There is similar thread for what you are looking for, check out this link,
Hope this will be helpful to you.
Hello<shameless plug>I think you are looking for alfSetPermissions.sh from alfresco-shell-tools
</shameless plug>
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