/** * Revokes the specified role from the user. */ public void revokeRole( JNUser user, String roleName ) throws ProcessingException { try { WebResponse r = goTo(project._getURL()+"/servlets/ProjectMemberList"); WebForm form = Util.getFormWithAction(r,"ProjectMemberList"); if(form==null) throw new IllegalStateException("form not found in "+r.getURL()); // starts-with is necesasry because someone fails to handle correctly String propName = (String)Util.getDom4j(r).selectObject( "string(//FORM[@action='ProjectMemberList']//TR[normalize-space(TD[1])='"+user.getName()+"']/TD[3]/text()[normalize-space(.)='"+roleName+"']/preceding-sibling::INPUT[1]/@name)"); if(propName==null || propName.length()==0) throw new ProcessingException("Unable to find the user "+user.getName()+" or the role "+roleName); form.toggleCheckbox(propName); SubmitButton submitButton = form.getSubmitButton("Button"); if(submitButton==null) throw new IllegalStateException("no submit button"); r = checkError(form.submit(submitButton)); if( r.getURL().toExternalForm().endsWith("ProjectMemberList") ) return; // successful throw new ProcessingException("failed to revoke role from "+user.getName()); } catch( IOException e ) { throw new ProcessingException("failed to revoke role from "+user.getName(),e); } catch( SAXException e ) { throw new ProcessingException("failed to revoke role from "+user.getName(),e); } }