0

I have an authorization filter. While trying to retrieve pathparameters, I am unable to get the values. could someone please tell me, what is wrong with the below code.

@AuthorizedAccess  //named exception
@Provider
public class AuthorizedAccessFilter implements ContainerRequestFilter {

/** The Constant logger. */
private final static Logger logger = LoggerFactory.getLogger(AuthorizedAccessFilter.class);


public void filter(ContainerRequestContext requestContext) {

        logger.info(AUTH_MESSAGE, requestContext.getUriInfo().getAbsolutePath());
        MultivaluedMap<String, String> pathParameters = requestContext.getUriInfo().getPathParameters();
        for (Entry<String, List<String>> e : pathParameters.entrySet()) {
            logger.info( " key :value " +e.getKey(), e.getValue());
        }
        logger.info("pathparammap = {} ",pathParameters.size());

 }

and it returns: it returns key name but it doesn't return the value.

AuthorizedAccessFilter  -  key value entity-id
AuthorizedAccessFilter  - pathparammap = 1 
Irshad
  • 1,016
  • 11
  • 30

1 Answers1

1

Well it looks like a simple incorrect format (1-st argument) in logger. You need to specify at least one {} that would be replaced with value of 2-nd logger.info argument

logger.info( " key :value {}" + e.getKey(), e.getValue());
or 
logger.info( " key :value {} {}" , e.getKey() , e.getValue());

Also take a look at SLF4J documentation

varren
  • 14,551
  • 2
  • 41
  • 72