private void handleSyncThingResponse(final SudoRetrieveThingResponse response) { log.debug("Retrieved thing response='{}' for thing ID='{}' (attempt={}).", response, thingId, syncAttempts); final Thing syncedThing = response.getThing(); updateThingSearchIndex(syncedThing); }
private void handleSyncThingResponse(final SudoRetrieveThingResponse response) { log.debug("Retrieved thing response='{}' for thing ID='{}' (attempt={}).", response, thingId, syncAttempts); final Thing syncedThing = response.getThing(); updateThingSearchIndex(syncedThing); }
@Nullable private static Entry<Enforcer> handleSudoRetrieveThingResponse(final Object response) { if (response instanceof SudoRetrieveThingResponse) { final SudoRetrieveThingResponse sudoRetrieveThingResponse = (SudoRetrieveThingResponse) response; final Thing thing = sudoRetrieveThingResponse.getThing(); final Optional<AccessControlList> accessControlListOptional = thing.getAccessControlList(); if (accessControlListOptional.isPresent()) { final AccessControlList accessControlList = accessControlListOptional.get(); final long revision = thing.getRevision().map(ThingRevision::toLong) .orElseThrow(badThingResponse("no revision")); return Entry.of(revision, AclEnforcer.of(accessControlList)); } else { // The thing exists, but it has a policy. Remove entry from cache. return null; } } else if (response instanceof ThingNotAccessibleException) { return Entry.nonexistent(); } else { throw new IllegalStateException("expect SudoRetrieveThingResponse, got: " + response); } }
private static Entry<EntityId> handleSudoRetrieveThingResponse(final Object response) { if (response instanceof SudoRetrieveThingResponse) { final SudoRetrieveThingResponse sudoRetrieveThingResponse = (SudoRetrieveThingResponse) response; final Thing thing = sudoRetrieveThingResponse.getThing(); final String thingId = thing.getId().orElseThrow(badThingResponse("no ThingId")); final long revision = thing.getRevision().map(ThingRevision::toLong) .orElseThrow(badThingResponse("no revision")); final Optional<AccessControlList> accessControlListOptional = thing.getAccessControlList(); if (accessControlListOptional.isPresent()) { final EntityId resourceKey = EntityId.of(ThingCommand.RESOURCE_TYPE, thingId); return Entry.of(revision, resourceKey); } else { final String policyId = thing.getPolicyId().orElseThrow(badThingResponse("no PolicyId or ACL")); final EntityId resourceKey = EntityId.of(PolicyCommand.RESOURCE_TYPE, policyId); return Entry.of(revision, resourceKey); } } else if (response instanceof ThingNotAccessibleException) { return Entry.nonexistent(); } else { throw new IllegalStateException("expect SudoRetrieveThingResponse, got: " + response); } }