/** * The entity path is currently only required for resources, which base their content hash on the resource type * path which can be specified using a relative or canonical path in the blueprint. For the content hash to be * consistent we need to convert to just a single representation of the path. * * @param entity the entity to produce the hash of * @param entityPath the canonical path of the entity (can be null for all but resources) * @return the content hash of the entity */ public static String of(Entity.Blueprint entity, CanonicalPath entityPath) { return ComputeHash.of(InventoryStructure.of(entity).build(), entityPath, false, true, false).getContentHash(); } }
private void addHashChangeNotifications(AbstractElement<?, ?> entity, Hashes newHashes, List<Notification<?, ?>> notifications) { DBG.debugf("Adding hash change notifications to entity %s", entity.getPath()); if (entity instanceof Syncable) { Syncable el = (Syncable) entity; if (!Objects.equals(el.getSyncHash(), newHashes.getSyncHash())) { notifications.add(new Notification<>(el, el, syncHashChanged())); } } if (entity instanceof ContentHashable) { ContentHashable el = (ContentHashable) entity; if (!Objects.equals(el.getContentHash(), newHashes.getContentHash())) { notifications.add(new Notification<>(el, el, contentHashChanged())); } } if (entity instanceof IdentityHashable) { IdentityHashable el = (IdentityHashable) entity; if (!Objects.equals(el.getIdentityHash(), newHashes.getIdentityHash())) { notifications.add(new Notification<>(el, el, identityHashChanged())); } } }
@Override public void updateHashes(Element entity, Hashes hashes) { setNonNullProperty(entity, Constants.Property.__contentHash.name(), hashes.getContentHash()); setNonNullProperty(entity, Constants.Property.__syncHash.name(), hashes.getSyncHash()); updateIdentityHash(entity, hashes.getIdentityHash()); }