Search in sources :

Example 51 with Processor

use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceImpl method createProcessor.

@Override
public Processor createProcessor(String bridgeId, String customerId, ProcessorRequest processorRequest) {
    /* We cannot deploy Processors to a Bridge that is not Available */
    Bridge bridge = bridgesService.getReadyBridge(bridgeId, customerId);
    if (processorDAO.findByBridgeIdAndName(bridgeId, processorRequest.getName()) != null) {
        throw new AlreadyExistingItemException("Processor with name '" + processorRequest.getName() + "' already exists for bridge with id '" + bridgeId + "' for customer '" + customerId + "'");
    }
    Processor newProcessor = new Processor();
    Set<BaseFilter> requestedFilters = processorRequest.getFilters();
    String requestedTransformationTemplate = processorRequest.getTransformationTemplate();
    BaseAction requestedAction = processorRequest.getAction();
    ActionProvider actionProvider = actionProviderFactory.getActionProvider(requestedAction.getType());
    BaseAction resolvedAction = actionProviderFactory.resolve(requestedAction, bridge.getId(), customerId, newProcessor.getId());
    newProcessor.setName(processorRequest.getName());
    newProcessor.setSubmittedAt(ZonedDateTime.now());
    newProcessor.setStatus(ManagedResourceStatus.ACCEPTED);
    newProcessor.setBridge(bridge);
    newProcessor.setShardId(shardService.getAssignedShardId(newProcessor.getId()));
    ProcessorDefinition definition = new ProcessorDefinition(requestedFilters, requestedTransformationTemplate, requestedAction, resolvedAction);
    newProcessor.setDefinition(definitionToJsonNode(definition));
    LOGGER.info("Processor with id '{}' for customer '{}' on bridge '{}' has been marked for creation", newProcessor.getId(), newProcessor.getBridge().getCustomerId(), newProcessor.getBridge().getId());
    createProcessorConnectorEntity(newProcessor, actionProvider, resolvedAction);
    workManager.schedule(newProcessor);
    return newProcessor;
}
Also used : ActionProvider(com.redhat.service.bridge.actions.ActionProvider) Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) Bridge(com.redhat.service.bridge.manager.models.Bridge) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) AlreadyExistingItemException(com.redhat.service.bridge.infra.exceptions.definitions.user.AlreadyExistingItemException)

Example 52 with Processor

use of com.redhat.service.bridge.manager.models.Processor in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorsAPI method addProcessorToBridge.

@POST
@Path("{bridgeId}/processors")
public Response addProcessorToBridge(@PathParam("bridgeId") @NotEmpty String bridgeId, @ValidActionParams @Valid ProcessorRequest processorRequest) {
    String customerId = identityResolver.resolve(jwt);
    Processor processor = processorService.createProcessor(bridgeId, customerId, processorRequest);
    return Response.status(Response.Status.CREATED).entity(processorService.toResponse(processor)).build();
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

Processor (com.redhat.service.bridge.manager.models.Processor)52 Bridge (com.redhat.service.bridge.manager.models.Bridge)34 QuarkusTest (io.quarkus.test.junit.QuarkusTest)32 Test (org.junit.jupiter.api.Test)32 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)14 ConnectorEntity (com.redhat.service.bridge.manager.models.ConnectorEntity)9 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)7 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)6 QueryInfo (com.redhat.service.bridge.infra.models.QueryInfo)6 Transactional (javax.transaction.Transactional)6 Connector (com.openshift.cloud.api.connector.models.Connector)5 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)5 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)4 InternalPlatformException (com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException)4 Work (com.redhat.service.bridge.manager.models.Work)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ZonedDateTime (java.time.ZonedDateTime)3 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)2 AlreadyExistingItemException (com.redhat.service.bridge.infra.exceptions.definitions.user.AlreadyExistingItemException)2 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)2