private static CreateEventRequest toAddEventRequest(Request request) { return CreateEventRequest.builder() .setAnalysis(request.mandatoryParam(PARAM_ANALYSIS)) .setName(request.mandatoryParam(PARAM_NAME)) .setCategory(request.mandatoryParamAsEnum(PARAM_CATEGORY, EventCategory.class)) .build(); }
@Override public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn(); HomepageTypes.Type type = request.mandatoryParamAsEnum(PARAM_TYPE, HomepageTypes.Type.class); String componentParameter = request.param(PARAM_COMPONENT); String organizationParameter = request.param(PARAM_ORGANIZATION); try (DbSession dbSession = dbClient.openSession(false)) { String parameter = getHomepageParameter(dbSession, type, componentParameter, request.param(PARAM_BRANCH), organizationParameter); UserDto user = dbClient.userDao().selectActiveUserByLogin(dbSession, userSession.getLogin()); checkState(user != null, "User login '%s' cannot be found", userSession.getLogin()); user.setHomepageType(type.name()); user.setHomepageParameter(parameter); dbClient.userDao().update(dbSession, user); dbSession.commit(); } response.noContent(); }
@Override public void handle(final Request request, final Response response) throws Exception { if (this.settings.getBoolean(BadgesPluginProperties.CE_ACTIVITY_BADGES_ACTIVATION_KEY)) { final String key = request.mandatoryParam("key"); final SVGImageTemplate template = request.mandatoryParamAsEnum("template", SVGImageTemplate.class); final boolean blinkingValueBackgroundColor = request.mandatoryParamAsBoolean("blinking"); LOGGER.debug("Retrieving compute engine activity status for key '{}'.", key); final CeActivityBadge ceActivityBadge = retrieveCeActivityBadge(request, key); // we prepare the response OutputStream final OutputStream responseOutputStream = response.stream() .setMediaType("image/svg+xml") .output(); LOGGER.debug("Retrieving SVG image for for compute engine activity '{}'.", ceActivityBadge); final InputStream svgImageInputStream = this.ceActivityBadgeGenerator.svgImageInputStreamFor(ceActivityBadge, template, blinkingValueBackgroundColor); LOGGER.debug("Writing SVG image to response OutputStream."); IOUtils.copy(svgImageInputStream, responseOutputStream); responseOutputStream.close(); // don't close svgImageInputStream, we want it to be reusable } else { LOGGER.warn("Received a compute engine activity badge request, but webservice is turned off."); response.noContent(); } }
final String key = request.mandatoryParam("key"); final String metric = request.mandatoryParam("metric"); final SVGImageTemplate template = request.mandatoryParamAsEnum("template", SVGImageTemplate.class); final boolean blinkingValueBackgroundColor = request.mandatoryParamAsBoolean("blinking"); final WsClient wsClient = WsClientFactories.getLocal()
private static CreateEventRequest toAddEventRequest(Request request) { return CreateEventRequest.builder() .setAnalysis(request.mandatoryParam(PARAM_ANALYSIS)) .setName(request.mandatoryParam(PARAM_NAME)) .setCategory(request.mandatoryParamAsEnum(PARAM_CATEGORY, EventCategory.class)) .build(); }
if (this.settings.getBoolean(BadgesPluginProperties.GATE_BADGES_ACTIVATION_KEY)) { final String key = request.mandatoryParam("key"); final SVGImageTemplate template = request.mandatoryParamAsEnum("template", SVGImageTemplate.class); final boolean blinkingValueBackgroundColor = request.mandatoryParamAsBoolean("blinking"); final WsClient wsClient = WsClientFactories.getLocal()
@Override public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn(); HomepageTypes.Type type = request.mandatoryParamAsEnum(PARAM_TYPE, HomepageTypes.Type.class); String componentParameter = request.param(PARAM_COMPONENT); String organizationParameter = request.param(PARAM_ORGANIZATION); try (DbSession dbSession = dbClient.openSession(false)) { String parameter = getHomepageParameter(dbSession, type, componentParameter, request.param(PARAM_BRANCH), organizationParameter); UserDto user = dbClient.userDao().selectActiveUserByLogin(dbSession, userSession.getLogin()); checkState(user != null, "User login '%s' cannot be found", userSession.getLogin()); user.setHomepageType(type.name()); user.setHomepageParameter(parameter); dbClient.userDao().update(dbSession, user); dbSession.commit(); } response.noContent(); }