protected boolean doOrder ( Node parentNode , List < OrderMember > members ) { boolean success = true ; for ( int i = 0 ; i < members . size ( ) ; i ++ ) { OrderMember member = members . get ( i ) ; int status = HTTPStatus . OK ; try { parentNode . getSession ( ) . refresh ( false ) ; String positionedNodeName = null ; if ( ! parentNode . hasNode ( member . getSegment ( ) ) ) { throw new PathNotFoundException ( ) ; } if ( ! new QName ( "DAV:" , "last" ) . equals ( member . getPosition ( ) ) ) { NodeIterator nodeIter = parentNode . getNodes ( ) ; boolean finded = false ; while ( nodeIter . hasNext ( ) ) { Node curNode = nodeIter . nextNode ( ) ; if ( new QName ( "DAV:" , "first" ) . equals ( member . getPosition ( ) ) ) { positionedNodeName = curNode . getName ( ) ; finded = true ; break ; } if ( new QName ( "DAV:" , "before" ) . equals ( member . getPosition ( ) ) && curNode . getName ( ) . equals ( member . getPositionSegment ( ) ) ) { positionedNodeName = curNode . getName ( ) ; finded = true ; break ; } if ( new QName ( "DAV:" , "after" ) . equals ( member . getPosition ( ) ) && curNode . getName ( ) . equals ( member . getPositionSegment ( ) ) ) { if ( nodeIter . hasNext ( ) ) { positionedNodeName = nodeIter . nextNode ( ) . getName ( ) ; } finded = true ; break ; } } if ( ! finded ) { throw new AccessDeniedException ( ) ; } } parentNode . getSession ( ) . refresh ( false ) ; parentNode . orderBefore ( member . getSegment ( ) , positionedNodeName ) ; parentNode . getSession ( ) . save ( ) ; } catch ( LockException exc ) { status = HTTPStatus . LOCKED ; } catch ( PathNotFoundException exc ) { status = HTTPStatus . FORBIDDEN ; } catch ( AccessDeniedException exc ) { status = HTTPStatus . FORBIDDEN ; } catch ( RepositoryException exc ) { LOG . error ( exc . getMessage ( ) , exc ) ; status = HTTPStatus . INTERNAL_ERROR ; } member . setStatus ( status ) ; if ( status != HTTPStatus . OK ) { success = false ; } } return success ; }
Order members .