diff --git a/3rd-dependencies/Release_0_2_0.md b/3rd-dependencies/Release_0_2_0.md index 98be8afb0..56113baf2 100644 --- a/3rd-dependencies/Release_0_2_0.md +++ b/3rd-dependencies/Release_0_2_0.md @@ -52,7 +52,7 @@ |org.apache.tomcat|tomcat-juli|8.0.28| [CQ10618](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10618) | |org.flywaydb|flyway-core|4.0.3| [CQ12947](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12947) | |org.glassfish|javax.json|1.0.4| [CQ10619](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10619) | -|org.hibernate|hibernate-validator|5.2.2.Final| [CQ10371](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10371) | +|org.hibernate|hibernate-validator|6.0.7.Final| [CQ15540](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=15540) | |org.jboss.logging|jboss-logging|3.2.1.Final| [CQ10621](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10621) | |org.jsoup|jsoup|1.8.3| [CQ12936](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12936) | |org.ow2.asm|asm-commons|5.0.1| [CQ12945](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12945) | diff --git a/3rd-dependencies/compile.txt b/3rd-dependencies/compile.txt index 9a8dcc2e3..6be872fef 100644 --- a/3rd-dependencies/compile.txt +++ b/3rd-dependencies/compile.txt @@ -1,41 +1,42 @@ aopalliance:aopalliance:jar:1.0:compile - ch.qos.logback:logback-classic:jar:1.1.3:compile - ch.qos.logback:logback-core:jar:1.1.3:compile - com.fasterxml.jackson.core:jackson-annotations:jar:2.8.2:compile - com.fasterxml.jackson.core:jackson-core:jar:2.8.2:compile - com.fasterxml.jackson.core:jackson-databind:jar:2.8.2:compile - com.fasterxml:classmate:jar:1.3.0:compile + ch.qos.logback:logback-classic:jar:1.1.11:compile + ch.qos.logback:logback-core:jar:1.1.11:compile + com.fasterxml.jackson.core:jackson-annotations:jar:2.8.9:compile + com.fasterxml.jackson.core:jackson-core:jar:2.8.9:compile + com.fasterxml.jackson.core:jackson-databind:jar:2.8.9:compile + com.fasterxml:classmate:jar:1.3.3:compile + com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile com.github.gwtd3:gwt-d3-api:jar:1.2.0:compile com.github.gwtd3:gwt-d3-js:jar:3.5.11:compile com.github.gwtd3:gwt-d3-js:jar:sources:3.5.11:compile com.google.guava:guava:jar:19.0:compile - com.h2database:h2:jar:1.4.186:compile - com.rabbitmq:amqp-client:jar:4.0.2:compile + com.h2database:h2:jar:1.4.195:compile + com.rabbitmq:amqp-client:jar:4.0.3:compile com.rabbitmq:http-client:jar:1.1.1.RELEASE:compile com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.9.vaadin2:compile com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile - com.vaadin.external.gwt:gwt-elemental:jar:2.7.0.vaadin4:compile - com.vaadin.external.gwt:gwt-user:jar:2.7.0.vaadin4:compile + com.vaadin.external.gwt:gwt-elemental:jar:2.7.0.vaadin5:compile + com.vaadin.external.gwt:gwt-user:jar:2.7.0.vaadin5:compile com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile - com.vaadin:vaadin-client:jar:7.7.7:compile - com.vaadin:vaadin-push:jar:7.7.7:compile + com.vaadin:vaadin-client:jar:7.7.9:compile + com.vaadin:vaadin-push:jar:7.7.9:compile com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile - com.vaadin:vaadin-server:jar:7.7.7:compile - com.vaadin:vaadin-shared:jar:7.7.7:compile + com.vaadin:vaadin-server:jar:7.7.9:compile + com.vaadin:vaadin-shared:jar:7.7.9:compile com.vaadin:vaadin-spring-boot:jar:1.1.1:compile com.vaadin:vaadin-spring:jar:1.1.1:compile - com.vaadin:vaadin-themes:jar:7.7.7:compile + com.vaadin:vaadin-themes:jar:7.7.9:compile commons-codec:commons-codec:jar:1.10:compile commons-io:commons-io:jar:2.4:compile cz.jirutka.rsql:rsql-parser:jar:2.1.0:compile - io.protostuff:protostuff-api:jar:1.5.3:compile - io.protostuff:protostuff-collectionschema:jar:1.5.3:compile - io.protostuff:protostuff-core:jar:1.5.3:compile - io.protostuff:protostuff-runtime:jar:1.5.3:compile + io.protostuff:protostuff-api:jar:1.5.6:compile + io.protostuff:protostuff-collectionschema:jar:1.5.6:compile + io.protostuff:protostuff-core:jar:1.5.6:compile + io.protostuff:protostuff-runtime:jar:1.5.6:compile javax.annotation:javax.annotation-api:jar:1.2:compile javax.servlet:javax.servlet-api:jar:3.1.0:compile javax.transaction:javax.transaction-api:jar:1.2:compile - javax.validation:validation-api:jar:1.1.0.Final:compile + javax.validation:validation-api:jar:2.0.1.Final:compile javax.validation:validation-api:jar:sources:1.0.0.GA:compile javax.websocket:javax.websocket-api:jar:1.0:compile org.apache.commons:commons-lang3:jar:3.4:compile @@ -44,64 +45,64 @@ org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.28:compile org.apache.tomcat:tomcat-jdbc:jar:8.0.28:compile org.apache.tomcat:tomcat-juli:jar:8.0.28:compile - org.aspectj:aspectjweaver:jar:1.8.9:compile + org.aspectj:aspectjweaver:jar:1.8.10:compile org.flywaydb:flyway-core:jar:4.0.3:compile org.glassfish:javax.json:jar:1.0.4:compile - org.hibernate:hibernate-validator:jar:5.2.2.Final:compile + org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile org.jsoup:jsoup:jar:1.8.3:compile org.mortbay.jasper:apache-el:jar:8.0.33:compile org.ow2.asm:asm-commons:jar:5.0.1:compile org.ow2.asm:asm-tree:jar:5.0.1:compile org.ow2.asm:asm:jar:5.0.1:compile - org.slf4j:jcl-over-slf4j:jar:1.7.22:compile - org.slf4j:jul-to-slf4j:jar:1.7.22:compile - org.slf4j:log4j-over-slf4j:jar:1.7.22:compile - org.slf4j:slf4j-api:jar:1.7.22:compile - org.springframework.amqp:spring-amqp:jar:1.7.1.RELEASE:compile - org.springframework.amqp:spring-rabbit:jar:1.7.1.RELEASE:compile - org.springframework.boot:spring-boot-actuator:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-autoconfigure:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-actuator:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-aop:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-jetty:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-logging:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-validation:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter-web:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot-starter:jar:1.4.5.RELEASE:compile - org.springframework.boot:spring-boot:jar:1.4.5.RELEASE:compile + org.slf4j:jcl-over-slf4j:jar:1.7.25:compile + org.slf4j:jul-to-slf4j:jar:1.7.25:compile + org.slf4j:log4j-over-slf4j:jar:1.7.25:compile + org.slf4j:slf4j-api:jar:1.7.25:compile + org.springframework.amqp:spring-amqp:jar:1.7.4.RELEASE:compile + org.springframework.amqp:spring-rabbit:jar:1.7.4.RELEASE:compile + org.springframework.boot:spring-boot-actuator:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-autoconfigure:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-actuator:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-aop:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-jetty:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-logging:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-validation:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter-web:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot-starter:jar:1.4.7.RELEASE:compile + org.springframework.boot:spring-boot:jar:1.4.7.RELEASE:compile org.springframework.cloud:spring-cloud-bus:jar:1.2.2.RELEASE:compile org.springframework.cloud:spring-cloud-context:jar:1.1.8.RELEASE:compile org.springframework.cloud:spring-cloud-stream:jar:1.1.2.RELEASE:compile - org.springframework.data:spring-data-commons:jar:1.12.8.RELEASE:compile - org.springframework.data:spring-data-jpa:jar:1.10.8.RELEASE:compile + org.springframework.data:spring-data-commons:jar:1.12.11.RELEASE:compile + org.springframework.data:spring-data-jpa:jar:1.10.11.RELEASE:compile org.springframework.hateoas:spring-hateoas:jar:0.23.0.RELEASE:compile - org.springframework.integration:spring-integration-core:jar:4.3.8.RELEASE:compile - org.springframework.integration:spring-integration-jmx:jar:4.3.8.RELEASE:compile + org.springframework.integration:spring-integration-core:jar:4.3.10.RELEASE:compile + org.springframework.integration:spring-integration-jmx:jar:4.3.10.RELEASE:compile org.springframework.integration:spring-integration-tuple:jar:1.0.0.RELEASE:compile org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile - org.springframework.retry:spring-retry:jar:1.1.2.RELEASE:compile + org.springframework.retry:spring-retry:jar:1.1.5.RELEASE:compile org.springframework.security:spring-security-aspects:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-config:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-core:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-crypto:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-web:jar:4.1.4.RELEASE:compile - org.springframework:spring-aop:jar:4.3.7.RELEASE:compile - org.springframework:spring-aspects:jar:4.3.7.RELEASE:compile - org.springframework:spring-beans:jar:4.3.7.RELEASE:compile - org.springframework:spring-context-support:jar:4.3.7.RELEASE:compile - org.springframework:spring-context:jar:4.3.7.RELEASE:compile - org.springframework:spring-core:jar:4.3.7.RELEASE:compile - org.springframework:spring-expression:jar:4.3.7.RELEASE:compile - org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile - org.springframework:spring-messaging:jar:4.3.7.RELEASE:compile - org.springframework:spring-orm:jar:4.3.7.RELEASE:compile + org.springframework:spring-aop:jar:4.3.9.RELEASE:compile + org.springframework:spring-aspects:jar:4.3.9.RELEASE:compile + org.springframework:spring-beans:jar:4.3.9.RELEASE:compile + org.springframework:spring-context-support:jar:4.3.9.RELEASE:compile + org.springframework:spring-context:jar:4.3.9.RELEASE:compile + org.springframework:spring-core:jar:4.3.9.RELEASE:compile + org.springframework:spring-expression:jar:4.3.9.RELEASE:compile + org.springframework:spring-jdbc:jar:4.3.9.RELEASE:compile + org.springframework:spring-messaging:jar:4.3.9.RELEASE:compile + org.springframework:spring-orm:jar:4.3.9.RELEASE:compile org.springframework:spring-tuple:jar:1.0.0.RELEASE:compile - org.springframework:spring-tx:jar:4.3.7.RELEASE:compile - org.springframework:spring-web:jar:4.3.7.RELEASE:compile - org.springframework:spring-webmvc:jar:4.3.7.RELEASE:compile + org.springframework:spring-tx:jar:4.3.9.RELEASE:compile + org.springframework:spring-web:jar:4.3.9.RELEASE:compile + org.springframework:spring-webmvc:jar:4.3.9.RELEASE:compile org.vaadin.addons.lazyquerycontainer:vaadin-lazyquerycontainer:jar:7.6.1.3:compile org.vaadin.addons:flexibleoptiongroup:jar:2.2.0:compile org.vaadin.addons:tokenfield:jar:7.0.1:compile diff --git a/hawkbit-core/pom.xml b/hawkbit-core/pom.xml index 86effb80b..2f9d78c5c 100644 --- a/hawkbit-core/pom.xml +++ b/hawkbit-core/pom.xml @@ -32,10 +32,6 @@ javax.validation validation-api - - org.hibernate - hibernate-validator - diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java index 5540bf150..d6d7dbb15 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java @@ -10,11 +10,11 @@ package org.eclipse.hawkbit.artifact.repository; import java.io.InputStream; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; -import org.hibernate.validator.constraints.NotEmpty; /** * ArtifactRepository service interface. diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java index 483ac5506..50dd46c98 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java @@ -48,20 +48,26 @@ public class DownloadArtifactCache { @Override public boolean equals(final Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } final DownloadArtifactCache other = (DownloadArtifactCache) obj; - if (downloadType != other.downloadType) + if (downloadType != other.downloadType) { return false; + } if (id == null) { - if (other.id != null) + if (other.id != null) { return false; - } else if (!id.equals(other.id)) + } + } else if (!id.equals(other.id)) { return false; + } return true; } } diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java index c9e049966..2688fd2ae 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java @@ -90,11 +90,11 @@ public class TenantAwareCacheManager implements TenancyCacheManager { getCacheNames(tenant).forEach(cachename -> delegate.getCache(buildKey(tenant, cachename)).clear()); } - private boolean isTenantInvalid(final String tenant) { + private static boolean isTenantInvalid(final String tenant) { return tenant == null || tenant.contains(TENANT_CACHE_DELIMITER); } - private String buildKey(final String tenant, final String cacheName) { + private static String buildKey(final String tenant, final String cacheName) { return tenant + TENANT_CACHE_DELIMITER + cacheName; } diff --git a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigData.java b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigData.java index a16ddf064..4cd140ca7 100644 --- a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigData.java +++ b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigData.java @@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ddi.json.model; import java.util.Map; -import org.hibernate.validator.constraints.NotEmpty; +import javax.validation.constraints.NotEmpty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java index 90607a426..543ce15e9 100644 --- a/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java +++ b/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java @@ -13,6 +13,7 @@ import java.lang.annotation.Target; import java.util.List; import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import org.eclipse.hawkbit.ddi.json.model.DdiActionFeedback; import org.eclipse.hawkbit.ddi.json.model.DdiArtifact; @@ -20,7 +21,6 @@ import org.eclipse.hawkbit.ddi.json.model.DdiCancel; import org.eclipse.hawkbit.ddi.json.model.DdiConfigData; import org.eclipse.hawkbit.ddi.json.model.DdiControllerBase; import org.eclipse.hawkbit.ddi.json.model.DdiDeploymentBase; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.hateoas.MediaTypes; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java index b5077379e..62db9cd44 100644 --- a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java +++ b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java @@ -80,8 +80,7 @@ public final class DataConversionHelper { return key; } - static List createArtifacts(final Target target, - final org.eclipse.hawkbit.repository.model.SoftwareModule module, + static List createArtifacts(final Target target, final SoftwareModule module, final ArtifactUrlHandler artifactUrlHandler, final SystemManagement systemManagement, final HttpRequest request) { diff --git a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java index 674c721e0..6107eefe8 100644 --- a/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java +++ b/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java @@ -15,6 +15,7 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import org.eclipse.hawkbit.api.ArtifactUrlHandler; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; @@ -54,7 +55,6 @@ import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder; import org.eclipse.hawkbit.security.HawkbitSecurityProperties; import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.util.IpUtil; -import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index c4d6371b3..cf6a354ca 100644 --- a/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -552,13 +552,13 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action.getId() + "/feedback", tenantAware.getCurrentTenant()).content(feedback).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); } mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action.getId() + "/feedback", tenantAware.getCurrentTenant()).content(feedback).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); } @Test @@ -582,7 +582,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action.getId() + "/feedback", tenantAware.getCurrentTenant()).content(feedback).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java index 41372562c..f6ed125b9 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentication.java @@ -22,10 +22,10 @@ import org.eclipse.hawkbit.security.ControllerPreAuthenticatedAnonymousFilter; import org.eclipse.hawkbit.security.ControllerPreAuthenticatedGatewaySecurityTokenFilter; import org.eclipse.hawkbit.security.ControllerPreAuthenticatedSecurityHeaderFilter; import org.eclipse.hawkbit.security.DdiSecurityProperties; +import org.eclipse.hawkbit.security.DmfTenantSecurityToken; import org.eclipse.hawkbit.security.PreAuthTokenSourceTrustAuthenticationProvider; import org.eclipse.hawkbit.security.PreAuthenticationFilter; import org.eclipse.hawkbit.security.SystemSecurityContext; -import org.eclipse.hawkbit.security.DmfTenantSecurityToken; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DelayedRequeueExceptionStrategy.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DelayedRequeueExceptionStrategy.java index f86bfbaf3..e35158c44 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DelayedRequeueExceptionStrategy.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DelayedRequeueExceptionStrategy.java @@ -40,7 +40,7 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa * @param delay * in {@link TimeUnit#MILLISECONDS} before requeue. */ - public DelayedRequeueExceptionStrategy(final long delay) { + DelayedRequeueExceptionStrategy(final long delay) { this.delay = delay; } @@ -62,23 +62,23 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa return false; } - private boolean invalidMessage(final Throwable cause) { + private static boolean invalidMessage(final Throwable cause) { return doesNotExist(cause) || quotaHit(cause) || invalidContent(cause) || invalidState(cause); } - private boolean invalidState(final Throwable cause) { + private static boolean invalidState(final Throwable cause) { return cause instanceof CancelActionNotAllowedException; } - private boolean quotaHit(final Throwable cause) { + private static boolean quotaHit(final Throwable cause) { return cause instanceof QuotaExceededException; } - private boolean doesNotExist(final Throwable cause) { + private static boolean doesNotExist(final Throwable cause) { return cause instanceof TenantNotExistException || cause instanceof EntityNotFoundException; } - private boolean invalidContent(final Throwable cause) { + private static boolean invalidContent(final Throwable cause) { return cause instanceof ConstraintViolationException || cause instanceof InvalidTargetAddressException || cause instanceof MessageConversionException || cause instanceof MessageHandlingException; } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index 5f6fbad24..7faf7281b 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.amqp; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -277,7 +277,7 @@ public class AmqpMessageHandlerServiceTest { @Test @Description("Tests the update of an action of a target without a exist action id") public void updateActionStatusWithoutActionId() { - when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty()); + when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty()); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.DOWNLOAD); @@ -297,7 +297,7 @@ public class AmqpMessageHandlerServiceTest { public void updateActionStatusWithoutExistActionId() { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); - when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.empty()); + when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty()); final DmfActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(DmfActionStatus.DOWNLOAD); final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(actionUpdateStatus, @@ -342,7 +342,7 @@ public class AmqpMessageHandlerServiceTest { final Artifact localArtifactMock = mock(Artifact.class); when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock)); - when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyObject(), anyObject())) + when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyString(), anyLong())) .thenThrow(EntityNotFoundException.class); // test @@ -396,7 +396,7 @@ public class AmqpMessageHandlerServiceTest { // Mock final Action action = createActionWithTarget(22L, Status.FINISHED); - when(controllerManagementMock.findActionWithDetails(any())).thenReturn(Optional.of(action)); + when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action)); when(controllerManagementMock.addUpdateActionStatus(any())).thenReturn(action); final ActionStatusBuilder builder = mock(ActionStatusBuilder.class); final ActionStatusCreate create = mock(ActionStatusCreate.class); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java index 9c2d39b6d..c677e74c5 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java @@ -59,7 +59,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq @Before public void testSetup() { - enableTargetTokenAuthentification(); + enableTargetTokenAuthentication(); } @Test @@ -393,7 +393,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, false); } - private void enableTargetTokenAuthentification() { + private void enableTargetTokenAuthentication() { tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED, false); tenantConfigurationManagement.addOrUpdateConfiguration( diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 16a27d10f..a4cacb888 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -728,7 +728,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); - final DistributionSet toLongName = testdataFactory.generateDistributionSet(RandomStringUtils.randomAscii(80)); + final DistributionSet toLongName = testdataFactory + .generateDistributionSet(RandomStringUtils.randomAlphanumeric(80)); mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Arrays.asList(toLongName))) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index 69727bfbe..726869183 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -539,7 +539,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn .andExpect(status().isBadRequest()); final DistributionSetType toLongName = entityFactory.distributionSetType().create().key("test123") - .name(RandomStringUtils.randomAscii(80)).build(); + .name(RandomStringUtils.randomAlphanumeric(80)).build(); mvc.perform(post("/rest/v1/distributionsettypes") .content(JsonBuilder.distributionSetTypes(Arrays.asList(toLongName))) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index d410d29cf..2db0168bd 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -431,7 +431,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra .andExpect(status().isBadRequest()); final SoftwareModule toLongName = entityFactory.softwareModule().create().type(osType) - .name(RandomStringUtils.randomAscii(80)).build(); + .name(RandomStringUtils.randomAlphanumeric(80)).build(); mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Arrays.asList(toLongName))) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index 71069b8ed..dc3471f6f 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -90,11 +90,10 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt } private SoftwareModuleType createTestType() { - SoftwareModuleType testType = softwareModuleTypeManagement - .create(entityFactory.softwareModuleType().create().key("test123").name("TestName123") - .description("Desc123").maxAssignments(5)); - testType = softwareModuleTypeManagement.update( - entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234")); + SoftwareModuleType testType = softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create() + .key("test123").name("TestName123").description("Desc123").maxAssignments(5)); + testType = softwareModuleTypeManagement + .update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234")); return testType; } @@ -251,8 +250,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt @Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).") public void deleteSoftwareModuleTypeUsed() throws Exception { final SoftwareModuleType testType = createTestType(); - softwareModuleManagement.create( - entityFactory.softwareModule().create().type(testType).name("name").version("version")); + softwareModuleManagement + .create(entityFactory.softwareModule().create().type(testType).name("name").version("version")); assertThat(softwareModuleTypeManagement.count()).isEqualTo(4); @@ -340,14 +339,13 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); - mvc.perform(post("/rest/v1/softwaremoduletypes") - .content( - "[{\"description\":\"Desc123\",\"id\":9223372036854775807,\"key\":\"test123\",\"maxAssignments\":5}]") + mvc.perform(post("/rest/v1/softwaremoduletypes").content( + "[{\"description\":\"Desc123\",\"id\":9223372036854775807,\"key\":\"test123\",\"maxAssignments\":5}]") .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final SoftwareModuleType toLongName = entityFactory.softwareModuleType().create().key("test123") - .name(RandomStringUtils.randomAscii(80)).build(); + .name(RandomStringUtils.randomAlphanumeric(80)).build(); mvc.perform( post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(Arrays.asList(toLongName))) .contentType(MediaType.APPLICATION_JSON)) @@ -372,8 +370,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt public void searchSoftwareModuleTypeRsql() throws Exception { softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test123") .name("TestName123").description("Desc123").maxAssignments(5)); - softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create() - .key("test1234").name("TestName1234").description("Desc1234").maxAssignments(5)); + softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test1234") + .name("TestName1234").description("Desc1234").maxAssignments(5)); final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234"; diff --git a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index 894cd1f7a..654736165 100644 --- a/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -713,8 +713,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest @Test @Description("Verfies that a properties of new targets are validated as in allowed size range.") public void createTargetWithInvalidPropertyBadRequest() throws Exception { - final Target test1 = entityFactory.target().create().controllerId("id1").name(RandomStringUtils.randomAscii(80)) - .build(); + final Target test1 = entityFactory.target().create().controllerId("id1") + .name(RandomStringUtils.randomAlphanumeric(80)).build(); final MvcResult mvcResult = mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) .content(JsonBuilder.targets(Arrays.asList(test1), true)).contentType(MediaType.APPLICATION_JSON)) diff --git a/hawkbit-repository/hawkbit-repository-api/pom.xml b/hawkbit-repository/hawkbit-repository-api/pom.xml index 40527955d..69cbdaef4 100644 --- a/hawkbit-repository/hawkbit-repository-api/pom.xml +++ b/hawkbit-repository/hawkbit-repository-api/pom.xml @@ -29,10 +29,6 @@ javax.validation validation-api - - org.hibernate - hibernate-validator - org.springframework.hateoas spring-hateoas diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java index f59b6896e..8e97df774 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository; import java.io.InputStream; import java.util.Optional; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; @@ -23,7 +24,6 @@ import org.eclipse.hawkbit.repository.exception.InvalidMD5HashException; import org.eclipse.hawkbit.repository.exception.InvalidSHA1HashException; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.hateoas.Identifiable; @@ -62,8 +62,8 @@ public interface ArtifactManagement { * @throws EntityNotFoundException * if given software module does not exist */ - @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - Artifact create(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename, + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) + Artifact create(@NotNull InputStream inputStream, long moduleId, final String filename, final boolean overrideExisting); /** @@ -99,8 +99,8 @@ public interface ArtifactManagement { * if check against provided SHA1 checksum failed */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - Artifact create(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename, - String providedMd5Sum, String providedSha1Sum, boolean overrideExisting, String contentType); + Artifact create(@NotNull InputStream stream, long moduleId, @NotEmpty String filename, String providedMd5Sum, + String providedSha1Sum, boolean overrideExisting, String contentType); /** * Garbage collects artifact binaries if only referenced by given @@ -116,7 +116,7 @@ public interface ArtifactManagement { * @return true if an binary was actually garbage collected */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - boolean clearArtifactBinary(@NotEmpty String artifactSha1Hash, @NotNull Long moduleId); + boolean clearArtifactBinary(@NotEmpty String artifactSha1Hash, long moduleId); /** * Deletes {@link Artifact} based on given id. @@ -129,7 +129,7 @@ public interface ArtifactManagement { * if artifact with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - void delete(@NotNull Long id); + void delete(long id); /** * Searches for {@link Artifact} with given {@link Identifiable}. @@ -140,7 +140,7 @@ public interface ArtifactManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_CONTROLLER) - Optional get(@NotNull Long id); + Optional get(long id); /** * Find by artifact by software module id and filename. @@ -156,7 +156,7 @@ public interface ArtifactManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_CONTROLLER) - Optional getByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId); + Optional getByFilenameAndSoftwareModule(@NotNull String filename, long softwareModuleId); /** * Find all local artifact by sha1 and return the first artifact. @@ -193,7 +193,7 @@ public interface ArtifactManagement { * if software module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId); + Page findBySoftwareModule(@NotNull Pageable pageReq, long swId); /** * Loads {@link AbstractDbArtifact} from store for given {@link Artifact}. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 5bd07e6d5..e58d06eca 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -15,6 +15,8 @@ import java.util.Map; import java.util.Optional; import javax.validation.ConstraintViolationException; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -30,7 +32,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -64,7 +65,7 @@ public interface ControllerManagement { * */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Action addCancelActionStatus(@NotNull ActionStatusCreate create); + Action addCancelActionStatus(@NotNull @Valid ActionStatusCreate create); /** * Retrieves assigned {@link SoftwareModule} of a target. @@ -74,7 +75,7 @@ public interface ControllerManagement { * @return {@link SoftwareModule} identified by ID */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Optional getSoftwareModule(@NotNull Long moduleId); + Optional getSoftwareModule(long moduleId); /** * Retrieves {@link SoftwareModuleMetadata} where @@ -108,7 +109,7 @@ public interface ControllerManagement { * {@link ActionStatusCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - ActionStatus addInformationalActionStatus(@NotNull ActionStatusCreate create); + ActionStatus addInformationalActionStatus(@NotNull @Valid ActionStatusCreate create); /** * Adds an {@link ActionStatus} entry for an update {@link Action} including @@ -130,7 +131,7 @@ public interface ControllerManagement { * {@link ActionStatusCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Action addUpdateActionStatus(@NotNull ActionStatusCreate create); + Action addUpdateActionStatus(@NotNull @Valid ActionStatusCreate create); /** * Retrieves oldest {@link Action} that is active and assigned to a @@ -146,7 +147,7 @@ public interface ControllerManagement { * */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Optional findOldestActiveActionByTarget(@NotNull String controllerId); + Optional findOldestActiveActionByTarget(@NotEmpty String controllerId); /** * Get the {@link Action} entity for given actionId with all lazy @@ -157,7 +158,7 @@ public interface ControllerManagement { * @return the corresponding {@link Action} */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Optional findActionWithDetails(@NotNull Long actionId); + Optional findActionWithDetails(long actionId); /** * Retrieves all the {@link ActionStatus} entries of the given @@ -173,7 +174,7 @@ public interface ControllerManagement { * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Page findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Long actionId); + Page findActionStatusByAction(@NotNull Pageable pageReq, long actionId); /** * Register new target in the repository (plug-and-play) and in case it @@ -207,8 +208,7 @@ public interface ControllerManagement { * */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Optional getActionForDownloadByTargetAndSoftwareModule(@NotEmpty String controllerId, - @NotNull Long moduleId); + Optional getActionForDownloadByTargetAndSoftwareModule(@NotEmpty String controllerId, long moduleId); /** * @return current {@link TenantConfigurationKey#POLLING_TIME_INTERVAL}. @@ -258,7 +258,7 @@ public interface ControllerManagement { * if target with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotEmpty String sha1Hash); + boolean hasTargetArtifactAssigned(long targetId, @NotEmpty String sha1Hash); /** * Registers retrieved status for given {@link Target} and {@link Action} if @@ -275,7 +275,7 @@ public interface ControllerManagement { * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Action registerRetrieved(@NotNull Long actionId, String message); + Action registerRetrieved(long actionId, String message); /** * Updates attributes of the controller. @@ -321,7 +321,7 @@ public interface ControllerManagement { */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.IS_SYSTEM_CODE) - Optional get(@NotNull Long targetId); + Optional get(long targetId); /** * Retrieves the specified number of messages from action history of the @@ -348,5 +348,5 @@ public interface ControllerManagement { * @return action history. */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - List getActionHistoryMessages(@NotNull Long actionId, final int messageCount); + List getActionHistoryMessages(long actionId, int messageCount); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index eb90ebd87..3904c77c0 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository; import java.util.Collection; import java.util.Optional; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -31,7 +32,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetWithActionType; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -68,7 +68,7 @@ public interface DeploymentManagement { * do not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, @NotNull ActionType actionType, + DistributionSetAssignmentResult assignDistributionSet(long dsID, @NotNull ActionType actionType, long forcedTimestamp, @NotEmpty Collection controllerIDs); /** @@ -90,7 +90,7 @@ public interface DeploymentManagement { * do not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, + DistributionSetAssignmentResult assignDistributionSet(long dsID, @NotEmpty Collection targets); /** @@ -114,7 +114,7 @@ public interface DeploymentManagement { * do not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, + DistributionSetAssignmentResult assignDistributionSet(long dsID, @NotEmpty Collection targets, String actionMessage); /** @@ -167,7 +167,7 @@ public interface DeploymentManagement { * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - Action cancelAction(@NotNull Long actionId); + Action cancelAction(long actionId); /** * counts all actions associated to a specific target. @@ -223,7 +223,7 @@ public interface DeploymentManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Optional findAction(@NotNull Long actionId); + Optional findAction(long actionId); /** * Retrieves all {@link Action}s from repository. @@ -251,7 +251,7 @@ public interface DeploymentManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull Long distributionSetId); + Slice findActionsByDistributionSet(@NotNull Pageable pageable, long distributionSetId); /** * Retrieves all {@link Action}s assigned to a specific {@link Target} and a @@ -304,7 +304,7 @@ public interface DeploymentManagement { * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Long actionId); + Page findActionStatusByAction(@NotNull Pageable pageReq, long actionId); /** * Retrieves all messages for an {@link ActionStatus}. @@ -317,7 +317,7 @@ public interface DeploymentManagement { * @return a page of messages by a specific {@link ActionStatus} id */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findMessagesByActionStatusId(@NotNull Pageable pageable, @NotNull Long actionStatusId); + Page findMessagesByActionStatusId(@NotNull Pageable pageable, long actionStatusId); /** * Get the {@link Action} entity for given actionId with all lazy attributes @@ -328,7 +328,7 @@ public interface DeploymentManagement { * @return the corresponding {@link Action} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Optional findActionWithDetails(@NotNull Long actionId); + Optional findActionWithDetails(long actionId); /** * Retrieves all active {@link Action}s of a specific target ordered by @@ -380,7 +380,7 @@ public interface DeploymentManagement { * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - Action forceQuitAction(@NotNull Long actionId); + Action forceQuitAction(long actionId); /** * Updates a {@link Action} and forces the {@link Action} if it's not @@ -394,7 +394,7 @@ public interface DeploymentManagement { * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - Action forceTargetAction(@NotNull Long actionId); + Action forceTargetAction(long actionId); /** * Starts all scheduled actions of an RolloutGroup parent. @@ -407,7 +407,7 @@ public interface DeploymentManagement { * @return the amount of started actions */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - long startScheduledActionsByRolloutGroupParent(@NotNull Long rolloutId, @NotNull Long distributionSetId, + long startScheduledActionsByRolloutGroupParent(long rolloutId, long distributionSetId, Long rolloutGroupParentId); /** diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index 754dfd6d3..5fcb1862a 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -12,6 +12,7 @@ import java.util.Collection; import java.util.List; import java.util.Optional; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -33,7 +34,6 @@ import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Target; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -66,7 +66,7 @@ public interface DistributionSetManagement * {@link DistributionSet#getType()}. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSet assignSoftwareModules(@NotNull Long setId, @NotEmpty Collection moduleIds); + DistributionSet assignSoftwareModules(long setId, @NotEmpty Collection moduleIds); /** * Assign a {@link DistributionSetTag} assignment to given @@ -83,7 +83,7 @@ public interface DistributionSetManagement * distribution sets. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - List assignTag(@NotEmpty Collection setIds, @NotNull Long tagId); + List assignTag(@NotEmpty Collection setIds, long tagId); /** * creates a list of distribution set meta data entries. @@ -102,7 +102,7 @@ public interface DistributionSetManagement * specific key */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - List createMetaData(@NotNull Long setId, @NotEmpty Collection metadata); + List createMetaData(long setId, @NotEmpty Collection metadata); /** * deletes a distribution set meta data entry. @@ -116,7 +116,7 @@ public interface DistributionSetManagement * if given set does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - void deleteMetaData(@NotNull Long setId, @NotEmpty String key); + void deleteMetaData(long setId, @NotEmpty String key); /** * retrieves the distribution set for a given action. @@ -129,7 +129,7 @@ public interface DistributionSetManagement * if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Optional getByAction(@NotNull Long actionId); + Optional getByAction(long actionId); /** * Find {@link DistributionSet} based on given ID including (lazy loaded) @@ -143,7 +143,7 @@ public interface DistributionSetManagement * @return {@link DistributionSet} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Optional getWithDetails(@NotNull Long setId); + Optional getWithDetails(long setId); /** * Find distribution set by name and version. @@ -172,7 +172,7 @@ public interface DistributionSetManagement * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findMetaDataByDistributionSetId(@NotNull Pageable pageable, @NotNull Long setId); + Page findMetaDataByDistributionSetId(@NotNull Pageable pageable, long setId); /** * finds all meta data by the given distribution set id. @@ -198,7 +198,7 @@ public interface DistributionSetManagement */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) Page findMetaDataByDistributionSetIdAndRsql(@NotNull Pageable pageable, - @NotNull Long setId, @NotNull String rsqlParam); + long setId, @NotNull String rsqlParam); /** * finds all {@link DistributionSet}s. @@ -273,7 +273,7 @@ public interface DistributionSetManagement * of distribution set tag with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findByTag(@NotNull Pageable pageable, @NotNull Long tagId); + Page findByTag(@NotNull Pageable pageable, long tagId); /** * retrieves {@link DistributionSet}s by filtering on the given parameters. @@ -290,7 +290,7 @@ public interface DistributionSetManagement * of distribution set tag with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId); + Page findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, long tagId); /** * finds a single distribution set meta data by its id. @@ -305,7 +305,7 @@ public interface DistributionSetManagement * is set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Optional getMetaDataByDistributionSetId(@NotNull Long setId, @NotEmpty String key); + Optional getMetaDataByDistributionSetId(long setId, @NotEmpty String key); /** * Checks if a {@link DistributionSet} is currently in use by a target in @@ -317,7 +317,7 @@ public interface DistributionSetManagement * @return true if in use */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - boolean isInUse(@NotNull Long setId); + boolean isInUse(long setId); /** * Toggles {@link DistributionSetTag} assignment to given @@ -356,7 +356,7 @@ public interface DistributionSetManagement * the DS is already in use. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSet unassignSoftwareModule(@NotNull Long setId, @NotNull Long moduleId); + DistributionSet unassignSoftwareModule(long setId, long moduleId); /** * Unassign a {@link DistributionSetTag} assignment to given @@ -372,7 +372,7 @@ public interface DistributionSetManagement * if set or tag with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSet unAssignTag(@NotNull Long setId, @NotNull Long tagId); + DistributionSet unAssignTag(long setId, long tagId); /** * updates a distribution set meta data value if corresponding entry exists. @@ -388,7 +388,7 @@ public interface DistributionSetManagement * updated */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSetMetadata updateMetaData(@NotNull Long setId, @NotNull MetaData metadata); + DistributionSetMetadata updateMetaData(long setId, @NotNull MetaData metadata); /** * Count all {@link DistributionSet}s in the repository that are not marked @@ -403,6 +403,6 @@ public interface DistributionSetManagement * if type with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - long countByTypeId(@NotNull Long typeId); + long countByTypeId(long typeId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java index c2e360d1e..4382b099b 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository; import java.util.Optional; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -20,7 +21,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -68,6 +68,6 @@ public interface DistributionSetTagManagement extends RepositoryManagement findByDistributionSet(@NotNull Pageable pageable, @NotNull Long setId); + Page findByDistributionSet(@NotNull Pageable pageable, long setId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeManagement.java index 9de6bf36d..a5d8d1ded 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeManagement.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit.repository; import java.util.Collection; import java.util.Optional; -import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotEmpty; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate; @@ -21,7 +21,6 @@ import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.security.access.prepost.PreAuthorize; /** @@ -66,7 +65,7 @@ public interface DistributionSetTypeManagement * by a {@link DistributionSet} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSetType assignOptionalSoftwareModuleTypes(@NotNull Long dsTypeId, + DistributionSetType assignOptionalSoftwareModuleTypes(long dsTypeId, @NotEmpty Collection softwareModuleTypeIds); /** @@ -87,7 +86,7 @@ public interface DistributionSetTypeManagement * by a {@link DistributionSet} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSetType assignMandatorySoftwareModuleTypes(@NotNull Long dsTypeId, + DistributionSetType assignMandatorySoftwareModuleTypes(long dsTypeId, @NotEmpty Collection softwareModuleTypes); /** @@ -109,6 +108,6 @@ public interface DistributionSetTypeManagement * by a {@link DistributionSet} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - DistributionSetType unassignSoftwareModuleType(@NotNull Long dsTypeId, @NotNull Long softwareModuleId); + DistributionSetType unassignSoftwareModuleType(long dsTypeId, long softwareModuleId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java index 39a252f48..f5a3a53c6 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Optional; import javax.validation.ConstraintViolationException; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -22,7 +24,6 @@ import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException; import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException; import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -52,7 +53,7 @@ public interface RepositoryManagement { * {@link BaseEntity} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - List create(@NotNull Collection creates); + List create(@NotNull @Valid Collection creates); /** * Creates new {@link SoftwareModuleType}. @@ -66,7 +67,7 @@ public interface RepositoryManagement { * {@link BaseEntity} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - T create(@NotNull C create); + T create(@NotNull @Valid C create); /** * Updates existing {@link BaseEntity}. @@ -87,7 +88,7 @@ public interface RepositoryManagement { * {@link BaseEntity} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - T update(@NotNull U update); + T update(@NotNull @Valid U update); /** * @return number of {@link BaseEntity}s in the repository. @@ -105,7 +106,7 @@ public interface RepositoryManagement { * BaseEntity with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY) - void delete(@NotNull Long id); + void delete(long id); /** * Delete {@link BaseEntity}s by their IDs. That is either a soft delete of @@ -139,7 +140,7 @@ public interface RepositoryManagement { * @return true if entity with given ID exists */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - boolean exists(@NotNull Long id); + boolean exists(long id); /** * Retrieve {@link BaseEntity} @@ -150,7 +151,7 @@ public interface RepositoryManagement { * {@link BaseEntity#getId()} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Optional get(@NotNull Long id); + Optional get(long id); /** * Retrieves {@link Page} of all {@link BaseEntity} of given type. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java index f785cbb4f..3b4b221d8 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java @@ -45,7 +45,7 @@ public interface RolloutGroupManagement { * of rollout with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRolloutWithDetailedStatus(@NotNull Pageable pageable, @NotNull Long rolloutId); + Page findByRolloutWithDetailedStatus(@NotNull Pageable pageable, long rolloutId); /** * @@ -65,7 +65,7 @@ public interface RolloutGroupManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) Page findAllTargetsOfRolloutGroupWithActionStatus(@NotNull Pageable pageable, - @NotNull Long rolloutGroupId); + long rolloutGroupId); /** * Retrieves a single {@link RolloutGroup} by its ID. @@ -77,7 +77,7 @@ public interface RolloutGroupManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Optional get(@NotNull Long rolloutGroupId); + Optional get(long rolloutGroupId); /** * Retrieves a page of {@link RolloutGroup}s filtered by a given @@ -100,7 +100,7 @@ public interface RolloutGroupManagement { * if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRolloutAndRsql(@NotNull Pageable pageable, @NotNull Long rolloutId, + Page findByRolloutAndRsql(@NotNull Pageable pageable, long rolloutId, @NotNull String rsqlParam); /** @@ -115,7 +115,7 @@ public interface RolloutGroupManagement { * @return a page of found {@link RolloutGroup}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRollout(@NotNull Pageable pageable, @NotNull Long rolloutId); + Page findByRollout(@NotNull Pageable pageable, long rolloutId); /** * Retrieves a page of {@link RolloutGroup}s filtered by a given @@ -128,7 +128,7 @@ public interface RolloutGroupManagement { * @return a page of found {@link RolloutGroup}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - long countByRollout(@NotNull Long rolloutId); + long countByRollout(long rolloutId); /** * Get targets of specified rollout group. @@ -144,7 +144,7 @@ public interface RolloutGroupManagement { * if group with ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - Page findTargetsOfRolloutGroup(@NotNull Pageable pageable, @NotNull Long rolloutGroupId); + Page findTargetsOfRolloutGroup(@NotNull Pageable pageable, long rolloutGroupId); /** * Get targets of specified rollout group. @@ -165,7 +165,7 @@ public interface RolloutGroupManagement { * if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - Page findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, @NotNull Long rolloutGroupId, + Page findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, long rolloutGroupId, @NotNull String rsqlParam); /** @@ -177,7 +177,7 @@ public interface RolloutGroupManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Optional getWithDetailedStatus(@NotNull Long rolloutGroupId); + Optional getWithDetailedStatus(long rolloutGroupId); /** * Count targets of rollout group. @@ -190,5 +190,5 @@ public interface RolloutGroupManagement { * if rollout group with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - long countTargetsOfRolloutsGroup(@NotNull Long rolloutGroupId); + long countTargetsOfRolloutsGroup(long rolloutGroupId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 7b450c31f..b6e48de7f 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -12,6 +12,8 @@ import java.util.List; import java.util.Optional; import javax.validation.ConstraintViolationException; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -31,7 +33,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation; import org.eclipse.hawkbit.repository.model.Target; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -158,7 +159,7 @@ public interface RolloutManagement { * if rollout or group parameters are invalid */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_CREATE) - Rollout create(@NotNull RolloutCreate rollout, @NotNull List groups, + Rollout create(@NotNull @Valid RolloutCreate rollout, @NotNull @Valid List groups, RolloutGroupConditions conditions); /** @@ -179,7 +180,7 @@ public interface RolloutManagement { * {@link RolloutGroupCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - ListenableFuture validateTargetsInGroups(List groups, + ListenableFuture validateTargetsInGroups(@Valid List groups, String targetFilter, Long createdAt); /** @@ -253,7 +254,7 @@ public interface RolloutManagement { * not exists */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Optional get(@NotNull Long rolloutId); + Optional get(long rolloutId); /** * Retrieves a specific rollout by its name. @@ -278,7 +279,7 @@ public interface RolloutManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Optional getWithDetailedStatus(@NotNull Long rolloutId); + Optional getWithDetailedStatus(long rolloutId); /** * Checks if rollout with given ID exists. @@ -288,7 +289,7 @@ public interface RolloutManagement { * * @return true if rollout exists */ - boolean exists(@NotNull Long rolloutId); + boolean exists(long rolloutId); /** * Pauses a rollout which is currently running. The Rollout switches @@ -313,7 +314,7 @@ public interface RolloutManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_HANDLE) - void pauseRollout(@NotNull Long rolloutId); + void pauseRollout(long rolloutId); /** * Resumes a paused rollout. The rollout switches back to @@ -330,7 +331,7 @@ public interface RolloutManagement { * paused rollouts can be resumed. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_HANDLE) - void resumeRollout(@NotNull Long rolloutId); + void resumeRollout(long rolloutId); /** * Starts a rollout which has been created. The rollout must be in @@ -351,7 +352,7 @@ public interface RolloutManagement { * ready rollouts can be started. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_HANDLE) - Rollout start(@NotNull Long rolloutId); + Rollout start(long rolloutId); /** * Update rollout details. @@ -369,7 +370,7 @@ public interface RolloutManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_UPDATE) - Rollout update(@NotNull RolloutUpdate update); + Rollout update(@NotNull @Valid RolloutUpdate update); /** * Deletes a rollout. A rollout might be deleted asynchronously by @@ -380,6 +381,6 @@ public interface RolloutManagement { * the ID of the rollout to be deleted */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_DELETE) - void delete(@NotNull Long rolloutId); + void delete(long rolloutId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java index 3803177fb..6d7819af8 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java @@ -12,6 +12,8 @@ import java.util.Collection; import java.util.List; import java.util.Optional; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -28,7 +30,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -71,7 +72,7 @@ public interface SoftwareModuleManagement * if software module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - List createMetaData(@NotNull Collection metadata); + List createMetaData(@NotNull @Valid Collection metadata); /** * creates or updates a single software module meta data entry. @@ -86,7 +87,7 @@ public interface SoftwareModuleManagement * if software module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - SoftwareModuleMetadata createMetaData(@NotNull SoftwareModuleMetadataCreate metadata); + SoftwareModuleMetadata createMetaData(@NotNull @Valid SoftwareModuleMetadataCreate metadata); /** * deletes a software module meta data entry. @@ -100,9 +101,11 @@ public interface SoftwareModuleManagement * of module or metadata entry does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - void deleteMetaData(@NotNull Long moduleId, @NotEmpty String key); + void deleteMetaData(long moduleId, @NotEmpty String key); /** + * returns all modules assigned to given {@link DistributionSet}. + * * @param pageable * the page request to page the result set * @param setId @@ -114,7 +117,7 @@ public interface SoftwareModuleManagement * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId); + Page findByAssignedTo(@NotNull Pageable pageable, long setId); /** * Filter {@link SoftwareModule}s with given @@ -150,8 +153,7 @@ public interface SoftwareModuleManagement * if software module type with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Optional getByNameAndVersionAndType(@NotEmpty String name, @NotEmpty String version, - @NotNull Long typeId); + Optional getByNameAndVersionAndType(@NotEmpty String name, @NotEmpty String version, long typeId); /** * finds a single software module meta data by its id. @@ -166,7 +168,7 @@ public interface SoftwareModuleManagement * is module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Optional getMetaDataBySoftwareModuleId(@NotNull Long moduleId, @NotEmpty String key); + Optional getMetaDataBySoftwareModuleId(long moduleId, @NotEmpty String key); /** * finds all meta data by the given software module id. @@ -183,7 +185,7 @@ public interface SoftwareModuleManagement * if software module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, @NotNull Long moduleId); + Page findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, long moduleId); /** * finds all meta data by the given software module id where @@ -202,7 +204,7 @@ public interface SoftwareModuleManagement */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) Page findMetaDataBySoftwareModuleIdAndTargetVisible(@NotNull Pageable pageable, - @NotNull Long moduleId); + long moduleId); /** * finds all meta data by the given software module id. @@ -226,7 +228,7 @@ public interface SoftwareModuleManagement * if software module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findMetaDataByRsql(@NotNull Pageable pageable, @NotNull Long moduleId, + Page findMetaDataByRsql(@NotNull Pageable pageable, long moduleId, @NotNull String rsqlParam); /** @@ -254,7 +256,7 @@ public interface SoftwareModuleManagement */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) Slice findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( - @NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, Long typeId); + @NotNull Pageable pageable, long orderByDistributionId, String searchText, Long typeId); /** * retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType} @@ -270,7 +272,7 @@ public interface SoftwareModuleManagement * if software module type with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Slice findByType(@NotNull Pageable pageable, @NotNull Long typeId); + Slice findByType(@NotNull Pageable pageable, long typeId); /** * updates a distribution set meta data value if corresponding entry exists. @@ -285,5 +287,5 @@ public interface SoftwareModuleManagement * updated */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - SoftwareModuleMetadata updateMetaData(@NotNull SoftwareModuleMetadataUpdate update); + SoftwareModuleMetadata updateMetaData(@NotNull @Valid SoftwareModuleMetadataUpdate update); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeManagement.java index 86bf56032..b6a110570 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeManagement.java @@ -10,11 +10,12 @@ package org.eclipse.hawkbit.repository; import java.util.Optional; +import javax.validation.constraints.NotEmpty; + import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate; import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.security.access.prepost.PreAuthorize; /** diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java index 6a144096f..bddbf8cac 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -117,7 +117,7 @@ public interface SystemManagement { * @return updated {@link TenantMetaData} entity */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION) - TenantMetaData updateTenantMetadata(@NotNull Long defaultDsType); + TenantMetaData updateTenantMetadata(long defaultDsType); /** * Returns {@link TenantMetaData} of given tenant ID. @@ -127,6 +127,6 @@ public interface SystemManagement { * @return {@link TenantMetaData} of given tenant */ @PreAuthorize(SpringEvalExpressions.IS_SYSTEM_CODE) - TenantMetaData getTenantMetadata(@NotNull Long tenantId); + TenantMetaData getTenantMetadata(long tenantId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java index f102a6b39..e725e05ab 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository; import java.util.Optional; import javax.validation.ConstraintViolationException; +import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -41,7 +42,7 @@ public interface TargetFilterQueryManagement { * {@link TargetFilterQueryCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - TargetFilterQuery create(@NotNull TargetFilterQueryCreate create); + TargetFilterQuery create(@NotNull @Valid TargetFilterQueryCreate create); /** * Delete target filter query. @@ -53,7 +54,7 @@ public interface TargetFilterQueryManagement { * if filter with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET) - void delete(@NotNull Long targetFilterQueryId); + void delete(long targetFilterQueryId); /** * Verifies provided filter syntax. @@ -145,7 +146,7 @@ public interface TargetFilterQueryManagement { * if DS with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByAutoAssignDSAndRsql(@NotNull Pageable pageable, @NotNull Long setId, + Page findByAutoAssignDSAndRsql(@NotNull Pageable pageable, long setId, String rsqlParam); /** @@ -168,7 +169,7 @@ public interface TargetFilterQueryManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Optional get(@NotNull Long targetFilterQueryId); + Optional get(long targetFilterQueryId); /** * Find target filter query by name. @@ -197,7 +198,7 @@ public interface TargetFilterQueryManagement { * {@link TargetFilterQueryUpdate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - TargetFilterQuery update(@NotNull TargetFilterQueryUpdate update); + TargetFilterQuery update(@NotNull @Valid TargetFilterQueryUpdate update); /** * updates the {@link TargetFilterQuery#getAutoAssignDistributionSet()}. @@ -213,6 +214,6 @@ public interface TargetFilterQueryManagement { * provided but not found */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - TargetFilterQuery updateAutoAssignDS(@NotNull Long queryId, Long dsId); + TargetFilterQuery updateAutoAssignDS(long queryId, Long dsId); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index 9d7c8c0fe..b595b076b 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -14,6 +14,8 @@ import java.util.Map; import java.util.Optional; import javax.validation.ConstraintViolationException; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -31,7 +33,6 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; @@ -56,7 +57,7 @@ public interface TargetManagement { * if given tagId or at least one of the targets do not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - List assignTag(@NotEmpty Collection controllerIds, @NotNull Long tagId); + List assignTag(@NotEmpty Collection controllerIds, long tagId); /** * Counts number of targets with given @@ -72,7 +73,7 @@ public interface TargetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - long countByAssignedDistributionSet(@NotNull Long distId); + long countByAssignedDistributionSet(long distId); /** * Count {@link Target}s for all the given filter parameters. @@ -120,7 +121,7 @@ public interface TargetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR + SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - long countByInstalledDistributionSet(@NotNull Long distId); + long countByInstalledDistributionSet(long distId); /** * Count {@link TargetFilterQuery}s for given target filter query. @@ -143,7 +144,7 @@ public interface TargetManagement { * if {@link TargetFilterQuery} with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - long countByTargetFilterQuery(@NotNull Long targetFilterQueryId); + long countByTargetFilterQuery(long targetFilterQueryId); /** * Counts all {@link Target}s in the repository. @@ -168,7 +169,7 @@ public interface TargetManagement { * */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - Target create(@NotNull TargetCreate create); + Target create(@NotNull @Valid TargetCreate create); /** * creates multiple {@link Target}s. If some of the given {@link Target}s @@ -187,7 +188,7 @@ public interface TargetManagement { * {@link TargetCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - List create(@NotNull Collection creates); + List create(@NotNull @Valid Collection creates); /** * Deletes all targets with the given IDs. @@ -230,7 +231,7 @@ public interface TargetManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, @NotNull Long distributionSetId, + Page findByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, long distributionSetId, @NotNull String rsqlParam); /** @@ -248,7 +249,7 @@ public interface TargetManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - long countByRsqlAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam); + long countByRsqlAndNonDS(long distributionSetId, @NotNull String rsqlParam); /** * Finds all targets for all the given parameter {@link TargetFilterQuery} @@ -293,7 +294,7 @@ public interface TargetManagement { * if rollout group with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group); + Page findByInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, long group); /** * retrieves {@link Target}s by the assigned {@link DistributionSet}. @@ -310,7 +311,7 @@ public interface TargetManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID); + Page findByAssignedDistributionSet(@NotNull Pageable pageReq, long distributionSetID); /** * Retrieves {@link Target}s by the assigned {@link DistributionSet} @@ -333,7 +334,7 @@ public interface TargetManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByAssignedDistributionSetAndRsql(@NotNull Pageable pageReq, @NotNull Long distributionSetID, + Page findByAssignedDistributionSetAndRsql(@NotNull Pageable pageReq, long distributionSetID, @NotNull String rsqlParam); /** @@ -388,7 +389,7 @@ public interface TargetManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByInstalledDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID); + Page findByInstalledDistributionSet(@NotNull Pageable pageReq, long distributionSetID); /** * retrieves {@link Target}s by the installed {@link DistributionSet} @@ -413,7 +414,7 @@ public interface TargetManagement { * if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByInstalledDistributionSetAndRsql(@NotNull Pageable pageReq, @NotNull Long distributionSetId, + Page findByInstalledDistributionSetAndRsql(@NotNull Pageable pageReq, long distributionSetId, @NotNull String rsqlParam); /** @@ -478,7 +479,7 @@ public interface TargetManagement { * if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByTargetFilterQuery(@NotNull Pageable pageable, @NotNull Long targetFilterQueryId); + Slice findByTargetFilterQuery(@NotNull Pageable pageable, long targetFilterQueryId); /** * method retrieves all {@link Target}s from the repo in the following @@ -508,7 +509,7 @@ public interface TargetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Slice findByFilterOrderByLinkedDistributionSet(@NotNull Pageable pageable, - @NotNull Long orderByDistributionId, @NotNull FilterParams filterParams); + long orderByDistributionId, @NotNull FilterParams filterParams); /** * Find targets by tag name. @@ -523,7 +524,7 @@ public interface TargetManagement { * if target tag with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByTag(@NotNull Pageable pageable, @NotNull Long tagId); + Page findByTag(@NotNull Pageable pageable, long tagId); /** * Find targets by tag name. @@ -546,7 +547,7 @@ public interface TargetManagement { * if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId); + Page findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, long tagId); /** * Toggles {@link TargetTag} assignment to given {@link Target}s by means @@ -579,7 +580,7 @@ public interface TargetManagement { * if TAG with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - Target unAssignTag(@NotEmpty String controllerID, @NotNull Long targetTagId); + Target unAssignTag(@NotEmpty String controllerID, long targetTagId); /** * updates the {@link Target}. @@ -596,7 +597,7 @@ public interface TargetManagement { * {@link TargetUpdate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - Target update(@NotNull TargetUpdate update); + Target update(@NotNull @Valid TargetUpdate update); /** * Find a {@link Target} based a given ID. @@ -606,7 +607,7 @@ public interface TargetManagement { * @return {@link Target} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Optional get(@NotNull Long id); + Optional get(long id); /** * Retrieves all targets. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java index 13be0aa30..6376f06b4 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Optional; import javax.validation.ConstraintViolationException; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; @@ -24,7 +26,6 @@ import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException; import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.access.prepost.PreAuthorize; @@ -58,7 +59,7 @@ public interface TargetTagManagement { * {@link TagCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - TargetTag create(@NotNull TagCreate create); + TargetTag create(@NotNull @Valid TagCreate create); /** * created multiple {@link TargetTag}s. @@ -74,7 +75,7 @@ public interface TargetTagManagement { * {@link TagCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) - List create(@NotNull Collection creates); + List create(@NotNull @Valid Collection creates); /** * Deletes {@link TargetTag} with given name. @@ -117,6 +118,7 @@ public interface TargetTagManagement { /** * Retrieves all target tags based on the given specification. + * * @param pageable * pagination parameter * @param rsqlParam @@ -151,7 +153,7 @@ public interface TargetTagManagement { * @return the found {@link TargetTag} */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Optional get(@NotNull Long id); + Optional get(long id); /** * updates the {@link TargetTag}. @@ -168,6 +170,6 @@ public interface TargetTagManagement { * {@link TagUpdate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - TargetTag update(@NotNull TagUpdate update); + TargetTag update(@NotNull @Valid TagUpdate update); } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java index 6bfc22f89..ff328a0b3 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/ActionStatusCreate.java @@ -35,7 +35,7 @@ public interface ActionStatusCreate { * for {@link ActionStatus#getOccurredAt()} * @return updated {@link ActionStatusCreate} object */ - ActionStatusCreate occurredAt(Long occurredAt); + ActionStatusCreate occurredAt(long occurredAt); /** * @param messages diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/TargetBuilder.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/TargetBuilder.java index a8ff36fc7..00cb9f593 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/TargetBuilder.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/builder/TargetBuilder.java @@ -8,8 +8,9 @@ */ package org.eclipse.hawkbit.repository.builder; +import javax.validation.constraints.NotEmpty; + import org.eclipse.hawkbit.repository.model.Target; -import org.hibernate.validator.constraints.NotEmpty; /** * Builder for {@link Target}. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java index a0b84991c..a7d530016 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidTenantConfigurationKeyException.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.repository.exception; -import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.AbstractServerRtException; +import org.eclipse.hawkbit.exception.SpServerError; /** * The {@link #InvalidTenantConfigurationKeyException} is thrown when an invalid diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java index 4cc545287..07ff99820 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/tenancy/configuration/validator/TenantConfigurationValidatorException.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.tenancy.configuration.validator; -import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.AbstractServerRtException; +import org.eclipse.hawkbit.exception.SpServerError; /** * Exception which is thrown, when the validation of the configuration value has diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/ValidString.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/ValidString.java new file mode 100644 index 000000000..9f4ab14e1 --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/ValidString.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.validation.Constraint; +import javax.validation.Payload; + +import org.hibernate.validator.constraints.SafeHtml; +import org.hibernate.validator.constraints.SafeHtml.WhiteListType; + +/** + * Constraint for strings submitted into the repository. + * + */ +@Constraint(validatedBy = {}) +@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, + ElementType.PARAMETER, ElementType.TYPE_USE }) +@Retention(RetentionPolicy.RUNTIME) +@SafeHtml(whitelistType = WhiteListType.NONE) +public @interface ValidString { + + String message() default "Invalid characters in string"; + + Class[] groups() default {}; + + Class[] payload() default {}; + +} diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java index 5e17d6350..d313a0a5c 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractActionStatusCreate.java @@ -10,9 +10,13 @@ package org.eclipse.hawkbit.repository.builder; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; +import org.eclipse.hawkbit.repository.ValidString; import org.eclipse.hawkbit.repository.model.Action.Status; +import org.springframework.util.StringUtils; /** * Create and update builder DTO. @@ -23,7 +27,9 @@ import org.eclipse.hawkbit.repository.model.Action.Status; public abstract class AbstractActionStatusCreate { protected Status status; protected Long occurredAt; - protected Collection messages; + + protected List<@ValidString String> messages; + protected Long actionId; public Long getActionId() { @@ -36,7 +42,7 @@ public abstract class AbstractActionStatusCreate { return (T) this; } - public T occurredAt(final Long occurredAt) { + public T occurredAt(final long occurredAt) { this.occurredAt = occurredAt; return (T) this; @@ -44,9 +50,9 @@ public abstract class AbstractActionStatusCreate { public T messages(final Collection messages) { if (this.messages == null) { - this.messages = messages; + this.messages = messages.stream().map(StringUtils::trimWhitespace).collect(Collectors.toList()); } else { - this.messages.addAll(messages); + this.messages.addAll(messages.stream().map(StringUtils::trimWhitespace).collect(Collectors.toList())); } return (T) this; @@ -56,7 +62,7 @@ public abstract class AbstractActionStatusCreate { if (this.messages == null) { this.messages = new ArrayList<>(); } - this.messages.add(message); + this.messages.add(StringUtils.trimWhitespace(message)); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java index 1f7848b67..0d81ec878 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetTypeUpdateCreate.java @@ -11,7 +11,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Collection; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; /** * Create and update builder DTO. @@ -20,8 +22,11 @@ import org.springframework.util.CollectionUtils; * update or create builder interface */ public abstract class AbstractDistributionSetTypeUpdateCreate extends AbstractNamedEntityBuilder { + @ValidString protected String colour; + @ValidString protected String key; + protected Collection mandatory; protected Collection optional; @@ -52,7 +57,7 @@ public abstract class AbstractDistributionSetTypeUpdateCreate extends Abstrac } public T colour(final String colour) { - this.colour = colour; + this.colour = StringUtils.trimWhitespace(colour); return (T) this; } @@ -61,7 +66,7 @@ public abstract class AbstractDistributionSetTypeUpdateCreate extends Abstrac } public T key(final String key) { - this.key = key; + this.key = StringUtils.trimWhitespace(key); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetUpdateCreate.java index 3323d10a0..86b3ab8a0 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractDistributionSetUpdateCreate.java @@ -11,6 +11,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Collection; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + /** * Create and update builder DTO. * @@ -18,8 +21,11 @@ import java.util.Optional; * update or create builder interface */ public abstract class AbstractDistributionSetUpdateCreate extends AbstractNamedEntityBuilder { + @ValidString protected String version; protected Boolean requiredMigrationStep; + + @ValidString protected String type; protected Collection modules; @@ -33,7 +39,7 @@ public abstract class AbstractDistributionSetUpdateCreate extends AbstractNam } public T type(final String type) { - this.type = type; + this.type = StringUtils.trimWhitespace(type); return (T) this; } @@ -51,7 +57,7 @@ public abstract class AbstractDistributionSetUpdateCreate extends AbstractNam } public T version(final String version) { - this.version = version; + this.version = StringUtils.trimWhitespace(version); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java index 5bddf2edf..c9c86eb05 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractMetadataUpdateCreate.java @@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + /** * Create and update builder DTO. * @@ -17,11 +20,14 @@ import java.util.Optional; * update or create builder interface */ public abstract class AbstractMetadataUpdateCreate { + @ValidString protected String key; + + @ValidString protected String value; public T key(final String key) { - this.key = key; + this.key = StringUtils.trimWhitespace(key); return (T) this; } @@ -30,7 +36,7 @@ public abstract class AbstractMetadataUpdateCreate { } public T value(final String value) { - this.value = value; + this.value = StringUtils.trimWhitespace(value); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java index 955da15ab..8ae8d3606 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractNamedEntityBuilder.java @@ -10,18 +10,24 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + public abstract class AbstractNamedEntityBuilder extends AbstractBaseEntityBuilder { + @ValidString protected String name; + + @ValidString protected String description; public T name(final String name) { - this.name = name; + this.name = StringUtils.trimWhitespace(name); return (T) this; } public T description(final String description) { - this.description = description; + this.description = StringUtils.trimWhitespace(description); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java index 050aa2508..8365707e0 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutGroupCreate.java @@ -8,7 +8,9 @@ */ package org.eclipse.hawkbit.repository.builder; +import org.eclipse.hawkbit.repository.ValidString; import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; +import org.springframework.util.StringUtils; /** * Create builder DTO. @@ -17,12 +19,13 @@ import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; * update or create builder interface */ public abstract class AbstractRolloutGroupCreate extends AbstractNamedEntityBuilder { + @ValidString protected String targetFilterQuery; protected Float targetPercentage; protected RolloutGroupConditions conditions; public T targetFilterQuery(final String targetFilterQuery) { - this.targetFilterQuery = targetFilterQuery; + this.targetFilterQuery = StringUtils.trimWhitespace(targetFilterQuery); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutUpdateCreate.java index 0e16f105f..11f28ba77 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractRolloutUpdateCreate.java @@ -10,7 +10,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; import org.eclipse.hawkbit.repository.model.Action.ActionType; +import org.springframework.util.StringUtils; /** * Create and update builder DTO. @@ -20,7 +22,10 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType; */ public abstract class AbstractRolloutUpdateCreate extends AbstractNamedEntityBuilder { protected Long set; + + @ValidString protected String targetFilterQuery; + protected ActionType actionType; protected Long forcedTime; protected Long startAt; @@ -31,7 +36,7 @@ public abstract class AbstractRolloutUpdateCreate extends AbstractNamedEntity } public T targetFilterQuery(final String targetFilterQuery) { - this.targetFilterQuery = targetFilterQuery; + this.targetFilterQuery = StringUtils.trimWhitespace(targetFilterQuery); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleTypeUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleTypeUpdateCreate.java index 1ac5cf440..833769cb9 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleTypeUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleTypeUpdateCreate.java @@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + /** * Create and update builder DTO. * @@ -17,8 +20,11 @@ import java.util.Optional; * update or create builder interface */ public abstract class AbstractSoftwareModuleTypeUpdateCreate extends AbstractNamedEntityBuilder { + @ValidString protected String colour; + @ValidString protected String key; + protected int maxAssignments = 1; public T maxAssignments(final int maxAssignments) { @@ -31,7 +37,7 @@ public abstract class AbstractSoftwareModuleTypeUpdateCreate extends Abstract } public T colour(final String colour) { - this.colour = colour; + this.colour = StringUtils.trimWhitespace(colour); return (T) this; } @@ -40,7 +46,7 @@ public abstract class AbstractSoftwareModuleTypeUpdateCreate extends Abstract } public T key(final String key) { - this.key = key; + this.key = StringUtils.trimWhitespace(key); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java index 4024c83b5..936c983b9 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractSoftwareModuleUpdateCreate.java @@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + /** * Create and update builder DTO. * @@ -17,12 +20,17 @@ import java.util.Optional; * update or create builder interface */ public abstract class AbstractSoftwareModuleUpdateCreate extends AbstractNamedEntityBuilder { + @ValidString protected String version; + + @ValidString protected String vendor; + + @ValidString protected String type; public T type(final String type) { - this.type = type; + this.type = StringUtils.trimWhitespace(type); return (T) this; } @@ -31,7 +39,7 @@ public abstract class AbstractSoftwareModuleUpdateCreate extends AbstractName } public T vendor(final String vendor) { - this.vendor = vendor; + this.vendor = StringUtils.trimWhitespace(vendor); return (T) this; } @@ -40,7 +48,7 @@ public abstract class AbstractSoftwareModuleUpdateCreate extends AbstractName } public T version(final String version) { - this.version = version; + this.version = StringUtils.trimWhitespace(version); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java index 6dedc9fe5..ba148c192 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java @@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + /** * Create and update builder DTO. * @@ -17,10 +20,11 @@ import java.util.Optional; * update or create builder interface */ public class AbstractTagUpdateCreate extends AbstractNamedEntityBuilder { + @ValidString protected String colour; public T colour(final String colour) { - this.colour = colour; + this.colour = StringUtils.trimWhitespace(colour); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java index 0a04dbda2..1b4938901 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetFilterQueryUpdateCreate.java @@ -10,6 +10,9 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; +import org.springframework.util.StringUtils; + /** * Create and update builder DTO. * @@ -17,8 +20,12 @@ import java.util.Optional; * update or create builder interface */ public abstract class AbstractTargetFilterQueryUpdateCreate extends AbstractBaseEntityBuilder { + @ValidString protected String name; + + @ValidString protected String query; + protected Long set; public T set(final long set) { @@ -31,7 +38,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate extends AbstractB } public T name(final String name) { - this.name = name; + this.name = StringUtils.trimWhitespace(name); return (T) this; } @@ -40,7 +47,7 @@ public abstract class AbstractTargetFilterQueryUpdateCreate extends AbstractB } public T query(final String query) { - this.query = query; + this.query = StringUtils.trimWhitespace(query); return (T) this; } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java index 87a6cb2fd..6bd6b6040 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTargetUpdateCreate.java @@ -11,8 +11,10 @@ package org.eclipse.hawkbit.repository.builder; import java.net.URI; import java.util.Optional; +import org.eclipse.hawkbit.repository.ValidString; import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; +import org.springframework.util.StringUtils; /** * Create and update builder DTO. @@ -21,14 +23,19 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; * update or create builder interface */ public class AbstractTargetUpdateCreate extends AbstractNamedEntityBuilder { + @ValidString protected String controllerId; + protected String address; + + @ValidString protected String securityToken; + protected Long lastTargetQuery; protected TargetUpdateStatus status; protected AbstractTargetUpdateCreate(final String controllerId) { - this.controllerId = controllerId; + this.controllerId = StringUtils.trimWhitespace(controllerId); } public T status(final TargetUpdateStatus status) { @@ -40,7 +47,7 @@ public class AbstractTargetUpdateCreate extends AbstractNamedEntityBuilder // check if this is a real URI if (address != null) { try { - URI.create(address); + URI.create(StringUtils.trimWhitespace(address)); } catch (final IllegalArgumentException e) { throw new InvalidTargetAddressException( "The given address " + address + " violates the RFC-2396 specification", e); @@ -51,7 +58,7 @@ public class AbstractTargetUpdateCreate extends AbstractNamedEntityBuilder } public T securityToken(final String securityToken) { - this.securityToken = securityToken; + this.securityToken = StringUtils.trimWhitespace(securityToken); return (T) this; } @@ -61,7 +68,7 @@ public class AbstractTargetUpdateCreate extends AbstractNamedEntityBuilder } public TargetCreate controllerId(final String controllerId) { - this.controllerId = controllerId; + this.controllerId = StringUtils.trimWhitespace(controllerId); return (TargetCreate) this; } diff --git a/hawkbit-repository/hawkbit-repository-jpa/pom.xml b/hawkbit-repository/hawkbit-repository-jpa/pom.xml index 34552301d..d5a8d16c8 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/pom.xml +++ b/hawkbit-repository/hawkbit-repository-jpa/pom.xml @@ -75,6 +75,10 @@ com.google.guava guava + + org.jsoup + jsoup + diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java index b88b43ae2..b912b4f18 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java @@ -85,7 +85,7 @@ public class JpaArtifactManagement implements ArtifactManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Artifact create(final InputStream stream, final Long moduleId, final String filename, + public Artifact create(final InputStream stream, final long moduleId, final String filename, final String providedMd5Sum, final String providedSha1Sum, final boolean overrideExisting, final String contentType) { AbstractDbArtifact result = null; @@ -117,7 +117,7 @@ public class JpaArtifactManagement implements ArtifactManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public boolean clearArtifactBinary(final String sha1Hash, final Long moduleId) { + public boolean clearArtifactBinary(final String sha1Hash, final long moduleId) { if (localArtifactRepository.existsWithSha1HashAndSoftwareModuleIdIsNot(sha1Hash, moduleId)) { // there are still other artifacts that need the binary @@ -137,7 +137,7 @@ public class JpaArtifactManagement implements ArtifactManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long id) { + public void delete(final long id) { final JpaArtifact existing = (JpaArtifact) get(id) .orElseThrow(() -> new EntityNotFoundException(Artifact.class, id)); @@ -149,12 +149,12 @@ public class JpaArtifactManagement implements ArtifactManagement { } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(localArtifactRepository.findOne(id)); } @Override - public Optional getByFilenameAndSoftwareModule(final String filename, final Long softwareModuleId) { + public Optional getByFilenameAndSoftwareModule(final String filename, final long softwareModuleId) { throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId); return localArtifactRepository.findFirstByFilenameAndSoftwareModuleId(filename, softwareModuleId); @@ -171,7 +171,7 @@ public class JpaArtifactManagement implements ArtifactManagement { } @Override - public Page findBySoftwareModule(final Pageable pageReq, final Long swId) { + public Page findBySoftwareModule(final Pageable pageReq, final long swId) { throwExceptionIfSoftwareModuleDoesNotExist(swId); return localArtifactRepository.findBySoftwareModuleId(pageReq, swId); @@ -206,7 +206,7 @@ public class JpaArtifactManagement implements ArtifactManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Artifact create(final InputStream inputStream, final Long moduleId, final String filename, + public Artifact create(final InputStream inputStream, final long moduleId, final String filename, final boolean overrideExisting) { return create(inputStream, moduleId, filename, null, null, overrideExisting, null); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java index fc046b7f7..73954b20a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java @@ -177,7 +177,7 @@ public class JpaControllerManagement implements ControllerManagement { @Override public Optional getActionForDownloadByTargetAndSoftwareModule(final String controllerId, - final Long moduleId) { + final long moduleId) { throwExceptionIfTargetDoesNotExist(controllerId); throwExceptionIfSoftwareModuleDoesNotExist(moduleId); @@ -215,7 +215,7 @@ public class JpaControllerManagement implements ControllerManagement { } @Override - public boolean hasTargetArtifactAssigned(final Long targetId, final String sha1Hash) { + public boolean hasTargetArtifactAssigned(final long targetId, final String sha1Hash) { throwExceptionIfTargetDoesNotExist(targetId); return actionRepository.count(ActionSpecifications.hasTargetAssignedArtifact(targetId, sha1Hash)) > 0; } @@ -233,7 +233,7 @@ public class JpaControllerManagement implements ControllerManagement { } @Override - public Optional findActionWithDetails(final Long actionId) { + public Optional findActionWithDetails(final long actionId) { return actionRepository.getById(actionId); } @@ -556,7 +556,7 @@ public class JpaControllerManagement implements ControllerManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Action registerRetrieved(final Long actionId, final String message) { + public Action registerRetrieved(final long actionId, final String message) { return handleRegisterRetrieved(actionId, message); } @@ -640,12 +640,12 @@ public class JpaControllerManagement implements ControllerManagement { } @Override - public Optional get(final Long targetId) { + public Optional get(final long targetId) { return Optional.ofNullable(targetRepository.findOne(targetId)); } @Override - public Page findActionStatusByAction(final Pageable pageReq, final Long actionId) { + public Page findActionStatusByAction(final Pageable pageReq, final long actionId) { if (!actionRepository.exists(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } @@ -654,7 +654,7 @@ public class JpaControllerManagement implements ControllerManagement { } @Override - public List getActionHistoryMessages(final Long actionId, final int messageCount) { + public List getActionHistoryMessages(final long actionId, final int messageCount) { // Just return empty list in case messageCount is zero. if (messageCount == 0) { return Collections.emptyList(); @@ -676,7 +676,7 @@ public class JpaControllerManagement implements ControllerManagement { } @Override - public Optional getSoftwareModule(final Long id) { + public Optional getSoftwareModule(final long id) { return Optional.ofNullable(softwareModuleRepository.findOne(id)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java index 9cc70e95b..8988d713c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java @@ -161,7 +161,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, final ActionType actionType, + public DistributionSetAssignmentResult assignDistributionSet(final long dsID, final ActionType actionType, final long forcedTimestamp, final Collection controllerIDs) { return assignDistributionSetToTargets(dsID, @@ -176,7 +176,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, + public DistributionSetAssignmentResult assignDistributionSet(final long dsID, final Collection targets) { return assignDistributionSetToTargets(dsID, targets, null, onlineDsAssignmentStrategy); @@ -186,7 +186,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, + public DistributionSetAssignmentResult assignDistributionSet(final long dsID, final Collection targets, final String actionMessage) { return assignDistributionSetToTargets(dsID, targets, actionMessage, onlineDsAssignmentStrategy); @@ -319,7 +319,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Action cancelAction(final Long actionId) { + public Action cancelAction(final long actionId) { LOG.debug("cancelAction({})", actionId); final JpaAction action = actionRepository.findById(actionId) @@ -349,7 +349,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Action forceQuitAction(final Long actionId) { + public Action forceQuitAction(final long actionId) { final JpaAction action = actionRepository.findById(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); @@ -374,7 +374,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { } @Override - public long startScheduledActionsByRolloutGroupParent(final Long rolloutId, final Long distributionSetId, + public long startScheduledActionsByRolloutGroupParent(final long rolloutId, final long distributionSetId, final Long rolloutGroupParentId) { long totalActionsCount = 0L; long lastStartedActionsCount; @@ -483,12 +483,12 @@ public class JpaDeploymentManagement implements DeploymentManagement { } @Override - public Optional findAction(final Long actionId) { + public Optional findAction(final long actionId) { return Optional.ofNullable(actionRepository.findOne(actionId)); } @Override - public Optional findActionWithDetails(final Long actionId) { + public Optional findActionWithDetails(final long actionId) { return actionRepository.getById(actionId); } @@ -562,7 +562,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Action forceTargetAction(final Long actionId) { + public Action forceTargetAction(final long actionId) { final JpaAction action = actionRepository.findById(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); @@ -574,7 +574,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { } @Override - public Page findActionStatusByAction(final Pageable pageReq, final Long actionId) { + public Page findActionStatusByAction(final Pageable pageReq, final long actionId) { if (!actionRepository.exists(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } @@ -583,7 +583,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { } @Override - public Page findMessagesByActionStatusId(final Pageable pageable, final Long actionStatusId) { + public Page findMessagesByActionStatusId(final Pageable pageable, final long actionStatusId) { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery countMsgQuery = cb.createQuery(Long.class); @@ -625,7 +625,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { } @Override - public Slice findActionsByDistributionSet(final Pageable pageable, final Long dsId) { + public Slice findActionsByDistributionSet(final Pageable pageable, final long dsId) { throwExceptionIfDistributionSetDoesNotExist(dsId); return actionRepository.findByDistributionSetId(pageable, dsId); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java index 8c806e04d..ecc103bff 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java @@ -131,12 +131,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { private AfterTransactionCommitExecutor afterCommit; @Override - public Optional getWithDetails(final Long distid) { + public Optional getWithDetails(final long distid) { return Optional.ofNullable(distributionSetRepository.findOne(DistributionSetSpecification.byId(distid))); } @Override - public long countByTypeId(final Long typeId) { + public long countByTypeId(final long typeId) { if (!distributionSetTypeManagement.exists(typeId)) { throw new EntityNotFoundException(DistributionSetType.class, typeId); } @@ -304,7 +304,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSet assignSoftwareModules(final Long setId, final Collection moduleIds) { + public DistributionSet assignSoftwareModules(final long setId, final Collection moduleIds) { final Collection modules = softwareModuleRepository.findByIdIn(moduleIds); @@ -325,7 +325,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSet unassignSoftwareModule(final Long setId, final Long moduleId) { + public DistributionSet unassignSoftwareModule(final long setId, final long moduleId) { final JpaDistributionSet set = findDistributionSetAndThrowExceptionIfNotFound(setId); final JpaSoftwareModule module = findSoftwareModuleAndThrowExceptionIfNotFound(moduleId); @@ -446,7 +446,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public List createMetaData(final Long dsId, final Collection md) { + public List createMetaData(final long dsId, final Collection md) { md.forEach(meta -> checkAndThrowAlreadyIfDistributionSetMetadataExists( new DsMetadataCompositeKey(dsId, meta.getKey()))); @@ -463,7 +463,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetMetadata updateMetaData(final Long dsId, final MetaData md) { + public DistributionSetMetadata updateMetaData(final long dsId, final MetaData md) { // check if exists otherwise throw entity not found exception final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(dsId, @@ -480,7 +480,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void deleteMetaData(final Long distributionSetId, final String key) { + public void deleteMetaData(final long distributionSetId, final String key) { final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId( distributionSetId, key).orElseThrow( () -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, key)); @@ -521,7 +521,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Override public Page findMetaDataByDistributionSetId(final Pageable pageable, - final Long distributionSetId) { + final long distributionSetId) { throwExceptionIfDistributionSetDoesNotExist(distributionSetId); return convertMdPage(distributionSetMetadataRepository @@ -533,7 +533,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Override public Page findMetaDataByDistributionSetIdAndRsql(final Pageable pageable, - final Long distributionSetId, final String rsqlParam) { + final long distributionSetId, final String rsqlParam) { throwExceptionIfDistributionSetDoesNotExist(distributionSetId); @@ -555,14 +555,14 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Optional getMetaDataByDistributionSetId(final Long setId, final String key) { + public Optional getMetaDataByDistributionSetId(final long setId, final String key) { throwExceptionIfDistributionSetDoesNotExist(setId); return Optional.ofNullable(distributionSetMetadataRepository.findOne(new DsMetadataCompositeKey(setId, key))); } @Override - public Optional getByAction(final Long actionId) { + public Optional getByAction(final long actionId) { if (!actionRepository.exists(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } @@ -571,7 +571,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public boolean isInUse(final Long setId) { + public boolean isInUse(final long setId) { throwExceptionIfDistributionSetDoesNotExist(setId); return actionRepository.countByDistributionSetId(setId) > 0; @@ -665,7 +665,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public List assignTag(final Collection dsIds, final Long dsTagId) { + public List assignTag(final Collection dsIds, final long dsTagId) { final List allDs = findDistributionSetListWithDetails(dsIds); if (allDs.size() < dsIds.size()) { @@ -690,7 +690,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSet unAssignTag(final Long dsId, final Long dsTagId) { + public DistributionSet unAssignTag(final long dsId, final long dsTagId) { final JpaDistributionSet set = (JpaDistributionSet) getWithDetails(dsId) .orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, dsId)); @@ -710,7 +710,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long setId) { + public void delete(final long setId) { throwExceptionIfDistributionSetDoesNotExist(setId); delete(Arrays.asList(setId)); @@ -728,7 +728,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Page findByTag(final Pageable pageable, final Long tagId) { + public Page findByTag(final Pageable pageable, final long tagId) { throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId); return convertDsPage(distributionSetRepository.findByTag(pageable, tagId), pageable); @@ -742,7 +742,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Page findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final Long tagId) { + public Page findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final long tagId) { throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId); final Specification spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class, @@ -769,12 +769,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(distributionSetRepository.findOne(id)); } @Override - public boolean exists(final Long id) { + public boolean exists(final long id) { return distributionSetRepository.exists(id); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java index f6a72e377..12178a69c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java @@ -136,7 +136,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage } @Override - public Page findByDistributionSet(final Pageable pageable, final Long setId) { + public Page findByDistributionSet(final Pageable pageable, final long setId) { if (!distributionSetRepository.exists(setId)) { throw new EntityNotFoundException(DistributionSet.class, setId); } @@ -176,7 +176,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(distributionSetTagRepository.findOne(id)); } @@ -184,12 +184,12 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long id) { + public void delete(final long id) { distributionSetTagRepository.delete(id); } @Override - public boolean exists(final Long id) { + public boolean exists(final long id) { return distributionSetTagRepository.exists(id); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java index f8b1040e6..fbfe8e281 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java @@ -101,7 +101,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetType assignMandatorySoftwareModuleTypes(final Long dsTypeId, + public DistributionSetType assignMandatorySoftwareModuleTypes(final long dsTypeId, final Collection softwareModulesTypeIds) { final Collection modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds); @@ -122,7 +122,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetType assignOptionalSoftwareModuleTypes(final Long dsTypeId, + public DistributionSetType assignOptionalSoftwareModuleTypes(final long dsTypeId, final Collection softwareModulesTypeIds) { final Collection modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds); @@ -143,7 +143,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public DistributionSetType unassignSoftwareModuleType(final Long dsTypeId, final Long softwareModuleTypeId) { + public DistributionSetType unassignSoftwareModuleType(final long dsTypeId, final long softwareModuleTypeId) { final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(dsTypeId); checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(dsTypeId); @@ -197,7 +197,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long typeId) { + public void delete(final long typeId) { final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(typeId) .orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, typeId)); @@ -275,12 +275,12 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(distributionSetTypeRepository.findOne(id)); } @Override - public boolean exists(final Long id) { + public boolean exists(final long id) { return distributionSetTypeRepository.exists(id); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java index d580b7c45..a09741a9d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java @@ -21,7 +21,6 @@ import javax.persistence.criteria.Join; import javax.persistence.criteria.JoinType; import javax.persistence.criteria.ListJoin; import javax.persistence.criteria.Root; -import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.repository.RolloutGroupFields; import org.eclipse.hawkbit.repository.RolloutGroupManagement; @@ -85,12 +84,12 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { private RolloutStatusCache rolloutStatusCache; @Override - public Optional get(final Long rolloutGroupId) { + public Optional get(final long rolloutGroupId) { return Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId)); } @Override - public Page findByRollout(final Pageable pageable, final Long rolloutId) { + public Page findByRollout(final Pageable pageable, final long rolloutId) { throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, pageable), pageable); @@ -105,7 +104,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findByRolloutAndRsql(final Pageable pageable, final Long rolloutId, + public Page findByRolloutAndRsql(final Pageable pageable, final long rolloutId, final String rsqlParam) { throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); @@ -130,7 +129,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findByRolloutWithDetailedStatus(final Pageable pageable, final Long rolloutId) { + public Page findByRolloutWithDetailedStatus(final Pageable pageable, final long rolloutId) { throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); final Page rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, pageable); @@ -155,7 +154,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Optional getWithDetailedStatus(final Long rolloutGroupId) { + public Optional getWithDetailedStatus(final long rolloutGroupId) { final Optional rolloutGroup = get(rolloutGroupId); if (!rolloutGroup.isPresent()) { @@ -201,7 +200,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findTargetsOfRolloutGroupByRsql(final Pageable pageable, final Long rolloutGroupId, + public Page findTargetsOfRolloutGroupByRsql(final Pageable pageable, final long rolloutGroupId, final String rsqlParam) { throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); @@ -219,7 +218,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findTargetsOfRolloutGroup(final Pageable page, final Long rolloutGroupId) { + public Page findTargetsOfRolloutGroup(final Pageable page, final long rolloutGroupId) { final JpaRolloutGroup rolloutGroup = rolloutGroupRepository.findById(rolloutGroupId) .orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutGroupId)); @@ -238,7 +237,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { @Override public Page findAllTargetsOfRolloutGroupWithActionStatus(final Pageable pageRequest, - final Long rolloutGroupId) { + final long rolloutGroupId) { throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); @@ -269,7 +268,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public long countTargetsOfRolloutsGroup(@NotNull final Long rolloutGroupId) { + public long countTargetsOfRolloutsGroup(final long rolloutGroupId) { throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); @@ -287,7 +286,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public long countByRollout(final Long rolloutId) { + public long countByRollout(final long rolloutId) { throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); return rolloutGroupRepository.countByRolloutId(rolloutId); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java index 244349994..498791387 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java @@ -186,7 +186,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { } @Override - public Optional get(final Long rolloutId) { + public Optional get(final long rolloutId) { return Optional.ofNullable(rolloutRepository.findOne(rolloutId)); } @@ -439,7 +439,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Rollout start(final Long rolloutId) { + public Rollout start(final long rolloutId) { LOGGER.debug("startRollout called for rollout {}", rolloutId); final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(rolloutId); @@ -571,7 +571,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void pauseRollout(final Long rolloutId) { + public void pauseRollout(final long rolloutId) { final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(rolloutId); if (!RolloutStatus.RUNNING.equals(rollout.getStatus())) { throw new RolloutIllegalStateException("Rollout can only be paused in state running but current state is " @@ -590,7 +590,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void resumeRollout(final Long rolloutId) { + public void resumeRollout(final long rolloutId) { final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(rolloutId); if (!(RolloutStatus.PAUSED.equals(rollout.getStatus()))) { throw new RolloutIllegalStateException("Rollout can only be resumed in state paused but current state is " @@ -818,7 +818,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long rolloutId) { + public void delete(final long rolloutId) { final JpaRollout jpaRollout = rolloutRepository.findOne(rolloutId); if (jpaRollout == null) { @@ -982,7 +982,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { } @Override - public Optional getWithDetailedStatus(final Long rolloutId) { + public Optional getWithDetailedStatus(final long rolloutId) { final Optional rollout = get(rolloutId); if (!rollout.isPresent()) { @@ -1041,7 +1041,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { } @Override - public boolean exists(final Long rolloutId) { + public boolean exists(final long rolloutId) { return rolloutRepository.exists(rolloutId); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java index 9490863cf..40a92eb11 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java @@ -149,7 +149,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Slice findByType(final Pageable pageable, final Long typeId) { + public Slice findByType(final Pageable pageable, final long typeId) { throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId); final List> specList = Lists.newArrayListWithExpectedSize(2); @@ -181,13 +181,13 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(softwareModuleRepository.findOne(id)); } @Override public Optional getByNameAndVersionAndType(final String name, final String version, - final Long typeId) { + final long typeId) { throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId); @@ -325,7 +325,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { @Override public Slice findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( - final Pageable pageable, final Long orderByDistributionId, final String searchText, final Long typeId) { + final Pageable pageable, final long orderByDistributionId, final String searchText, final Long typeId) { final List resultList = new ArrayList<>(); final int pageSize = pageable.getPageSize(); @@ -436,7 +436,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Page findByAssignedTo(final Pageable pageable, final Long setId) { + public Page findByAssignedTo(final Pageable pageable, final long setId) { if (!distributionSetRepository.exists(setId)) { throw new EntityNotFoundException(DistributionSet.class, setId); } @@ -526,7 +526,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void deleteMetaData(final Long moduleId, final String key) { + public void deleteMetaData(final long moduleId, final String key) { final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(moduleId, key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key)); @@ -541,7 +541,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Page findMetaDataByRsql(final Pageable pageable, final Long softwareModuleId, + public Page findMetaDataByRsql(final Pageable pageable, final long softwareModuleId, final String rsqlParam) { throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId); @@ -565,7 +565,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Page findMetaDataBySoftwareModuleId(final Pageable pageable, final Long swId) { + public Page findMetaDataBySoftwareModuleId(final Pageable pageable, final long swId) { throwExceptionIfSoftwareModuleDoesNotExist(swId); return convertMdPage(softwareModuleMetadataRepository.findAll( @@ -575,7 +575,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Optional getMetaDataBySoftwareModuleId(final Long moduleId, final String key) { + public Optional getMetaDataBySoftwareModuleId(final long moduleId, final String key) { throwExceptionIfSoftwareModuleDoesNotExist(moduleId); return Optional.ofNullable(softwareModuleMetadataRepository.findOne(new SwMetadataCompositeKey(moduleId, key))); @@ -589,18 +589,18 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long moduleId) { + public void delete(final long moduleId) { delete(Arrays.asList(moduleId)); } @Override - public boolean exists(final Long id) { + public boolean exists(final long id) { return softwareModuleRepository.exists(id); } @Override public Page findMetaDataBySoftwareModuleIdAndTargetVisible(final Pageable pageable, - final Long moduleId) { + final long moduleId) { throwExceptionIfSoftwareModuleDoesNotExist(moduleId); return convertMdPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible( diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java index bcf022371..9fbaaf37b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java @@ -128,7 +128,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long typeId) { + public void delete(final long typeId) { final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(typeId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, typeId)); @@ -180,12 +180,12 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(softwareModuleTypeRepository.findOne(id)); } @Override - public boolean exists(final Long id) { + public boolean exists(final long id) { return softwareModuleTypeRepository.exists(id); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java index cf4671092..49ce5466b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java @@ -281,7 +281,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public TenantMetaData updateTenantMetadata(final Long defaultDsType) { + public TenantMetaData updateTenantMetadata(final long defaultDsType) { final JpaTenantMetaData data = (JpaTenantMetaData) getTenantMetadata(); data.setDefaultDsType(distributionSetTypeRepository.findOne(defaultDsType)); @@ -319,7 +319,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst } @Override - public TenantMetaData getTenantMetadata(final Long tenantId) { + public TenantMetaData getTenantMetadata(final long tenantId) { return tenantMetaDataRepository.findOne(tenantId); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java index d302f3d38..30a7f20f8 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java @@ -84,7 +84,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public void delete(final Long targetFilterQueryId) { + public void delete(final long targetFilterQueryId) { if (!targetFilterQueryRepository.exists(targetFilterQueryId)) { throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId); } @@ -136,7 +136,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Page findByAutoAssignDSAndRsql(final Pageable pageable, final Long setId, + public Page findByAutoAssignDSAndRsql(final Pageable pageable, final long setId, final String rsqlFilter) { final List> specList = Lists.newArrayListWithExpectedSize(2); @@ -173,7 +173,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Optional get(final Long targetFilterQueryId) { + public Optional get(final long targetFilterQueryId) { return Optional.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId)); } @@ -192,7 +192,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme @Override @Transactional - public TargetFilterQuery updateAutoAssignDS(final Long queryId, final Long dsId) { + public TargetFilterQuery updateAutoAssignDS(final long queryId, final Long dsId) { final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(queryId); targetFilterQuery.setAutoAssignDistributionSet( diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java index 18887cbc9..8c83468e9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java @@ -24,7 +24,6 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Expression; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.repository.FilterParams; import org.eclipse.hawkbit.repository.TargetFields; @@ -137,7 +136,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Slice findByTargetFilterQuery(final Pageable pageable, final Long targetFilterQueryId) { + public Slice findByTargetFilterQuery(final Pageable pageable, final long targetFilterQueryId) { final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId) .orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId)); @@ -205,14 +204,14 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByAssignedDistributionSet(final Pageable pageReq, final Long distributionSetID) { + public Page findByAssignedDistributionSet(final Pageable pageReq, final long distributionSetID) { throwEntityNotFoundIfDsDoesNotExist(distributionSetID); return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID); } @Override - public Page findByAssignedDistributionSetAndRsql(final Pageable pageReq, final Long distributionSetID, + public Page findByAssignedDistributionSetAndRsql(final Pageable pageReq, final long distributionSetID, final String rsqlParam) { throwEntityNotFoundIfDsDoesNotExist(distributionSetID); @@ -242,13 +241,13 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByInstalledDistributionSet(final Pageable pageReq, final Long distributionSetID) { + public Page findByInstalledDistributionSet(final Pageable pageReq, final long distributionSetID) { throwEntityNotFoundIfDsDoesNotExist(distributionSetID); return targetRepository.findByInstalledDistributionSetId(pageReq, distributionSetID); } @Override - public Page findByInstalledDistributionSetAndRsql(final Pageable pageable, final Long distributionSetId, + public Page findByInstalledDistributionSetAndRsql(final Pageable pageable, final long distributionSetId, final String rsqlParam) { throwEntityNotFoundIfDsDoesNotExist(distributionSetId); @@ -372,7 +371,7 @@ public class JpaTargetManagement implements TargetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public List assignTag(final Collection controllerIds, final Long tagId) { + public List assignTag(final Collection controllerIds, final long tagId) { final List allTargets = targetRepository .findAll(TargetSpecifications.byControllerIdWithTagsInJoin(controllerIds)); @@ -399,7 +398,7 @@ public class JpaTargetManagement implements TargetManagement { @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) - public Target unAssignTag(final String controllerID, final Long targetTagId) { + public Target unAssignTag(final String controllerID, final long targetTagId) { final JpaTarget target = (JpaTarget) targetRepository.findByControllerId(controllerID) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerID)); @@ -417,7 +416,7 @@ public class JpaTargetManagement implements TargetManagement { @Override public Slice findByFilterOrderByLinkedDistributionSet(final Pageable pageable, - final Long orderByDistributionId, final FilterParams filterParams) { + final long orderByDistributionId, final FilterParams filterParams) { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(JpaTarget.class); final Root targetRoot = query.from(JpaTarget.class); @@ -470,21 +469,21 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public long countByAssignedDistributionSet(final Long distId) { + public long countByAssignedDistributionSet(final long distId) { throwEntityNotFoundIfDsDoesNotExist(distId); return targetRepository.countByAssignedDistributionSetId(distId); } @Override - public long countByInstalledDistributionSet(final Long distId) { + public long countByInstalledDistributionSet(final long distId) { throwEntityNotFoundIfDsDoesNotExist(distId); return targetRepository.countByInstalledDistributionSetId(distId); } @Override - public Page findByTargetFilterQueryAndNonDS(final Pageable pageRequest, final Long distributionSetId, + public Page findByTargetFilterQueryAndNonDS(final Pageable pageRequest, final long distributionSetId, final String targetFilterQuery) { throwEntityNotFoundIfDsDoesNotExist(distributionSetId); @@ -512,8 +511,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByInRolloutGroupWithoutAction(@NotNull final Pageable pageRequest, - @NotNull final Long group) { + public Page findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) { if (!rolloutGroupRepository.exists(group)) { throw new EntityNotFoundException(RolloutGroup.class, group); } @@ -534,7 +532,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public long countByRsqlAndNonDS(final Long distributionSetId, final String targetFilterQuery) { + public long countByRsqlAndNonDS(final long distributionSetId, final String targetFilterQuery) { throwEntityNotFoundIfDsDoesNotExist(distributionSetId); final Specification spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class, @@ -564,7 +562,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByTag(final Pageable pageable, final Long tagId) { + public Page findByTag(final Pageable pageable, final long tagId) { throwEntityNotFoundExceptionIfTagDoesNotExist(tagId); return convertPage(targetRepository.findByTag(pageable, tagId), pageable); @@ -577,7 +575,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final Long tagId) { + public Page findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final long tagId) { throwEntityNotFoundExceptionIfTagDoesNotExist(tagId); @@ -589,7 +587,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public long countByTargetFilterQuery(final Long targetFilterQueryId) { + public long countByTargetFilterQuery(final long targetFilterQueryId) { final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId) .orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId)); @@ -609,7 +607,7 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(targetRepository.findOne(id)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java index a28ee58df..634a5c3b3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java @@ -133,7 +133,7 @@ public class JpaTargetTagManagement implements TargetTagManagement { } @Override - public Optional get(final Long id) { + public Optional get(final long id) { return Optional.ofNullable(targetTagRepository.findOne(id)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java index 4c09aac57..cb7e4dd47 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaArtifact.java @@ -18,13 +18,13 @@ import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.hibernate.validator.constraints.NotEmpty; /** * JPA implementation of {@link LocalArtifact}. diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java index 2bc05dab9..02228dd92 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTargetFilterQuery.java @@ -17,12 +17,12 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.Size; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.TargetFilterQuery; -import org.hibernate.validator.constraints.NotEmpty; /** * Stored target filter. diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java index 3446610fc..9ee970ed1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantConfiguration.java @@ -13,11 +13,11 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.eclipse.hawkbit.repository.model.TenantConfiguration; -import org.hibernate.validator.constraints.NotEmpty; /** * A JPA entity which stores the tenant specific configuration. diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java index 16f90316d..98a2d6861 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java @@ -40,6 +40,7 @@ import com.google.common.collect.Lists; @TestPropertySource(locations = "classpath:/jpa-test.properties") public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest { + protected static final String INVALID_TEXT_HTML = "