Search in sources :

Example 31 with DetectUserFriendlyException

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;
}
Also used : IntegrationEscapeUtil(com.synopsys.integration.util.IntegrationEscapeUtil) DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) IOException(java.io.IOException) File(java.io.File)

Example 32 with DetectUserFriendlyException

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);
    }
}
Also used : DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) IntegrationException(com.synopsys.integration.exception.IntegrationException) IOException(java.io.IOException) File(java.io.File)

Example 33 with DetectUserFriendlyException

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);
    }
}
Also used : DetectUserFriendlyException(com.synopsys.integration.detect.configuration.DetectUserFriendlyException) IOException(java.io.IOException) SpdxCreator(com.synopsys.integration.bdio.model.SpdxCreator)

Aggregations

DetectUserFriendlyException (com.synopsys.integration.detect.configuration.DetectUserFriendlyException)33 File (java.io.File)14 IntegrationException (com.synopsys.integration.exception.IntegrationException)12 IOException (java.io.IOException)12 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)5 ExitCodeType (com.synopsys.integration.detect.configuration.enumeration.ExitCodeType)3 ArrayList (java.util.ArrayList)3 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)2 SpdxCreator (com.synopsys.integration.bdio.model.SpdxCreator)2 Bdio2Writer (com.synopsys.integration.blackduck.bdio2.util.Bdio2Writer)2 UploadTarget (com.synopsys.integration.blackduck.codelocation.upload.UploadTarget)2 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)2 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)2 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 ProductRunData (com.synopsys.integration.detect.lifecycle.run.data.ProductRunData)2 CustomFieldOperation (com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldOperation)2 CustomFieldView (com.synopsys.integration.detect.workflow.blackduck.project.customfields.CustomFieldView)2 SilentIntLogger (com.synopsys.integration.log.SilentIntLogger)2 Slf4jIntLogger (com.synopsys.integration.log.Slf4jIntLogger)2 FileOutputStream (java.io.FileOutputStream)2