Search in sources :

Example 1 with MappingIdentifier

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier in project sechub by mercedes-benz.

the class ScanConfigTestJSONasNamePatternDialogAction method resolveMappingIdentifier.

private MappingIdentifier resolveMappingIdentifier() {
    String mappingId = getMappingUI().getMappingId();
    MappingIdentifier identifier = MappingIdentifier.getIdentifierOrNull(mappingId);
    if (identifier == null) {
        throw new IllegalStateException("did not found a mapping identifier for :" + mappingId);
    }
    return identifier;
}
Also used : MappingIdentifier(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier)

Example 2 with MappingIdentifier

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier in project sechub by mercedes-benz.

the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method execute.

@Override
protected void execute(ActionEvent e) throws Exception {
    /* convert to rows */
    String json = getMappingUI().getJSON();
    MappingIdentifier identifier = resolveMappingIdentifier();
    ScanMappingConfiguration config = createScanConfig(json, identifier);
    DeveloperToolsScanMappingConfigurationService scanMappingConfigurationService = new DeveloperToolsScanMappingConfigurationService();
    scanMappingConfigurationService.switchConfigurationIfChanged(config);
    NamePatternIdProvider provider = scanMappingConfigurationService.getNamePatternIdProvider(identifier);
    boolean ongoing = true;
    while (ongoing) {
        /* ui */
        Optional<String> value = getDialogUI().getContext().getDialogUI().getUserInput("Enter a name to check", "pattern");
        if (!value.isPresent()) {
            return;
        }
        String pattern = value.get();
        String id = provider.getIdForName(pattern);
        ongoing = getDialogUI().getContext().getDialogUI().confirm("Pattern '" + pattern + "' results in '" + id + "'\n\nDo you want to test another value?");
    }
}
Also used : MappingIdentifier(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier) DeveloperToolsScanMappingConfigurationService(com.mercedesbenz.sechub.domain.scan.config.DeveloperToolsScanMappingConfigurationService) NamePatternIdProvider(com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider) ScanMappingConfiguration(com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration)

Example 3 with MappingIdentifier

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier in project sechub by mercedes-benz.

the class MappingIdentifierTest method hasTypeContainedIn_works.

@Test
public void hasTypeContainedIn_works() {
    MappingIdentifier adapterConfigId = CHECKMARX_NEWPROJECT_TEAM_ID;
    assertTrue(adapterConfigId.hasTypeContainedIn(MappingType.PRODUCT_EXECUTOR_CONFIGURATION_PARAMETER));
    assertTrue(adapterConfigId.hasTypeContainedIn(MappingType.COMMON_CONFIGURATION, MappingType.PRODUCT_EXECUTOR_CONFIGURATION_PARAMETER));
    assertTrue(adapterConfigId.hasTypeContainedIn(MappingType.PRODUCT_EXECUTOR_CONFIGURATION_PARAMETER, MappingType.COMMON_CONFIGURATION));
    assertTrue(adapterConfigId.hasTypeContainedIn(MappingType.PRODUCT_EXECUTOR_CONFIGURATION_PARAMETER, MappingType.ADAPTER_CONFIGURATION));
    assertFalse(adapterConfigId.hasTypeContainedIn(MappingType.COMMON_CONFIGURATION));
    assertFalse(adapterConfigId.hasTypeContainedIn(MappingType.ADAPTER_CONFIGURATION));
    assertFalse(adapterConfigId.hasTypeContainedIn((MappingType[]) null));
    assertFalse(adapterConfigId.hasTypeContainedIn(new MappingType[] {}));
    assertFalse(adapterConfigId.hasTypeContainedIn(new MappingType[] { null }));
}
Also used : MappingType(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier.MappingType) MappingIdentifier(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier) Test(org.junit.Test)

Example 4 with MappingIdentifier

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier in project sechub by mercedes-benz.

the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method resolveMappingIdentifier.

private MappingIdentifier resolveMappingIdentifier() {
    String mappingId = getMappingUI().getMappingId();
    MappingIdentifier identifier = MappingIdentifier.getIdentifierOrNull(mappingId);
    if (identifier == null) {
        throw new IllegalStateException("did not found a mapping identifier for :" + mappingId);
    }
    return identifier;
}
Also used : MappingIdentifier(com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier)

Example 5 with MappingIdentifier

use of com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier 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

MappingIdentifier (com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier)6 DeveloperToolsScanConfigService (com.mercedesbenz.sechub.domain.scan.config.DeveloperToolsScanConfigService)1 DeveloperToolsScanMappingConfigurationService (com.mercedesbenz.sechub.domain.scan.config.DeveloperToolsScanMappingConfigurationService)1 NamePatternIdProvider (com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider)1 NamePatternIdprovider (com.mercedesbenz.sechub.domain.scan.config.NamePatternIdprovider)1 ScanConfig (com.mercedesbenz.sechub.domain.scan.config.ScanConfig)1 ScanMappingConfiguration (com.mercedesbenz.sechub.domain.scan.config.ScanMappingConfiguration)1 MappingType (com.mercedesbenz.sechub.sharedkernel.mapping.MappingIdentifier.MappingType)1 IsReceivingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)1 MappingMessage (com.mercedesbenz.sechub.sharedkernel.messaging.MappingMessage)1 UseCaseAdmiUpdatesMappingConfiguration (com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdmiUpdatesMappingConfiguration)1 Test (org.junit.Test)1