use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class AccumulatorProcessor method process.
@Override
public DBStoreEvent process(final NotificationResults notificationData) throws Exception {
if (notificationData != null) {
try {
final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactoryAndLogErrors(logger);
if (hubServicesFactory != null) {
logger.info("Processing accumulated notifications");
final NotificationItemProcessor notificationItemProcessor = new NotificationItemProcessor(globalProperties, hubServicesFactory.getRestConnection().logger);
final DBStoreEvent storeEvent = notificationItemProcessor.process(notificationData.getNotificationContentItems());
return storeEvent;
}
} catch (final Exception ex) {
logger.error("Error occurred durring processing of accumulated notifications", ex);
}
} else {
logger.info("No notifications to process");
}
return null;
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class EmailGroupChannel method getEmailAddressesForGroup.
private List<String> getEmailAddressesForGroup(final HubServicesFactory hubServicesFactory, final String hubGroup) throws IntegrationException {
final UserGroupService groupService = hubServicesFactory.createUserGroupService();
final UserGroupView userGroupView = groupService.getGroupByName(hubGroup);
if (userGroupView == null) {
throw new IntegrationException("Could not find the Hub group: " + hubGroup);
}
logger.info(userGroupView.toString());
logger.info(userGroupView.json);
final List<UserView> users = hubServicesFactory.createHubService().getAllResponses(userGroupView, UserGroupView.USERS_LINK_RESPONSE);
return users.stream().map(user -> user.email).collect(Collectors.toList());
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory in project hub-alert by blackducksoftware.
the class HubDataActions method getHubGroups.
public List<HubGroup> getHubGroups() throws IntegrationException {
final HubServicesFactory hubServicesFactory = globalProperties.createHubServicesFactory(logger);
if (hubServicesFactory != null) {
final List<UserGroupView> rawGroups = hubServicesFactory.createHubService().getAllResponses(ApiDiscovery.USERGROUPS_LINK_RESPONSE);
final List<HubGroup> groups = new ArrayList<>();
for (final UserGroupView userGroupView : rawGroups) {
final HubGroup hubGroup = new HubGroup(userGroupView.name, userGroupView.active, userGroupView._meta.href);
groups.add(hubGroup);
}
return groups;
} else {
throw new AlertException("Missing global configuration.");
}
}
use of com.blackducksoftware.integration.hub.service.HubServicesFactory 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.hub.service.HubServicesFactory in project hub-fortify-ssc-integration-service by blackducksoftware.
the class RestConnectionHelper method createHubServicesFactory.
/**
* Create the Hub Services factory based on logger
*
* @param logger
* @return
*/
private static HubServicesFactory createHubServicesFactory(final IntLogger logger, final PropertyConstants propertyConstants) {
final RestConnection restConnection = getApplicationPropertyRestConnection(propertyConstants);
restConnection.logger = logger;
// Adjust the number of connections in the connection pool. The keepAlive info is the same as the default
// constructor
final PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(5, TimeUnit.MINUTES);
connManager.setDefaultMaxPerRoute(propertyConstants.getMaximumThreadSize());
connManager.setMaxTotal(propertyConstants.getMaximumThreadSize());
restConnection.getClientBuilder().setConnectionManager(connManager);
// restConnection.getClientBuilder().setMaxConnPerRoute(propertyConstants.getMaximumThreadSize())
// .setMaxConnTotal(propertyConstants.getMaximumThreadSize())
// .setConnectionTimeToLive(5, TimeUnit.MINUTES);
final HubServicesFactory hubServicesFactory = new HubServicesFactory(restConnection);
return hubServicesFactory;
}
Aggregations