diff options
author | jbion <joffrey.bion@amadeus.com> | 2017-05-27 23:01:11 +0200 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2017-05-27 23:01:11 +0200 |
commit | cfb287f6d29c87e5a74fadeb2e027ece403485b0 (patch) | |
tree | 6d98c4f60cbe56763e8d361a54b34fead7d025f1 /backend/src/main/java | |
parent | Improve forbidden subscription exception message (diff) | |
download | seven-wonders-cfb287f6d29c87e5a74fadeb2e027ece403485b0.tar.gz seven-wonders-cfb287f6d29c87e5a74fadeb2e027ece403485b0.tar.bz2 seven-wonders-cfb287f6d29c87e5a74fadeb2e027ece403485b0.zip |
Remove ForbiddenSubscriptionException
The exception was not processed by the ExceptionHandler anyway, so
nothing was sent to the user. We need to find a way to send an error to
the user. In the meantime, an error log will suffice.
Diffstat (limited to 'backend/src/main/java')
-rw-r--r-- | backend/src/main/java/org/luxons/sevenwonders/config/TopicSubscriptionInterceptor.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/backend/src/main/java/org/luxons/sevenwonders/config/TopicSubscriptionInterceptor.java b/backend/src/main/java/org/luxons/sevenwonders/config/TopicSubscriptionInterceptor.java index 27f3bd24..855b7800 100644 --- a/backend/src/main/java/org/luxons/sevenwonders/config/TopicSubscriptionInterceptor.java +++ b/backend/src/main/java/org/luxons/sevenwonders/config/TopicSubscriptionInterceptor.java @@ -1,7 +1,8 @@ package org.luxons.sevenwonders.config; -import org.luxons.sevenwonders.errors.ApiMisuseException; import org.luxons.sevenwonders.validation.DestinationAccessValidator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -13,6 +14,8 @@ import org.springframework.stereotype.Component; @Component public class TopicSubscriptionInterceptor extends ChannelInterceptorAdapter { + private static final Logger logger = LoggerFactory.getLogger(TopicSubscriptionInterceptor.class); + private final DestinationAccessValidator destinationAccessValidator; @Autowired @@ -27,16 +30,14 @@ public class TopicSubscriptionInterceptor extends ChannelInterceptorAdapter { String username = headerAccessor.getUser().getName(); String destination = headerAccessor.getDestination(); if (!destinationAccessValidator.hasAccess(username, destination)) { - throw new ForbiddenSubscriptionException(username, destination); + sendForbiddenSubscriptionError(username, destination); + return null; } } return message; } - private static class ForbiddenSubscriptionException extends ApiMisuseException { - - ForbiddenSubscriptionException(String username, String destination) { - super(String.format("Player '%s' is not allowed to access %s", username, destination)); - } + private void sendForbiddenSubscriptionError(String username, String destination) { + logger.error(String.format("Player '%s' is not allowed to access %s", username, destination)); } } |