1 package com.atlassian.plugins.rest.interceptor;
2
3 import com.atlassian.plugins.rest.common.interceptor.MethodInvocation;
4 import com.atlassian.plugins.rest.common.interceptor.ResourceInterceptor;
5
6 import java.lang.reflect.InvocationTargetException;
7
8 public class MessageInterceptor implements ResourceInterceptor {
9 private final NameProviderService nameProviderService;
10
11 public MessageInterceptor(NameProviderService nameProviderService) {
12 this.nameProviderService = nameProviderService;
13 }
14
15 public void intercept(MethodInvocation invocation) throws IllegalAccessException, InvocationTargetException {
16 invocation.invoke();
17 final Message message = (Message) invocation.getHttpContext().getResponse().getEntity();
18 message.setMessage(message.getMessage() + ": " + nameProviderService.getName());
19 }
20 }