/** * Returns the name. * * @return The name. */ @Override public String toString() { return getName(); } }
/** * Returns the name. * * @return The name. */ @Override public String toString() { return getName(); } }
CacheInfo( Instant lastModified, Tag tag ) { this.lastModified = lastModified; entity = tag.getName().split( "/" )[ 0 ]; }
/** * Returns tag formatted as an HTTP tag string. * * @return The formatted HTTP tag string. * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a> */ public String format() { if (getName().equals("*")) { return "*"; } final StringBuilder sb = new StringBuilder(); if (isWeak()) { sb.append("W/"); } return sb.append('"').append(getName()).append('"').toString(); }
/** * Returns tag formatted as an HTTP tag string. * * @return The formatted HTTP tag string. * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a> */ public String format() { if ("*".equals(getName())) { return "*"; } final StringBuilder sb = new StringBuilder(); if (isWeak()) { sb.append("W/"); } return sb.append('"').append(getName()).append('"').toString(); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * the equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { boolean result = (object != null) && (object instanceof Tag); if (result) { final Tag that = (Tag) object; if (checkWeakness) { result = (that.isWeak() == isWeak()); } if (result) { if (getName() == null) { result = (that.getName() == null); } else { result = getName().equals(that.getName()); } } } return result; }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * The equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { boolean result = (object != null) && (object instanceof Tag); if (result) { final Tag that = (Tag) object; if (checkWeakness) { result = (that.isWeak() == isWeak()); } if (result) { if (getName() == null) { result = (that.getName() == null); } else { result = getName().equals(that.getName()); } } } return result; }
/** * Returns tag formatted as an HTTP tag string. * * @return The formatted HTTP tag string. * @see <a * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP * Entity Tags</a> */ public String format() { if (getName().equals("*")) { return "*"; } final StringBuilder sb = new StringBuilder(); if (isWeak()) { sb.append("W/"); } return sb.append('"').append(getName()).append('"').toString(); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * The equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { if (!(object instanceof Tag)) { return false; } final Tag that = (Tag) object; if (checkWeakness && that.isWeak() != isWeak()) { return false; } return Objects.equals(getName(), that.getName()); }
/** * Converts a Restlet-EntityTag to a JAX-RS-EntityTag * * @param restletEntityTag * the Restlet-EntityTag to convert. * @return The corresponding JAX-RS-Entity-Tag */ public static EntityTag toJaxRsEntityTag(Tag restletEntityTag) { return (restletEntityTag == null) ? null : new EntityTag(restletEntityTag.getName(), restletEntityTag.isWeak()); }
@VisibleForTesting Representation renderStorageFileItem(final Request req, final StorageFileItem file) throws ResourceException { final StorageFileItemRepresentation fileRepresentation = new StorageFileItemRepresentation(file); if (file.getResourceStoreRequest().getIfModifiedSince() != 0 && file.getModified() <= file.getResourceStoreRequest().getIfModifiedSince()) { // this is a conditional GET using time-stamp throw new ResourceException(Status.REDIRECTION_NOT_MODIFIED, "Resource is not modified."); } else if (file.getResourceStoreRequest().getIfNoneMatch() != null && fileRepresentation.getTag() != null && file.getResourceStoreRequest().getIfNoneMatch().equals(fileRepresentation.getTag().getName())) { // this is a conditional GET using ETag throw new ResourceException(Status.REDIRECTION_NOT_MODIFIED, "Resource is not modified."); } else { return fileRepresentation; } }
return (entity != null && entity.getSize() != -1) ? Long.toString(entity.getSize()) : null; case "et": return (entity != null && entity.getTag() != null) ? entity.getTag().getName() : null; case "m": return (this.request.getMethod() != null) ? this.request.getMethod().getName() : null; return (entity != null && entity.getSize() != -1) ? Long.toString(entity.getSize()) : null; case "ET": return (entity != null && entity.getTag() != null) ? entity.getTag().getName() : null; case "S": return (status != null) ? Integer.toString(status.getCode()) : null;
result.setIfNoneMatch( tag.getName() );