Skip to content

Commit

Permalink
[#1580] Software Module & Distribution Set lock: add lock at mgmt lev…
Browse files Browse the repository at this point in the history
…el (#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>
  • Loading branch information
avgustinmm committed Feb 15, 2024
1 parent 9bc0e74 commit 23ad6a1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 70 deletions.
Expand Up @@ -26,22 +26,9 @@
public interface DistributionSet extends NamedVersionedEntity {

/**
* @return <code>true</code> if the set is deleted and only kept for history
* purposes.
*/
boolean isDeleted();

/**
* @return <code>true</code> if {@link DistributionSet} contains a mandatory
* migration step, i.e. unfinished {@link Action}s will kept active
* and not automatically canceled if overridden by a newer update.
*/
boolean isRequiredMigrationStep();

/**
* @return the auto assign target filters
* @return type of the {@link DistributionSet}.
*/
List<TargetFilterQuery> getAutoAssignFilters();
DistributionSetType getType();

/**
*
Expand All @@ -50,32 +37,45 @@ public interface DistributionSet extends NamedVersionedEntity {
Set<SoftwareModule> getModules();

/**
* Searches through modules for the given type.
*
* @param type
* to search for
* @return SoftwareModule of given type
* @return <code>true</code> if all defined
* {@link DistributionSetType#getMandatoryModuleTypes()} of
* {@link #getType()} are present in this {@link DistributionSet}.
*/
default Optional<SoftwareModule> findFirstModuleByType(final SoftwareModuleType type) {
return getModules().stream().filter(module -> module.getType().equals(type)).findAny();
}
boolean isComplete();

/**
* @return type of the {@link DistributionSet}.
* @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.
*/
DistributionSetType getType();
boolean isLocked();

/**
* @return <code>true</code> if all defined
* {@link DistributionSetType#getMandatoryModuleTypes()} of
* {@link #getType()} are present in this {@link DistributionSet}.
* @return <code>true</code> if this {@link DistributionSet} is deleted and only kept for history
* purposes.
*/
boolean isComplete();
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
* and not automatically canceled if overridden by a newer update.
*/
boolean isRequiredMigrationStep();

/**
* Searches through modules for the given type.
*
* @param type
* to search for
* @return SoftwareModule of given type
*/
default Optional<SoftwareModule> findFirstModuleByType(final SoftwareModuleType type) {
return getModules().stream().filter(module -> module.getType().equals(type)).findAny();
}
}
Expand Up @@ -14,63 +14,63 @@

/**
* Software package as sub element of a {@link DistributionSet}.
*
*/
public interface SoftwareModule extends NamedVersionedEntity {

/**
* Maximum length of software vendor.
*/
int VENDOR_MAX_SIZE = 256;

/**
* @param artifactId
* to look for
* @return found {@link Artifact}
*/
default Optional<Artifact> getArtifact(final Long artifactId) {
return getArtifacts().stream().filter(artifact -> artifact.getId().equals(artifactId)).findAny();
}

/**
* @param fileName
* to look for
* @return found {@link Artifact}
* @return the type of the software module
*/
default Optional<Artifact> getArtifactByFilename(final String fileName) {
return getArtifacts().stream().filter(artifact -> artifact.getFilename().equalsIgnoreCase(fileName.trim()))
.findAny();
}
SoftwareModuleType getType();

/**
* @return immutable list of all artifacts
*/
List<Artifact> getArtifacts();

/**
* @return the vendor of this software module
* @return the vendor of this {@link SoftwareModule}.
*/
String getVendor();

/**
* @return the type of the software module
* @return {@code true} if this software module is marked as encrypted
* otherwise {@code false}
*/
SoftwareModuleType getType();
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 software module is marked as deleted
* @return {@code true} if this {@link SoftwareModule} is marked as deleted
* otherwise {@code false}
*/
boolean isDeleted();

/**
* @return immutable list of {@link DistributionSet}s the module is assigned
* to
* @param artifactId
* to look for
* @return found {@link Artifact}
*/
List<DistributionSet> getAssignedTo();
default Optional<Artifact> getArtifact(final Long artifactId) {
return getArtifacts().stream().filter(artifact -> artifact.getId().equals(artifactId)).findAny();
}

/**
* @return {@code true} if this software module is marked as encrypted
* otherwise {@code false}
* @param fileName
* to look for
* @return found {@link Artifact}
*/
boolean isEncrypted();
}
default Optional<Artifact> getArtifactByFilename(final String fileName) {
return getArtifacts().stream().filter(artifact -> artifact.getFilename().equalsIgnoreCase(fileName.trim()))
.findAny();
}
}
Expand Up @@ -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;

Expand Down
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -190,15 +190,6 @@ public void setEncrypted(final boolean encrypted) {
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(
Expand Down

0 comments on commit 23ad6a1

Please sign in to comment.