mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-10-20 00:13:20 +00:00
Allow cloning of ACL during Project cloning
Signed-off-by: Valentijn Scholten <valentijnscholten@gmail.com>
This commit is contained in:
parent
7878b039b7
commit
a5ff479c9a
6 changed files with 51 additions and 7 deletions
|
@ -27,6 +27,8 @@ import alpine.model.UserPrincipal;
|
|||
import alpine.persistence.PaginatedResult;
|
||||
import alpine.resources.AlpineRequest;
|
||||
import com.github.packageurl.PackageURL;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dependencytrack.auth.Permissions;
|
||||
import org.dependencytrack.event.IndexEvent;
|
||||
|
@ -49,6 +51,7 @@ import java.security.Principal;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -536,7 +539,8 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
}
|
||||
|
||||
public Project clone(UUID from, String newVersion, boolean includeTags, boolean includeProperties,
|
||||
boolean includeComponents, boolean includeServices, boolean includeAuditHistory) {
|
||||
boolean includeComponents, boolean includeServices, boolean includeAuditHistory,
|
||||
boolean includeACL) {
|
||||
final Project source = getObjectByUuid(Project.class, from, Project.FetchGroup.ALL.name());
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
@ -627,6 +631,15 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
}
|
||||
}
|
||||
|
||||
if (includeACL) {
|
||||
//It's possible that the DT instance is being prepared for ACL enabling,
|
||||
//So client can request to includeACL even if ACL is not (yet) enabled
|
||||
List<Team> accessTeams = source.getAccessTeams();
|
||||
if (CollectionUtils.isEmpty(accessTeams)) {
|
||||
project.setAccessTeams(new LinkedList<>(accessTeams));
|
||||
}
|
||||
}
|
||||
|
||||
project = getObjectById(Project.class, project.getId());
|
||||
Event.dispatch(new IndexEvent(IndexEvent.Action.CREATE, pm.detachCopy(project)));
|
||||
commitSearchIndex(true, Project.class);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue