use of com.redhat.service.smartevents.manager.models.Processor 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()));
}
if (ManagedResourceStatus.DELETED == processorDTO.getStatus()) {
p.setStatus(ManagedResourceStatus.DELETED);
processorDAO.deleteById(processorDTO.getId());
metricsService.onOperationComplete(p, MetricsOperation.DELETE);
return p;
}
boolean provisioningCallback = p.getStatus() == ManagedResourceStatus.PROVISIONING;
p.setStatus(processorDTO.getStatus());
if (ManagedResourceStatus.READY == processorDTO.getStatus()) {
if (provisioningCallback) {
if (p.getPublishedAt() == null) {
p.setPublishedAt(ZonedDateTime.now());
metricsService.onOperationComplete(p, MetricsOperation.PROVISION);
} else {
metricsService.onOperationComplete(p, MetricsOperation.MODIFY);
}
}
}
return p;
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method getProcessor.
@Transactional
@Override
public Processor getProcessor(String bridgeId, String processorId, String customerId) {
Bridge bridge = bridgesService.getBridge(bridgeId, customerId);
Processor processor = processorDAO.findByIdBridgeIdAndCustomerId(bridge.getId(), processorId, 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.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorsAPI method getProcessor.
@APIResponses(value = { @APIResponse(description = "Success.", responseCode = "200", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ProcessorResponse.class))), @APIResponse(description = "Bad request.", responseCode = "400", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Unauthorized.", responseCode = "401"), @APIResponse(description = "Forbidden.", responseCode = "403"), @APIResponse(description = "Not found.", responseCode = "404", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Internal error.", responseCode = "500", content = @Content(mediaType = MediaType.APPLICATION_JSON)) })
@Operation(summary = "Get a Processor of a Bridge instance", description = "Get a Processor of a Bridge instance for the authenticated user.")
@GET
@Path("{bridgeId}/processors/{processorId}")
public Response getProcessor(@NotEmpty @PathParam("bridgeId") String bridgeId, @NotEmpty @PathParam("processorId") String processorId) {
String customerId = identityResolver.resolve(jwt);
Processor processor = processorService.getProcessor(bridgeId, processorId, customerId);
return Response.ok(processorService.toResponse(processor)).build();
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorsAPI method addProcessorToBridge.
@APIResponses(value = { @APIResponse(description = "Accepted.", responseCode = "202", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ProcessorResponse.class))), @APIResponse(description = "Bad request.", responseCode = "400", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Unauthorized.", responseCode = "401"), @APIResponse(description = "Forbidden.", responseCode = "403"), @APIResponse(description = "Not found.", responseCode = "404", content = @Content(mediaType = MediaType.APPLICATION_JSON)), @APIResponse(description = "Internal error.", responseCode = "500", content = @Content(mediaType = MediaType.APPLICATION_JSON)) })
@Operation(summary = "Create a Processor of a Bridge instance", description = "Create a Processor of a Bridge instance for the authenticated user.")
@POST
@Path("{bridgeId}/processors")
public Response addProcessorToBridge(@NotEmpty @PathParam("bridgeId") String bridgeId, @Valid ProcessorRequest processorRequest) {
String customerId = identityResolver.resolve(jwt);
String owner = identityResolver.resolveOwner(jwt);
Processor processor = processorService.createProcessor(bridgeId, customerId, owner, processorRequest);
return Response.accepted(processorService.toResponse(processor)).build();
}
use of com.redhat.service.smartevents.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorDAO method findByBridgeIdAndCustomerId.
private ListResult<Processor> findByBridgeIdAndCustomerId(String bridgeId, String customerId, QueryProcessorResourceInfo queryInfo, Set<ProcessorType> restrictTypes) {
/*
* Unfortunately we can't rely on Panaches in-built Paging due the fetched join in our query
* for Processor e.g. join fetch p.bridge. Instead, we simply build a list of ids to fetch and then
* execute the join fetch as normal. So the workflow here is:
*
* - Count the number of Processors on a bridge. If > 0
* - Select the ids of the Processors that need to be retrieved based on the page/size requirements
* - Select the Processors in the list of ids, performing the fetch join of the Bridge
*/
// We don't consider filtering here; so this could be short-cut more but the additional code doesn't really make it worthwhile
Parameters p = Parameters.with(Bridge.CUSTOMER_ID_PARAM, customerId).and(Processor.BRIDGE_ID_PARAM, bridgeId);
Long processorCount = countProcessorsOnBridge(p);
if (processorCount == 0L) {
return new ListResult<>(emptyList(), queryInfo.getPageNumber(), processorCount);
}
ProcessorResults results = getProcessorIds(customerId, bridgeId, queryInfo, restrictTypes);
List<Processor> processors = find("#PROCESSOR.findByIds", Parameters.with(IDS_PARAM, results.ids)).list();
return new ListResult<>(processors, queryInfo.getPageNumber(), results.total);
}
Aggregations