use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class RapidModeGenerateJsonOperation method generateJsonFile.
public File generateJsonFile(NameVersion projectNameVersion, List<DeveloperScanComponentResultView> results) throws DetectUserFriendlyException {
IntegrationEscapeUtil escapeUtil = new IntegrationEscapeUtil();
String escapedProjectName = escapeUtil.replaceWithUnderscore(projectNameVersion.getName());
String escapedProjectVersionName = escapeUtil.replaceWithUnderscore(projectNameVersion.getVersion());
File jsonScanFile = new File(directoryManager.getScanOutputDirectory(), escapedProjectName + "_" + escapedProjectVersionName + "_BlackDuck_DeveloperMode_Result.json");
if (jsonScanFile.exists()) {
try {
Files.delete(jsonScanFile.toPath());
} catch (IOException ex) {
logger.warn(String.format("Unable to delete an already-existing Black Duck Rapid Scan Result file: %s", jsonScanFile.getAbsoluteFile()));
// TODO: Uhm, ew. - jp
new Slf4jIntLogger(logger).error(ex);
}
}
String jsonString = gson.toJson(results);
logger.trace("Rapid Scan JSON result output: ");
logger.trace(String.format("%s", jsonString));
try {
DetectFileUtils.writeToFile(jsonScanFile, jsonString);
} catch (IOException ex) {
throw new DetectUserFriendlyException("Cannot create rapid scan output file", ex, ExitCodeType.FAILURE_UNKNOWN_ERROR);
}
return jsonScanFile;
}
use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class DockerAirGapCreator method installDockerDependencies.
public void installDockerDependencies(File dockerFolder) throws DetectUserFriendlyException {
try {
File dockerZip = dockerInspectorInstaller.installAirGap(dockerFolder);
ZipUtil.unpack(dockerZip, dockerFolder);
FileUtils.deleteQuietly(dockerZip);
} catch (IntegrationException | IOException e) {
throw new DetectUserFriendlyException("An error occurred installing docker inspector.", e, ExitCodeType.FAILURE_GENERAL_ERROR);
}
}
use of com.synopsys.integration.detect.configuration.DetectUserFriendlyException in project synopsys-detect by blackducksoftware.
the class DetectBdioWriter method writeBdioFile.
public void writeBdioFile(File outputFile, SimpleBdioDocument simpleBdioDocument) throws DetectUserFriendlyException {
if (outputFile.exists()) {
boolean deleteSuccess = outputFile.delete();
logger.debug(String.format("%s deleted: %b", outputFile.getAbsolutePath(), deleteSuccess));
}
try {
String detectVersion = detectInfo.getDetectVersion();
SpdxCreator detectCreator = SpdxCreator.createToolSpdxCreator("Detect", detectVersion);
simpleBdioDocument.getBillOfMaterials().creationInfo.setPrimarySpdxCreator(detectCreator);
simpleBdioFactory.writeSimpleBdioDocumentToFile(outputFile, simpleBdioDocument);
logger.debug(String.format("BDIO Generated: %s", outputFile.getAbsolutePath()));
} catch (IOException e) {
throw new DetectUserFriendlyException(e.getMessage(), e, ExitCodeType.FAILURE_GENERAL_ERROR);
}
}
Aggregations