Search in sources :

Example 1 with MappingMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage in project sechub by mercedes-benz.

the class UpdateMappingService method sendEvent.

@IsSendingAsyncMessage(MessageID.MAPPING_CONFIGURATION_CHANGED)
private void sendEvent(Mapping mapping) {
    MappingMessage mappingMessage = new MappingMessage();
    mappingMessage.setMappingId(mapping.getId());
    mappingMessage.setMappingData(MappingData.fromString(mapping.getData()));
    DomainMessage request = DomainMessageFactory.createEmptyRequest(MessageID.MAPPING_CONFIGURATION_CHANGED);
    request.set(MessageDataKeys.CONFIG_MAPPING_DATA, mappingMessage);
    eventBus.sendAsynchron(request);
}
Also used : MappingMessage(com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 2 with MappingMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage in project sechub by mercedes-benz.

the class ScanMessageHandler method handleMappingConfigurationChanged.

@IsReceivingAsyncMessage(MessageID.MAPPING_CONFIGURATION_CHANGED)
@UseCaseAdmiUpdatesMappingConfiguration(@Step(number = 3, name = "Event handler", description = "Receives mapping configuration change event"))
private void handleMappingConfigurationChanged(DomainMessage request) {
    MappingMessage data = request.get(MessageDataKeys.CONFIG_MAPPING_DATA);
    String mappingId = data.getMappingId();
    MappingIdentifier found = MappingIdentifier.getIdentifierOrNull(mappingId);
    if (found == null) {
        LOG.error("Mapping identifier with id:{} does not exist!", mappingId);
        return;
    }
    /* filter only relevant parts - message may contain uninteresting stuff */
    if (!found.hasTypeContainedIn(MappingType.ADAPTER_CONFIGURATION, MappingType.COMMON_CONFIGURATION)) {
        LOG.debug("Mapping with id:{} is not relevant for cluster configuration and so ignored.", mappingId);
        return;
    }
    updateScanMappingService.updateScanMapping(mappingId, data.getMappingData());
}
Also used : MappingIdentifier(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier) MappingMessage(com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage) UseCaseAdmiUpdatesMappingConfiguration(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdmiUpdatesMappingConfiguration) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Aggregations

MappingMessage (com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage)2 MappingIdentifier (com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier)1 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)1 IsReceivingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)1 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)1 UseCaseAdmiUpdatesMappingConfiguration (com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdmiUpdatesMappingConfiguration)1