package jetbrains.buildServer.usageStatistics.impl; import java.util.EventListener; import java.util.Map; import javax.servlet.http.HttpServletRequest; import jetbrains.buildServer.users.SUser; import jetbrains.buildServer.util.EventDispatcher; import jetbrains.buildServer.web.openapi.PagePlaces; import jetbrains.buildServer.web.openapi.PlaceId; import jetbrains.buildServer.web.openapi.PluginDescriptor; import jetbrains.buildServer.web.openapi.SimplePageExtension; import jetbrains.buildServer.web.util.SessionUser; import org.jetbrains.annotations.NotNull; /** * @author Maxim.Manuylov * Date: 5/23/12 */ public class GetRequestDetector extends SimplePageExtension { @NotNull private final EventDispatcher myDispatcher = EventDispatcher.create(Listener.class); public GetRequestDetector(@NotNull final PagePlaces pagePlaces, @NotNull final PluginDescriptor pluginDescriptor) { super(pagePlaces, PlaceId.ALL_PAGES_FOOTER, "getRequestProcessor", pluginDescriptor.getPluginResourcesPath("empty.jsp")); register(); } public void addListener(@NotNull final Listener listener) { myDispatcher.addListener(listener); } @Override public void fillModel(@NotNull final Map model, @NotNull final HttpServletRequest request) { if (isGet(request)) { SUser user = null; try { user = SessionUser.getUser(request); } catch (final Exception ignore) {} // TW-18334 if (user != null) { myDispatcher.getMulticaster().onGetRequest(request, user); } } } public static interface Listener extends EventListener { void onGetRequest(@NotNull HttpServletRequest request, @NotNull SUser user); } }