Search in sources :

Example 11 with ProjectVersionRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-alert by blackducksoftware.

the class BlackDuckProviderService method findOrCreateBlackDuckProjectAndVersion.

public ProjectVersionWrapper findOrCreateBlackDuckProjectAndVersion(String projectName, String projectVersionName) throws IntegrationException {
    setupBlackDuckServicesFactory();
    ProjectService projectService = blackDuckServicesFactory.createProjectService();
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
    projectVersionRequest.setVersionName(projectVersionName);
    projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
    projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
    projectRequest.setVersionRequest(projectVersionRequest);
    Optional<ProjectVersionWrapper> existingProjectVersion = projectService.getProjectVersion(projectRequest.getName(), projectVersionRequest.getVersionName());
    if (existingProjectVersion.isPresent()) {
        intLogger.info(String.format("Project: %s Version %s already exists", projectName, projectVersionName));
        return existingProjectVersion.get();
    }
    intLogger.info(String.format("Creating project: %s", projectName));
    return projectService.createProject(projectRequest);
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)

Example 12 with ProjectVersionRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest in project blackduck-alert by blackducksoftware.

the class BlackDuckProviderService method deleteBlackDuckProjectAndVersion.

public void deleteBlackDuckProjectAndVersion(String projectName, String projectVersionName) throws IntegrationException {
    setupBlackDuckServicesFactory();
    ProjectService projectService = blackDuckServicesFactory.createProjectService();
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
    projectVersionRequest.setVersionName(projectVersionName);
    projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
    projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
    projectRequest.setVersionRequest(projectVersionRequest);
    Optional<ProjectVersionWrapper> existingProjectVersion = projectService.getProjectVersion(projectRequest.getName(), projectVersionRequest.getVersionName());
    if (existingProjectVersion.isPresent()) {
        intLogger.info(String.format("Project: %s Version %s already exists", projectName, projectVersionName));
        BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
        blackDuckApiClient.delete(existingProjectVersion.get().getProjectVersionView());
        blackDuckApiClient.delete(existingProjectVersion.get().getProjectView());
        intLogger.info(String.format("Deleting project: %s", projectName));
    }
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)

Aggregations

ProjectVersionRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)12 ProjectRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest)11 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)11 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)7 Test (org.junit.jupiter.api.Test)6 ProjectService (com.synopsys.integration.blackduck.service.dataservice.ProjectService)5 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)3 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)2 ProjectSyncModel (com.synopsys.integration.blackduck.service.model.ProjectSyncModel)2 HttpUrl (com.synopsys.integration.rest.HttpUrl)2 ComplexLicenseRequest (com.synopsys.integration.blackduck.api.manual.temporary.component.ComplexLicenseRequest)1 BlackDuckApiException (com.synopsys.integration.blackduck.exception.BlackDuckApiException)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 IntLogger (com.synopsys.integration.log.IntLogger)1 SilentIntLogger (com.synopsys.integration.log.SilentIntLogger)1 Date (java.util.Date)1