use of com.blackducksoftware.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class ChannelRequestHelper method sendGenericRequest.
public Response sendGenericRequest(final Request request) throws IntegrationException {
Response response = null;
try {
final HubService service = hubServicesFactory.createHubService();
response = service.executeRequest(request);
logger.trace("Response: " + response.toString());
return response;
} catch (final Exception generalException) {
logger.error("Error sending request", generalException);
throw new AlertException(generalException.getMessage());
}
}
use of com.blackducksoftware.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class ChannelRestConnectionFactory method createUnauthenticatedRestConnection.
public RestConnection createUnauthenticatedRestConnection(final URL url, final IntLogger intLogger, final int timeout) {
if (url == null) {
logger.error("URL WAS NULL");
return null;
}
final UnauthenticatedRestConnectionBuilder restConnectionBuilder = new UnauthenticatedRestConnectionBuilder();
restConnectionBuilder.setBaseUrl(url.toString());
restConnectionBuilder.setLogger(intLogger);
if (globalProperties.getHubTrustCertificate() != null) {
restConnectionBuilder.setAlwaysTrustServerCertificate(globalProperties.getHubTrustCertificate());
}
restConnectionBuilder.setProxyHost(globalProperties.getHubProxyHost());
if (globalProperties.getHubProxyPort() != null) {
restConnectionBuilder.setProxyPort(NumberUtils.toInt(globalProperties.getHubProxyPort()));
}
if (globalProperties.getHubProxyUsername() != null) {
restConnectionBuilder.setProxyUsername(globalProperties.getHubProxyUsername());
}
if (globalProperties.getHubProxyPassword() != null) {
restConnectionBuilder.setProxyPassword(globalProperties.getHubProxyPassword());
}
restConnectionBuilder.setTimeout(timeout);
final RestConnection connection = restConnectionBuilder.build();
try {
// the build operation will catch the issues based on the configuration settings and throw an exception
// the IntegrationException caught here is unlikely to occur with an UnauthenticatedRestConnection.
connection.connect();
return connection;
} catch (final IntegrationException e) {
logger.error("Could not connect to " + url.toString(), e);
return null;
}
}
use of com.blackducksoftware.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class NotificationItemProcessor method init.
public void init(final GlobalProperties globalProperties, final IntLogger intLogger) {
HubServicesFactory hubServicesFactory;
try {
hubServicesFactory = globalProperties.createHubServicesFactory(intLogger);
final ProjectService projectService = hubServicesFactory.createProjectService();
final MapProcessorCache policyCache = new UserNotificationCache(projectService);
final VulnerabilityCache vulnerabilityCache = new VulnerabilityCache(projectService, hubServicesFactory);
getCacheList().add(policyCache);
getCacheList().add(vulnerabilityCache);
getProcessorMap().put(PolicyViolationContentItem.class, new PolicyViolationProcessor(policyCache, intLogger));
getProcessorMap().put(PolicyViolationClearedContentItem.class, new PolicyViolationClearedProcessor(policyCache, intLogger));
getProcessorMap().put(PolicyOverrideContentItem.class, new PolicyOverrideProcessor(policyCache, intLogger));
getProcessorMap().put(VulnerabilityContentItem.class, new VulnerabilityProcessor(vulnerabilityCache, intLogger));
} catch (final IntegrationException ex) {
intLogger.error("Error building the notification processor", ex);
}
}
use of com.blackducksoftware.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class AuditEntryActionsTest method testResendNotificationException.
@Test
public void testResendNotificationException() {
final AuditEntryRepositoryWrapper auditEntryRepository = Mockito.mock(AuditEntryRepositoryWrapper.class);
final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
final AuditNotificationRepositoryWrapper auditNotificationRepository = Mockito.mock(AuditNotificationRepositoryWrapper.class);
final CommonDistributionRepositoryWrapper commonDistributionRepositoryWrapper = Mockito.mock(CommonDistributionRepositoryWrapper.class);
final MockAuditEntryEntity mockAuditEntryEntity = new MockAuditEntryEntity();
final MockNotificationEntity mockNotificationEntity = new MockNotificationEntity();
Mockito.when(auditEntryRepository.findOne(Mockito.anyLong())).thenReturn(mockAuditEntryEntity.createEmptyEntity());
Mockito.when(commonDistributionRepositoryWrapper.findOne(Mockito.anyLong())).thenReturn(null);
Mockito.when(notificationRepository.findAll(Mockito.any())).thenReturn(Arrays.asList(mockNotificationEntity.createEntity()));
final AuditEntryActions auditEntryActions = new AuditEntryActions(auditEntryRepository, new NotificationManager(notificationRepository, vulnerabilityRepository, auditEntryRepository, auditNotificationRepository), auditNotificationRepository, commonDistributionRepositoryWrapper, null, null, null, null);
List<AuditEntryRestModel> restModel = null;
try {
restModel = auditEntryActions.resendNotification(1L);
fail();
} catch (final IllegalArgumentException e) {
assertTrue(true);
} catch (final IntegrationException e) {
fail();
}
assertNull(restModel);
}
Aggregations