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;
}
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?");
}
}
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 }));
}
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;
}
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());
}
Aggregations