use of com.synopsys.integration.azure.boards.common.http.HttpServiceException 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);
}
}
use of com.synopsys.integration.azure.boards.common.http.HttpServiceException in project hub-alert by blackducksoftware.
the class AzureCustomFieldManager method findOrCreateAlertCustomProjectField.
private ProjectWorkItemFieldModel findOrCreateAlertCustomProjectField(String projectName, String fieldName, String fieldReferenceName, String fieldDescription) throws AlertException {
ProjectWorkItemFieldModel fieldRequestModel = ProjectWorkItemFieldModel.workItemStringField(fieldName, fieldReferenceName, fieldDescription);
Optional<ProjectWorkItemFieldModel> customField = getAlertCustomProjectField(projectName, fieldRequestModel.getReferenceName());
if (customField.isPresent()) {
return customField.get();
}
// custom field not found so create it
try {
return projectService.createProjectField(organizationName, projectName, fieldRequestModel);
} catch (IOException e) {
throw new AlertException(String.format("There was a problem creating the request to create the Alert Custom Field (%s) in the Azure project: %s", fieldReferenceName, projectName), e);
} catch (HttpServiceException e) {
throw new AlertException(String.format("There was a problem creating the Alert Custom Field (%s) in the Azure project: %s", fieldReferenceName, projectName), e);
}
}
use of com.synopsys.integration.azure.boards.common.http.HttpServiceException in project hub-alert by blackducksoftware.
the class AzureCustomFieldManager method getWorkItemTypeRefName.
private String getWorkItemTypeRefName(String processId, String workItemTypeName) throws AlertException {
try {
AzureArrayResponseModel<ProcessWorkItemTypesResponseModel> processWorkItemTypes = processService.getWorkItemTypes(organizationName, processId);
ProcessWorkItemTypesResponseModel matchingWorkItemType = processWorkItemTypes.getValue().stream().filter(workItemType -> workItemType.getName().equals(workItemTypeName)).findFirst().orElseThrow(() -> new AlertException(String.format("No work item type '%s' exists for the Azure process with id: '%s'", workItemTypeName, processId)));
if (matchingWorkItemType.getReferenceName().startsWith(UNMODIFIABLE_WORK_ITEM_PREFIX)) {
// if the reference name starts with this prefix, we know it is a system default so it can not be modified and fields can not be added to it, so we need to create a "copy" of it
matchingWorkItemType = copyWorkItem(processId, matchingWorkItemType);
}
return matchingWorkItemType.getReferenceName();
} catch (HttpServiceException e) {
throw new AlertException(String.format("There was a problem trying to get the work item types for the Azure process with id: %s", processId), e);
}
}
use of com.synopsys.integration.azure.boards.common.http.HttpServiceException 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);
}
}
use of com.synopsys.integration.azure.boards.common.http.HttpServiceException in project hub-alert by blackducksoftware.
the class AzureBoardsIssueTransitioner method findAndPerformTransition.
@Override
protected void findAndPerformTransition(ExistingIssueDetails<Integer> existingIssueDetails, String transitionName) throws AlertException {
WorkItemElementOperationModel replaceSystemStateField = WorkItemElementOperationModel.fieldElement(WorkItemElementOperation.REPLACE, WorkItemResponseFields.System_State, transitionName);
WorkItemRequest request = new WorkItemRequest(List.of(replaceSystemStateField));
Integer issueId = existingIssueDetails.getIssueId();
try {
workItemService.updateWorkItem(organizationName, distributionDetails.getProjectNameOrId(), issueId, request);
} catch (HttpServiceException e) {
List<String> availableStates = retrieveAvailableStates(existingIssueDetails.getIssueId()).stream().map(WorkItemTypeStateResponseModel::getName).collect(Collectors.toList());
throw new IssueMissingTransitionException(existingIssueDetails.getIssueKey(), transitionName, availableStates);
}
}
Aggregations