protected boolean checkIfMatch ( final HttpServletRequest request , final HttpServletResponse response , final Attributes resourceAttributes ) throws IOException { final String eTag = resourceAttributes . getETag ( ) ; final String headerValue = request . getHeader ( "If-Match" ) ; if ( headerValue != null ) { if ( headerValue . indexOf ( ' ' ) == - 1 ) { final StringTokenizer commaTokenizer = new StringTokenizer ( headerValue , "," ) ; boolean conditionSatisfied = false ; while ( ! conditionSatisfied && commaTokenizer . hasMoreTokens ( ) ) { final String currentToken = commaTokenizer . nextToken ( ) ; if ( currentToken . trim ( ) . equals ( eTag ) ) conditionSatisfied = true ; } // If none of the given ETags match, 412 Precodition failed is // sent back if ( ! conditionSatisfied ) { response . sendError ( HttpServletResponse . SC_PRECONDITION_FAILED ) ; return false ; } } } return true ; }
Check if the if - match condition is satisfied .