/** * Indicates if there are some range conditions set. * * @return True if there are some range conditions set. */ public boolean hasSomeRange() { return getRangeTag() != null || getRangeDate() != null; }
/** * Returns the range conditional status of an entity. * * @param tag * The tag of the entity. * @param modificationDate * The modification date of the entity. * @return The status of the response. */ public Status getRangeStatus(Tag tag, Date modificationDate) { Status result = Status.CLIENT_ERROR_PRECONDITION_FAILED; if (getRangeTag() != null) { boolean all = getRangeTag().equals(Tag.ALL); // If a tag exists if (tag != null) { if (all || getRangeTag().equals(tag)) { result = Status.SUCCESS_OK; } } } else if (getRangeDate() != null) { // If a modification date exists if (getRangeDate().equals(modificationDate)) { result = Status.SUCCESS_OK; } } return result; }
conditions.setRangeTag(request.getConditions().getRangeTag()); conditions.setUnmodifiedSince(request.getConditions() .getUnmodifiedSince());
if (conditions.getRangeTag() != null && conditions.getRangeDate() != null) { Context.getCurrentLogger() .log(WARNING, "Unable to format the HTTP If-Range header due to the presence of both entity tag and modification date."); } else if (conditions.getRangeTag() != null) { addHeader(HEADER_IF_RANGE, TagWriter.write(conditions.getRangeTag()), headers); } else if (conditions.getRangeDate() != null) { addHeader(HEADER_IF_RANGE, DateWriter.write(conditions.getRangeDate()), headers);