Skip to content

Commit

Permalink
Review: rename left over conciergeForwarder references to commandForw…
Browse files Browse the repository at this point in the history
…arder

Signed-off-by: David Schwilk <david.schwilk@bosch.io>
  • Loading branch information
DerSchwilk committed Jun 3, 2022
1 parent be02619 commit 06a229c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void testSignalEnrichment() {
@Test
public void testSignalEnrichmentWithPayloadMappedTargets() {
resetActorSystemWithCachingSignalEnrichmentProvider();
final TestProbe proxyActorProbe = TestProbe.apply("mockConciergeForwarder", actorSystem);
final TestProbe proxyActorProbe = TestProbe.apply("mockEdgeForwarder", actorSystem);
setUpProxyActor(proxyActorProbe.ref());

new TestKit(actorSystem) {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private MockProxyActor(final ActorRef notificationRecipient) {
}

/**
* Create a mock /connectivityRoot/conciergeForwarder actor that forwards everything to the last ActorRef message it
* Create a mock /connectivityRoot/edgeCommandForwarder actor that forwards everything to the last ActorRef message it
* received.
*
* @param actorSystem the actor system where the mock concierge forwarder is to be created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void succeedsWithMandatoryFields() {
}

@Test(expected = NullPointerException.class)
public void failWithMissingConciergeForwarder() {
public void failWithMissingCommandForwarder() {
system = ActorSystem.create();
SearchSource.newBuilder()
.dittoHeaders(DittoHeaders.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@
import org.eclipse.ditto.internal.utils.akka.logging.ThreadSafeDittoLoggingAdapter;
import org.eclipse.ditto.internal.utils.cacheloaders.EnforcementCacheKey;
import org.eclipse.ditto.internal.utils.cacheloaders.config.AskWithRetryConfig;
import org.eclipse.ditto.policies.api.Permission;
import org.eclipse.ditto.policies.model.ResourceKey;
import org.eclipse.ditto.policies.model.enforcers.Enforcer;
import org.eclipse.ditto.things.model.ThingConstants;

import akka.actor.ActorRef;
import akka.pattern.AskTimeoutException;

/**
* Contains self-type requirements for aspects of enforcer actor dealing with specific commands.
Expand Down Expand Up @@ -164,37 +159,6 @@ protected DittoInternalErrorException reportUnknownResponse(final String hint, f
return DittoInternalErrorException.newBuilder().dittoHeaders(dittoHeaders()).build();
}

/**
* Extend a signal by subject headers given with granted and revoked READ access.
* The subjects are provided by the given enforcer for the resource type {@link ThingConstants#ENTITY_TYPE}.
*
* @param signal the signal to extend.
* @param enforcer the enforcer.
* @return the extended signal.
*/
protected static <T extends Signal<T>> T addEffectedReadSubjectsToThingSignal(final Signal<T> signal,
final Enforcer enforcer) {

final var resourceKey = ResourceKey.newInstance(ThingConstants.ENTITY_TYPE, signal.getResourcePath());
final var authorizationSubjects = enforcer.getSubjectsWithUnrestrictedPermission(resourceKey, Permission.READ);
final var newHeaders = DittoHeaders.newBuilder(signal.getDittoHeaders())
.readGrantedSubjects(authorizationSubjects)
.build();

return signal.setDittoHeaders(newHeaders);
}

/**
* Check whether response or error from a future is {@code AskTimeoutException}.
*
* @param response response from a future.
* @param error error thrown in a future.
* @return whether either is {@code AskTimeoutException}.
*/
protected static boolean isAskTimeoutException(final Object response, @Nullable final Throwable error) {
return error instanceof AskTimeoutException || response instanceof AskTimeoutException;
}

/**
* @return the configuration of "ask with retry" pattern during enforcement.
*/
Expand Down Expand Up @@ -321,11 +285,4 @@ protected DittoHeaders dittoHeaders() {
return signal().getDittoHeaders();
}

/**
* @return the {@code ConciergeForwarderActor} reference
*/
protected ActorRef commandForwarder() {
return context.getCommandForwarder();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private Contextual(@Nullable final T message,
static <T extends WithDittoHeaders> Contextual<T> forActor(final ActorRef self,
final ActorSystem actorSystem,
final ActorRef pubSubMediator,
final ActorRef conciergeForwarder,
final ActorRef commandForwarder,
final AskWithRetryConfig askWithRetryConfig,
final ThreadSafeDittoLoggingAdapter log) {

Expand All @@ -100,7 +100,7 @@ static <T extends WithDittoHeaders> Contextual<T> forActor(final ActorRef self,
actorSystem.getScheduler(),
actorSystem.dispatchers().lookup(POLICY_ENFORCER_CACHE_DISPATCHER),
pubSubMediator,
conciergeForwarder,
commandForwarder,
askWithRetryConfig,
log,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private PlaceholderReferenceNotSupportedException notSupportedException(
* Creates a new {@link PolicyIdReferencePlaceholderResolver} responsible for resolving a policy id of a referenced
* entity.
*
* @param commandForwarderActor the ActorRef of the {@code ConciergeForwarderActor} which to ask for "retrieve"
* @param commandForwarderActor the ActorRef of the {@code EdgeCommandForwarderActor} which to ask for "retrieve"
* commands.
* @param askWithRetryConfig the configuration for the "ask with retry" pattern applied when asking for retrieves.
* @param actorSystem the actorSystem to load scheduler and dispatcher to use for the "ask with retry" pattern from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void setup() {
public void testOrdering() {
final var testKit = ACTOR_SYSTEM_RESOURCE.newTestKit();
final var pubSubProbe = ACTOR_SYSTEM_RESOURCE.newTestProbe();
final var conciergeForwarderProbe = ACTOR_SYSTEM_RESOURCE.newTestProbe();
final var commandForwarderProbe = ACTOR_SYSTEM_RESOURCE.newTestProbe();
final var receiver = ACTOR_SYSTEM_RESOURCE.newTestKit();
final var mockLogger = mock(ThreadSafeDittoLoggingAdapter.class);
doAnswer(invocation -> mockLogger).when(mockLogger).withCorrelationId(any(DittoHeaders.class));
Expand All @@ -70,7 +70,7 @@ public void testOrdering() {
final Contextual<WithDittoHeaders> baseContextual = Contextual.forActor(testKit.getRef(),
ACTOR_SYSTEM_RESOURCE.getActorSystem(),
pubSubProbe.ref(),
conciergeForwarderProbe.ref(),
commandForwarderProbe.ref(),
DefaultAskWithRetryConfig.of(ConfigFactory.empty(), "test"),
mockLogger);
final var thingId = ThingId.of("busy", "thing");
Expand Down

0 comments on commit 06a229c

Please sign in to comment.