++numThatAppy;
LinkedList stateList = ifHeader.getStateList();
boolean doContinue = false;
for (Iterator stateListIter = stateList.iterator(); stateListIter.hasNext();) {
DAVIFState state = (DAVIFState) stateListIter.next();
if (state.getType() == DAVIFStateType.IF_ETAG) {
String currentETag = null;
String givenETag = null;
String stateETag = state.getETag();
if (stateETag.startsWith("W/")) {
givenETag = stateETag.substring(2);
} else {
givenETag = stateETag;
}
if (eTag.startsWith("W/")) {
currentETag = eTag.substring(2);
} else {
currentETag = eTag;
}
boolean eTagsDoNotMatch = !givenETag.equals(currentETag);
if (state.getCondition() == DAVIFState.IF_CONDITION_NORMAL && eTagsDoNotMatch) {
reason = "an entity-tag was specified, but the resource's actual ETag does not match.";
doContinue = true;
break;
} else if (state.getCondition() == DAVIFState.IF_CONDITION_NOT && !eTagsDoNotMatch) {
reason = "an entity-tag was specified using the \"Not\" form, but the resource's actual ETag matches the provided entity-tag.";
doContinue = true;
break;
}
} else if (state.getType() == DAVIFStateType.IF_OPAQUE_LOCK) {
if (provider == null) {
if (state.getCondition() == DAVIFState.IF_CONDITION_NOT) {
continue;
}
reason = "a State-token was supplied, but a lock database is not available for to provide the required lock.";
doContinue = true;
break;
}
boolean matched = false;
if (lock != null) {
if (!lock.getLockToken().equals(state.getLockToken())) {
continue;
}
seenLockToken = true;
if (state.getCondition() == DAVIFState.IF_CONDITION_NOT) {
reason = "a State-token was supplied, which used a \"Not\" condition. The State-token was found in the locks on this resource";
doContinue = true;
break;
}
String lockAuthUser = lock.getAuthUser();
String requestUser = resource.getUserName();
if (lockAuthUser != null && (requestUser == null || !lockAuthUser.equals(requestUser))) {
throw new DAVException("User \"{0}\" submitted a locktoken created by user \"{1}\".",
new Object[] { requestUser, lockAuthUser }, HttpServletResponse.SC_FORBIDDEN, 0);
}
matched = true;
}
if (!matched && state.getCondition() == DAVIFState.IF_CONDITION_NORMAL) {
reason = "a State-token was supplied, but it was not found in the locks on this resource.";
doContinue = true;
break;
}
} else if (state.getType() == DAVIFStateType.IF_UNKNOWN) {
if (state.getCondition() == DAVIFState.IF_CONDITION_NORMAL) {
reason = "an unknown state token was supplied";
doContinue = true;
break;
}
}