package jetbrains.buildServer.serverSide; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import jetbrains.buildServer.controllers.BaseController; import jetbrains.buildServer.web.openapi.SimpleWebExtension; import jetbrains.buildServer.web.openapi.WebControllerManager; import jetbrains.buildServer.web.openapi.WebPlace; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.RedirectView; public class SettingsController extends BaseController implements JokeSettings { private boolean myEnabled; public SettingsController(final SBuildServer server, final WebControllerManager manager) { super(server); manager.registerController("/admin/aprilJokeSettings.html", this); SimpleWebExtension extension = new SimpleWebExtension(manager) { public void fillModel(final Map model, @NotNull final HttpServletRequest request) { super.fillModel(model, request); model.put("jokeSettings", SettingsController.this); } }; extension.setPluginName(JokeSettings.PLUGIN_NAME); extension.setPlace(WebPlace.ADMIN_SERVER_CONFIGURATION); extension.setJspPath("settings.jsp"); extension.register(); } @Nullable protected ModelAndView doHandle(final HttpServletRequest request, final HttpServletResponse response) throws Exception { if (request.getParameter("enabled") != null) { myEnabled = Boolean.valueOf(request.getParameter("enabled")); } return new ModelAndView(new RedirectView("/admin/serverConfig.html", true)); } public boolean isEnabled() { return myEnabled; } }