001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.client; 007 008import static org.fcrepo.client.HeaderHelpers.UTC_RFC_1123_FORMATTER; 009import static org.fcrepo.client.FedoraHeaderConstants.MEMENTO_DATETIME; 010 011import java.net.URI; 012import java.time.Instant; 013 014/** 015 * Builds a POST request for creating a memento (LDPRm) with the state given in the request body 016 * and the datetime given in the Memento-Datetime request header. 017 * 018 * @author bbpennel 019 */ 020public class HistoricMementoBuilder extends PostBuilder { 021 022 /** 023 * Instantiate builder 024 * 025 * @param uri uri of the resource this request is being made to 026 * @param client the client 027 * @param mementoInstant Instant to use for the memento-datetime 028 */ 029 public HistoricMementoBuilder(final URI uri, final FcrepoClient client, final Instant mementoInstant) { 030 super(uri, client); 031 final String rfc1123Datetime = UTC_RFC_1123_FORMATTER.format(mementoInstant); 032 request.setHeader(MEMENTO_DATETIME, rfc1123Datetime); 033 } 034 035 /** 036 * Instantiate builder. 037 * 038 * @param uri uri of the resource this request is being made to 039 * @param client the client 040 * @param mementoDatetime RFC1123 formatted date to use for the memento-datetime 041 */ 042 public HistoricMementoBuilder(final URI uri, final FcrepoClient client, final String mementoDatetime) { 043 super(uri, client); 044 // Parse the datetime to ensure that it is in RFC1123 format 045 UTC_RFC_1123_FORMATTER.parse(mementoDatetime); 046 request.setHeader(MEMENTO_DATETIME, mementoDatetime); 047 } 048}