Fix some compile warnings (#2919)

* Fix some compile warnings
* Some classes made final
* JPA entities made not serializable

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-02-11 14:05:46 +02:00
committed by GitHub
parent 17eacc729b
commit 62c76311e5
89 changed files with 362 additions and 358 deletions

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.artifact.exception;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
@@ -21,6 +23,9 @@ import org.eclipse.hawkbit.exception.SpServerError;
@ToString(callSuper = true)
public class FileSizeQuotaExceededException extends AbstractServerRtException {
@Serial
private static final long serialVersionUID = 1L;
private static final String MAX_ARTIFACT_SIZE_EXCEEDED = "Maximum artifact size (%s) exceeded.";
private static final SpServerError errorType = SpServerError.SP_FILE_SIZE_QUOTA_EXCEEDED;

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.artifact.exception;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
@@ -21,6 +23,9 @@ import org.eclipse.hawkbit.exception.SpServerError;
@ToString(callSuper = true)
public class StorageQuotaExceededException extends AbstractServerRtException {
@Serial
private static final long serialVersionUID = 1L;
private static final String MAX_ARTIFACT_SIZE_TOTAL_EXCEEDED = "Storage quota exceeded, %s left.";
private static final SpServerError errorType = SpServerError.SP_STORAGE_QUOTA_EXCEEDED;

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.security.controller;
import static org.eclipse.hawkbit.context.AccessContext.asTenant;
import java.io.Serial;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
@@ -61,6 +62,9 @@ public interface Authenticator {
@EqualsAndHashCode(callSuper = true)
private static class AuthenticatedController extends AbstractAuthenticationToken {
@Serial
private static final long serialVersionUID = 1L;
private static final Collection<GrantedAuthority> CONTROLLER_AUTHORITY =
List.of(new SimpleGrantedAuthority(SpRole.CONTROLLER_ROLE));
private final String controllerId;

View File

@@ -16,19 +16,13 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.util.ErrorHandler;
/**
* {@link RabbitListenerContainerFactory} that can be configured through
* hawkBit's {@link AmqpProperties}.
* {@link RabbitListenerContainerFactory} that can be configured through hawkBit's {@link AmqpProperties}.
*/
public class ConfigurableRabbitListenerContainerFactory extends SimpleRabbitListenerContainerFactory {
public final class ConfigurableRabbitListenerContainerFactory extends SimpleRabbitListenerContainerFactory {
private final int declarationRetries;
/**
* Constructor.
*
* @param missingQueuesFatal the missingQueuesFatal to set.
* @param declarationRetries The number of retries
* @param errorHandler the error handler which should be use
* @see SimpleMessageListenerContainer#setMissingQueuesFatal
*/
public ConfigurableRabbitListenerContainerFactory(

View File

@@ -32,7 +32,7 @@ import org.springframework.util.ObjectUtils;
*/
@ToString
@Slf4j
class RequeueExceptionStrategy implements FatalExceptionStrategy {
final class RequeueExceptionStrategy implements FatalExceptionStrategy {
private final List<FatalExceptionStrategy> fatalExceptionStrategies = new ArrayList<>();

View File

@@ -43,7 +43,6 @@ import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.ActionProperties;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -427,8 +426,8 @@ class AmqpMessageHandlerServiceTest {
* Test next update is provided on finished action
*/
@Test
@SuppressWarnings("unchecked")
void lookupNextUpdateActionAfterFinished() {
// Mock
final Action action = createActionWithTarget(22L);
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
@@ -460,7 +459,7 @@ class AmqpMessageHandlerServiceTest {
* Test feedback code is persisted in messages when provided with DmfActionUpdateStatus
*/
@Test
void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
void feedBackCodeIsPersistedInMessages() {
// Mock
final Action action = createActionWithTarget(22L);
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
@@ -471,9 +470,7 @@ class AmqpMessageHandlerServiceTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(
23L, DmfActionStatus.RUNNING, null, 2L, null, 12);
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(23L, DmfActionStatus.RUNNING, null, 2L, null, 12);
final Message message = createMessage(actionUpdateStatus, messageProperties);
// test

View File

@@ -133,11 +133,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
void registerTargetWithName() {
final String controllerId = TARGET_PREFIX + "registerTargetWithName";
final String name = "NonDefaultTargetName";
registerAndAssertTargetWithExistingTenant(controllerId, name, 1, TargetUpdateStatus.REGISTERED, CREATED_BY,
null);
registerSameTargetAndAssertBasedOnVersion(controllerId, name + "_updated", 1, TargetUpdateStatus.REGISTERED,
null);
registerAndAssertTargetWithExistingTenant(controllerId, name, 1, TargetUpdateStatus.REGISTERED, CREATED_BY, null);
registerSameTargetAndAssertBasedOnVersion(controllerId, name + "_updated", 1, TargetUpdateStatus.REGISTERED, null);
Mockito.verifyNoInteractions(getDeadletterListener());
}
@@ -156,8 +153,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
attributes.put("testKey1", "testValue1");
attributes.put("testKey2", "testValue2");
registerAndAssertTargetWithExistingTenant(controllerId, null, 1, TargetUpdateStatus.REGISTERED, CREATED_BY,
attributes);
registerAndAssertTargetWithExistingTenant(controllerId, null, 1, TargetUpdateStatus.REGISTERED, CREATED_BY, attributes);
attributes.put("testKey3", "testValue3");
registerSameTargetAndAssertBasedOnVersion(controllerId, null, 1, TargetUpdateStatus.REGISTERED, attributes);
@@ -176,24 +172,22 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
void registerTargetWithNameAndAttributes() {
final String controllerId = TARGET_PREFIX + "registerTargetWithAttributes";
final String name = "NonDefaultTargetName";
final Map<String, String> attributes = new HashMap<>();
attributes.put("testKey1", "testValue1");
attributes.put("testKey2", "testValue2");
registerAndAssertTargetWithExistingTenant(controllerId, name, 1, TargetUpdateStatus.REGISTERED, CREATED_BY,
attributes);
registerAndAssertTargetWithExistingTenant(controllerId, name, 1, TargetUpdateStatus.REGISTERED, CREATED_BY, attributes);
attributes.put("testKey3", "testValue3");
registerSameTargetAndAssertBasedOnVersion(controllerId, name + "_updated", 1, TargetUpdateStatus.REGISTERED,
attributes);
registerSameTargetAndAssertBasedOnVersion(controllerId, name + "_updated", 1, TargetUpdateStatus.REGISTERED, attributes);
Mockito.verifyNoInteractions(getDeadletterListener());
}
@ParameterizedTest
/**
* Tests register invalid target with empty controller id.
*/
@ParameterizedTest
@ValueSource(strings = { "", "Invalid Invalid" })
@NullSource
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@@ -328,10 +322,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0);
}
@ParameterizedTest
/**
* Tests null type message header. This message should forwarded to the deadletter queue
*/
@ParameterizedTest
@ValueSource(strings = { "", "NotExist" })
@NullSource
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@@ -344,10 +338,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0);
}
@ParameterizedTest
/**
* Tests null topic message header. This message should forwarded to the deadletter queue
*/
@ParameterizedTest
@ValueSource(strings = { "", "NotExist" })
@NullSource
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@@ -372,10 +366,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage();
}
@ParameterizedTest
/**
* Tests invalid null message content. This message should forwarded to the deadletter queue
*/
@ParameterizedTest
@ValueSource(strings = { "", "Invalid Content" })
@NullSource
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
@@ -607,8 +601,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerAndAssertTargetWithExistingTenant(controllerId);
final DistributionSet distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
testdataFactory.addSoftwareModuleMetadata(distributionSet);
assignDistributionSetWithMaintenanceWindow(distributionSet.getId(), controllerId, getTestSchedule(2),
getTestDuration(1), getTestTimeZone());
assignDistributionSetWithMaintenanceWindow(
distributionSet.getId(), controllerId, getTestSchedule(2), getTestDuration(1), getTestTimeZone());
// test
registerSameTargetAndAssertBasedOnVersion(controllerId, 1, TargetUpdateStatus.PENDING);
@@ -639,8 +633,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerAndAssertTargetWithExistingTenant(controllerId);
final DistributionSet distributionSet = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
testdataFactory.addSoftwareModuleMetadata(distributionSet);
assignDistributionSetWithMaintenanceWindow(distributionSet.getId(), controllerId, getTestSchedule(-5),
getTestDuration(10), getTestTimeZone());
assignDistributionSetWithMaintenanceWindow(
distributionSet.getId(), controllerId, getTestSchedule(-5), getTestDuration(10), getTestTimeZone());
// test
registerSameTargetAndAssertBasedOnVersion(controllerId, 1, TargetUpdateStatus.PENDING);
@@ -770,22 +764,16 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Expect(type = TargetPollEvent.class, count = 1) })
void updateAttributesWithDifferentUpdateModes() {
final String controllerId = TARGET_PREFIX + "updateAttributes";
// setup
registerAndAssertTargetWithExistingTenant(controllerId);
// no update mode specified
updateAttributesWithoutUpdateMode();
// update mode REPLACE
updateAttributesWithUpdateModeReplace();
// update mode MERGE
updateAttributesWithUpdateModeMerge();
// update mode REMOVE
updateAttributesWithUpdateModeRemove();
}
/**
@@ -902,8 +890,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Expect(type = TargetAttributesRequestedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 1) })
void downloadOnlyAssignmentAllowsActionStatusUpdatesWhenTargetReportsFinishedAndUpdatesInstalledDS()
throws IOException {
void downloadOnlyAssignmentAllowsActionStatusUpdatesWhenTargetReportsFinishedAndUpdatesInstalledDS() throws IOException {
// create target
final String controllerId = TARGET_PREFIX + "registerTargets_1";
final DistributionSet distributionSet = createTargetAndDistributionSetAndAssign(controllerId, DOWNLOAD_ONLY);
@@ -1125,10 +1112,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
}
private void updateAttributesWithUpdateModeRemove() {
// assemble the expected attributes
final Map<String, String> expectedAttributes = targetManagement
.getControllerAttributes(DMF_ATTR_TEST_CONTROLLER_ID);
final Map<String, String> expectedAttributes = targetManagement.getControllerAttributes(DMF_ATTR_TEST_CONTROLLER_ID);
expectedAttributes.remove("k1");
expectedAttributes.remove("k3");
@@ -1256,8 +1241,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
}
private void sendUpdateAttributeMessage(final DmfAttributeUpdate attributeUpdate) {
final Message updateMessage = createUpdateAttributesMessage(DMF_ATTR_TEST_CONTROLLER_ID,
AbstractAmqpServiceIntegrationTest.TENANT_EXIST, attributeUpdate);
final Message updateMessage = createUpdateAttributesMessage(DMF_ATTR_TEST_CONTROLLER_ID, TENANT_EXIST, attributeUpdate);
getDmfClient().send(updateMessage);
}
@@ -1266,8 +1250,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
await().untilAsserted(() -> {
try {
SecurityContextSwitch.asPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusByAction(actionId, PAGE).getContent();
final List<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(actionId, PAGE).getContent();
assertThat(actionStatusList).hasSize(statusListCount);
final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus)
@@ -1283,9 +1266,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
}
private int getAuthenticationMessageCount() {
return Integer
.parseInt(Objects.requireNonNull(getRabbitAdmin().getQueueProperties(amqpProperties.getReceiverQueue()))
.get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString());
return Integer.parseInt(Objects.requireNonNull(
getRabbitAdmin().getQueueProperties(amqpProperties.getReceiverQueue())).get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString());
}
private void assertEmptyReceiverQueueCount() {
@@ -1298,8 +1280,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) {
assertEmptyReceiverQueueCount();
await().untilAsserted(
() -> Mockito.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any()));
await().untilAsserted(() -> Mockito.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any()));
Mockito.reset(getDeadletterListener());
}
}

View File

@@ -54,11 +54,6 @@
<artifactId>http-client</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>

View File

@@ -61,12 +61,6 @@
<artifactId>spring-ai-mcp-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>

View File

@@ -9,8 +9,13 @@
*/
package org.eclipse.hawkbit.mcp.server.client;
import java.io.Serial;
public class McpAuthenticationException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1L;
public McpAuthenticationException(String message) {
super(message);
}

View File

@@ -43,7 +43,7 @@ import org.springframework.hateoas.RepresentationModel;
}
}
}""")
public class MgmtActionId extends RepresentationModel<MgmtActionId> {
public final class MgmtActionId extends RepresentationModel<MgmtActionId> {
@Schema(description = "ID of the action")
private long id;

View File

@@ -24,7 +24,7 @@ import lombok.NoArgsConstructor;
*/
@NoArgsConstructor
@JsonDeserialize(using = MgmtDistributionSetAssignmentsDeserializer.class)
public class MgmtDistributionSetAssignments extends ArrayList<MgmtDistributionSetAssignment> {
public final class MgmtDistributionSetAssignments extends ArrayList<MgmtDistributionSetAssignment> {
@Serial
private static final long serialVersionUID = 1L;
@@ -39,16 +39,6 @@ public class MgmtDistributionSetAssignments extends ArrayList<MgmtDistributionSe
add(assignment);
}
/**
* Constructor for an object that contains multiple distribution set
* assignments
*
* @param assignments the assignments
*/
public MgmtDistributionSetAssignments(final List<MgmtDistributionSetAssignment> assignments) {
super(assignments);
}
@Override
@JsonIgnore
public boolean isEmpty() {

View File

@@ -470,6 +470,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(DistributionSet.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);

View File

@@ -97,8 +97,6 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
private RolloutGroupManagement rolloutGroupManagement;
@Autowired
private RolloutTestApprovalStrategy approvalStrategy;
@Autowired
private DistributionSetManagement distributionSetManagement;
/**
* Handles the GET request of retrieving a single rollout.
@@ -1984,7 +1982,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
private long postRollout(final String name, final int groupSize, final Long distributionSetId,
final String targetFilterQuery, final int targets, final Action.ActionType type, final Long startTime,
final Long forceTime, boolean isDynamic, String dynamicGroupSuffix, int dynamicGroupTargetsCount) throws Exception {
final Long forceTime, boolean isDynamic, final String dynamicGroupSuffix, int dynamicGroupTargetsCount) throws Exception {
final String actionType = MgmtRestModelMapper.convertActionType(type).getName();
final String rollout = JsonBuilder.rollout(name, "desc", groupSize, distributionSetId, targetFilterQuery,
new RolloutGroupConditionBuilder().withDefaults().build(), null, actionType, null, startTime, forceTime,

View File

@@ -381,6 +381,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
@@ -424,6 +425,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
@@ -558,6 +560,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
@@ -604,6 +607,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);

View File

@@ -14,6 +14,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.hawkbit.auth.SpPermission;
@@ -95,7 +96,7 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> {
// returns default DS type because of READ_TARGET
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)).hasSize(1);
assertThat((Map<?, ?>) new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)).hasSize(1);
});
}

View File

@@ -14,6 +14,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.hawkbit.auth.SpPermission;
@@ -94,11 +95,10 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
@Test
@WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
void onlyDSIfNoTenantConfig() throws Exception {
mvc.perform(get("/rest/v1/system/configs"))
.andExpect(result -> {
mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> {
// returns default DS type because of READ_TARGET
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)).hasSize(1);
assertThat((Map<?, ?>) new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)).hasSize(1);
});
}

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.ql;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@@ -20,6 +22,9 @@ import lombok.ToString;
@ToString(callSuper = true)
public class QueryException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1L;
public enum ErrorCode {
INVALID_SYNTAX,
UNSUPPORTED_FIELD,

View File

@@ -506,6 +506,7 @@ public interface RolloutManagement extends PermissionSupport {
* The name suffix, by default "" is used.
*/
@NotNull
@Builder.Default
private String nameSuffix = "";
/**

View File

@@ -63,7 +63,6 @@ public interface SoftwareModuleTypeManagement<T extends SoftwareModuleType>
@Builder.Default
private int maxAssignments = 1;
@Builder.Default
private int minArtifacts;
}

View File

@@ -36,7 +36,7 @@ public abstract class AbstractAssignmentEvent extends RemoteTenantAwareEvent {
@Serial
private static final long serialVersionUID = 1L;
private final Map<String, ActionProperties> actions = new HashMap<>();
private final HashMap<String, ActionProperties> actions = new HashMap<>();
protected AbstractAssignmentEvent(final Action a) {
super(a.getTenant(), null);
@@ -45,8 +45,7 @@ public abstract class AbstractAssignmentEvent extends RemoteTenantAwareEvent {
protected AbstractAssignmentEvent(final String tenant, final Object source, final List<Action> a) {
super(tenant, source);
actions.putAll(a.stream()
.collect(Collectors.toMap(action -> action.getTarget().getControllerId(), ActionProperties::new)));
actions.putAll(a.stream().collect(Collectors.toMap(action -> action.getTarget().getControllerId(), ActionProperties::new)));
}
public Optional<ActionProperties> getActionPropertiesForController(final String controllerId) {

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.repository.event.remote;
import java.io.Serial;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -23,6 +24,9 @@ import org.springframework.context.ApplicationEvent;
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class AbstractRemoteEvent extends ApplicationEvent {
@Serial
private static final long serialVersionUID = 1L;
private final String id;
// for serialization libs like jackson

View File

@@ -10,6 +10,7 @@
package org.eclipse.hawkbit.repository.event.remote;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collection;
import lombok.Data;
@@ -31,12 +32,12 @@ public class RolloutStoppedEvent extends RemoteTenantAwareEvent {
@Serial
private static final long serialVersionUID = 1L;
private Collection<Long> rolloutGroupIds;
private ArrayList<Long> rolloutGroupIds;
private long rolloutId;
public RolloutStoppedEvent(final String tenant, final long rolloutId, final Collection<Long> rolloutGroupIds) {
super(tenant, rolloutId);
this.rolloutId = rolloutId;
this.rolloutGroupIds = rolloutGroupIds;
this.rolloutGroupIds = new ArrayList<>(rolloutGroupIds);
}
}

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.repository.event.remote.service;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.eclipse.hawkbit.repository.event.remote.AbstractRemoteEvent;
@@ -17,6 +19,9 @@ import org.eclipse.hawkbit.repository.event.remote.AbstractRemoteEvent;
@EqualsAndHashCode(callSuper = true)
public abstract class AbstractServiceRemoteEvent<T extends AbstractRemoteEvent> extends AbstractRemoteEvent {
@Serial
private static final long serialVersionUID = 1L;
private final T remoteEvent;
protected AbstractServiceRemoteEvent(T remoteEvent) {

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.repository.exception;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
@@ -22,6 +24,9 @@ import org.eclipse.hawkbit.repository.model.BaseEntity;
@ToString(callSuper = true)
public class AssignmentQuotaExceededException extends AbstractServerRtException {
@Serial
private static final long serialVersionUID = 1L;
private static final String ASSIGNMENT_QUOTA_EXCEEDED_MESSAGE = "Quota exceeded: Cannot assign %s more %s entities to %s '%s'. The maximum is %s.";
private static final SpServerError errorType = SpServerError.SP_QUOTA_EXCEEDED;

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.exception;
import java.io.Serial;
import java.util.Collection;
import java.util.Collections;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -33,22 +32,15 @@ public class IncompatibleTargetTypeException extends AbstractServerRtException {
@Serial
private static final long serialVersionUID = 1L;
private final Collection<String> targetTypeNames;
private final Collection<String> distributionSetTypeNames;
public IncompatibleTargetTypeException(final String targetTypeName, final Collection<String> distributionSetTypeNames) {
super(SpServerError.SP_TARGET_TYPE_INCOMPATIBLE,
String.format("Target of type %s is not compatible with distribution set of types %s", targetTypeName, distributionSetTypeNames)
);
this.targetTypeNames = Collections.singleton(targetTypeName);
this.distributionSetTypeNames = distributionSetTypeNames;
String.format("Target of type %s is not compatible with distribution set of types %s",
targetTypeName, distributionSetTypeNames));
}
public IncompatibleTargetTypeException(final Collection<String> targetTypeNames, final String distributionSetTypeName) {
super(SpServerError.SP_TARGET_TYPE_INCOMPATIBLE,
String.format("Targets of types %s are not compatible with distribution set of type %s", targetTypeNames,
distributionSetTypeName));
this.targetTypeNames = targetTypeNames;
this.distributionSetTypeNames = Collections.singleton(distributionSetTypeName);
String.format("Targets of types %s are not compatible with distribution set of type %s",
targetTypeNames, distributionSetTypeName));
}
}

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.model;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
import org.eclipse.hawkbit.repository.Identifiable;
@@ -17,7 +16,7 @@ import org.eclipse.hawkbit.repository.Identifiable;
/**
* Core information of all entities.
*/
public interface BaseEntity extends Serializable, Identifiable<Long> {
public interface BaseEntity extends Identifiable<Long> {
static Long getIdOrNull(final BaseEntity entity) {
return entity == null ? null : entity.getId();

View File

@@ -19,10 +19,9 @@ public class EventJacksonMessageConverter extends MappingJackson2MessageConverte
public static final MimeType APPLICATION_REMOTE_EVENT_JSON = new MimeType("application", "remote-event-json");
public EventJacksonMessageConverter() {
super(APPLICATION_REMOTE_EVENT_JSON);
ObjectMapper objectMapper = new ObjectMapper();
final ObjectMapper objectMapper = new ObjectMapper();
EventType.getNamedTypes().forEach(objectMapper::registerSubtypes);
setObjectMapper(objectMapper);
}

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.repository.jpa;
import java.io.Serial;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -142,6 +143,9 @@ public class JpaConfiguration extends JpaBaseConfiguration {
static class CustomHibernateJpaDialect extends HibernateJpaDialect {
@Serial
private static final long serialVersionUID = 1L;
protected CustomHibernateJpaDialect() {
super();
this.setJdbcExceptionTranslator(JpaExceptionTranslator.getTranslator());

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.repository.jpa.acm;
import java.io.Serial;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.List;
@@ -70,7 +71,7 @@ public class AccessControllerConfiguration {
return new AccessController<>() {
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
public Optional<Specification<JpaAction>> getAccessRules(final Operation operation) {
return targetAccessController.getAccessRules(map(operation)).map(targetSpec -> (actionRoot, query, cb) -> {
final Join<JpaAction, JpaTarget> targetJoin = actionRoot.join(JpaAction_.target);
@@ -162,6 +163,9 @@ public class AccessControllerConfiguration {
private static class RawAuthoritiesAuthentication implements Authentication {
@Serial
private static final long serialVersionUID = 1L;
private final Authentication authentication;
private final transient SingletonSupplier<List<? extends GrantedAuthority>> rawAuthoritiesSupplier;

View File

@@ -20,7 +20,6 @@ import javax.sql.DataSource;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.repository.jpa.utils.DeploymentHelper;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.dao.PessimisticLockingFailureException;
import org.springframework.dao.QueryTimeoutException;
import org.springframework.integration.jdbc.lock.DefaultLockRepository;
@@ -55,10 +54,8 @@ public class DistributedLockRepository extends DefaultLockRepository {
// lock <-> next refresh time
private final Map<String, Instant> lockToRefreshTime = new ConcurrentHashMap<>();
/**
* @param dataSource to use for managing the locks
*/
public DistributedLockRepository(final DataSource dataSource, final LockProperties lockProperties, final PlatformTransactionManager txManager) {
public DistributedLockRepository(
final DataSource dataSource, final LockProperties lockProperties, final PlatformTransactionManager txManager) {
super(dataSource);
this.txManager = txManager;
@@ -109,11 +106,10 @@ public class DistributedLockRepository extends DefaultLockRepository {
txManager, "lock-acquire", Isolation.READ_COMMITTED.value(), status -> super.acquire(lock));
if (acquired) {
// update next refresh time
refreshAfterMillis.ifPresent(
afterMillis -> lockToRefreshTime.put(lock, Instant.now().plus(afterMillis, ChronoUnit.MILLIS)));
refreshAfterMillis.ifPresent(afterMillis -> lockToRefreshTime.put(lock, Instant.now().plus(afterMillis, ChronoUnit.MILLIS)));
}
return acquired;
} catch (final DataIntegrityViolationException | DeadlockLoserDataAccessException e) {
} catch (final DataIntegrityViolationException | PessimisticLockingFailureException e) {
log.debug("Could not acquire cluster lock {}. I guess another node has it.", lock, e);
return false;
} catch (final QueryTimeoutException e) {

View File

@@ -124,7 +124,8 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
static {
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED = new EnumMap<>(Database.class);
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(Database.POSTGRESQL,
QUERY_DELETE_ACTIONS_BY_STATE_AND_LAST_MODIFIED.put(
Database.POSTGRESQL,
"DELETE FROM sp_action " + "WHERE id IN (SELECT id FROM sp_action " + "WHERE tenant=" + Jpa.nativeQueryParamPrefix() + "tenant" + " AND status IN (%s)" + " AND last_modified_at<" + Jpa.nativeQueryParamPrefix() + "last_modified_at LIMIT " + ACTION_PAGE_LIMIT + ")");
}

View File

@@ -421,8 +421,8 @@ public class JpaDistributionSetManagement
private List<JpaDistributionSet> updateTag(
final Collection<Long> dsIds, final long dsTagId,
final BiFunction<DistributionSetTag, JpaDistributionSet, JpaDistributionSet> updater) {
final DistributionSetTag tag = distributionSetTagManagement.get(dsTagId);
final BiFunction<JpaDistributionSetTag, JpaDistributionSet, JpaDistributionSet> updater) {
final JpaDistributionSetTag tag = distributionSetTagManagement.get(dsTagId);
final List<JpaDistributionSet> allDs = dsIds.size() == 1 ?
jpaRepository.findById(dsIds.iterator().next())
.map(List::of)

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
@@ -36,9 +34,6 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
@SuppressWarnings("squid:S2160")
public abstract class AbstractJpaNamedEntity extends AbstractJpaTenantAwareBaseEntity implements NamedEntity {
@Serial
private static final long serialVersionUID = 1L;
@Column(name = "name", nullable = false, length = NAME_MAX_SIZE)
@Size(min = 1, max = NAME_MAX_SIZE)
@NotNull

View File

@@ -9,14 +9,14 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.NamedEntity;
@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
/**
* Extension for {@link NamedEntity} that are versioned.
*/
@NoArgsConstructor(access = AccessLevel.PROTECTED) // Default constructor needed for JPA entities
@Setter
@Getter
@ToString(callSuper = true)
@@ -33,27 +34,13 @@ import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
@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)
@Size(min = 1, max = NamedVersionedEntity.VERSION_MAX_SIZE)
@NotNull
private String version;
/**
* parameterized constructor.
*
* @param name of the entity
* @param version of the entity
* @param description
*/
AbstractJpaNamedVersionedEntity(final String name, final String version, final String description) {
super(name, description);
this.version = version;
}
AbstractJpaNamedVersionedEntity() {
// Default constructor needed for JPA entities
}
}

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
@@ -34,9 +32,6 @@ import org.eclipse.hawkbit.repository.model.Type;
@SuppressWarnings("squid:S2160")
public abstract class AbstractJpaTypeEntity extends AbstractJpaNamedEntity implements Type {
@Serial
private static final long serialVersionUID = 1L;
@Column(name = "type_key", nullable = false, updatable = false, length = KEY_MAX_SIZE)
@Size(min = 1, max = KEY_MAX_SIZE)
@NotNull

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;
import jakarta.persistence.Column;
@@ -35,10 +33,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@NoArgsConstructor // Default constructor for JPA
@Entity
@Table(name = "sp_ds_type_element")
public class DistributionSetTypeElement implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
public class DistributionSetTypeElement {
@EmbeddedId
private DistributionSetTypeElementCompositeKey key;

View File

@@ -9,9 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
@@ -25,10 +22,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Data
@Embeddable
public class DistributionSetTypeElementCompositeKey implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
public class DistributionSetTypeElementCompositeKey {
@Column(name = "distribution_set_type", nullable = false, updatable = false)
private Long dsType;

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.model;
import static org.eclipse.hawkbit.repository.model.BaseEntity.getIdOrNull;
import java.io.Serial;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
@@ -72,13 +71,9 @@ import org.eclipse.hawkbit.repository.model.Target;
@SuppressWarnings({ "squid:S2160", "java:S1710", "java:S1171", "java:S3599" })
public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Action, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@Getter
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(
name = "distribution_set", nullable = false, updatable = false)
@JoinColumn(name = "distribution_set", nullable = false, updatable = false)
@NotNull
private JpaDistributionSet distributionSet;

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -46,9 +45,6 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
@SuppressWarnings("squid:S2160")
public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements ActionStatus {
@Serial
private static final long serialVersionUID = 1L;
private static final int MESSAGE_ENTRY_LENGTH = 512;
@Setter

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -40,9 +38,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
@SuppressWarnings("squid:S2160")
public class JpaArtifact extends AbstractJpaTenantAwareBaseEntity implements Artifact {
@Serial
private static final long serialVersionUID = 1L;
@ManyToOne(optional = false, cascade = { CascadeType.PERSIST }, fetch = FetchType.LAZY)
@JoinColumn(
name = "software_module", nullable = false, updatable = false)

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -68,9 +67,6 @@ public class JpaDistributionSet
extends AbstractJpaNamedVersionedEntity
implements DistributionSet, WithMetadata<String, String>, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = JpaDistributionSetType.class)
@JoinColumn(name = "ds_type", nullable = false, updatable = false)
@NotNull
@@ -81,17 +77,14 @@ public class JpaDistributionSet
name = "sp_ds_sm",
joinColumns = { @JoinColumn(name = "ds_id", nullable = false) },
inverseJoinColumns = { @JoinColumn(name = "sm_id", nullable = false) })
private Set<SoftwareModule> modules = new HashSet<>();
private Set<JpaSoftwareModule> modules = new HashSet<>();
@ManyToMany(targetEntity = JpaDistributionSetTag.class)
@JoinTable(
name = "sp_ds_tag",
joinColumns = {
@JoinColumn(name = "ds", nullable = false) },
inverseJoinColumns = {
@JoinColumn(
name = "tag", nullable = false) })
private Set<DistributionSetTag> tags = new HashSet<>();
joinColumns = { @JoinColumn(name = "ds", nullable = false) },
inverseJoinColumns = { @JoinColumn(name = "tag", nullable = false) })
private Set<JpaDistributionSetTag> tags = new HashSet<>();
// no cascade option on an ElementCollection, the target objects are always persisted, merged, removed with their parent
@Getter
@@ -128,7 +121,7 @@ public class JpaDistributionSet
}
@SuppressWarnings("java:S1144") // used via reflection copy utils
private JpaDistributionSet setModules(final Set<SoftwareModule> modules) {
private JpaDistributionSet setModules(final Set<JpaSoftwareModule> modules) {
if (modules == null) {
return this; // do not change
}
@@ -163,14 +156,14 @@ public class JpaDistributionSet
}).orElse(true);
}
public void addModule(final SoftwareModule softwareModule) {
public void addModule(final JpaSoftwareModule softwareModule) {
if (isLocked()) {
throw new LockedException(JpaDistributionSet.class, getId(), "ADD_SOFTWARE_MODULE");
}
checkTypeCompatability(softwareModule);
final Optional<SoftwareModule> found = modules.stream()
final Optional<JpaSoftwareModule> found = modules.stream()
.filter(module -> module.getId().equals(softwareModule.getId())).findAny();
if (found.isPresent()) {
return;
@@ -199,14 +192,14 @@ public class JpaDistributionSet
return Collections.unmodifiableSet(tags);
}
public void addTag(final DistributionSetTag tag) {
public void addTag(final JpaDistributionSetTag tag) {
if (tags == null) {
tags = new HashSet<>();
}
tags.add(tag);
}
public void removeTag(final DistributionSetTag tag) {
public void removeTag(final JpaDistributionSetTag tag) {
if (tags != null) {
tags.remove(tag);
}

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.List;
import jakarta.persistence.Entity;
@@ -35,19 +34,9 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
@SuppressWarnings("squid:S2160")
public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@ManyToMany(mappedBy = "tags", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY)
private List<DistributionSet> assignedToDistributionSet;
/**
* Public constructor.
*
* @param name of the {@link DistributionSetTag}
* @param description of the {@link DistributionSetTag}
* @param colour of tag in UI
*/
public JpaDistributionSetTag(final String name, final String description, final String colour) {
super(name, description, colour);
}

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
@@ -42,9 +41,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@SuppressWarnings("squid:S2160")
public class JpaDistributionSetType extends AbstractJpaTypeEntity implements DistributionSetType, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@OneToMany(
mappedBy = "dsType", targetEntity = DistributionSetTypeElement.class,
fetch = FetchType.EAGER,
@@ -125,7 +121,8 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis
.publishEvent(new DistributionSetTypeDeletedEvent(getTenant(), getId(), getClass()));
}
private JpaDistributionSetType replaceOrAddModuleTypes(final Set<SoftwareModuleType> smTypes, final boolean mandatory, final boolean replace) {
private JpaDistributionSetType replaceOrAddModuleTypes(final Set<SoftwareModuleType> smTypes, final boolean mandatory,
final boolean replace) {
if (smTypes == null) {
return this; // do not change
}

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
@@ -63,9 +62,6 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
@SuppressWarnings({ "squid:S2160", "java:S1710", "java:S1171", "java:S3599" })
public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@OneToMany(targetEntity = JpaRolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, mappedBy = "rollout")
private List<JpaRolloutGroup> rolloutGroups = new ArrayList<>();

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.List;
import java.util.Map;
@@ -48,9 +47,6 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
@SuppressWarnings("squid:S2160")
public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGroup, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@Getter
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "rollout", nullable = false, updatable = false)

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -67,9 +65,6 @@ public class JpaSoftwareModule
extends AbstractJpaNamedVersionedEntity
implements SoftwareModule, WithMetadata<MetadataValue, JpaSoftwareModule.JpaMetadataValue>, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@ManyToOne
@JoinColumn(name = "sm_type", nullable = false, updatable = false)
@NotNull
@@ -178,10 +173,7 @@ public class JpaSoftwareModule
@Data
@Embeddable
public static class JpaMetadataValue implements MetadataValue, Serializable {
@Serial
private static final long serialVersionUID = 1L;
public static class JpaMetadataValue implements MetadataValue {
@Column(name = "meta_value", length = SoftwareModule.METADATA_VALUE_MAX_SIZE)
@Size(max = METADATA_VALUE_MAX_SIZE)

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
@@ -36,9 +34,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@SuppressWarnings("squid:S2160")
public class JpaSoftwareModuleType extends AbstractJpaTypeEntity implements SoftwareModuleType, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@Setter(value = lombok.AccessLevel.PRIVATE) // used via reflection
@Column(name = "min_artifacts", nullable = false)
@Min(0)

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.Size;
@@ -31,9 +29,6 @@ import org.eclipse.hawkbit.repository.model.Tag;
@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)
@Size(max = Tag.COLOUR_MAX_SIZE)
private String colour;

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -84,9 +83,6 @@ import org.springframework.util.ObjectUtils;
@SuppressWarnings({ "squid:S2160", "java:S1710" })
public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@Setter
@Getter
@Column(name = "controller_id", length = Target.CONTROLLER_ID_MAX_SIZE, updatable = false, nullable = false)

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.Optional;
import jakarta.persistence.Column;
@@ -46,9 +45,6 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
@SuppressWarnings("squid:S2160")
public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity implements TargetFilterQuery, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@Column(name = "name", length = NamedEntity.NAME_MAX_SIZE, nullable = false)
@Size(max = NamedEntity.NAME_MAX_SIZE)
@NotEmpty

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
@@ -31,9 +29,6 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
@Table(name = "sp_target_tag")
public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
public JpaTargetTag(final String name, final String description, final String colour) {
super(name, description, colour);
}

View File

@@ -9,7 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -40,9 +39,6 @@ import org.eclipse.hawkbit.repository.model.TargetType;
@SuppressWarnings("java:S2160") // the super class equals/hashcode shall be used
public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType, EventAwareEntity {
@Serial
private static final long serialVersionUID = 1L;
@ManyToMany(targetEntity = JpaDistributionSetType.class)
@JoinTable(
name = "sp_target_type_ds_type",

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -39,9 +37,6 @@ import org.eclipse.hawkbit.repository.model.TenantConfiguration;
@SuppressWarnings("squid:S2160")
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)
@Size(min = 1, max = TenantConfiguration.KEY_MAX_SIZE)
@NotNull

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
@@ -47,9 +45,6 @@ import org.eclipse.hawkbit.repository.model.TenantMetaData;
@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)
@Size(min = 1, max = 40)
@NotNull

View File

@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import jakarta.persistence.CascadeType;
@@ -35,10 +33,7 @@ import org.eclipse.hawkbit.repository.model.Target;
@IdClass(RolloutTargetGroupId.class)
@Entity
@Table(name = "sp_rollout_target_group")
public class RolloutTargetGroup implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
public class RolloutTargetGroup {
@Id
@ManyToOne(optional = false, targetEntity = JpaRolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST })

View File

@@ -9,9 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.io.Serializable;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -24,10 +21,7 @@ import org.eclipse.hawkbit.repository.model.Target;
@NoArgsConstructor // Default constructor for JPA
@Getter
@EqualsAndHashCode
public class RolloutTargetGroupId implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
public class RolloutTargetGroupId {
private Long rolloutGroup;
private Long target;

View File

@@ -136,7 +136,7 @@ public interface BaseEntityRepository<T extends AbstractJpaBaseEntity>
return Optional.empty();
}
@SuppressWarnings("uchecked")
@SuppressWarnings("unchecked")
default Class<? extends BaseEntity> getManagementClass() {
final Class<T> domainClass = getDomainClass();
final String domainClassSimpleName = domainClass.getSimpleName();

View File

@@ -41,7 +41,7 @@ import org.springframework.util.ObjectUtils;
* @param <ID> the type of the id of the entity the repository manages
*/
@SuppressWarnings("java:S119") // inherited from SimpleJpaRepository
public class HawkbitBaseRepository<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
public final class HawkbitBaseRepository<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
implements JpaSpecificationEntityGraphExecutor<T>, NoCountSliceRepository<T>, ACMRepository<T> {
private final EntityManager entityManager;

View File

@@ -9,12 +9,17 @@
*/
package org.eclipse.hawkbit.repository.jpa.rollout.condition;
import java.io.Serial;
/**
* Exception indicating that a specific evaluator is missing in the application
* context.
*/
public class EvaluatorNotConfiguredException extends RuntimeException {
@Serial
private static final long serialVersionUID = 1L;
private static final String MESSAGE_FORMAT = "Cannot find any configured evaluator for action/condition '%s'. Please ensure to configure one in the application context to make use of it.";
/**

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.repository.jpa.utils;
import java.io.Serial;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -94,6 +95,9 @@ public class StatisticsUtils {
// Map with user-friendly toString, sorted and without the last ", "
private static class MapUFToString extends HashMap<String, Double> {
@Serial
private static final long serialVersionUID = 1L;
@Override
public String toString() {
if (isEmpty()) {

View File

@@ -124,6 +124,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
protected static <T> T[] toArray(final Iterable<? extends T> it, final Class<T> type) {
final List<T> list = toList(it);
@SuppressWarnings("unchecked")
final T[] array = (T[]) Array.newInstance(type, list.size());
for (int i = 0; i < array.length; i++) {
array[i] = list.get(i);

View File

@@ -46,6 +46,7 @@ class TargetTypeManagementTest extends AbstractAccessControllerManagementTest {
}
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
void verifyRead() {
// permissions to read only type1 target types
runAs(withAuthorities(READ_TARGET_TYPE + "/id==" + targetType1.getId()), () -> {

View File

@@ -150,12 +150,11 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
final String successCondition = "50";
final String errorCondition = "80";
final String rolloutName = "rolloutTest";
final String targetPrefixName = rolloutName;
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName);
testdataFactory.createTargets(amountTargetsForRollout, targetPrefixName + "-", targetPrefixName);
testdataFactory.createTargets(amountTargetsForRollout, rolloutName + "-", rolloutName);
final Rollout createdRollout = testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups,
"controllerId==" + targetPrefixName + "-*", distributionSet, successCondition, errorCondition);
final Rollout createdRollout = testdataFactory.createRolloutByVariables(
rolloutName, "desc", amountGroups,"controllerId==" + rolloutName + "-*", distributionSet, successCondition, errorCondition);
rolloutManagement.delete(createdRollout.getId());
rolloutHandler.handleAll();

View File

@@ -987,12 +987,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final int noOfDeployedTargets = 4;
final int noOfDistributionSets = 3;
final DeploymentResult deploymentResult = prepareComplexRepo(undeployedTargetPrefix, noOfUndeployedTargets,
deployedTargetPrefix, noOfDeployedTargets, noOfDistributionSets, "myTestDS");
final DeploymentResult deploymentResult = prepareComplexRepo(
undeployedTargetPrefix, noOfUndeployedTargets, deployedTargetPrefix, noOfDeployedTargets, noOfDistributionSets, "myTestDS");
final List<Long> deployedTargetIDs = deploymentResult.getDeployedTargetIDs();
final List<Long> undeployedTargetIDs = deploymentResult.getUndeployedTargetIDs();
@SuppressWarnings({"unchecked", "rawtypes"})
final Collection<JpaTarget> savedNakedTargets = (Collection) deploymentResult.getUndeployedTargets();
@SuppressWarnings({"unchecked", "rawtypes"})
final Collection<JpaTarget> savedDeployedTargets = (Collection) deploymentResult.getDeployedTargets();
// retrieving all Actions created by the assignDistributionSet call

View File

@@ -123,12 +123,10 @@ public abstract class AbstractIntegrationTest {
protected static final Pageable UNPAGED = Pageable.unpaged();
protected static final URI LOCALHOST = URI.create("http://127.0.0.1");
protected static final int DEFAULT_TEST_WEIGHT = 500;
protected static final Random RND = TestdataFactory.RND;
/**
* Number of {@link DistributionSetType}s that exist in every test case. One
* generated by using
* Number of {@link DistributionSetType}s that exist in every test case. One generated by using
* {@link TestdataFactory#findOrCreateDefaultTestDsType()} and three
* {@link SystemManagement#getTenantMetadata()};
*/

View File

@@ -139,6 +139,7 @@ public class SecurityContextSwitch {
// in some cases it could be serializable, e.g. if got via {@link java.lang.reflect.AnnotatedElement} (see javadoc) or WithUserImpl,
// and in some cases it used to be serialized, e.g. in {@link SecurityContextSerializer#JavaSerialization.serialize},
// must not be made transient!
@SuppressWarnings("serial")
private final WithUser annotation;
WithUserSecurityContext(final WithUser annotation) {
@@ -197,6 +198,9 @@ public class SecurityContextSwitch {
private static class WithUserImpl implements WithUser, Serializable {
@Serial
private static final long serialVersionUID = 1L;
private final String principal;
private final String tenant;
private final boolean autoCreateTenant;

View File

@@ -47,7 +47,7 @@ public class DmfApp {
}
@Bean
DmfTenant dmfTenant(Tenant tenant, Amqp amqp) {
DmfTenant dmfTenant(final Tenant tenant, final Amqp amqp) {
return new DmfTenant(tenant, amqp);
}

View File

@@ -25,7 +25,7 @@ import org.springframework.amqp.core.Message;
/**
* An in-memory simulated DMF Tenant to hold the controller twins in memory and be able to retrieve them again.
*/
public class DmfTenant {
public final class DmfTenant {
@Getter
private final Tenant tenant;
@@ -39,8 +39,8 @@ public class DmfTenant {
public DmfTenant(final Tenant tenant, final Amqp amqp, final boolean initVHost) {
this.tenant = tenant;
this.vHost = amqp.getVhost(tenant.getDmf(), initVHost);
this.vHost.register(this);
vHost = amqp.getVhost(tenant.getDmf(), initVHost);
vHost.register(this);
}
public void destroy() {

View File

@@ -46,7 +46,7 @@ import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
* Abstract class for sender and receiver service.
*/
@Slf4j
public class VHost extends DmfSender implements MessageListener {
public final class VHost extends DmfSender implements MessageListener {
private static final String REGEX_EXTRACT_ACTION_ID = "[^0-9]";
@@ -54,19 +54,12 @@ public class VHost extends DmfSender implements MessageListener {
private final ConcurrentHashMap<String, DmfTenant> dmfTenants = new ConcurrentHashMap<>();
private final Set<Long> openActions = Collections.synchronizedSet(new HashSet<>());
public VHost(final ConnectionFactory connectionFactory, final AmqpProperties amqpProperties) {
this(connectionFactory, amqpProperties, true);
}
public VHost(final ConnectionFactory connectionFactory, final AmqpProperties amqpProperties, final boolean initVHost) {
super(new RabbitTemplate(connectionFactory), amqpProperties);
// It is necessary to define rabbitTemplate as a Bean and set
// Jackson2JsonMessageConverter explicitly here in order to convert only
// OUTCOMING messages to json. In case of INCOMING messages,
// Jackson2JsonMessageConverter can not handle messages with NULL
// payload (e.g. REQUEST_ATTRIBUTES_UPDATE), so the
// SimpleMessageConverter is used instead per default.
// It is necessary to define rabbitTemplate as a Bean and set Jackson2JsonMessageConverter explicitly here in order to convert only
// OUTCOMING messages to JSON. In case of INCOMING messages, Jackson2JsonMessageConverter can not handle messages with NULL
// payload (e.g. REQUEST_ATTRIBUTES_UPDATE), so the SimpleMessageConverter is used instead per default.
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
if (initVHost) {

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui;
import static feign.Util.ISO_8859_1;
import java.io.Serial;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
@@ -53,6 +54,9 @@ import org.springframework.security.oauth2.core.oidc.user.OidcUser;
@Import(FeignClientsConfiguration.class)
public class HawkbitUiApp implements AppShellConfigurator {
@Serial
private static final long serialVersionUID = 1L;
private static final String AUTHORIZATION_HEADER = "Authorization";
private static final RequestInterceptor AUTHORIZATION = requestTemplate -> {
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui;
import java.io.Serial;
import java.util.List;
import java.util.Optional;
@@ -49,10 +50,13 @@ import org.eclipse.hawkbit.ui.view.TargetView;
/**
* The main view is a top-level placeholder for other views.
*/
public class MainLayout extends AppLayout {
public final class MainLayout extends AppLayout {
static final List<Class<? extends Component>> DEFAULT_VIEW_PRIORITY = List.of(TargetView.class, DistributionSetView.class,
SoftwareModuleView.class, RolloutView.class);
@Serial
private static final long serialVersionUID = 1L;
static final List<Class<? extends Component>> DEFAULT_VIEW_PRIORITY = List.of(
TargetView.class, DistributionSetView.class, SoftwareModuleView.class, RolloutView.class);
private final transient AuthenticatedUser authenticatedUser;
private final AccessAnnotationChecker accessChecker;
private H2 viewTitle;

View File

@@ -10,6 +10,7 @@
package org.eclipse.hawkbit.ui;
import java.io.Serial;
import java.util.Arrays;
import java.util.Locale;
@@ -19,6 +20,9 @@ import org.springframework.stereotype.Component;
@Component
public class SimpleI18NProvider extends DefaultI18NProvider {
@Serial
private static final long serialVersionUID = 1L;
SimpleI18NProvider() {
super(Arrays.stream(Locale.getAvailableLocales()).toList());
}

View File

@@ -10,6 +10,8 @@
package org.eclipse.hawkbit.ui;
import java.io.Serial;
import com.vaadin.flow.server.ServiceInitEvent;
import com.vaadin.flow.server.VaadinServiceInitListener;
import com.vaadin.flow.spring.annotation.SpringComponent;
@@ -19,6 +21,9 @@ import lombok.extern.slf4j.Slf4j;
@SpringComponent
public class VaadinServiceInit implements VaadinServiceInitListener {
@Serial
private static final long serialVersionUID = 1L;
@Override
public void serviceInit(ServiceInitEvent event) {
// cache zoneId of client as soon as possible

View File

@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.ui.component;
import static org.eclipse.hawkbit.ui.view.Constants.STATUS;
import java.io.Serial;
import java.util.List;
import java.util.Optional;
@@ -39,7 +40,10 @@ import org.eclipse.hawkbit.ui.view.TargetView;
import org.eclipse.hawkbit.ui.view.util.Utils;
@Slf4j
public class TargetActionsHistory extends Grid<TargetActionsHistory.ActionStatusEntry> {
public final class TargetActionsHistory extends Grid<TargetActionsHistory.ActionStatusEntry> {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private transient MgmtTarget target;

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.ui.view;
import java.io.Serial;
import jakarta.annotation.security.RolesAllowed;
import com.vaadin.flow.component.html.H2;
@@ -24,7 +26,10 @@ import org.eclipse.hawkbit.ui.MainLayout;
@Route(value = "about", layout = MainLayout.class)
@RouteAlias(value = "", layout = MainLayout.class)
@RolesAllowed({ "ANONYMOUS" })
public class AboutView extends VerticalLayout {
public final class AboutView extends VerticalLayout {
@Serial
private static final long serialVersionUID = 1L;
public AboutView() {
setSpacing(false);

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view;
import java.io.Serial;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@@ -32,12 +33,15 @@ import org.eclipse.hawkbit.ui.MainLayout;
@Route(value = "config", layout = MainLayout.class)
@RolesAllowed({ "CONFIG_READ" })
@Slf4j
public class ConfigView extends VerticalLayout {
public final class ConfigView extends VerticalLayout {
@Serial
private static final long serialVersionUID = 1L;
private static final String WIDTH = "width";
private static final String PX_300 = "300px";
private final Map<String, MgmtSystemTenantConfigurationValueRequest> configValue = new HashMap<>();
private final transient Map<String, MgmtSystemTenantConfigurationValueRequest> configValue = new HashMap<>();
public ConfigView(final HawkbitMgmtClient hawkbitClient) {
setSpacing(false);

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view;
import java.io.Serial;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -64,6 +65,9 @@ import org.eclipse.hawkbit.ui.view.util.Utils;
@Uses(Icon.class)
public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
@Serial
private static final long serialVersionUID = 1L;
public DistributionSetView(final HawkbitMgmtClient hawkbitClient) {
super(
new DistributionSetFilter(hawkbitClient),
@@ -184,6 +188,9 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
private static class DistributionSetDetails extends FormLayout {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final TextArea description = new TextArea("Description");
@@ -238,6 +245,9 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
private static class CreateDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final Select<MgmtDistributionSetType> type;
@@ -325,6 +335,9 @@ public class DistributionSetView extends TableView<MgmtDistributionSet, Long> {
@SuppressWarnings({ "java:S1171", "java:S3599" })
private static class AddSoftwareModulesDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final transient Set<MgmtSoftwareModule> softwareModules = Collections.synchronizedSet(new HashSet<>());
private AddSoftwareModulesDialog(final long distributionSetId, final HawkbitMgmtClient hawkbitClient) {

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.ui.view;
import java.io.Serial;
import com.vaadin.flow.component.login.LoginI18n;
import com.vaadin.flow.component.login.LoginOverlay;
import com.vaadin.flow.router.BeforeEnterEvent;
@@ -23,7 +25,10 @@ import org.eclipse.hawkbit.ui.security.AuthenticatedUser;
@AnonymousAllowed
@PageTitle("Login")
@Route(value = "login")
public class LoginView extends LoginOverlay implements BeforeEnterObserver {
public final class LoginView extends LoginOverlay implements BeforeEnterObserver {
@Serial
private static final long serialVersionUID = 1L;
private final transient AuthenticatedUser authenticatedUser;

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view;
import java.io.Serial;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Map;
@@ -63,7 +64,10 @@ import org.springframework.util.ObjectUtils;
@RolesAllowed({ "ROLLOUT_READ" })
@Uses(Icon.class)
@SuppressWarnings({ "java:S1171", "java:S3599" })
public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
public final class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
@Serial
private static final long serialVersionUID = 1L;
public RolloutView(final HawkbitMgmtClient hawkbitClient) {
super(
@@ -105,6 +109,9 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
private static class Actions extends HorizontalLayout {
@Serial
private static final long serialVersionUID = 1L;
private final long rolloutId;
private final Grid<MgmtRolloutResponseBody> grid;
private final transient HawkbitMgmtClient hawkbitClient;
@@ -190,6 +197,9 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
private static class RolloutDetails extends FormLayout {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final TextArea description = new TextArea(Constants.DESCRIPTION);
@@ -283,6 +293,9 @@ public class RolloutView extends TableView<MgmtRolloutResponseBody, Long> {
private static class CreateDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final TextField name;
private final ComboBox<MgmtDistributionSet> distributionSet;
private final ComboBox<MgmtTargetFilterQuery> targetFilter;

View File

@@ -12,6 +12,7 @@ package org.eclipse.hawkbit.ui.view;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serial;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -69,6 +70,9 @@ import org.springframework.web.multipart.MultipartFile;
@Slf4j
public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
@Serial
private static final long serialVersionUID = 1L;
@Autowired
public SoftwareModuleView(final HawkbitMgmtClient hawkbitClient) {
this(true, hawkbitClient);
@@ -156,6 +160,9 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
private static class SoftwareModuleDetails extends FormLayout {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final TextArea description = new TextArea(Constants.DESCRIPTION);
@@ -202,6 +209,9 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
private static class CreateDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final Select<MgmtSoftwareModuleType> type;
private final TextField name;
private final TextField version;
@@ -337,6 +347,9 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
private static class AddArtifactsDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final transient Set<MgmtArtifact> artifacts = Collections.synchronizedSet(new HashSet<>());
private AddArtifactsDialog(

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view;
import java.io.Serial;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Collections;
@@ -91,7 +92,10 @@ import org.springframework.util.ObjectUtils;
@Route(value = "targets", layout = MainLayout.class)
@RolesAllowed({ "TARGET_READ" })
@Uses(Icon.class)
public class TargetView extends TableView<TargetView.TargetWithDs, String> {
public final class TargetView extends TableView<TargetView.TargetWithDs, String> {
@Serial
private static final long serialVersionUID = 1L;
public static final String STATUS = "Status";
public static final String UPDATE = "Sync";
@@ -344,6 +348,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
protected static class TargetDetailedView extends VerticalLayout {
@Serial
private static final long serialVersionUID = 1L;
private final Span targetId;
private final TargetDetails targetDetails;
private final TargetAssignedInstalled targetAssignedInstalled;
@@ -383,6 +390,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class TargetDetails extends FormLayout {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final TextArea description = new TextArea(Constants.DESCRIPTION);
private final TextField createdBy = Utils.textField(Constants.CREATED_BY);
@@ -444,6 +454,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class TargetAssignedInstalled extends FormLayout {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final LinkedTextArea assigned = new LinkedTextArea("Assigned Distribution Set", "/distribution_sets?");
private final LinkedTextArea installed = new LinkedTextArea("Installed Distribution Set", "/distribution_sets?");
@@ -489,6 +502,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class TargetTags extends VerticalLayout {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private final ComboBox<MgmtTag> tagSelector = new ComboBox<>(TAG);
private final HorizontalLayout tagsArea = new HorizontalLayout();
@@ -601,6 +617,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class TargetMetadata extends VerticalLayout {
@Serial
private static final long serialVersionUID = 1L;
public static final String KEY = "Key";
public static final String VALUE = "Value";
@@ -672,7 +691,10 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
}
}
public static class TargetActionsHistoryLayout extends VerticalLayout {
public static final class TargetActionsHistoryLayout extends VerticalLayout {
@Serial
private static final long serialVersionUID = 1L;
private final TargetActionsHistory targetActionsHistory;
@@ -689,6 +711,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
public static class ActionStepsGrid extends Grid<ActionStepsGrid.ActionStepEntry> {
@Serial
private static final long serialVersionUID = 1L;
private final transient HawkbitMgmtClient hawkbitClient;
private transient MgmtTarget target;
private transient Long actionId;
@@ -775,6 +800,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class RegisterDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final Select<MgmtTargetType> type;
private final TextField controllerId;
private final TextField name;
@@ -850,6 +878,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class AssignDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final ComboBox<MgmtDistributionSet> distributionSet;
private final Select<MgmtActionType> actionType;
private final DateTimePicker forceTime = new DateTimePicker("Force Time");
@@ -918,6 +949,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class CreateTagDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final TextField name;
private final TextArea description = new TextArea(Constants.DESCRIPTION);
@@ -961,6 +995,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class AddMetadataDialog extends Utils.BaseDialog<Void> {
@Serial
private static final long serialVersionUID = 1L;
private final TextField key;
private final TextField value;
@@ -1001,6 +1038,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class TargetStatusCell extends HorizontalLayout {
@Serial
private static final long serialVersionUID = 1L;
private TargetStatusCell(final MgmtTarget target) {
final MgmtPollStatus pollStatus = target.getPollStatus();
add(pollStatusIconMapper(pollStatus));
@@ -1024,6 +1064,9 @@ public class TargetView extends TableView<TargetView.TargetWithDs, String> {
private static class TargetUpdateStatusCell extends HorizontalLayout {
@Serial
private static final long serialVersionUID = 1L;
private TargetUpdateStatusCell(final MgmtTarget target) {
final String targetUpdateStatus = Optional.ofNullable(target.getUpdateStatus()).orElse("unknown");
add(targetUpdateStatusMapper(targetUpdateStatus));

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view.util;
import java.io.Serial;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -30,7 +31,10 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.theme.lumo.LumoUtility;
import org.springframework.util.ObjectUtils;
public class Filter extends Div {
public final class Filter extends Div {
@Serial
private static final long serialVersionUID = 1L;
private transient Rsql rsql;
private final transient Rsql secondaryRsql;

View File

@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.ui.view.util;
import java.io.Serial;
import com.vaadin.flow.component.card.Card;
import com.vaadin.flow.component.card.CardVariant;
import com.vaadin.flow.component.html.Anchor;
@@ -17,25 +19,27 @@ import com.vaadin.flow.component.html.Span;
public class LinkedTextArea extends Div {
String queryPrefix;
Card card;
@Serial
private static final long serialVersionUID = 1L;
public LinkedTextArea(String title, String queryPrefix) {
super();
private final String queryPrefix;
private final Card card;
public LinkedTextArea(final String title, final String queryPrefix) {
this.queryPrefix = queryPrefix;
card = new Card();
card.setTitle(title);
this.queryPrefix = queryPrefix;
}
public void setValueWithLink(String value, String query) {
var span = new Span(value);
final Span span = new Span(value);
span.setWhiteSpace(WhiteSpace.PRE_WRAP);
card.add(span);
card.addThemeVariants(CardVariant.LUMO_ELEVATED);
if (query != null) {
var a = new Anchor(queryPrefix + query, card);
a.addClassName("nocolor");
add(a);
final Anchor anchor = new Anchor(queryPrefix + query, card);
anchor.addClassName("nocolor");
add(anchor);
} else {
add(card);
}

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view.util;
import java.io.Serial;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
@@ -24,7 +25,10 @@ import com.vaadin.flow.theme.lumo.LumoUtility;
// id type shall have proper equals and hashCode - i.e. eligible hash set element
@SuppressWarnings("java:S119") // better readability
public class SelectionGrid<T, ID> extends Grid<T> {
public final class SelectionGrid<T, ID> extends Grid<T> {
@Serial
private static final long serialVersionUID = 1L;
private volatile String rsqlFilter;

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view.util;
import java.io.Serial;
import java.util.concurrent.CompletionStage;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -38,6 +39,9 @@ import org.eclipse.hawkbit.ui.view.Constants;
@SuppressWarnings("java:S119") // better readability
public class TableView<T, ID> extends Div implements Constants, BeforeEnterObserver {
@Serial
private static final long serialVersionUID = 1L;
private static final String COLOR = "color";
private static final String VAR_LUMO_SECONDARY_TEXT_COLOR = "var(--lumo-secondary-text-color)";
private static final String VAR_LUMO_PRIMARY_COLOR = "var(--lumo-primary-color)";

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.ui.view.util;
import java.io.Serial;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
@@ -58,17 +59,15 @@ import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.data.renderer.LocalDateTimeRenderer;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.theme.lumo.LumoUtility;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import org.eclipse.hawkbit.ui.view.Constants;
@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE) // prevent initialization
@Slf4j
public class Utils {
private Utils() {
// prevent initialization
}
public static final String COMBO_NAME_ALLOWED_CHARS = "[0-9a-zA-Z-_./]";
public static TextField textField(final String label) {
@@ -148,8 +147,8 @@ public class Utils {
return layout;
}
private static <T, ID> ConfirmDialog promptForDeleteConfirmation(Function<SelectionGrid<T, ID>, CompletionStage<Void>> removeHandler,
SelectionGrid<T, ID> selectionGrid) {
private static <T, ID> ConfirmDialog promptForDeleteConfirmation(
final Function<SelectionGrid<T, ID>, CompletionStage<Void>> removeHandler, final SelectionGrid<T, ID> selectionGrid) {
final ConfirmDialog dialog = new ConfirmDialog();
dialog.setHeader("Confirm Deletion");
dialog.setText("Are you sure you want to delete the selected items? This action cannot be undone.");
@@ -160,9 +159,7 @@ public class Utils {
dialog.setConfirmButtonTheme(ButtonVariant.LUMO_ERROR.getVariantName());
dialog.setConfirmText("Delete");
dialog.addConfirmListener(event -> {
removeHandler
.apply(selectionGrid)
.thenAccept(v -> selectionGrid.refreshGrid(false));
removeHandler.apply(selectionGrid).thenAccept(v -> selectionGrid.refreshGrid(false));
dialog.close();
});
return dialog;
@@ -238,6 +235,9 @@ public class Utils {
public static class BaseDialog<T> extends Dialog {
@Serial
private static final long serialVersionUID = 1L;
protected final transient CompletableFuture<T> result = new CompletableFuture<>();
protected BaseDialog(final String headerTitle) {

11
pom.xml
View File

@@ -196,6 +196,12 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@@ -378,6 +384,7 @@
-->
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<ratchetFrom>${ratchetFrom}</ratchetFrom>
<java>
@@ -467,7 +474,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-Xlint:all</compilerArgument>
<parameters>true</parameters>
<proc>full</proc>
<compilerArgument>-Xlint:all,-processing</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>