use of com.blackducksoftware.integration.fortify.batch.model.BlackDuckFortifyMapperGroup in project hub-fortify-ssc-integration-service by blackducksoftware.
the class Initializer method execute.
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
logger.info("Started MappingParserTask");
// Delete the files that are error out in previous run
Arrays.stream(new File(propertyConstants.getReportDir()).listFiles()).forEach(File::delete);
logger.debug("Found Mapping file:: " + propertyConstants.getMappingJsonPath());
// Create the mapping between Hub and Fortify
final List<BlackDuckFortifyMapperGroup> groupMap = mappingParser.createMapping(propertyConstants.getMappingJsonPath());
logger.info("blackDuckFortifyMappers :" + groupMap.toString());
// Create the threads for parallel processing
ExecutorService exec = Executors.newFixedThreadPool(propertyConstants.getMaximumThreadSize());
List<Future<?>> futures = new ArrayList<>(groupMap.size());
for (BlackDuckFortifyMapperGroup blackDuckFortifyMapperGroup : groupMap) {
futures.add(exec.submit(new BlackDuckFortifyPushThread(blackDuckFortifyMapperGroup, hubServices, fortifyFileTokenApi, fortifyUploadApi, propertyConstants)));
}
for (Future<?> f : futures) {
// wait for a processor to complete
f.get();
}
jobStatus = true;
logger.info("After all threads processing");
return RepeatStatus.FINISHED;
}
use of com.blackducksoftware.integration.fortify.batch.model.BlackDuckFortifyMapperGroup in project hub-fortify-ssc-integration-service by blackducksoftware.
the class MappingParser method buildGroupedMappings.
/**
* This method, groups multiple Hub projects mapped to the same Fortify application.
*
* @param blackDuckFortifyMappers
* @return
* @throws IOException
* @throws IntegrationException
*/
private List<BlackDuckFortifyMapperGroup> buildGroupedMappings(List<BlackDuckFortifyMapper> blackDuckFortifyMappers) throws IOException, IntegrationException {
Map<String, BlackDuckFortifyMapperGroup> mappings = new HashMap<>();
try {
for (BlackDuckFortifyMapper blackDuckFortifyMapper : blackDuckFortifyMappers) {
int applicationId;
List<HubProjectVersion> hubProjectVersions = new ArrayList<>();
BlackDuckFortifyMapperGroup blackDuckFortifyMapperGroup;
HubProjectVersion hubProjectVersion = new HubProjectVersion(blackDuckFortifyMapper.getHubProject(), blackDuckFortifyMapper.getHubProjectVersion());
String key = blackDuckFortifyMapper.getFortifyApplication() + '_' + blackDuckFortifyMapper.getFortifyApplicationVersion();
if (mappings.containsKey(key)) {
blackDuckFortifyMapperGroup = mappings.get(key);
hubProjectVersions = blackDuckFortifyMapperGroup.getHubProjectVersion();
applicationId = blackDuckFortifyMapperGroup.getFortifyApplicationId();
} else {
applicationId = getFortifyApplicationId(blackDuckFortifyMapper);
}
hubProjectVersions.add(hubProjectVersion);
blackDuckFortifyMapperGroup = new BlackDuckFortifyMapperGroup(blackDuckFortifyMapper.getFortifyApplication(), blackDuckFortifyMapper.getFortifyApplicationVersion(), hubProjectVersions, applicationId);
mappings.put(key, blackDuckFortifyMapperGroup);
}
} catch (IOException ioe) {
logger.error(ioe.getMessage(), ioe);
throw new IOException(ioe);
}
return new ArrayList<>(mappings.values());
}
Aggregations