fix(outbound): wire rulesReferencing to AlertRuleRepository (Plan 01 gate)
Replaces the Plan 01 stub that returned [] with a real call through AlertRuleRepository.findRuleIdsByOutboundConnectionId. Adds AlertingBeanConfig exposing the AlertRuleRepository bean; widens OutboundBeanConfig constructor to inject it. Delete and narrow-envs guards now correctly block when rules reference a connection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.cameleer.server.app.alerting.config;
|
||||
|
||||
import com.cameleer.server.app.alerting.storage.PostgresAlertRuleRepository;
|
||||
import com.cameleer.server.core.alerting.AlertRuleRepository;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
@Configuration
|
||||
public class AlertingBeanConfig {
|
||||
|
||||
@Bean
|
||||
public AlertRuleRepository alertRuleRepository(JdbcTemplate jdbc, ObjectMapper om) {
|
||||
return new PostgresAlertRuleRepository(jdbc, om);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.cameleer.server.app.outbound;
|
||||
|
||||
import com.cameleer.server.core.alerting.AlertRuleRepository;
|
||||
import com.cameleer.server.core.outbound.OutboundConnection;
|
||||
import com.cameleer.server.core.outbound.OutboundConnectionRepository;
|
||||
import com.cameleer.server.core.outbound.OutboundConnectionService;
|
||||
@@ -13,10 +14,15 @@ import java.util.UUID;
|
||||
public class OutboundConnectionServiceImpl implements OutboundConnectionService {
|
||||
|
||||
private final OutboundConnectionRepository repo;
|
||||
private final AlertRuleRepository ruleRepo;
|
||||
private final String tenantId;
|
||||
|
||||
public OutboundConnectionServiceImpl(OutboundConnectionRepository repo, String tenantId) {
|
||||
public OutboundConnectionServiceImpl(
|
||||
OutboundConnectionRepository repo,
|
||||
AlertRuleRepository ruleRepo,
|
||||
String tenantId) {
|
||||
this.repo = repo;
|
||||
this.ruleRepo = ruleRepo;
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
@@ -91,8 +97,7 @@ public class OutboundConnectionServiceImpl implements OutboundConnectionService
|
||||
|
||||
@Override
|
||||
public List<UUID> rulesReferencing(UUID id) {
|
||||
// Plan 01 stub. Plan 02 will wire this to AlertRuleRepository.
|
||||
return List.of();
|
||||
return ruleRepo.findRuleIdsByOutboundConnectionId(id);
|
||||
}
|
||||
|
||||
private void assertNameUnique(String name, UUID excludingId) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.cameleer.server.app.outbound.config;
|
||||
import com.cameleer.server.app.outbound.OutboundConnectionServiceImpl;
|
||||
import com.cameleer.server.app.outbound.crypto.SecretCipher;
|
||||
import com.cameleer.server.app.outbound.storage.PostgresOutboundConnectionRepository;
|
||||
import com.cameleer.server.core.alerting.AlertRuleRepository;
|
||||
import com.cameleer.server.core.outbound.OutboundConnectionRepository;
|
||||
import com.cameleer.server.core.outbound.OutboundConnectionService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -29,7 +30,8 @@ public class OutboundBeanConfig {
|
||||
@Bean
|
||||
public OutboundConnectionService outboundConnectionService(
|
||||
OutboundConnectionRepository repo,
|
||||
AlertRuleRepository ruleRepo,
|
||||
@Value("${cameleer.server.tenant.id:default}") String tenantId) {
|
||||
return new OutboundConnectionServiceImpl(repo, tenantId);
|
||||
return new OutboundConnectionServiceImpl(repo, ruleRepo, tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user