/** * The object's eTag hash should match the parameter <code>eTag</code>. * * <p /> * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the payload */ public GetOptions ifETagMatches(String eTag) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()"); this.headers.put(IF_MATCH, String.format("\"%1$s\"", checkNotNull(eTag, "eTag"))); return this; }
/** * The object's eTag hash should match the parameter <code>eTag</code>. * * <p /> * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the payload */ public GetOptions ifETagMatches(String eTag) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()"); this.headers.put(IF_MATCH, String.format("\"%1$s\"", checkNotNull(eTag, "eTag"))); return this; }
/** * The object's eTag hash should match the parameter <code>eTag</code>. * * <p /> * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the payload */ public GetOptions ifETagMatches(String eTag) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()"); this.headers.put(IF_MATCH, String.format("\"%1$s\"", checkNotNull(eTag, "eTag"))); return this; }
/** * Only return the object if it hasn't changed since this time. * <p /> * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.headers.put(IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince"))); return this; }
/** * Only return the object if it hasn't changed since this time. * <p /> * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.headers.put(IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince"))); return this; }
/** * Only return the object if it hasn't changed since this time. * <p /> * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.headers.put(IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince"))); return this; }
/** * Only return the object if it hasn't changed since this time. * <p /> * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.headers.put(IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince"))); return this; }
/** * Only return the object if it hasn't changed since this time. * <p /> * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.headers.put(IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince"))); return this; }
/** * Only return the object if it hasn't changed since this time. * <p /> * Not compatible with {@link #ifETagDoesntMatch(String)} or {@link #ifModifiedSince(Date)} */ public GetOptions ifUnmodifiedSince(Date ifUnmodifiedSince) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifUnmodifiedSince()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifUnmodifiedSince()"); this.headers.put(IF_UNMODIFIED_SINCE, dateService.rfc822DateFormat(checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince"))); return this; }
/** * The object's eTag hash should match the parameter <code>eTag</code>. * * <p /> * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the payload */ public GetOptions ifETagMatches(String eTag) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()"); this.headers.put(IF_MATCH, maybeQuoteETag(checkNotNull(eTag, "eTag"))); return this; }
/** * The object's eTag hash should match the parameter <code>eTag</code>. * * <p /> * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the payload */ public GetOptions ifETagMatches(String eTag) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()"); this.headers.put(IF_MATCH, maybeQuoteETag(checkNotNull(eTag, "eTag"))); return this; }
/** * The object's eTag hash should match the parameter <code>eTag</code>. * * <p /> * Not compatible with {@link #ifETagDoesntMatch(byte[])} or {@link #ifModifiedSince(Date)} * * @param eTag * hash representing the payload */ public GetOptions ifETagMatches(String eTag) { checkArgument(getIfNoneMatch() == null, "ifETagDoesntMatch() is not compatible with ifETagMatches()"); checkArgument(getIfModifiedSince() == null, "ifModifiedSince() is not compatible with ifETagMatches()"); this.headers.put(IF_MATCH, maybeQuoteETag(checkNotNull(eTag, "eTag"))); return this; }
@Test public void testNullIfETagDoesntMatch() { GetOptions options = new GetOptions(); assertNull(options.getIfNoneMatch()); }
@Test public void testNullIfETagDoesntMatch() { GetOptions options = new GetOptions(); assertNull(options.getIfNoneMatch()); }
@Test public void testIfETagDoesntMatchStatic() { GetOptions options = ifETagDoesntMatch(etag); matchesHex(options.getIfNoneMatch()); }
@Test public void testIfETagDoesntMatchStatic() { GetOptions options = ifETagDoesntMatch(etag); matchesHex(options.getIfNoneMatch()); }
public GetOptions apply(org.jclouds.http.options.GetOptions[] from) { checkNotNull(from, "options"); org.jclouds.blobstore.options.GetOptions to = new org.jclouds.blobstore.options.GetOptions(); if (from.length != 0) { if (from[0].getIfMatch() != null) { to.ifETagMatches(from[0].getIfMatch().replace("\"", "")); } if (from[0].getIfModifiedSince() != null) { Date time = dateService.rfc822DateParse(from[0].getIfModifiedSince()); to.ifModifiedSince(time); } if (from[0].getIfNoneMatch() != null) { to.ifETagDoesntMatch(from[0].getIfNoneMatch().replace("\"", "")); } if (from[0].getIfUnmodifiedSince() != null) { Date time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince()); to.ifUnmodifiedSince(time); } for (String range : from[0].getRanges()) { String[] firstLast = range.split("\\-"); to.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); } } return to; }
@Test public void testIfETagDoesntMatch() { GetOptions options = new GetOptions(); options.ifETagDoesntMatch(etag); matchesHex(options.getIfNoneMatch()); }
@Test public void testIfETagDoesntMatch() { GetOptions options = new GetOptions(); options.ifETagDoesntMatch(etag); matchesHex(options.getIfNoneMatch()); }
public GetOptions apply(org.jclouds.http.options.GetOptions[] from) { checkNotNull(from, "options"); org.jclouds.blobstore.options.GetOptions to = new org.jclouds.blobstore.options.GetOptions(); if (from.length != 0) { if (from[0].getIfMatch() != null) { to.ifETagMatches(Strings2.replaceAll(from[0].getIfMatch(), '"', "")); } if (from[0].getIfModifiedSince() != null) { Date time = dateService.rfc822DateParse(from[0].getIfModifiedSince()); to.ifModifiedSince(time); } if (from[0].getIfNoneMatch() != null) { to.ifETagDoesntMatch(Strings2.replaceAll(from[0].getIfNoneMatch(), '"', "")); } if (from[0].getIfUnmodifiedSince() != null) { Date time = dateService.rfc822DateParse(from[0].getIfUnmodifiedSince()); to.ifUnmodifiedSince(time); } for (String range : from[0].getRanges()) { String[] firstLast = range.split("\\-"); to.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1])); } } return to; }