@Override public void handle(Request wsRequest, Response wsResponse) throws Exception { final ListResponse.Builder listResponseBuilder = ListResponse.newBuilder(); final ListResponse.Rule.Builder ruleBuilder = ListResponse.Rule.newBuilder(); try (DbSession dbSession = dbClient.openSession(false)) { dbClient.ruleDao().selectEnabled(dbSession, resultContext -> { RuleDefinitionDto dto = resultContext.getResultObject(); ruleBuilder .clear() .setRepository(dto.getRepositoryKey()) .setKey(dto.getRuleKey()) .setName(nullToEmpty(dto.getName())) .setInternalKey(nullToEmpty(dto.getConfigKey())); listResponseBuilder.addRules(ruleBuilder.build()); }); } // JSON response is voluntarily not supported. This WS is for internal use. wsResponse.stream().setMediaType(MediaTypes.PROTOBUF); listResponseBuilder.build().writeTo(wsResponse.stream().output()); }
@Override public void handle(Request wsRequest, Response wsResponse) throws Exception { final ListResponse.Builder listResponseBuilder = ListResponse.newBuilder(); final ListResponse.Rule.Builder ruleBuilder = ListResponse.Rule.newBuilder(); try (DbSession dbSession = dbClient.openSession(false)) { dbClient.ruleDao().selectEnabled(dbSession, resultContext -> { RuleDefinitionDto dto = resultContext.getResultObject(); ruleBuilder .clear() .setRepository(dto.getRepositoryKey()) .setKey(dto.getRuleKey()) .setName(nullToEmpty(dto.getName())) .setInternalKey(nullToEmpty(dto.getConfigKey())); listResponseBuilder.addRules(ruleBuilder.build()); }); } // JSON response is voluntarily not supported. This WS is for internal use. wsResponse.stream().setMediaType(MediaTypes.PROTOBUF); listResponseBuilder.build().writeTo(wsResponse.stream().output()); }