Fix some issues found by qodana (#2083)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.hawkbit.repository.event.entity.EntityCreatedEvent;
|
||||
@@ -20,6 +22,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
@NoArgsConstructor(access = AccessLevel.PUBLIC) // for serialization libs like jackson
|
||||
public class TargetFilterQueryCreatedEvent extends RemoteEntityEvent<TargetFilterQuery> implements EntityCreatedEvent {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -20,6 +21,7 @@ import org.eclipse.hawkbit.repository.Identifiable;
|
||||
@Data
|
||||
public class AssignedSoftwareModule implements Serializable, Identifiable<Long> {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final SoftwareModule softwareModule;
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -22,6 +23,7 @@ import org.springframework.util.StringUtils;
|
||||
public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
|
||||
@ValidString
|
||||
@Getter
|
||||
protected String key;
|
||||
@ValidString
|
||||
protected String value;
|
||||
@@ -31,10 +33,6 @@ public abstract class AbstractMetadataUpdateCreate<T> {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public T value(final String value) {
|
||||
this.value = StringUtils.trimWhitespace(value);
|
||||
return (T) this;
|
||||
|
||||
@@ -235,8 +235,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
// ValidatorFactory shall NOT be closed because after closing the generated Validator
|
||||
// methods shall not be called - we need the validator in future
|
||||
processor.setValidator(Validation.byDefaultProvider().configure()
|
||||
.addProperty(BaseHibernateValidatorConfiguration.ALLOW_PARALLEL_METHODS_DEFINE_PARAMETER_CONSTRAINTS,
|
||||
"true")
|
||||
.addProperty(BaseHibernateValidatorConfiguration.ALLOW_PARALLEL_METHODS_DEFINE_PARAMETER_CONSTRAINTS,"true")
|
||||
.buildValidatorFactory().getValidator());
|
||||
return processor;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class AutoAssignChecker extends AbstractAutoAssignExecutor {
|
||||
} catch (final PersistenceException | AbstractServerRtException e) {
|
||||
log.error("Error during auto assign check of target filter query id {}", targetFilterQuery.getId(), e);
|
||||
}
|
||||
log.debug("Auto assign check call for tenant {} and target filter query id {} finished",
|
||||
getContextAware().getCurrentTenant(), targetFilterQuery.getId());
|
||||
log.debug("Auto assign check call for tenant {} and target filter query id {} for device {} finished",
|
||||
getContextAware().getCurrentTenant(), targetFilterQuery.getId(), controllerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSyn
|
||||
try {
|
||||
afterCommitRunnable.run();
|
||||
} catch (final RuntimeException e) {
|
||||
log.error("Failed to execute runnable " + afterCommitRunnable, e);
|
||||
log.error("Failed to execute runnable {}", afterCommitRunnable, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
try {
|
||||
assertTargetUpdateAllowed(action);
|
||||
forceQuitAction(action.getId());
|
||||
log.debug("Action {} force canceled", action.getId());
|
||||
log.debug("Action {} force canceled (force)", action.getId());
|
||||
} catch (final InsufficientPermissionException e) {
|
||||
log.trace("Could not cancel action {} due to insufficient permissions.", action.getId(), e);
|
||||
} catch (final EntityNotFoundException e) {
|
||||
|
||||
@@ -145,7 +145,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
RSQLUtility.validateRsqlFor(query, TargetFields.class);
|
||||
return true;
|
||||
} catch (final RSQLParserException | RSQLParameterUnsupportedFieldException e) {
|
||||
log.debug("The RSQL query '" + query + "' is invalid.", e);
|
||||
log.debug("The RSQL query '{}}' is invalid.", query, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(
|
||||
final String configurationKeyName) {
|
||||
@Cacheable(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||
public <T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(final String configurationKeyName) {
|
||||
checkAccess(configurationKeyName);
|
||||
|
||||
final TenantConfigurationKey configurationKey = tenantConfigurationProperties.fromKeyName(configurationKeyName);
|
||||
@@ -117,16 +117,15 @@ public class JpaTenantConfigurationManagement implements TenantConfigurationMana
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "tenantConfiguration", key = "#configurationKeyName")
|
||||
public <T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(final String configurationKeyName,
|
||||
final Class<T> propertyType) {
|
||||
public <T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(
|
||||
final String configurationKeyName, final Class<T> propertyType) {
|
||||
checkAccess(configurationKeyName);
|
||||
|
||||
final TenantConfigurationKey configurationKey = tenantConfigurationProperties.fromKeyName(configurationKeyName);
|
||||
|
||||
validateTenantConfigurationDataType(configurationKey, propertyType);
|
||||
|
||||
final TenantConfiguration tenantConfiguration = tenantConfigurationRepository
|
||||
.findByKey(configurationKey.getKeyName());
|
||||
final TenantConfiguration tenantConfiguration = tenantConfigurationRepository.findByKey(configurationKey.getKeyName());
|
||||
|
||||
return buildTenantConfigurationValueByKey(configurationKey, propertyType, tenantConfiguration);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Objects;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
@@ -26,6 +27,7 @@ import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
@MappedSuperclass
|
||||
public abstract class AbstractJpaMetaData implements MetaData {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
|
||||
@@ -24,8 +24,7 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
* addition to their technical ID.
|
||||
*/
|
||||
@MappedSuperclass
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public abstract class AbstractJpaNamedEntity extends AbstractJpaTenantAwareBaseEntity implements NamedEntity {
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -21,11 +23,11 @@ import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
|
||||
* Extension for {@link NamedEntity} that are versioned.
|
||||
*/
|
||||
@MappedSuperclass
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEntity implements NamedVersionedEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "version", nullable = false, length = NamedVersionedEntity.VERSION_MAX_SIZE)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.PrePersist;
|
||||
@@ -31,6 +33,7 @@ import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
|
||||
@Multitenant(MultitenantType.SINGLE_TABLE)
|
||||
public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEntity implements TenantAwareBaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
@@ -34,6 +35,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
@Table(name = "sp_ds_type_element")
|
||||
public class DistributionSetTypeElement implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@EmbeddedId
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
@@ -20,6 +21,7 @@ import jakarta.persistence.Embeddable;
|
||||
@Embeddable
|
||||
public class DistributionSetTypeElementCompositeKey implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "distribution_set_type", nullable = false, updatable = false)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -17,6 +18,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
public final class DsMetadataCompositeKey implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String key;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
@@ -34,11 +36,11 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
@Index(name = "sp_idx_artifact_02", columnList = "tenant,sha1_hash"),
|
||||
@Index(name = "sp_idx_artifact_prim", columnList = "tenant,id") })
|
||||
@Entity
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Artifact {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "sha1_hash", length = 40, nullable = false, updatable = false)
|
||||
|
||||
@@ -66,8 +66,7 @@ import org.springframework.context.ApplicationEvent;
|
||||
@Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "DistributionSet.detail", attributeNodes = { @NamedAttributeNode("modules"),
|
||||
@NamedAttributeNode("tags"), @NamedAttributeNode("type") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implements DistributionSet, EventAwareEntity {
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -30,6 +32,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
@Table(name = "sp_ds_metadata")
|
||||
public class JpaDistributionSetMetadata extends AbstractJpaMetaData implements DistributionSetMetadata {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -30,12 +31,14 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
* and use them also for filtering the DistributionSet list.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_distributionset_tag", indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_distribution_set_tag_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_ds_tag"))
|
||||
@Table(name = "sp_distributionset_tag",
|
||||
indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id"),
|
||||
@Index(name = "sp_idx_distribution_set_tag_01", columnList = "tenant,name") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_ds_tag"))
|
||||
public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManyToMany(mappedBy = "tags", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY)
|
||||
|
||||
@@ -48,8 +48,7 @@ import org.springframework.util.CollectionUtils;
|
||||
@Index(name = "sp_idx_distribution_set_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_dst_name"),
|
||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_dst_key") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaDistributionSetType extends AbstractJpaTypeEntity implements DistributionSetType, EventAwareEntity {
|
||||
|
||||
@@ -136,11 +135,11 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis
|
||||
@Override
|
||||
public boolean checkComplete(final DistributionSet distributionSet) {
|
||||
final List<SoftwareModuleType> smTypes = distributionSet.getModules().stream().map(SoftwareModule::getType)
|
||||
.distinct().collect(Collectors.toList());
|
||||
.distinct().toList();
|
||||
if (smTypes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return smTypes.containsAll(getMandatoryModuleTypes());
|
||||
return new HashSet<>(smTypes).containsAll(getMandatoryModuleTypes());
|
||||
}
|
||||
|
||||
public JpaDistributionSetType addOptionalModuleType(final SoftwareModuleType smType) {
|
||||
|
||||
@@ -61,8 +61,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Index(name = "sp_idx_base_sw_module_02", columnList = "tenant,deleted,module_type"),
|
||||
@Index(name = "sp_idx_base_sw_module_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "SoftwareModule.artifacts", attributeNodes = { @NamedAttributeNode("artifacts") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implements SoftwareModule, EventAwareEntity {
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -31,6 +33,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
@Table(name = "sp_sw_metadata")
|
||||
public class JpaSoftwareModuleMetadata extends AbstractJpaMetaData implements SoftwareModuleMetadata {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
|
||||
@@ -33,8 +33,7 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Index(name = "sp_idx_software_module_type_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "type_key", "tenant" }, name = "uk_smt_type_key"),
|
||||
@UniqueConstraint(columnNames = { "name", "tenant" }, name = "uk_smt_name") })
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaSoftwareModuleType extends AbstractJpaTypeEntity implements SoftwareModuleType, EventAwareEntity {
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -20,11 +22,11 @@ import org.eclipse.hawkbit.repository.model.Tag;
|
||||
* kind of entity.
|
||||
*/
|
||||
@MappedSuperclass
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTag extends AbstractJpaNamedEntity implements Tag {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "colour", nullable = true, length = Tag.COLOUR_MAX_SIZE)
|
||||
|
||||
@@ -76,8 +76,7 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
@Index(name = "sp_idx_target_05", columnList = "tenant,last_modified_at"),
|
||||
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"controller_id", "tenant" }, name = "uk_tenant_controller_id"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
@Slf4j
|
||||
public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAwareEntity {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -30,6 +32,7 @@ import org.eclipse.hawkbit.repository.model.TargetMetadata;
|
||||
@Table(name = "sp_target_metadata")
|
||||
public class JpaTargetMetadata extends AbstractJpaMetaData implements TargetMetadata {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -29,12 +31,11 @@ import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
|
||||
@Entity
|
||||
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
||||
"tenant" }, name = "uk_tenant_key"))
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity
|
||||
implements TenantConfiguration, EventAwareEntity {
|
||||
public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity implements TenantConfiguration, EventAwareEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "conf_key", length = TenantConfiguration.KEY_MAX_SIZE, nullable = false, updatable = false)
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ConstraintMode;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -38,11 +40,11 @@ import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
@Index(name = "sp_idx_tenant_prim", columnList = "tenant,id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "tenant" }, name = "uk_tenantmd_tenant") })
|
||||
@Entity
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||
// sub entities
|
||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for sub entities
|
||||
@SuppressWarnings("squid:S2160")
|
||||
public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMetaData {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "tenant", nullable = false, updatable = false, length = 40)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
@@ -19,6 +20,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
*/
|
||||
public class RolloutTargetGroupId implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long rolloutGroup;
|
||||
|
||||
@@ -9,30 +9,27 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The Software Module meta data composite key which contains the meta data key
|
||||
* The Software Module meta-data composite key which contains the meta-data key
|
||||
* and the ID of the software module itself.
|
||||
*/
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
public final class SwMetadataCompositeKey implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String key;
|
||||
|
||||
private Long softwareModule;
|
||||
|
||||
/**
|
||||
* Default constructor for JPA.
|
||||
*/
|
||||
public SwMetadataCompositeKey() {
|
||||
// Default constructor for JPA.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param moduleId the software module for this meta data
|
||||
* @param key the key of the meta data
|
||||
* @param moduleId the software module for this meta-data
|
||||
* @param key the key of the meta-data
|
||||
*/
|
||||
public SwMetadataCompositeKey(final Long moduleId, final String key) {
|
||||
this.softwareModule = moduleId;
|
||||
|
||||
@@ -9,28 +9,27 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.model;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The Target Metadata composite key which contains the meta data key and the ID
|
||||
* of the Target itself.
|
||||
* The Target Metadata composite key which contains the meta-data key and the ID of the Target itself.
|
||||
*/
|
||||
@NoArgsConstructor // Default constructor for JPA
|
||||
public final class TargetMetadataCompositeKey implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String key;
|
||||
|
||||
private Long target;
|
||||
|
||||
public TargetMetadataCompositeKey() {
|
||||
// Default constructor for JPA.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target the target Id for this meta data
|
||||
* @param key the key of the meta data
|
||||
* @param target the target Id for this meta-data
|
||||
* @param key the key of the meta-data
|
||||
*/
|
||||
public TargetMetadataCompositeKey(final Long target, final String key) {
|
||||
this.target = target;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class RolloutGroupEvaluationManager {
|
||||
final List<RolloutGroupActionEvaluator<T>> evaluators, final T action) {
|
||||
return evaluators.stream().filter(evaluator -> evaluator.getAction() == action).findFirst().orElseThrow(() -> {
|
||||
log.warn("Could not find suitable evaluator for the '{}' action.", action.name());
|
||||
throw new EvaluatorNotConfiguredException(action.name());
|
||||
return new EvaluatorNotConfiguredException(action.name());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class RolloutGroupEvaluationManager {
|
||||
return evaluators.stream().filter(evaluator -> evaluator.getCondition() == condition).findFirst()
|
||||
.orElseThrow(() -> {
|
||||
log.warn("Could not find suitable evaluator for the '{}' condition.", condition.name());
|
||||
throw new EvaluatorNotConfiguredException(condition.name());
|
||||
return new EvaluatorNotConfiguredException(condition.name());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class ThresholdRolloutGroupErrorCondition
|
||||
final Long error = actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(),
|
||||
rolloutGroup.getId(), Action.Status.ERROR);
|
||||
try {
|
||||
final Integer threshold = Integer.valueOf(expression);
|
||||
final int threshold = Integer.parseInt(expression);
|
||||
|
||||
if (totalGroup == 0) {
|
||||
// in case e.g. targets has been deleted we don't have any
|
||||
@@ -50,7 +50,7 @@ public class ThresholdRolloutGroupErrorCondition
|
||||
// calculate threshold
|
||||
return ((float) error / (float) totalGroup) > ((float) threshold / 100F);
|
||||
} catch (final NumberFormatException e) {
|
||||
log.error("Cannot evaluate condition expression " + expression, e);
|
||||
log.error("Cannot evaluate condition expression {}", expression, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ThresholdRolloutGroupSuccessCondition
|
||||
return ((float) finished / (float) totalGroup) >= ((float) threshold / 100F);
|
||||
|
||||
} catch (final NumberFormatException e) {
|
||||
log.error("Cannot evaluate condition expression " + expression, e);
|
||||
log.error("Cannot evaluate condition expression {}", expression, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,15 +225,15 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
return builder;
|
||||
}
|
||||
|
||||
builder = message.substring(message.indexOf(':') + 1, message.length());
|
||||
if (builder.indexOf("Was expecting") != -1) {
|
||||
builder = message.substring(message.indexOf(':') + 1);
|
||||
if (builder.contains("Was expecting")) {
|
||||
builder = builder.substring(0, builder.lastIndexOf("Was expecting"));
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(expectedTokens)) {
|
||||
final StringBuilder tokens = new StringBuilder();
|
||||
expectedTokens.stream().forEach(value -> tokens.append(value.getSuggestion() + ","));
|
||||
builder = builder.concat("Was expecting :" + tokens.toString().substring(0, tokens.length() - 1));
|
||||
expectedTokens.stream().forEach(value -> tokens.append(value.getSuggestion()).append(","));
|
||||
builder = builder.concat("Was expecting :" + tokens.substring(0, tokens.length() - 1));
|
||||
}
|
||||
builder = builder.replace('\r', ' ');
|
||||
builder = builder.replace('\n', ' ');
|
||||
@@ -290,7 +290,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
final String finalTmpTokenName = tmpTokenName;
|
||||
return Arrays.stream(TargetFields.values())
|
||||
.filter(field -> field.toString().equalsIgnoreCase(finalTmpTokenName))
|
||||
.map(TargetFields::getSubEntityAttributes).flatMap(List::stream).count() > 0;
|
||||
.map(TargetFields::getSubEntityAttributes).mapToLong(List::size).sum() > 0;
|
||||
}
|
||||
|
||||
private static boolean isMap(final String tokenImageName) {
|
||||
@@ -316,16 +316,14 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
|
||||
private static boolean containsValue(final String imageName) {
|
||||
if (!imageName.contains(".")) {
|
||||
return FIELD_NAMES.stream().filter(value -> value.equalsIgnoreCase(imageName)).count() > 0;
|
||||
return FIELD_NAMES.stream().anyMatch(value -> value.equalsIgnoreCase(imageName));
|
||||
}
|
||||
final String[] split = imageName.split("\\.");
|
||||
if (split.length > 1 && FIELD_NAMES.contains(split[0].toLowerCase())) {
|
||||
return SUB_NAMES.get(split[0].toLowerCase()).stream()
|
||||
.filter(subname -> (split[0] + "." + subname).equalsIgnoreCase(imageName)).count() > 0;
|
||||
.anyMatch(subname -> (split[0] + "." + subname).equalsIgnoreCase(imageName));
|
||||
}
|
||||
return FIELD_NAMES.stream().filter(value -> value.equalsIgnoreCase(imageName)).count() > 0;
|
||||
return FIELD_NAMES.stream().anyMatch(value -> value.equalsIgnoreCase(imageName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -578,7 +578,7 @@ public final class TargetSpecifications {
|
||||
hasTagsPredicates.add(exp.isNull());
|
||||
}
|
||||
if (isAtLeastOneTagActive(tagNames)) {
|
||||
hasTagsPredicates.add(exp.in(tagNames));
|
||||
hasTagsPredicates.add(exp.in((Object[]) tagNames));
|
||||
}
|
||||
|
||||
return hasTagsPredicates.stream().reduce(cb::or)
|
||||
|
||||
@@ -14,6 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -175,11 +176,11 @@ public class EventVerifier extends AbstractTestExecutionListener {
|
||||
|
||||
private static final class ResetCounterMarkerEvent extends RemoteApplicationEvent {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ResetCounterMarkerEvent() {
|
||||
super(new Object(), "resetcounter");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user