*
* @return The condition data applying to this call.
*/
@Override
public Conditions getConditions() {
Conditions result = super.getConditions();
if (!this.conditionAdded) {
// Extract the header values
String ifMatchHeader = getHttpCall().getRequestHeaders().getValues(
HttpConstants.HEADER_IF_MATCH);
String ifNoneMatchHeader = getHttpCall().getRequestHeaders()
.getValues(HttpConstants.HEADER_IF_NONE_MATCH);
Date ifModifiedSince = null;
Date ifUnmodifiedSince = null;
for (Parameter header : getHttpCall().getRequestHeaders()) {
if (header.getName().equalsIgnoreCase(
HttpConstants.HEADER_IF_MODIFIED_SINCE)) {
ifModifiedSince = getHttpCall().parseDate(
header.getValue(), false);
} else if (header.getName().equalsIgnoreCase(
HttpConstants.HEADER_IF_UNMODIFIED_SINCE)) {
ifUnmodifiedSince = getHttpCall().parseDate(
header.getValue(), false);
}
}
// Set the If-Modified-Since date
if ((ifModifiedSince != null) && (ifModifiedSince.getTime() != -1)) {
result.setModifiedSince(ifModifiedSince);
}
// Set the If-Unmodified-Since date
if ((ifUnmodifiedSince != null)
&& (ifUnmodifiedSince.getTime() != -1)) {
result.setUnmodifiedSince(ifUnmodifiedSince);
}
// Set the If-Match tags
List<Tag> match = null;
Tag current = null;
if (ifMatchHeader != null) {
try {
HeaderReader hr = new HeaderReader(ifMatchHeader);
String value = hr.readValue();
while (value != null) {
current = Tag.parse(value);
// Is it the first tag?
if (match == null) {
match = new ArrayList<Tag>();
result.setMatch(match);
}
// Add the new tag
match.add(current);
// Read the next token
value = hr.readValue();
}
} catch (Exception e) {
this.context.getLogger().log(
Level.INFO,
"Unable to process the if-match header: "
+ ifMatchHeader);
}
}
// Set the If-None-Match tags
List<Tag> noneMatch = null;
if (ifNoneMatchHeader != null) {
try {
HeaderReader hr = new HeaderReader(ifNoneMatchHeader);
String value = hr.readValue();
while (value != null) {
current = Tag.parse(value);
// Is it the first tag?
if (noneMatch == null) {
noneMatch = new ArrayList<Tag>();
result.setNoneMatch(noneMatch);
}
noneMatch.add(current);
// Read the next token