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());
}
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);
}
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));
}
}
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);
}
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;
}
Aggregations