use of com.redhat.cloud.notifications.models.EndpointProperties in project notifications-backend by RedHatInsights.
the class EndpointRepository method loadTypedProperties.
private <T extends EndpointProperties> void loadTypedProperties(Class<T> typedEndpointClass, Set<Endpoint> endpoints, EndpointType type) {
Map<UUID, Endpoint> endpointsMap = endpoints.stream().filter(e -> e.getType().equals(type)).collect(Collectors.toMap(Endpoint::getId, Function.identity()));
if (endpointsMap.size() > 0) {
String hql = "FROM " + typedEndpointClass.getSimpleName() + " WHERE id IN (:endpointIds)";
List<T> propList = statelessSessionFactory.getCurrentSession().createQuery(hql, typedEndpointClass).setParameter("endpointIds", endpointsMap.keySet()).getResultList();
for (T props : propList) {
if (props != null) {
Endpoint endpoint = endpointsMap.get(props.getId());
endpoint.setProperties(props);
// Todo: NOTIF-429 backward compatibility change - Remove soon.
if (typedEndpointClass.equals(CamelProperties.class)) {
endpoint.getProperties(CamelProperties.class).setSubType(endpoint.getSubType());
}
}
}
}
}
use of com.redhat.cloud.notifications.models.EndpointProperties in project notifications-backend by RedHatInsights.
the class EndpointResource method deleteEndpoint.
@DELETE
@Path("/{id}")
@RolesAllowed(ConsoleIdentityProvider.RBAC_WRITE_INTEGRATIONS_ENDPOINTS)
@APIResponse(responseCode = "204", description = "The integration has been deleted", content = @Content(schema = @Schema(type = SchemaType.STRING)))
@Transactional
public Response deleteEndpoint(@Context SecurityContext sec, @PathParam("id") UUID id) {
RhIdPrincipal principal = (RhIdPrincipal) sec.getUserPrincipal();
EndpointType endpointType = endpointRepository.getEndpointTypeById(principal.getAccount(), id);
checkSystemEndpoint(endpointType);
if (obEnabled) {
Endpoint e = endpointRepository.getEndpoint(principal.getAccount(), id);
if (e != null) {
EndpointProperties properties = e.getProperties();
if (properties instanceof CamelProperties) {
CamelProperties cp = (CamelProperties) properties;
// Special case wrt OpenBridge
if (e.getSubType().equals("slack")) {
String processorId = cp.getExtras().get(OB_PROCESSOR_ID);
if (processorId != null) {
// Should not be null under normal operations.
try {
bridgeApiService.deleteProcessor(bridge.getId(), processorId, bridgeAuth.getToken());
} catch (Exception ex) {
LOGGER.warn("Removal of OB processor failed:" + ex.getMessage());
// Nothing more we can do
}
} else {
LOGGER.warn("ProcessorId was null for endpoint " + id.toString());
}
}
}
}
}
endpointRepository.deleteEndpoint(principal.getAccount(), id);
return Response.noContent().build();
}
Aggregations