Search in sources :

Example 1 with AzureApiVersionAppender

use of com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender in project hub-alert by blackducksoftware.

the class AzureBoardsProcessorFactory method createProcessor.

@Override
public IssueTrackerProcessor<Integer> createProcessor(AzureBoardsJobDetailsModel distributionDetails) throws AlertException {
    AzureBoardsProperties azureBoardsProperties = azureBoardsPropertiesFactory.createAzureBoardsProperties();
    String organizationName = azureBoardsProperties.getOrganizationName();
    azureBoardsProperties.validateProperties();
    // Initialize Http Service
    ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
    AzureHttpRequestCreator azureHttpRequestCreator = azureBoardsProperties.createAzureHttpRequestCreator(proxy, gson);
    AzureHttpService azureHttpService = new AzureHttpService(gson, azureHttpRequestCreator);
    // Common Azure Boards Services
    AzureApiVersionAppender apiVersionAppender = new AzureApiVersionAppender();
    AzureProjectService projectService = new AzureProjectService(azureHttpService, apiVersionAppender);
    AzureWorkItemService workItemService = new AzureWorkItemService(azureHttpService, azureHttpRequestCreator);
    AzureWorkItemQueryService workItemQueryService = new AzureWorkItemQueryService(azureHttpService, apiVersionAppender);
    String projectNameOrId = distributionDetails.getProjectNameOrId();
    String teamProjectName = retrieveProjectNameIfNecessary(projectService, organizationName, projectNameOrId);
    installCustomFieldsIfNecessary(organizationName, teamProjectName, distributionDetails.getWorkItemType(), projectService, new AzureProcessService(azureHttpService, apiVersionAppender));
    // Searcher Requirements
    AzureBoardsIssueStatusResolver azureBoardsIssueStatusResolver = new AzureBoardsIssueStatusResolver(distributionDetails.getWorkItemCompletedState(), distributionDetails.getWorkItemReopenState());
    AzureBoardsIssueTrackerQueryManager queryManager = new AzureBoardsIssueTrackerQueryManager(organizationName, distributionDetails, workItemService, workItemQueryService);
    // Extractor Requirements
    AzureBoardsExistingIssueDetailsCreator issueDetailsCreator = new AzureBoardsExistingIssueDetailsCreator(organizationName, issueCategoryRetriever, azureBoardsIssueStatusResolver);
    AzureBoardsWorkItemFinder workItemFinder = new AzureBoardsWorkItemFinder(queryManager, teamProjectName);
    AzureBoardsProjectAndVersionIssueFinder projectAndVersionIssueFinder = new AzureBoardsProjectAndVersionIssueFinder(gson, issueDetailsCreator, workItemFinder);
    AzureBoardsComponentIssueFinder componentIssueFinder = new AzureBoardsComponentIssueFinder(gson, workItemFinder, issueDetailsCreator);
    IssueTrackerSearcher<Integer> azureBoardsSearcher = new IssueTrackerSearcher<>(projectAndVersionIssueFinder, projectAndVersionIssueFinder, componentIssueFinder, componentIssueFinder, modelTransformer);
    IssueTrackerModelExtractor<Integer> extractor = new IssueTrackerModelExtractor<>(formatter, azureBoardsSearcher);
    // Message Sender Requirements
    AzureWorkItemTypeStateService workItemTypeStateService = new AzureWorkItemTypeStateService(azureHttpService, apiVersionAppender);
    AzureWorkItemCommentService workItemCommentService = new AzureWorkItemCommentService(azureHttpService, apiVersionAppender);
    IssueTrackerMessageSender<Integer> messageSender = azureBoardsMessageSenderFactory.createMessageSender(workItemService, workItemTypeStateService, workItemCommentService, organizationName, distributionDetails);
    return new IssueTrackerProcessor<>(extractor, messageSender);
}
Also used : AzureBoardsProjectAndVersionIssueFinder(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsProjectAndVersionIssueFinder) AzureBoardsWorkItemFinder(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsWorkItemFinder) AzureWorkItemTypeStateService(com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService) AzureWorkItemQueryService(com.synopsys.integration.azure.boards.common.service.query.AzureWorkItemQueryService) ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) IssueTrackerModelExtractor(com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor) AzureWorkItemCommentService(com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService) AzureHttpRequestCreator(com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator) AzureHttpService(com.synopsys.integration.azure.boards.common.http.AzureHttpService) AzureBoardsExistingIssueDetailsCreator(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsExistingIssueDetailsCreator) AzureBoardsProperties(com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties) IssueTrackerProcessor(com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor) IssueTrackerSearcher(com.synopsys.integration.alert.api.channel.issue.search.IssueTrackerSearcher) AzureProjectService(com.synopsys.integration.azure.boards.common.service.project.AzureProjectService) AzureApiVersionAppender(com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender) AzureBoardsComponentIssueFinder(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsComponentIssueFinder) AzureBoardsIssueStatusResolver(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsIssueStatusResolver) AzureWorkItemService(com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService) AzureProcessService(com.synopsys.integration.azure.boards.common.service.process.AzureProcessService)

Example 2 with AzureApiVersionAppender

use of com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender in project hub-alert by blackducksoftware.

the class AzureBoardsGlobalFieldModelTestAction method testConfig.

@Override
public MessageResult testConfig(String configId, FieldModel fieldModel, FieldUtility registeredFieldValues) throws IntegrationException {
    try {
        Optional<ConfigurationFieldModel> configurationFieldModel = registeredFieldValues.getField(AzureBoardsDescriptor.KEY_ORGANIZATION_NAME);
        String organizationName = configurationFieldModel.flatMap(ConfigurationFieldModel::getFieldValue).orElse(null);
        AzureBoardsProperties azureBoardsProperties = AzureBoardsProperties.fromFieldAccessor(azureBoardsCredentialDataStoreFactory, azureRedirectUrlCreator.createOAuthRedirectUri(), registeredFieldValues);
        AzureHttpService azureHttpService = createAzureHttpService(azureBoardsProperties);
        AzureProjectService azureProjectService = new AzureProjectService(azureHttpService, new AzureApiVersionAppender());
        azureProjectService.getProjects(organizationName);
        return new MessageResult("Successfully connected to Azure instance.");
    } catch (HttpServiceException ex) {
        logger.error("Global Test Action failed testing Azure Boards connection.", ex);
        throw (ex);
    }
}
Also used : HttpServiceException(com.synopsys.integration.azure.boards.common.http.HttpServiceException) AzureApiVersionAppender(com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) AzureHttpService(com.synopsys.integration.azure.boards.common.http.AzureHttpService) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) AzureProjectService(com.synopsys.integration.azure.boards.common.service.project.AzureProjectService) AzureBoardsProperties(com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)

Example 3 with AzureApiVersionAppender

use of com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender in project hub-alert by blackducksoftware.

the class AzureBoardsMessageSenderFactory method createMessageSender.

@Override
public IssueTrackerMessageSender<Integer> createMessageSender(AzureBoardsJobDetailsModel distributionDetails) throws AlertException {
    AzureBoardsProperties azureBoardsProperties = azureBoardsPropertiesFactory.createAzureBoardsProperties();
    azureBoardsProperties.validateProperties();
    // Initialize Http Service
    ProxyInfo proxy = proxyManager.createProxyInfoForHost(AzureHttpRequestCreatorFactory.DEFAULT_BASE_URL);
    AzureHttpRequestCreator azureHttpRequestCreator = azureBoardsProperties.createAzureHttpRequestCreator(proxy, gson);
    AzureHttpService azureHttpService = new AzureHttpService(gson, azureHttpRequestCreator);
    // Azure Boards Services
    AzureApiVersionAppender apiVersionAppender = new AzureApiVersionAppender();
    AzureWorkItemService workItemService = new AzureWorkItemService(azureHttpService, azureHttpRequestCreator);
    AzureWorkItemTypeStateService workItemTypeStateService = new AzureWorkItemTypeStateService(azureHttpService, apiVersionAppender);
    AzureWorkItemCommentService workItemCommentService = new AzureWorkItemCommentService(azureHttpService, apiVersionAppender);
    return createMessageSender(workItemService, workItemTypeStateService, workItemCommentService, azureBoardsProperties.getOrganizationName(), distributionDetails);
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) AzureApiVersionAppender(com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender) AzureWorkItemCommentService(com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService) AzureWorkItemService(com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService) AzureWorkItemTypeStateService(com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService) AzureHttpRequestCreator(com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator) AzureHttpService(com.synopsys.integration.azure.boards.common.http.AzureHttpService) AzureBoardsProperties(com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)

Example 4 with AzureApiVersionAppender

use of com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender in project hub-alert by blackducksoftware.

the class AzureOAuthCallbackController method testGetProjects.

private void testGetProjects(AzureHttpService azureHttpService, String organizationName, String oAuthRequestKey) {
    try {
        AzureProjectService azureProjectService = new AzureProjectService(azureHttpService, new AzureApiVersionAppender());
        AzureArrayResponseModel<TeamProjectReferenceResponseModel> projects = azureProjectService.getProjects(organizationName);
        Integer projectCount = projects.getCount();
        logger.info("OAuth request with id {}: Azure Boards project count: {}", oAuthRequestKey, projectCount);
    } catch (HttpServiceException ex) {
        logger.error("OAuth request with id {}: Error in azure oauth get projects validation test ", oAuthRequestKey, ex);
    }
}
Also used : HttpServiceException(com.synopsys.integration.azure.boards.common.http.HttpServiceException) AzureApiVersionAppender(com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender) TeamProjectReferenceResponseModel(com.synopsys.integration.azure.boards.common.service.project.TeamProjectReferenceResponseModel) AzureProjectService(com.synopsys.integration.azure.boards.common.service.project.AzureProjectService)

Aggregations

AzureApiVersionAppender (com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender)4 AzureBoardsProperties (com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)3 AzureHttpService (com.synopsys.integration.azure.boards.common.http.AzureHttpService)3 AzureProjectService (com.synopsys.integration.azure.boards.common.service.project.AzureProjectService)3 AzureHttpRequestCreator (com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator)2 HttpServiceException (com.synopsys.integration.azure.boards.common.http.HttpServiceException)2 AzureWorkItemCommentService (com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService)2 AzureWorkItemTypeStateService (com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService)2 AzureWorkItemService (com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService)2 ProxyInfo (com.synopsys.integration.rest.proxy.ProxyInfo)2 IssueTrackerModelExtractor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor)1 IssueTrackerProcessor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor)1 IssueTrackerSearcher (com.synopsys.integration.alert.api.channel.issue.search.IssueTrackerSearcher)1 AzureBoardsComponentIssueFinder (com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsComponentIssueFinder)1 AzureBoardsExistingIssueDetailsCreator (com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsExistingIssueDetailsCreator)1 AzureBoardsIssueStatusResolver (com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsIssueStatusResolver)1 AzureBoardsProjectAndVersionIssueFinder (com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsProjectAndVersionIssueFinder)1 AzureBoardsWorkItemFinder (com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsWorkItemFinder)1 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)1 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)1