Feature/java11 build (#1280)

* hawkBit on Java 11

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>

* Preparing java 11 build

- Update eclipse-link maven plugin dependencies
- Fixing warnings, adopt to java-11 style

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Preparing java 11 build

- Fixing warnings, adapt to java-11 style
- Added since to deprecated

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Fixing sonar warnings

- removed deprecated API

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Fixing sonar warnings & failing test

- Added suppressWarning
- added WithSpringAuthorityRule to clean-up listener

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Compile warnings

- Test if final causes issues in tests

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Removed deprecated code

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Reverted changes

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Removed final as this causes invalid reflective access exceptions

- The eclipselink generated classes seem to modify the field directly
- update plugin version

Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>

* Upgrade eclipselink from 2.7.9 to 2.7.10

* Remove @deprecated endpoints from MgmtTargetTagResource

* Remove dependencies already defined in eclipselink-maven-plugin

* Try eclipselink 2.7.11-RC1

* Set project encoding to UTF-8

* Upgrade surefire and failsafe plugins to 3.0.0-M7

* Try fixed string instead of a random generated one

* Replace JsonBuilder by Jackson ObjectMapper usage

* Use JsonBuilder again

* Use APPLICATION_JSON_UTF8 instead of APPLICATION_JSON

* Try to replace com.vaadin.external.google:android-json by org.json:json

* Add debugging outputs

* Improve debugging outputs

* Improve debugging outputs

* Use Jackson instead of JsonBuilder

* Use Jackson instead of JsonBuilder 2nd part

* Use Spring json dependency

* Use eclipselink 2.7.11

* Fix RootControllerDocumentationTest

* Improve helper methods of AbstractDDiApiIntegrationTest

* Upgrade SpringBoot and SpringCloud versions

* Improve deprecation notice for 0.3.0M8

* Fix BaseAmqpServiceTest

* Fix SpecificationsBuilderTest

* Removed deprecated code

* Define maven-enforcer-plugin version

* Remove com.google.code.findbugs.jsr305

Signed-off-by: Florian Ruschbaschan <florian.ruschbaschan@bosch.io>

* Update circleci image to openjdk:openjdk:11.0.13-jdk-buster

Signed-off-by: Florian Ruschbaschan <florian.ruschbaschan@bosch.io>

* Fix javadoc generation and license check

Signed-off-by: Florian Ruschbaschan <florian.ruschbaschan@bosch.io>

* Fix review findings

Signed-off-by: Florian Ruschbaschan <florian.ruschbaschan@bosch.io>

Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>
Signed-off-by: Peter Vigier <Peter.Vigier@bosch.io>
Signed-off-by: Florian Ruschbaschan <florian.ruschbaschan@bosch.io>
Co-authored-by: Dominic Schabel <dominic.schabel@bosch.io>
Co-authored-by: Peter Vigier <Peter.Vigier@bosch.io>
Co-authored-by: Markus Block <markus.block@bosch-si.com>
This commit is contained in:
Florian Ruschbaschan
2022-09-19 10:33:31 +02:00
committed by GitHub
parent 537548defb
commit 32718676a4
36 changed files with 562 additions and 825 deletions

View File

@@ -32,6 +32,7 @@ public interface ArtifactEncryption {
*
* @return secrets key/value pairs
* @throws ArtifactEncryptionFailedException
* thrown in case of an error while generating secrets
*/
Map<String, String> generateSecrets();
@@ -44,6 +45,7 @@ public interface ArtifactEncryption {
* artifact stream to encrypt
* @return encrypted input stream
* @throws ArtifactEncryptionFailedException
* thrown in case of an error while encrypting the provided stream
*/
InputStream encryptStream(final Map<String, String> secrets, final InputStream stream);
@@ -56,6 +58,7 @@ public interface ArtifactEncryption {
* artifact stream to decrypt
* @return decrypted input stream
* @throws ArtifactEncryptionFailedException
* thrown in case of an error while decrypting the provided stream
*/
InputStream decryptStream(final Map<String, String> secrets, final InputStream stream);

View File

@@ -206,6 +206,7 @@ public interface TargetFilterQueryManagement {
*
* @return the page with the found {@link TargetFilterQuery}s
* @param pageable
* pagination information
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<TargetFilterQuery> findWithAutoAssignDS(@NotNull Pageable pageable);

View File

@@ -66,59 +66,16 @@ public interface TargetManagement {
List<Target> assignTag(@NotEmpty Collection<String> controllerIds, long tagId);
/**
* Counts number of targets with given
* {@link Target#getAssignedDistributionSet()}.
*
* @param distId
* to search for
* Counts number of targets with the given distribution set assigned.
*
* @param distId to search for
* @return number of found {@link Target}s.
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
* @throws EntityNotFoundException if distribution set with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
long countByAssignedDistributionSet(long distId);
/**
* Count {@link Target}s for all the given filter parameters.
*
* @param status
* find targets having one of these {@link TargetUpdateStatus}s.
* Set to <code>null</code> in case this is not required.
* @param overdueState
* find targets that are overdue (targets that did not respond
* during the configured intervals: poll_itvl + overdue_itvl).
* Set to <code>null</code> in case this is not required.
* @param searchText
* to find targets having the text anywhere in name or
* description. Set <code>null</code> in case this is not
* required.
* @param installedOrAssignedDistributionSetId
* to find targets having the {@link DistributionSet} as
* installed or assigned. Set to <code>null</code> in case this
* is not required.
* @param tagNames
* to find targets which are having any one in this tag names.
* Set <code>null</code> in case this is not required.
* @param selectTargetWithNoTag
* flag to select targets with no tag assigned
*
* @return the found number of {@link Target}s
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
*
* @deprecated this method
* {@link TargetManagement#countByFilters(FilterParams)} should
* be used instead.
*/
@Deprecated
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByFilters(Collection<TargetUpdateStatus> status, Boolean overdueState, String searchText,
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames);
/**
* Count {@link Target}s for all the given filter parameters.
*
@@ -135,14 +92,11 @@ public interface TargetManagement {
long countByFilters(@NotNull final FilterParams filterParams);
/**
* Counts number of targets with given with given distribution set Id
* Get the count of targets with the given distribution set id.
*
* @param distId
* to search for
* @param distId to search for
* @return number of found {@link Target}s.
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
* @throws EntityNotFoundException if distribution set with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
@@ -152,12 +106,9 @@ public interface TargetManagement {
* Checks if there is already a {@link Target} that has the given
* distribution set Id assigned or installed.
*
* @param distId
* to search for
* @param distId to search for
* @return <code>true</code> if a {@link Target} exists.
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
* @throws EntityNotFoundException if distribution set with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
@@ -226,8 +177,8 @@ public interface TargetManagement {
Target create(@NotNull @Valid TargetCreate create);
/**
* creates multiple {@link Target}s. If some of the given {@link Target}s
* already exists in the DB a {@link EntityAlreadyExistsException} is
* creates multiple {@link Target}s. If the given {@link Target}s
* already exists in the DB an {@link EntityAlreadyExistsException} is
* thrown. {@link Target}s contain all objects of the parameter targets,
* including duplicates.
*
@@ -546,28 +497,27 @@ public interface TargetManagement {
Slice<Target> findByTargetFilterQuery(@NotNull Pageable pageable, long targetFilterQueryId);
/**
* method retrieves all {@link Target}s from the repo in the following
* order:
* method retrieves all {@link Target}s from the repo in the following order:
* <p>
* 1) {@link Target}s which have the given {@link DistributionSet} as
* {@link Target#getTarget()} {@link Target#getInstalledDistributionSet()}
* <p>
* 2) {@link Target}s which have the given {@link DistributionSet} as
* {@link Target#getAssignedDistributionSet()}
* <p>
* 3) {@link Target}s which have no connection to the given
* {@link DistributionSet}.
* <ol>
* <li>{@link Target}s which have the given {@link DistributionSet} as installed
* distribution set</li>
* <li>{@link Target}s which have the given {@link DistributionSet} as assigned
* distribution set</li>
* <li>{@link Target}s which have no connection to the given
* {@link DistributionSet}</li>
* </ol>
*
* @param pageable
* the page request to page the result set
* @param orderByDistributionId
* {@link DistributionSet#getId()} to be ordered by
* @param filterParams
* the filters to apply; only filters are enabled that have
* non-null value; filters are AND-gated
* the filters to apply; only filters are enabled that have non-null
* value; filters are AND-gated
* @return a paged result {@link Page} of the {@link Target}s in a defined
* order.
*
*
* @throws EntityNotFoundException
* if distribution set with given ID does not exist
*/
@@ -614,17 +564,16 @@ public interface TargetManagement {
Page<Target> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, long tagId);
/**
* Toggles {@link TargetTag} assignment to given {@link Target}s by means
* that if some (or all) of the targets in the list have the {@link Tag} not
* yet assigned, they will be. Only if all of theme have the tag already
* assigned they will be removed instead.
* Toggles {@link TargetTag} assignment to given {@link Target}s by means that
* if some (or all) of the targets in the list have the {@link Tag} not yet
* assigned, they will be. Only if all of them have the tag already assigned
* they will be removed instead.
*
* @param controllerIds
* to toggle for
* @param tagName
* to toggle
* @return TagAssigmentResult with all meta data of the assignment outcome.
*
* @return TagAssigmentResult with all metadata of the assignment outcome.
* @throws EntityNotFoundException
* if tag with given name does not exist
*/
@@ -641,7 +590,7 @@ public interface TargetManagement {
* to set the type to
* @param typeId
* to assign targets to
* @return {@link TargetTypeAssignmentResult} with all meta data of the
* @return {@link TargetTypeAssignmentResult} with all metadata of the
* assignment outcome.
*
* @throws EntityNotFoundException
@@ -656,7 +605,7 @@ public interface TargetManagement {
*
* @param controllerIds
* to remove the type from
* @return {@link TargetTypeAssignmentResult} with all meta data of the
* @return {@link TargetTypeAssignmentResult} with all metadata of the
* assignment outcome.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
@@ -827,15 +776,15 @@ public interface TargetManagement {
* for
* @param metadata
* the meta data entries to create or update
* @return the updated or created target meta data entries
*
* @return the updated or created target metadata entries
*
* @throws EntityNotFoundException
* if given target does not exist
*
*
* @throws EntityAlreadyExistsException
* in case one of the meta data entry already exists for the
* in case one of the metadata entry already exists for the
* specific key
*
*
* @throws AssignmentQuotaExceededException
* if the maximum number of {@link MetaData} entries is exceeded
* for the addressed {@link Target}
@@ -847,10 +796,10 @@ public interface TargetManagement {
* Deletes a target meta data entry.
*
* @param controllerId
* where meta data has to be deleted
* where metadata has to be deleted
* @param key
* of the meta data element
*
*
* @throws EntityNotFoundException
* if given target does not exist
*/
@@ -863,10 +812,10 @@ public interface TargetManagement {
* @param pageable
* the page request to page the result
* @param controllerId
* the controller id to retrieve the meta data from
* the controller id to retrieve the metadata from
*
* @return a paged result of all meta data entries for a given target id
*
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
@@ -875,12 +824,12 @@ public interface TargetManagement {
/**
* Counts all meta data by the given target id.
*
*
* @param controllerId
* the controller id to retrieve the meta data from
*
* @return count of all meta data entries for a given target id
*
*
* @throws EntityNotFoundException
* if target with given ID does not exist
*/
@@ -888,17 +837,17 @@ public interface TargetManagement {
long countMetaDataByControllerId(@NotEmpty String controllerId);
/**
* Finds all meta data by the given target id and query.
*
* Finds all metadata by the given target id and query.
*
* @param pageable
* the page request to page the result
* @param controllerId
* the controller id to retrieve the meta data from
* the controller id to retrieve the metadata from
* @param rsqlParam
* rsql query string
*
* @return a paged result of all meta data entries for a given target id
*
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
@@ -932,14 +881,14 @@ public interface TargetManagement {
* Updates a target meta data value if corresponding entry exists.
*
* @param controllerId
* {@link Target} controller id of the meta data entry to be
* {@link Target} controller id of the metadata entry to be
* updated
* @param metadata
* meta data entry to be updated
* @return the updated meta data entry
*
*
* @throws EntityNotFoundException
* in case the meta data entry does not exists and cannot be
* in case the metadata entry does not exist and cannot be
* updated
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)

View File

@@ -56,8 +56,10 @@ public interface TargetType extends NamedEntity {
}
/**
* Unassigns a distribution set type from target types
* Unassigns a {@link DistributionSetType} from {@link TargetType}
*
* @param dsTypeId
* that will be removed from {@link TargetType}
* @return the resulting target type
*/
TargetType removeDistributionSetType(final Long dsTypeId);

View File

@@ -29,6 +29,7 @@ public class TenantUsage {
* Constructor.
*
* @param tenantName
* name of the tenant
*/
public TenantUsage(final String tenantName) {
this.tenantName = tenantName;

View File

@@ -9,7 +9,7 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.hawkbit</groupId>
@@ -18,13 +18,11 @@
</parent>
<artifactId>hawkbit-repository-jpa</artifactId>
<name>hawkBit :: Repository :: JPA Implementation</name>
<properties>
<apt.source.dir>${project.build.directory}/generated-sources/apt/</apt.source.dir>
<classgraph.version>4.8.90</classgraph.version>
<eclipselink.maven.plugin.version>2.7.5.1</eclipselink.maven.plugin.version>
</properties>
<dependencies>
<!-- Hawkbit -->
<dependency>
@@ -70,7 +68,11 @@
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
@@ -89,14 +91,13 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Static weaver for EclipseLink -->
<plugin>
<groupId>com.ethlo.persistence.tools</groupId>
<artifactId>eclipselink-maven-plugin</artifactId>
<version>${eclipselink.maven.plugin.version}</version>
<executions>
<execution>
<id>modelgen</id>
@@ -117,24 +118,10 @@
</configuration>
<dependencies>
<dependency>
<!--
Required for Java 11 since plugin version is build on
EclipseLink 2.7.5 (which doesn't have latest fixes for Java 11)
-->
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>${eclipselink.version}</version>
</dependency>
<dependency>
<!--
Required for Java 11 since plugin uses older version (4.8.21)
which suffer from NPE while weaving. We require at least 4.8.48
see: https://github.com/ethlo/eclipselink-maven-plugin/issues/31
-->
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>${classgraph.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>

View File

@@ -743,7 +743,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
throw new InvalidTargetAttributeException();
}
final JpaTarget target = (JpaTarget) targetRepository.findOne(TargetSpecifications.hasControllerId(controllerId))
final JpaTarget target = targetRepository.findOne(TargetSpecifications.hasControllerId(controllerId))
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
// get the modifiable attribute map

View File

@@ -188,10 +188,10 @@ public class JpaTargetManagement implements TargetManagement {
final JpaTarget updatedTarget = JpaManagementHelper.touch(entityManager, targetRepository, target);
final List<TargetMetadata> createdMetadata = Collections.unmodifiableList(md.stream()
final List<TargetMetadata> createdMetadata = md.stream()
.map(meta -> targetMetadataRepository
.save(new JpaTargetMetadata(meta.getKey(), meta.getValue(), updatedTarget)))
.collect(Collectors.toList()));
.collect(Collectors.toUnmodifiableList());
// TargetUpdatedEvent is not sent within the touch() method due to the
// "lastModifiedAt" field being ignored in JpaTarget
@@ -228,12 +228,12 @@ public class JpaTargetManagement implements TargetManagement {
// target indirectly
final JpaTarget target = JpaManagementHelper.touch(entityManager, targetRepository,
getByControllerIdAndThrowIfNotFound(controllerId));
final JpaTargetMetadata matadata = targetMetadataRepository.save(updatedMetadata);
final JpaTargetMetadata metadata = targetMetadataRepository.save(updatedMetadata);
// target update event is set to ignore "lastModifiedAt" field so it is
// not send automatically within the touch() method
eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetUpdatedEvent(target, eventPublisherHolder.getApplicationId()));
return matadata;
return metadata;
}
@Override
@@ -247,7 +247,7 @@ public class JpaTargetManagement implements TargetManagement {
final JpaTarget target = JpaManagementHelper.touch(entityManager, targetRepository,
getByControllerIdAndThrowIfNotFound(controllerId));
targetMetadataRepository.deleteById(metadata.getId());
// target update event is set to ignore "lastModifiedAt" field so it is
// target update event is set to ignore "lastModifiedAt" field, so it is
// not send automatically within the touch() method
eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetUpdatedEvent(target, eventPublisherHolder.getApplicationId()));
@@ -419,14 +419,6 @@ public class JpaTargetManagement implements TargetManagement {
return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, pageable, specList);
}
@Override
public long countByFilters(final Collection<TargetUpdateStatus> status, final Boolean overdueState,
final String searchText, final Long installedOrAssignedDistributionSetId,
final Boolean selectTargetWithNoTag, final String... tagNames) {
return countByFilters(new FilterParams(status, overdueState, searchText, installedOrAssignedDistributionSetId,
selectTargetWithNoTag, tagNames));
}
@Override
public long countByFilters(final FilterParams filterParams) {
final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams);
@@ -590,8 +582,8 @@ public class JpaTargetManagement implements TargetManagement {
allTargets.forEach(target -> target.addTag(tag));
final List<Target> result = Collections
.unmodifiableList(allTargets.stream().map(targetRepository::save).collect(Collectors.toList()));
final List<Target> result = allTargets.stream().map(targetRepository::save)
.collect(Collectors.toUnmodifiableList());
// No reason to save the tag
entityManager.detach(tag);

View File

@@ -45,7 +45,7 @@ public class ParseExceptionWrapper {
/**
* Get the current token
*
*
* @return the current token or {@code null} if there is non.
*/
public TokenWrapper getCurrentToken() {

View File

@@ -46,7 +46,7 @@ public class LazyControllerManagementTest extends AbstractJpaIntegrationTest {
TimeUnit.MILLISECONDS.sleep(10);
controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST);
TimeUnit.MILLISECONDS.sleep(repositoryProperties.getPollPersistenceFlushTime() + 1);
TimeUnit.MILLISECONDS.sleep(repositoryProperties.getPollPersistenceFlushTime() + 10);
final Target updated = targetManagement.get(target.getId()).get();

View File

@@ -93,7 +93,7 @@ public class SpecificationsBuilderTest {
when(criteriaBuilder.equal(any(Path.class), eq("testValue1"))).thenReturn(equalPredicate1);
when(criteriaBuilder.equal(any(Path.class), eq("testValue2"))).thenReturn(equalPredicate2);
when(criteriaBuilder.and(eq(equalPredicate2), eq(equalPredicate1))).thenReturn(combinedPredicate);
when(criteriaBuilder.and(eq(equalPredicate1), eq(equalPredicate2))).thenReturn(combinedPredicate);
when(root.get("field1")).thenReturn(field1);
when(root.get("field2")).thenReturn(field2);

View File

@@ -34,6 +34,11 @@
<artifactId>hawkbit-repository-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-security-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-artifact-repository-filesystem</artifactId>
@@ -140,4 +145,4 @@
<artifactId>awaitility</artifactId>
</dependency>
</dependencies>
</project>
</project>

View File

@@ -24,10 +24,12 @@ public class CleanupTestExecutionListener extends AbstractTestExecutionListener
@Override
public void afterTestMethod(final TestContext testContext) throws Exception {
final ApplicationContext applicationContext = testContext.getApplicationContext();
new JpaTestRepositoryManagement(applicationContext.getBean(TenantAwareCacheManager.class),
applicationContext.getBean(SystemSecurityContext.class),
applicationContext.getBean(SystemManagement.class)).clearTestRepository();
WithSpringAuthorityRule.runAsPrivileged(() -> {
final ApplicationContext applicationContext = testContext.getApplicationContext();
new JpaTestRepositoryManagement(applicationContext.getBean(TenantAwareCacheManager.class),
applicationContext.getBean(SystemSecurityContext.class),
applicationContext.getBean(SystemManagement.class)).clearTestRepository();
return null;
});
}
}