Search in sources :

Example 46 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException in project hub-fortify-ssc-integration-service by blackducksoftware.

the class MappingParser method createApplicationVersion.

/**
 * Creates a new Application Version, updates the attributes and commits the application to mark it complete on the
 * UI
 *
 * @param createRequest
 * @return int - Application ID
 * @throws IOException
 * @throws IntegrationException
 */
private int createApplicationVersion(final CreateApplicationRequest createRequest) throws IOException, IntegrationException {
    int applicationId = 0;
    applicationId = fortifyApplicationVersionApi.createApplicationVersion(createRequest);
    try {
        final List<UpdateFortifyApplicationAttributesRequest> updateAttributerequest = addCustomAttributes();
        logger.info("updateAttributerequest::" + updateAttributerequest);
        fortifyApplicationVersionApi.updateApplicationAttributes(applicationId, updateAttributerequest);
        final CommitFortifyApplicationRequest commitRequest = new CommitFortifyApplicationRequest(true);
        fortifyApplicationVersionApi.commitApplicationVersion(applicationId, commitRequest);
    } catch (final IOException e) {
        fortifyApplicationVersionApi.deleteApplicationVersion(applicationId);
        throw new IOException(e);
    } catch (final IntegrationException e) {
        fortifyApplicationVersionApi.deleteApplicationVersion(applicationId);
        throw new IntegrationException(e);
    }
    return applicationId;
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) UpdateFortifyApplicationAttributesRequest(com.blackducksoftware.integration.fortify.model.UpdateFortifyApplicationAttributesRequest) CommitFortifyApplicationRequest(com.blackducksoftware.integration.fortify.model.CommitFortifyApplicationRequest) IOException(java.io.IOException) JsonIOException(com.google.gson.JsonIOException)

Example 47 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException in project hub-fortify-ssc-integration-service by blackducksoftware.

the class HubServices method getComponentVersionRecommendations.

/**
 * Get the Black Duck component version recommendations for the given component version
 *
 * @param componentVersionRemediatingUrl
 * @return
 * @throws IntegrationException
 */
public Recommendation getComponentVersionRecommendations(final String componentVersionRemediatingUrl) throws IntegrationException {
    logger.debug("Getting Black Duck component version remediating");
    Recommendation recommendation = null;
    if (componentVersionRemediatingUrl != null) {
        final HubService hubResponseService = hubServicesFactory.createHubService();
        try {
            recommendation = hubResponseService.getResponse(componentVersionRemediatingUrl, Recommendation.class);
        } catch (final IntegrationException e) {
            if (!e.getMessage().contains("Error: 404 : 404")) {
                throw new IntegrationException(e);
            }
        }
    }
    return recommendation;
}
Also used : HubIntegrationException(com.blackducksoftware.integration.hub.exception.HubIntegrationException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) Recommendation(com.blackducksoftware.integration.fortify.hub.model.Recommendation) HubService(com.blackducksoftware.integration.hub.service.HubService)

Aggregations

IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)47 IOException (java.io.IOException)14 Test (org.junit.Test)14 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)8 HubIntegrationException (com.blackducksoftware.integration.hub.exception.HubIntegrationException)6 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)5 Request (com.blackducksoftware.integration.hub.request.Request)4 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)4 UpdateFortifyApplicationAttributesRequest (com.blackducksoftware.integration.fortify.model.UpdateFortifyApplicationAttributesRequest)3 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)3 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)3 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)3 ProjectService (com.blackducksoftware.integration.hub.service.ProjectService)3 UserGroupService (com.blackducksoftware.integration.hub.service.UserGroupService)3 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Authenticator (okhttp3.Authenticator)3 OkHttpClient (okhttp3.OkHttpClient)3