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);
}
use of com.blackducksoftware.integration.exception.IntegrationException in project hub-detect by blackducksoftware.
the class HubManager method manageExistingCodeLocations.
public void manageExistingCodeLocations(final List<String> codeLocationNames) {
if (!detectConfiguration.getHubOfflineMode()) {
final CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService();
for (final String codeLocationName : codeLocationNames) {
try {
final CodeLocationView codeLocationView = codeLocationService.getCodeLocationByName(codeLocationName);
if (detectConfiguration.getProjectCodeLocationDeleteOldNames()) {
try {
codeLocationService.deleteCodeLocation(codeLocationView);
logger.info(String.format("Deleted code location '%s'", codeLocationName));
} catch (final IntegrationException e) {
logger.error(String.format("Not able to delete the code location '%s': %s", codeLocationName, e.getMessage()));
}
} else {
logger.warn(String.format("Found a code location with a naming pattern that is no longer supported: %s. This code location may need to be removed to avoid duplicate entries in the Bill of Materials. You can run with --detect.project.codelocation.delete.old.names=true which will automatically delete these code locations, but please USE CAUTION.", codeLocationName));
}
} catch (final DoesNotExistException e) {
logger.debug(String.format("Didn't find the code location %s - this is a good thing!", codeLocationName));
} catch (final IntegrationException e) {
logger.error(String.format("Error finding the code location name %s: %s", codeLocationName, e.getMessage()));
}
}
}
}
use of com.blackducksoftware.integration.exception.IntegrationException in project hub-detect by blackducksoftware.
the class HubServiceWrapper method assertHubConnection.
public void assertHubConnection(final IntLogger intLogger) throws IntegrationException {
logger.info("Attempting connection to the Hub");
try {
final HubServerConfig hubServerConfig = createHubServerConfig(intLogger);
final RestConnection connection = hubServerConfig.createRestConnection(intLogger);
connection.connect();
logger.info("Connection to the Hub was successful");
} catch (final IllegalStateException e) {
throw new IntegrationException(e.getMessage(), e);
}
}
Aggregations