use of com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method getProcessor.
@Transactional
@Override
public Processor getProcessor(String processorId, String bridgeId, String customerId) {
Bridge bridge = bridgesService.getBridge(bridgeId, customerId);
Processor processor = processorDAO.findByIdBridgeIdAndCustomerId(processorId, bridge.getId(), bridge.getCustomerId());
if (processor == null) {
throw new ItemNotFoundException(String.format("Processor with id '%s' does not exist on Bridge '%s' for customer '%s'", processorId, bridgeId, customerId));
}
return processor;
}
use of com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method doDeleteProcessor.
@Transactional
protected Processor doDeleteProcessor(String bridgeId, String processorId, String customerId) {
Processor processor = processorDAO.findByIdBridgeIdAndCustomerId(processorId, bridgeId, customerId);
if (processor == null) {
throw new ItemNotFoundException(String.format("Processor with id '%s' does not exist on bridge '%s' for customer '%s'", processorId, bridgeId, customerId));
}
processor.setStatus(ManagedResourceStatus.DEPROVISION);
LOGGER.info("Processor with id '{}' for customer '{}' on bridge '{}' has been marked for deletion", processor.getId(), processor.getBridge().getCustomerId(), processor.getBridge().getId());
connectorService.deleteConnectorEntity(processor);
return processor;
}
use of com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method updateProcessorStatus.
@Transactional
@Override
public Processor updateProcessorStatus(ProcessorDTO processorDTO) {
Bridge bridge = bridgesService.getBridge(processorDTO.getBridgeId());
Processor p = processorDAO.findById(processorDTO.getId());
if (p == null) {
throw new ItemNotFoundException(String.format("Processor with id '%s' does not exist for Bridge '%s' for customer '%s'", bridge.getId(), bridge.getCustomerId(), processorDTO.getCustomerId()));
}
p.setStatus(processorDTO.getStatus());
p.setModifiedAt(ZonedDateTime.now());
if (processorDTO.getStatus().equals(ManagedResourceStatus.DELETED)) {
processorDAO.deleteById(processorDTO.getId());
}
if (processorDTO.getStatus().equals(ManagedResourceStatus.READY) && Objects.isNull(p.getPublishedAt())) {
p.setPublishedAt(ZonedDateTime.now());
}
// Update metrics
meterRegistry.counter("manager.processor.status.change", Collections.singletonList(Tag.of("status", processorDTO.getStatus().toString()))).increment();
return p;
}
use of com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class SendToBridgeActionTransformerTest method beforeEach.
@BeforeEach
void beforeEach() {
reset(bridgesServiceMock);
when(bridgesServiceMock.getReadyBridge(BRIDGE_ID, TEST_CUSTOMER_ID)).thenReturn(bridge);
when(bridgesServiceMock.getReadyBridge(OTHER_BRIDGE_ID, TEST_CUSTOMER_ID)).thenReturn(otherBridge);
when(bridgesServiceMock.getReadyBridge(UNAVAILABLE_BRIDGE_ID, TEST_CUSTOMER_ID)).thenThrow(new BridgeLifecycleException("Unavailable bridge"));
when(bridgesServiceMock.getReadyBridge(not(or(eq(UNAVAILABLE_BRIDGE_ID), or(eq(BRIDGE_ID), eq(OTHER_BRIDGE_ID)))), eq(TEST_CUSTOMER_ID))).thenThrow(new ItemNotFoundException("Bridge not found"));
when(bridgesServiceMock.getReadyBridge(any(), not(eq(TEST_CUSTOMER_ID)))).thenThrow(new ItemNotFoundException("Customer not found"));
}
Aggregations