Source:
public Boolean markLastSeen(final InsightsLastSeen insightLastSeen) { final PrimaryKey key = new PrimaryKey(AttributeName.ACCOUNT_ID.shortName(), insightLastSeen.accountId); final AttributeUpdate attribute = new AttributeUpdate(insightLastSeen.seenCategory.name()); attribute.put(insightLastSeen.updatedUTC.getMillis()); final UpdateItemSpec updateItemSpec = new UpdateItemSpec() .withPrimaryKey("account_id", insightLastSeen.accountId) .withReturnValues(ReturnValue.ALL_NEW) .withUpdateExpression("set #category = :val1 , #account_last_updated = :val1") .withNameMap(new NameMap() .with("#category", insightLastSeen.seenCategory.name()) .with("#account_last_updated", AttributeName.LAST_UPDATED_UTC.shortName())) .withValueMap(new ValueMap() .withNumber(":val1", insightLastSeen.updatedUTC.getMillis())); final UpdateItemOutcome updatedItem = table.updateItem(updateItemSpec); final Item item = updatedItem.getItem(); if (!item.hasAttribute(insightLastSeen.seenCategory.name())) { LOGGER.error("error=mark-last-seen-insights-fail-insight-missing account_id={}", insightLastSeen.accountId); return false; } final long categoryUpdatedUTC = item.getLong(insightLastSeen.seenCategory.name()); final long accountUpdatedUTC = item.getLong(insightLastSeen.seenCategory.name()); if (categoryUpdatedUTC != insightLastSeen.updatedUTC.getMillis()) { LOGGER.error("error=mark-last-seen-insights-fail-wrong-timestamp account_id={}", insightLastSeen.accountId); return false; } if (accountUpdatedUTC != insightLastSeen.updatedUTC.getMillis()) { LOGGER.error("error=mark-last-seen-insights-fail-wrong-last-updated-timestamp account_id={}", insightLastSeen.accountId); return false; } return true; }

Target:
public Boolean markLastSeen(final InsightsLastSeen insightLastSeen) { final PrimaryKey key = new PrimaryKey(AttributeName.ACCOUNT_ID.shortName(), insightLastSeen.accountId); final AttributeUpdate attribute = new AttributeUpdate(insightLastSeen.seenCategory.name()); attribute.put(insightLastSeen.updatedUTC.getMillis()); final UpdateItemSpec updateItemSpec = new UpdateItemSpec() .withPrimaryKey("account_id", insightLastSeen.accountId) .withReturnValues(ReturnValue.ALL_NEW) .withUpdateExpression("set #category = :val1 , #account_last_updated = :val1") .withNameMap(new NameMap() .with("#category", insightLastSeen.seenCategory.name()) .with("#account_last_updated", AttributeName.LAST_UPDATED_UTC.shortName())) .withValueMap(new ValueMap() .withNumber(":val1", insightLastSeen.updatedUTC.getMillis())); final UpdateItemOutcome updatedItem = table.updateItem(updateItemSpec); final Item item = updatedItem.getItem(); if (!item.hasAttribute(insightLastSeen.seenCategory.name())) { LOGGER.error("error=mark-last-seen-insights-fail-insight-missing account_id={}", insightLastSeen.accountId); return false; } final long updatedUTC = item.getLong(insightLastSeen.seenCategory.name()); if (updatedUTC != insightLastSeen.updatedUTC.getMillis()) { LOGGER.error("error=mark-last-seen-insights-fail-wrong-timestamp account_id={}", insightLastSeen.accountId); return false; } if (updatedUTC!= insightLastSeen.updatedUTC.getMillis()) { LOGGER.error("error=mark-last-seen-insights-fail-wrong-last-updated-timestamp account_id={}", insightLastSeen.accountId); return false; } return true; }