[#1580] Software Module & Distribution Set lock: add lock at mgmt level (#1644)

Additionally,

* removed DistributionSet.getAutoAssignFilters and
* removed SoftwareModule.getAssignedTo both are not used and exposed via Mgmt API.

Maybe, if needed, they could be returned back along with exposing them via Mgmt API.

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-15 09:20:48 +02:00
committed by GitHub
parent 9bc0e74f47
commit 23ad6a140f
4 changed files with 71 additions and 79 deletions

View File

@@ -26,11 +26,41 @@ import java.util.Set;
public interface DistributionSet extends NamedVersionedEntity {
/**
* @return <code>true</code> if the set is deleted and only kept for history
* @return type of the {@link DistributionSet}.
*/
DistributionSetType getType();
/**
*
* @return unmodifiableSet of {@link SoftwareModule}.
*/
Set<SoftwareModule> getModules();
/**
* @return <code>true</code> if all defined
* {@link DistributionSetType#getMandatoryModuleTypes()} of
* {@link #getType()} are present in this {@link DistributionSet}.
*/
boolean isComplete();
/**
* @return <code>true</code> if this {@link DistributionSet} is locked. If so it's 'functional'
* properties (e.g. software modules) could not be modified anymore.
*/
boolean isLocked();
/**
* @return <code>true</code> if this {@link DistributionSet} is deleted and only kept for history
* purposes.
*/
boolean isDeleted();
/**
* @return <code>false</code> if this {@link DistributionSet} is
* invalidated.
*/
boolean isValid();
/**
* @return <code>true</code> if {@link DistributionSet} contains a mandatory
* migration step, i.e. unfinished {@link Action}s will kept active
@@ -38,17 +68,6 @@ public interface DistributionSet extends NamedVersionedEntity {
*/
boolean isRequiredMigrationStep();
/**
* @return the auto assign target filters
*/
List<TargetFilterQuery> getAutoAssignFilters();
/**
*
* @return unmodifiableSet of {@link SoftwareModule}.
*/
Set<SoftwareModule> getModules();
/**
* Searches through modules for the given type.
*
@@ -59,23 +78,4 @@ public interface DistributionSet extends NamedVersionedEntity {
default Optional<SoftwareModule> findFirstModuleByType(final SoftwareModuleType type) {
return getModules().stream().filter(module -> module.getType().equals(type)).findAny();
}
/**
* @return type of the {@link DistributionSet}.
*/
DistributionSetType getType();
/**
* @return <code>true</code> if all defined
* {@link DistributionSetType#getMandatoryModuleTypes()} of
* {@link #getType()} are present in this {@link DistributionSet}.
*/
boolean isComplete();
/**
* @return <code>false</code> if this {@link DistributionSet} is
* invalidated.
*/
boolean isValid();
}
}

View File

@@ -14,14 +14,47 @@ import java.util.Optional;
/**
* Software package as sub element of a {@link DistributionSet}.
*
*/
public interface SoftwareModule extends NamedVersionedEntity {
/**
* Maximum length of software vendor.
*/
int VENDOR_MAX_SIZE = 256;
/**
* @return the type of the software module
*/
SoftwareModuleType getType();
/**
* @return immutable list of all artifacts
*/
List<Artifact> getArtifacts();
/**
* @return the vendor of this {@link SoftwareModule}.
*/
String getVendor();
/**
* @return {@code true} if this software module is marked as encrypted
* otherwise {@code false}
*/
boolean isEncrypted();
/**
* @return <code>true</code> if this {@link SoftwareModule} is locked. If so it's 'functional'
* properties (e.g. software modules) could not be modified anymore.
*/
boolean isLocked();
/**
* @return {@code true} if this {@link SoftwareModule} is marked as deleted
* otherwise {@code false}
*/
boolean isDeleted();
/**
* @param artifactId
* to look for
@@ -40,37 +73,4 @@ public interface SoftwareModule extends NamedVersionedEntity {
return getArtifacts().stream().filter(artifact -> artifact.getFilename().equalsIgnoreCase(fileName.trim()))
.findAny();
}
/**
* @return immutable list of all artifacts
*/
List<Artifact> getArtifacts();
/**
* @return the vendor of this software module
*/
String getVendor();
/**
* @return the type of the software module
*/
SoftwareModuleType getType();
/**
* @return {@code true} if this software module is marked as deleted
* otherwise {@code false}
*/
boolean isDeleted();
/**
* @return immutable list of {@link DistributionSet}s the module is assigned
* to
*/
List<DistributionSet> getAssignedTo();
/**
* @return {@code true} if this software module is marked as encrypted
* otherwise {@code false}
*/
boolean isEncrypted();
}
}

View File

@@ -123,6 +123,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
private boolean requiredMigrationStep;
@ToString.Exclude
@Getter(AccessLevel.NONE)
@OneToMany(mappedBy = "autoAssignDistributionSet", targetEntity = JpaTargetFilterQuery.class, fetch = FetchType.LAZY)
private List<TargetFilterQuery> autoAssignFilters;

View File

@@ -88,6 +88,9 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Size(max = SoftwareModule.VENDOR_MAX_SIZE)
private String vendor;
@Column(name = "encrypted")
private boolean encrypted;
@ToString.Exclude
@CascadeOnDelete
@OneToMany(mappedBy = "softwareModule", fetch = FetchType.LAZY, targetEntity = JpaSoftwareModuleMetadata.class)
@@ -99,9 +102,6 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Column(name = "deleted")
private boolean deleted;
@Column(name = "encrypted")
private boolean encrypted;
@ToString.Exclude
@Getter(AccessLevel.NONE)
@CascadeOnDelete
@@ -190,15 +190,6 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
this.encrypted = encrypted;
}
@Override
public List<DistributionSet> getAssignedTo() {
if (assignedTo == null) {
return Collections.emptyList();
}
return Collections.unmodifiableList(assignedTo);
}
@Override
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(