mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-11-01 14:10:57 +00:00
Merge pull request #3179 from nscuro/supplier-manufacturer-corrections
Supplier and manufacturer corrections
This commit is contained in:
commit
065e483a98
22 changed files with 871 additions and 238 deletions
|
|
@ -40,6 +40,7 @@ import org.dependencytrack.model.Component;
|
|||
import org.dependencytrack.model.ConfigPropertyConstants;
|
||||
import org.dependencytrack.model.FindingAttribution;
|
||||
import org.dependencytrack.model.Project;
|
||||
import org.dependencytrack.model.ProjectMetadata;
|
||||
import org.dependencytrack.model.ProjectProperty;
|
||||
import org.dependencytrack.model.ProjectVersion;
|
||||
import org.dependencytrack.model.ServiceComponent;
|
||||
|
|
@ -49,6 +50,7 @@ import org.dependencytrack.notification.NotificationConstants;
|
|||
import org.dependencytrack.notification.NotificationGroup;
|
||||
import org.dependencytrack.notification.NotificationScope;
|
||||
import org.dependencytrack.util.NotificationUtil;
|
||||
|
||||
import javax.jdo.FetchPlan;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.jdo.Query;
|
||||
|
|
@ -509,40 +511,6 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Project.
|
||||
* @param uuid the uuid of the project to update
|
||||
* @param name the name of the project
|
||||
* @param description a description of the project
|
||||
* @param version the project version
|
||||
* @param tags a List of Tags - these will be resolved if necessary
|
||||
* @param purl an optional Package URL
|
||||
* @param active specified if the project is active
|
||||
* @param commitIndex specifies if the search index should be committed (an expensive operation)
|
||||
* @return the updated Project
|
||||
*/
|
||||
@Override
|
||||
public Project updateProject(UUID uuid, String name, String description, String version, List<Tag> tags, PackageURL purl, boolean active, boolean commitIndex) {
|
||||
final Project project = getObjectByUuid(Project.class, uuid);
|
||||
project.setName(name);
|
||||
project.setDescription(description);
|
||||
project.setVersion(version);
|
||||
project.setPurl(purl);
|
||||
|
||||
if (!active && Boolean.TRUE.equals(project.isActive()) && hasActiveChild(project)){
|
||||
throw new IllegalArgumentException("Project cannot be set to inactive, if active children are present.");
|
||||
}
|
||||
project.setActive(active);
|
||||
|
||||
final List<Tag> resolvedTags = resolveTags(tags);
|
||||
bind(project, resolvedTags);
|
||||
|
||||
final Project result = persist(project);
|
||||
Event.dispatch(new IndexEvent(IndexEvent.Action.UPDATE, result));
|
||||
commitSearchIndex(commitIndex, Project.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Project.
|
||||
* @param transientProject the project to update
|
||||
|
|
@ -554,6 +522,8 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
final Project project = getObjectByUuid(Project.class, transientProject.getUuid());
|
||||
project.setAuthor(transientProject.getAuthor());
|
||||
project.setPublisher(transientProject.getPublisher());
|
||||
project.setManufacturer(transientProject.getManufacturer());
|
||||
project.setSupplier(transientProject.getSupplier());
|
||||
project.setGroup(transientProject.getGroup());
|
||||
project.setName(transientProject.getName());
|
||||
project.setDescription(transientProject.getDescription());
|
||||
|
|
@ -614,6 +584,8 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
}
|
||||
Project project = new Project();
|
||||
project.setAuthor(source.getAuthor());
|
||||
project.setManufacturer(source.getManufacturer());
|
||||
project.setSupplier(source.getSupplier());
|
||||
project.setPublisher(source.getPublisher());
|
||||
project.setGroup(source.getGroup());
|
||||
project.setName(source.getName());
|
||||
|
|
@ -630,6 +602,14 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
project.setParent(source.getParent());
|
||||
project = persist(project);
|
||||
|
||||
if (source.getMetadata() != null) {
|
||||
final var metadata = new ProjectMetadata();
|
||||
metadata.setProject(project);
|
||||
metadata.setAuthors(source.getMetadata().getAuthors());
|
||||
metadata.setSupplier(source.getMetadata().getSupplier());
|
||||
persist(metadata);
|
||||
}
|
||||
|
||||
if (includeTags) {
|
||||
for (final Tag tag: source.getTags()) {
|
||||
tag.getProjects().add(project);
|
||||
|
|
@ -751,6 +731,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
deleteVexs(project);
|
||||
removeProjectFromNotificationRules(project);
|
||||
removeProjectFromPolicies(project);
|
||||
delete(project.getMetadata());
|
||||
delete(project.getProperties());
|
||||
delete(getAllBoms(project));
|
||||
delete(project.getChildren());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue