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 {
10 private final NameProviderService nameProviderService;
11
12 public MessageInterceptor(NameProviderService nameProviderService)
13 {
14 this.nameProviderService = nameProviderService;
15 }
16
17 public void intercept(MethodInvocation invocation) throws IllegalAccessException, InvocationTargetException
18 {
19 invocation.invoke();
20 final Message message = (Message) invocation.getHttpContext().getResponse().getEntity();
21 message.setMessage(message.getMessage() + ": " + nameProviderService.getName());
22 }
23 }