[#1651] Add SoftwareModule and DistributionSet unlock (REST) (#1677)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-03-08 11:28:24 +02:00
committed by GitHub
parent 4d104873de
commit ce9918ce00
10 changed files with 57 additions and 65 deletions

View File

@@ -10,12 +10,20 @@
package org.eclipse.hawkbit.repository.builder;
import jakarta.annotation.Nullable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.util.Optional;
/**
* Update implementation.
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
@Accessors(fluent = true)
public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateCreate<DistributionSetUpdate>
implements DistributionSetUpdate {
@@ -25,17 +33,4 @@ public class GenericDistributionSetUpdate extends AbstractDistributionSetUpdateC
public GenericDistributionSetUpdate(final Long id) {
super.id = id;
}
public DistributionSetUpdate locked(@Nullable final Boolean locked) {
if (Boolean.FALSE.equals(locked)) {
this.locked = null;
} else {
this.locked = locked;
}
return this;
}
public Boolean getLocked() {
return locked;
}
}

View File

@@ -10,12 +10,20 @@
package org.eclipse.hawkbit.repository.builder;
import jakarta.annotation.Nullable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.util.Optional;
/**
* Update implementation.
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
@Accessors(fluent = true)
public class GenericSoftwareModuleUpdate extends AbstractSoftwareModuleUpdateCreate<SoftwareModuleUpdate>
implements SoftwareModuleUpdate {
@@ -25,17 +33,4 @@ public class GenericSoftwareModuleUpdate extends AbstractSoftwareModuleUpdateCre
public GenericSoftwareModuleUpdate(final Long id) {
super.id = id;
}
public SoftwareModuleUpdate locked(@Nullable final Boolean locked) {
if (Boolean.FALSE.equals(locked)) {
this.locked = null;
} else {
this.locked = locked;
}
return this;
}
public Boolean getLocked() {
return locked;
}
}

View File

@@ -286,8 +286,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
update.getDescription().ifPresent(set::setDescription);
update.getVersion().ifPresent(set::setVersion);
if (Boolean.TRUE.equals(update.getLocked()) && !set.isLocked()) {
// lock/unlock ONLY if locked flag is present!
if (Boolean.TRUE.equals(update.locked())) {
set.lock();
} else if (Boolean.FALSE.equals(update.locked())) {
set.unlock();
}
if (update.isRequiredMigrationStep() != null

View File

@@ -142,8 +142,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
update.getDescription().ifPresent(module::setDescription);
update.getVendor().ifPresent(module::setVendor);
if (Boolean.TRUE.equals(update.getLocked()) && !module.isLocked()) {
// lock/unlock ONLY if locked flag is present!
if (Boolean.TRUE.equals(update.locked())) {
module.lock();
} else if (Boolean.FALSE.equals(update.locked())) {
module.unlock();
}
return softwareModuleRepository.save(module);