use of com.blackducksoftware.integration.fortify.batch.model.BlackDuckFortifyMapper 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());
}
use of com.blackducksoftware.integration.fortify.batch.model.BlackDuckFortifyMapper in project hub-fortify-ssc-integration-service by blackducksoftware.
the class MappingParser method createMapping.
/**
* Creates a list a mappingObject read from the mapping.json file
*
* @param filePath
* - Filepath to mapping.json
* @return List<BlackDuckForfifyMapper> Mapped objects with Fortify ID
* @throws IOException
* @throws IntegrationException
*/
public List<BlackDuckFortifyMapperGroup> createMapping(String filePath) throws JsonIOException, IOException, IntegrationException {
Gson gson;
List<BlackDuckFortifyMapper> mapping;
try {
gson = new Gson();
Type listType = new TypeToken<List<BlackDuckFortifyMapper>>() {
}.getType();
mapping = gson.fromJson(new FileReader(filePath), listType);
} catch (JsonIOException jio) {
logger.error("Exception occured while creating Mappings", jio);
throw new JsonIOException("Exception occured while creating Mappings", jio);
} catch (FileNotFoundException fe) {
logger.error("File Not Found for creating Mappings", fe);
throw new FileNotFoundException("Error finding the mapping.json file :: " + filePath);
}
return buildGroupedMappings(mapping);
}
Aggregations