@Override public void selectSubject(final Subject subject) { String uri = ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_SUBJECT .create() .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, subject.getType().getName()) .build(project.getName(), subject.getPrincipal()); ResourceAuthorizationRequestBuilderFactory.newBuilder() // .forResource(uri) // .authorize(getView().getDeleteAllAuthorizer()) // .delete() .send(); ResourceRequestBuilderFactory.<JsArray<Acl>>newBuilder() .forResource(uri) .get() .withCallback( new ResourceCallback<JsArray<Acl>>() { @Override public void onResource(Response response, JsArray<Acl> acls) { List<Acl> subjectAcls = JsArrays.toList(acls); if (!subjectAcls.isEmpty()) { getView().setSubjectData(subject, subjectAcls); } else { // refresh and select another subject if any retrievePermissions(); } } }) .send(); }
private void retrievePermissions() { ResourceRequestBuilderFactory.<JsArray<Subject>>newBuilder() .forResource( ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_SUBJECTS .create() .build(project.getName())) .get() .withCallback( new ResourceCallback<JsArray<Subject>>() { @Override public void onResource(Response response, JsArray<Subject> subjects) { List<Subject> subjectList = JsArrays.toList(subjects); getView().setData(subjectList); if (!subjectList.isEmpty()) { selectFirstUser(subjectList); } } private void selectFirstUser(List<Subject> subjectList) { Subject selection = subjectList.get(0); if (!Subject.SubjectType.USER.isSubjectType(selection.getType())) { for (Subject subject : subjectList) { if (Subject.SubjectType.USER.isSubjectType(subject.getType())) { selection = subject; break; } } } selectSubject(selection); } }) .send(); }
@Override public void deleteAllSubjectPermissions(final Subject subject) { String uri = ResourcePermissionRequestPaths.UriBuilders.PROJECT_PERMISSIONS_SUBJECT .create() .query(ResourcePermissionRequestPaths.TYPE_QUERY_PARAM, subject.getType().getName()) .build(project.getName(), subject.getPrincipal()); ResourceRequestBuilderFactory.<JsArray<Acl>>newBuilder() .forResource(uri) .delete() .withCallback( Response.SC_OK, new ResponseCodeCallback() { @Override public void onResponseCode(Request request, Response response) { selectSubject(subject); } }) .send(); }