Search in sources :

Example 1 with AzureHttpRequestCreator

use of com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator 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 AzureHttpRequestCreator

use of com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator 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 3 with AzureHttpRequestCreator

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

the class AzureBoardsProperties method createAzureHttpService.

public AzureHttpService createAzureHttpService(ProxyInfo proxy, Gson gson, String authorizationCode) throws AlertException {
    HttpTransport httpTransport = createHttpTransport(proxy);
    try {
        AuthorizationCodeFlow oAuthFlow = createOAuthFlow(httpTransport);
        Credential oAuthCredential = requestTokens(oAuthFlow, authorizationCode).orElseThrow(() -> new AlertException(String.format("Cannot request Azure OAuth credential associated with '%s'", oauthUserId)));
        AzureHttpRequestCreator httpRequestCreator = AzureHttpRequestCreatorFactory.withCredential(httpTransport, oAuthCredential, gson);
        return new AzureHttpService(gson, httpRequestCreator);
    } catch (IOException e) {
        throw new AlertException("Cannot request OAuth credentials", e);
    }
}
Also used : HttpTransport(com.google.api.client.http.HttpTransport) ApacheHttpTransport(com.google.api.client.http.apache.v2.ApacheHttpTransport) Credential(com.google.api.client.auth.oauth2.Credential) StoredCredential(com.google.api.client.auth.oauth2.StoredCredential) AzureHttpRequestCreator(com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator) IOException(java.io.IOException) AzureHttpService(com.synopsys.integration.azure.boards.common.http.AzureHttpService) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) AuthorizationCodeFlow(com.google.api.client.auth.oauth2.AuthorizationCodeFlow) AzureAuthorizationCodeFlow(com.synopsys.integration.azure.boards.common.oauth.AzureAuthorizationCodeFlow)

Aggregations

AzureHttpRequestCreator (com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator)3 AzureHttpService (com.synopsys.integration.azure.boards.common.http.AzureHttpService)3 AzureBoardsProperties (com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)2 AzureApiVersionAppender (com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender)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 AuthorizationCodeFlow (com.google.api.client.auth.oauth2.AuthorizationCodeFlow)1 Credential (com.google.api.client.auth.oauth2.Credential)1 StoredCredential (com.google.api.client.auth.oauth2.StoredCredential)1 HttpTransport (com.google.api.client.http.HttpTransport)1 ApacheHttpTransport (com.google.api.client.http.apache.v2.ApacheHttpTransport)1 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 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)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