Skip to content

Commit

Permalink
Fix search actor paths in documentation; fix deserialization of Updat…
Browse files Browse the repository at this point in the history
…eThing.

Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Jun 12, 2022
1 parent d7cbff0 commit bc6b253
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ the same commands.

```json
{
"targetActorSelection": "/user/thingsSearchRoot/searchUpdaterRoot/backgroundSyncProxy",
"targetActorSelection": "/user/thingsWildcardSearchRoot/searchUpdaterRoot/backgroundSyncProxy",
"headers": {
"aggregate": false,
"is-grouped-topic": true
Expand Down Expand Up @@ -924,7 +924,7 @@ for a particular thing by a DevOp-command and bring the entry up-to-date immedia

```json
{
"targetActorSelection": "/user/thingsSearchRoot/searchUpdaterRoot/thingsUpdater",
"targetActorSelection": "/user/thingsWildcardSearchRoot/searchUpdaterRoot/thingsUpdater",
"headers": {
"aggregate": false,
"is-grouped-topic": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ public static UpdateThing of(final ThingId thingId,
* "thingId".
*/
public static UpdateThing fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
return of(
ThingId.of(jsonObject.getValueOrThrow(JSON_THING_ID)),
jsonObject.getValueOrThrow(JSON_INVALIDATE_THING),
jsonObject.getValueOrThrow(JSON_INVALIDATE_POLICY),
UpdateReason.valueOf(jsonObject.getValueOrThrow(JSON_UPDATE_REASON)),
dittoHeaders
);
final UpdateReason updateReason = jsonObject.getValue(JSON_UPDATE_REASON)
.map(UpdateThing::updateReasonFromString)
.orElse(UpdateReason.UNKNOWN);
final boolean invalidateThing = jsonObject.getValue(JSON_INVALIDATE_THING).orElse(false);
final boolean invalidatePolicy = jsonObject.getValue(JSON_INVALIDATE_POLICY).orElse(false);
return of(ThingId.of(jsonObject.getValueOrThrow(JSON_THING_ID)), invalidateThing, invalidatePolicy,
updateReason, dittoHeaders);
}

@Override
Expand Down Expand Up @@ -241,4 +241,12 @@ public String toString() {
"]";
}

private static UpdateReason updateReasonFromString(final String name) {
try {
return UpdateReason.valueOf(name);
} catch (final IllegalArgumentException e) {
return UpdateReason.UNKNOWN;
}
}

}

0 comments on commit bc6b253

Please sign in to comment.