
nl.tweeenveertig.openstack.headers.object.conditional.IfUnmodifiedSince Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of joss Show documentation
Show all versions of joss Show documentation
Java Client library for OpenStack Storage (Swift)
package nl.tweeenveertig.openstack.headers.object.conditional;
import nl.tweeenveertig.openstack.exception.HttpStatusExceptionUtil;
import org.apache.http.HttpStatus;
import org.apache.http.impl.cookie.DateParseException;
import java.util.Date;
public class IfUnmodifiedSince extends AbstractIfSince {
public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
public IfUnmodifiedSince(Long milliseconds) {
super(milliseconds);
}
public IfUnmodifiedSince(String sinceDate) throws DateParseException {
super(sinceDate);
}
public IfUnmodifiedSince(Date date) {
super(date);
}
@Override
public void sinceAgainst(Date modificationDate) {
// Milliseconds are not supplied by the browser
if (getDate().getTime() / 1000 < modificationDate.getTime() / 1000) {
HttpStatusExceptionUtil.throwException(HttpStatus.SC_PRECONDITION_FAILED);
}
}
@Override
public String getHeaderName() {
return IF_UNMODIFIED_SINCE;
}
}