All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.tweeenveertig.openstack.headers.object.conditional.IfUnmodifiedSince Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
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;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy