Search in sources :

Example 6 with ProjectRequest

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

the class ProjectServiceTestIT method testSetLicenseForProjectVersion.

@Test
public void testSetLicenseForProjectVersion() throws IntegrationException {
    String projectName = "InitialName";
    deleteProjectIfExists(projectName);
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(projectName);
    projectRequest.setProjectTier(2);
    projectRequest.setDescription("Initial Description");
    ProjectVersionRequest projectVersionRequest = new ProjectVersionRequest();
    projectVersionRequest.setVersionName("InitialVersion");
    projectVersionRequest.setPhase(ProjectVersionPhaseType.DEVELOPMENT);
    projectVersionRequest.setDistribution(ProjectVersionDistributionType.OPENSOURCE);
    ComplexLicenseRequest complexLicenseRequest = new ComplexLicenseRequest();
    String licenseName = ".NETZ GPL 2.0 With Exception License";
    complexLicenseRequest.setLicense(licenseService.getLicenseUrlByLicenseName(licenseName).get().string());
    projectVersionRequest.setLicense(complexLicenseRequest);
    projectRequest.setVersionRequest(projectVersionRequest);
    ProjectVersionWrapper projectVersionWrapper = ProjectServiceTestIT.projectService.createProject(projectRequest);
    ProjectVersionView projectVersion = projectVersionWrapper.getProjectVersionView();
    Assertions.assertEquals(licenseName, projectVersion.getLicense().getLicenseDisplay());
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ComplexLicenseRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ComplexLicenseRequest) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest) Test(org.junit.jupiter.api.Test)

Example 7 with ProjectRequest

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

the class ProjectService method syncProjectAndVersion.

public ProjectVersionWrapper syncProjectAndVersion(ProjectSyncModel projectSyncModel, boolean performUpdate) throws IntegrationException {
    String projectName = projectSyncModel.getName();
    Optional<ProjectView> optionalProjectView = getProjectByName(projectName);
    if (!optionalProjectView.isPresent()) {
        logger.info(String.format("The %s project was not found, so it will be created - if a version was included, it will also be created.", projectName));
        ProjectRequest projectRequest = projectSyncModel.createProjectRequest();
        return createProject(projectRequest);
    }
    ProjectView projectView = optionalProjectView.get();
    if (performUpdate) {
        logger.info(String.format("The %s project was found and performUpdate=true, so it will be updated.", projectName));
        projectSyncModel.populateProjectView(projectView);
        blackDuckApiClient.put(projectView);
        projectView = blackDuckApiClient.getResponse(projectView.getHref(), ProjectView.class);
    }
    ProjectVersionView projectVersionView = null;
    if (projectSyncModel.shouldHandleProjectVersion()) {
        String projectVersionName = projectSyncModel.getVersionName();
        Optional<ProjectVersionView> optionalProjectVersionView = getProjectVersion(projectView, projectVersionName);
        if (optionalProjectVersionView.isPresent()) {
            projectVersionView = optionalProjectVersionView.get();
            if (performUpdate) {
                logger.info(String.format("The %s version was found and performUpdate=true, so the version will be updated.", projectVersionName));
                projectSyncModel.populateProjectVersionView(projectVersionView);
                blackDuckApiClient.put(projectVersionView);
                projectVersionView = blackDuckApiClient.getResponse(projectVersionView.getHref(), ProjectVersionView.class);
            }
        } else {
            logger.info(String.format("The %s version was not found, so it will be created under the %s project.", projectVersionName, projectName));
            ProjectVersionRequest projectVersionRequest = projectSyncModel.createProjectVersionRequest();
            projectVersionView = createProjectVersion(projectView, projectVersionRequest);
        }
    }
    return new ProjectVersionWrapper(projectView, projectVersionView);
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) ProjectVersionRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectVersionRequest)

Example 8 with ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project hub-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)

Example 9 with ProjectRequest

use of com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest in project hub-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 10 with ProjectRequest

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

the class ProjectSyncModel method createProjectRequest.

public ProjectRequest createProjectRequest() {
    ProjectRequest projectRequest = new ProjectRequest();
    projectRequest.setName(name);
    projectRequest.setDescription(description);
    projectRequest.setProjectLevelAdjustments(projectLevelAdjustments);
    projectRequest.setProjectOwner(projectOwner);
    projectRequest.setProjectTier(projectTier);
    projectRequest.setProjectGroup(projectGroup);
    projectRequest.setCloneCategories(cloneCategories);
    projectRequest.setCustomSignatureEnabled(customSignatureEnabled);
    projectRequest.setVersionRequest(createProjectVersionRequest());
    return projectRequest;
}
Also used : ProjectRequest(com.synopsys.integration.blackduck.api.manual.temporary.component.ProjectRequest)

Aggregations

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