* @param perm The integer value of the Permission as defined in <code>RepositoryFilePermissions</code>
*/
private void updatePermissionForUserOrRole( Document fileInfo, String recipient, String recipientType, boolean grant, int perm ) {
// first let's see if this node exists
Node foundPermission = null;
NodeList aces = fileInfo.getElementsByTagName( ACES_ELEMENT_NAME );
for ( int i = 0; i < aces.getLength(); i++ ) {
Element ace = (Element) aces.item( i );
if ( ace.getElementsByTagName( RECIPIENT_ELEMENT_NAME ).item( 0 ).getFirstChild().getNodeValue().equals(
recipient ) && ace.getElementsByTagName( RECIPIENT_TYPE_ELEMENT_NAME ).item( 0 ).getFirstChild().getNodeValue().equals(
recipientType ) ) {
NodeList permissions = ace.getElementsByTagName( PERMISSIONS_ELEMENT_NAME );
for ( int j = 0; j < permissions.getLength(); j++ ) {
Node testNode = permissions.item( j );
if ( testNode.getFirstChild() != null && Integer.parseInt( testNode.getFirstChild()
.getNodeValue() ) == perm ) {
foundPermission = testNode;
break;
}