@Test public void lastModifiedAndEtagApply() { final DateTime now = DateTime.now(); final String etag = "foo-bar"; final NestedAttributesMap attributes = nestedAttributesMap(); attributes.child(Content.CONTENT).set(Content.P_LAST_MODIFIED, now.toDate()); attributes.child(Content.CONTENT).set(Content.P_ETAG, etag); Asset asset = mock(Asset.class); when(asset.attributes()).thenReturn(attributes); AttributesMap contentAttributes = new AttributesMap(); contentAttributes.set(Content.CONTENT_LAST_MODIFIED, now); contentAttributes.set(Content.CONTENT_ETAG, etag); Content.applyToAsset(asset, contentAttributes); assertThat(asset.attributes().child(Content.CONTENT).get(Content.P_LAST_MODIFIED, Date.class), equalTo(now.toDate())); assertThat(asset.attributes().child(Content.CONTENT).get(Content.P_ETAG, String.class), equalTo( etag)); }
public static void applyToAsset(final Asset asset, final AttributesMap contentAttributes) { checkNotNull(asset); checkNotNull(contentAttributes); final NestedAttributesMap assetAttributes = asset.attributes().child(CONTENT); assetAttributes.set(P_LAST_MODIFIED, toDate(contentAttributes.get(Content.CONTENT_LAST_MODIFIED, DateTime.class))); assetAttributes.set(P_ETAG, contentAttributes.get(Content.CONTENT_ETAG, String.class)); final CacheInfo cacheInfo = contentAttributes.get(CacheInfo.class); if (cacheInfo != null) { CacheInfo.applyToAsset(asset, cacheInfo); } }
Content implements Payload { public static void applyToAsset(final Asset asset, final AttributesMap contentAttributes) { checkNotNull(asset); checkNotNull(contentAttributes); final NestedAttributesMap assetAttributes = asset.attributes().child(CONTENT); assetAttributes.set(P_LAST_MODIFIED, toDate(contentAttributes.get(Content.CONTENT_LAST_MODIFIED, DateTime.class))); assetAttributes.set(P_ETAG, contentAttributes.get(Content.CONTENT_ETAG, String.class)); final CacheInfo cacheInfo = contentAttributes.get(CacheInfo.class); if (cacheInfo != null) { CacheInfo.applyToAsset(asset, cacheInfo); } } }
Content implements Payload { public static void applyToAsset(final Asset asset, final AttributesMap contentAttributes) { checkNotNull(asset); checkNotNull(contentAttributes); final NestedAttributesMap assetAttributes = asset.attributes().child(CONTENT); assetAttributes.set(P_LAST_MODIFIED, toDate(contentAttributes.get(Content.CONTENT_LAST_MODIFIED, DateTime.class))); assetAttributes.set(P_ETAG, contentAttributes.get(Content.CONTENT_ETAG, String.class)); final CacheInfo cacheInfo = contentAttributes.get(CacheInfo.class); if (cacheInfo != null) { CacheInfo.applyToAsset(asset, cacheInfo); } } Content(final Payload payload); protected  Content(final Payload payload, final AttributesMap attributes); }
Content implements Payload { public static void applyToAsset(final Asset asset, final AttributesMap contentAttributes) { checkNotNull(asset); checkNotNull(contentAttributes); final NestedAttributesMap assetAttributes = asset.attributes().child(CONTENT); assetAttributes.set(P_LAST_MODIFIED, toDate(contentAttributes.get(Content.CONTENT_LAST_MODIFIED, DateTime.class))); assetAttributes.set(P_ETAG, contentAttributes.get(Content.CONTENT_ETAG, String.class)); final CacheInfo cacheInfo = contentAttributes.get(CacheInfo.class); if (cacheInfo != null) { CacheInfo.applyToAsset(asset, cacheInfo); } } Content(final Payload payload); protected  Content(final Payload payload, final AttributesMap attributes); @Override InputStream openInputStream(); @Override long getSize(); @Nullable @Override String getContentType(); @Override void close(); @Override void copy(final InputStream inputStream, final OutputStream outputStream); @Nonnull AttributesMap getAttributes(); @Override String toString(); static void extractFromAsset(final Asset asset,
                                      final Iterable<HashAlgorithm> hashAlgorithms,
                                      final AttributesMap contentAttributes); static void applyToAsset(final Asset asset, final AttributesMap contentAttributes); @Nullable static Asset findAsset(final StorageTx tx, final Bucket bucket, Content content); @Nonnull static AttributesMap maintainLastModified(final Asset asset,
                                                   @Nullable final AttributesMap contentAttributes); }
Content implements Payload { public static void applyToAsset(final Asset asset, final AttributesMap contentAttributes) { checkNotNull(asset); checkNotNull(contentAttributes); final NestedAttributesMap assetAttributes = asset.attributes().child(CONTENT); assetAttributes.set(P_LAST_MODIFIED, toDate(contentAttributes.get(Content.CONTENT_LAST_MODIFIED, DateTime.class))); assetAttributes.set(P_ETAG, contentAttributes.get(Content.CONTENT_ETAG, String.class)); final CacheInfo cacheInfo = contentAttributes.get(CacheInfo.class); if (cacheInfo != null) { CacheInfo.applyToAsset(asset, cacheInfo); } } Content(final Payload payload); protected  Content(final Payload payload, final AttributesMap attributes); @Override InputStream openInputStream(); @Override long getSize(); @Nullable @Override String getContentType(); @Override void close(); @Override void copy(final InputStream inputStream, final OutputStream outputStream); @Nonnull AttributesMap getAttributes(); @Override String toString(); static void extractFromAsset(final Asset asset,
                                      final Iterable<HashAlgorithm> hashAlgorithms,
                                      final AttributesMap contentAttributes); static void applyToAsset(final Asset asset, final AttributesMap contentAttributes); @Nullable static Asset findAsset(final StorageTx tx, final Bucket bucket, Content content); @Nonnull static AttributesMap maintainLastModified(final Asset asset,
                                                   @Nullable final AttributesMap contentAttributes); @VisibleForTesting
  static final String CONTENT; static final String CONTENT_LAST_MODIFIED; static final String CONTENT_ETAG; static final String CONTENT_HASH_CODES_MAP; static final TypeToken<Map<HashAlgorithm, HashCode>> T_CONTENT_HASH_CODES_MAP; @VisibleForTesting
  static final String P_LAST_MODIFIED; @VisibleForTesting
  static final String P_ETAG; }