Merge branch 'master' into MECS-1454_Search_filter_improvements
This commit is contained in:
@@ -9,6 +9,7 @@ Please read this if you intend to contribute to the project.
|
|||||||
* Java files:
|
* Java files:
|
||||||
* we follow the standard eclipse IDE (built in) code formatter with the following changes:
|
* we follow the standard eclipse IDE (built in) code formatter with the following changes:
|
||||||
* Tab policy: spaces only: 4
|
* Tab policy: spaces only: 4
|
||||||
|
* We recommend using at least Eclipse [Mars](https://www.eclipse.org/mars/) IDE release. It seems that the Java code formatter line break handling has been changed between [Luna](https://www.eclipse.org/luna/) and Mars.
|
||||||
* XML files:
|
* XML files:
|
||||||
* we follow the standard eclipse IDE XML formatter with the following changes:
|
* we follow the standard eclipse IDE XML formatter with the following changes:
|
||||||
* Indent using spaces only: 3
|
* Indent using spaces only: 3
|
||||||
@@ -36,7 +37,7 @@ If you don’t, you need to [register](https://dev.eclipse.org/site_login/create
|
|||||||
|
|
||||||
* Add your github username in your Eclipse Foundation account settings. Log in it to Eclipse and go to account settings.
|
* Add your github username in your Eclipse Foundation account settings. Log in it to Eclipse and go to account settings.
|
||||||
|
|
||||||
* "Sign-off" your commits (NOTE! This is only necessary if contributing to the vertx-core project)
|
* "Sign-off" your commits
|
||||||
|
|
||||||
Every commit you make in your patch or pull request MUST be "signed off".
|
Every commit you make in your patch or pull request MUST be "signed off".
|
||||||
|
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -10,6 +10,20 @@ Want to chat with the team behind hawkBit? [ for a runtime ready Spring Boot based update server that is empowered by hawkBit.
|
||||||
|
|
||||||
|
# Releases and Roadmap
|
||||||
|
|
||||||
|
* We are currently working on the first formal release under the Eclipse banner: 0.1 (see [Release 0.1 branch](https://github.com/eclipse/hawkbit/tree/release-train-0.1)).
|
||||||
|
* The master branch contains future development towards 0.2. We are currently focusing on:
|
||||||
|
* Rollout Management for large scale rollouts.
|
||||||
|
* Clustering capabilities for the update server.
|
||||||
|
* Upgrade of Spring Boot and Vaadin depedencies.
|
||||||
|
* And of course tons of usability improvements and bug fixes.
|
||||||
|
|
||||||
|
|
||||||
## Try out examples
|
## Try out examples
|
||||||
#### Standalone Test Application Server
|
#### Standalone Test Application Server
|
||||||
[Example Application](examples/hawkbit-example-app)
|
[Example Application](examples/hawkbit-example-app)
|
||||||
@@ -28,7 +42,7 @@ mvn install
|
|||||||
`hawkbit-http-security` : implementation for security filters for HTTP.
|
`hawkbit-http-security` : implementation for security filters for HTTP.
|
||||||
`hawkbit-rest-api` : API classes for the REST Management API.
|
`hawkbit-rest-api` : API classes for the REST Management API.
|
||||||
`hawkbit-rest-resource` : HTTP REST endpoints for the Management and the Direct Device API.
|
`hawkbit-rest-resource` : HTTP REST endpoints for the Management and the Direct Device API.
|
||||||
`hawkbit-rest-resource` : Vaadin UI.
|
`hawkbit-ui` : Vaadin UI.
|
||||||
`hawkbit-cache-redis` : spring cache manager configuration and implementation with redis, distributed cache and distributed events.
|
`hawkbit-cache-redis` : spring cache manager configuration and implementation with redis, distributed cache and distributed events.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,7 @@
|
|||||||
# Examples
|
# Examples
|
||||||
TODO
|
|
||||||
|
Example projects that show how hawkBit can be used to create, run or access an hawkBit empowered update server.
|
||||||
|
|
||||||
|
`hawkbit-device-simulator` : Simulates device software updates, leveraging the hawkBit device integration options.
|
||||||
|
`hawkbit-example-app` : Allows you to run a Spring Boot and hawkBit based update server.
|
||||||
|
`hawkbit-mgmt-api-client` : Example client for the hawkBit management API.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>hawkbit-examples-parent</artifactId>
|
<artifactId>hawkbit-examples-parent</artifactId>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-artifact-repository-mongo</artifactId>
|
<artifactId>hawkbit-artifact-repository-mongo</artifactId>
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class MongoConfiguration extends AbstractMongoConfiguration {
|
|||||||
*
|
*
|
||||||
* Based on MongoProperties#builder method.
|
* Based on MongoProperties#builder method.
|
||||||
*/
|
*/
|
||||||
private Builder createBuilderOutOfOptions(final MongoClientOptions options) {
|
private static Builder createBuilderOutOfOptions(final MongoClientOptions options) {
|
||||||
final Builder builder = MongoClientOptions.builder();
|
final Builder builder = MongoClientOptions.builder();
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
builder.alwaysUseMBeans(options.isAlwaysUseMBeans());
|
builder.alwaysUseMBeans(options.isAlwaysUseMBeans());
|
||||||
@@ -108,8 +108,8 @@ public class MongoConfiguration extends AbstractMongoConfiguration {
|
|||||||
builder.socketFactory(options.getSocketFactory());
|
builder.socketFactory(options.getSocketFactory());
|
||||||
builder.socketKeepAlive(options.isSocketKeepAlive());
|
builder.socketKeepAlive(options.isSocketKeepAlive());
|
||||||
builder.socketTimeout(options.getSocketTimeout());
|
builder.socketTimeout(options.getSocketTimeout());
|
||||||
builder.threadsAllowedToBlockForConnectionMultiplier(options
|
builder.threadsAllowedToBlockForConnectionMultiplier(
|
||||||
.getThreadsAllowedToBlockForConnectionMultiplier());
|
options.getThreadsAllowedToBlockForConnectionMultiplier());
|
||||||
builder.writeConcern(options.getWriteConcern());
|
builder.writeConcern(options.getWriteConcern());
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||||
<name>hawkBit :: Spring Boot Autoconfigure</name>
|
<name>hawkBit :: Spring Boot Autoconfigure</name>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.autoconfigure.scheduling;
|
|||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.RejectedExecutionHandler;
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -46,19 +45,15 @@ public class ExecutorAutoConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public Executor asyncExecutor() {
|
public Executor asyncExecutor() {
|
||||||
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<Runnable>(
|
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(
|
||||||
asyncConfigurerProperties.getQueuesize());
|
asyncConfigurerProperties.getQueuesize());
|
||||||
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
|
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(asyncConfigurerProperties.getCorethreads(),
|
||||||
asyncConfigurerProperties.getCorethreads(), asyncConfigurerProperties.getMaxthreads(),
|
asyncConfigurerProperties.getMaxthreads(), asyncConfigurerProperties.getIdletimeout(),
|
||||||
asyncConfigurerProperties.getIdletimeout(), TimeUnit.MILLISECONDS, blockingQueue,
|
TimeUnit.MILLISECONDS, blockingQueue,
|
||||||
new ThreadFactoryBuilder().setNameFormat("central-executor-pool-%d").build());
|
new ThreadFactoryBuilder().setNameFormat("central-executor-pool-%d").build());
|
||||||
threadPoolExecutor.setRejectedExecutionHandler(new RejectedExecutionHandler() {
|
threadPoolExecutor.setRejectedExecutionHandler((r, executor) -> LOGGER.warn(
|
||||||
@Override
|
"Reject runnable for centralExecutorService, reached limit of queue size {}",
|
||||||
public void rejectedExecution(final Runnable r, final java.util.concurrent.ThreadPoolExecutor executor) {
|
executor.getQueue().size()));
|
||||||
LOGGER.warn("Reject runnable for centralExecutorService, reached limit of queue size {}", executor
|
|
||||||
.getQueue().size());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,35 +159,27 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (securityConfiguration.getAnonymousEnabled()) {
|
if (securityConfiguration.getAnonymousEnabled()) {
|
||||||
LOG.info("******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************");
|
LOG.info(
|
||||||
|
"******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************");
|
||||||
final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
|
final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
|
||||||
"controllerAnonymousFilter", "anonymous", Collections.singletonList(new SimpleGrantedAuthority(
|
"controllerAnonymousFilter", "anonymous", Collections.singletonList(
|
||||||
SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS)));
|
new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS)));
|
||||||
anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource);
|
||||||
httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and()
|
httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and()
|
||||||
.securityContext().disable().anonymous().authenticationFilter(anoymousFilter);
|
.securityContext().disable().anonymous().authenticationFilter(anoymousFilter);
|
||||||
} else {
|
} else {
|
||||||
httpSec.addFilter(securityHeaderFilter)
|
httpSec.addFilter(securityHeaderFilter).addFilter(securityTokenFilter)
|
||||||
.addFilter(securityTokenFilter)
|
.addFilter(gatewaySecurityTokenFilter).antMatcher("/*/controller/**").anonymous().disable()
|
||||||
.addFilter(gatewaySecurityTokenFilter)
|
.authorizeRequests().anyRequest().authenticated().and().exceptionHandling()
|
||||||
.antMatcher("/*/controller/**")
|
.authenticationEntryPoint((request, response, authException) -> response
|
||||||
.anonymous()
|
.setStatus(HttpStatus.UNAUTHORIZED.value()))
|
||||||
.disable()
|
.and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||||
.authorizeRequests()
|
|
||||||
.anyRequest()
|
|
||||||
.authenticated()
|
|
||||||
.and()
|
|
||||||
.exceptionHandling()
|
|
||||||
.authenticationEntryPoint(
|
|
||||||
(request, response, authException) -> response.setStatus(HttpStatus.UNAUTHORIZED
|
|
||||||
.value())).and().sessionManagement()
|
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see
|
||||||
* org.springframework.security.config.annotation.web.configuration.
|
* org.springframework.security.config.annotation.web.configuration.
|
||||||
* WebSecurityConfigurerAdapter
|
* WebSecurityConfigurerAdapter
|
||||||
@@ -196,8 +188,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration
|
auth.authenticationProvider(
|
||||||
.getRpTrustedIPs()));
|
new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,10 +204,12 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
public FilterRegistrationBean dosFilter() {
|
public FilterRegistrationBean dosFilter() {
|
||||||
final FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
|
final FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
|
||||||
|
|
||||||
filterRegBean.setFilter(new DosFilter(environment
|
filterRegBean
|
||||||
.getProperty("security.dos.filter.maxRead", Integer.class, 200), environment.getProperty(
|
.setFilter(
|
||||||
"security.dos.filter.maxWrite", Integer.class, 50), environment
|
new DosFilter(environment.getProperty("security.dos.filter.maxRead", Integer.class, 200),
|
||||||
.getProperty("security.dos.filter.whitelist"), environment.getProperty("security.clients.blacklist"),
|
environment.getProperty("security.dos.filter.maxWrite", Integer.class, 50),
|
||||||
|
environment.getProperty("security.dos.filter.whitelist"), environment
|
||||||
|
.getProperty("security.clients.blacklist"),
|
||||||
environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
|
environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
|
||||||
filterRegBean.addUrlPatterns("/{tenant}/controller/v1/*", "/rest/*");
|
filterRegBean.addUrlPatterns("/{tenant}/controller/v1/*", "/rest/*");
|
||||||
return filterRegBean;
|
return filterRegBean;
|
||||||
@@ -301,7 +295,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
}, RequestHeaderAuthenticationFilter.class)
|
}, RequestHeaderAuthenticationFilter.class)
|
||||||
.addFilterAfter(
|
.addFilterAfter(
|
||||||
new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement),
|
new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement),
|
||||||
RequestHeaderAuthenticationFilter.class).authorizeRequests().anyRequest().authenticated()
|
RequestHeaderAuthenticationFilter.class)
|
||||||
|
.authorizeRequests().anyRequest().authenticated()
|
||||||
.antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
|
.antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
|
||||||
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**")
|
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**")
|
||||||
.hasAnyAuthority(SpPermission.SYSTEM_DIAG);
|
.hasAnyAuthority(SpPermission.SYSTEM_DIAG);
|
||||||
@@ -310,12 +305,13 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WebSecurityConfigurer} for external (management) access.
|
* {@link WebSecurityConfigurer} for external (management) access.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@Order(400)
|
@Order(400)
|
||||||
@EnableVaadinSecurity
|
@EnableVaadinSecurity
|
||||||
public static class UISecurityConfigurationAdapter extends WebSecurityConfigurerAdapter implements EnvironmentAware {
|
public static class UISecurityConfigurationAdapter extends WebSecurityConfigurerAdapter
|
||||||
|
implements EnvironmentAware {
|
||||||
|
|
||||||
private static final String XFRAME_OPTION_DENY = "DENY";
|
private static final String XFRAME_OPTION_DENY = "DENY";
|
||||||
private static final String XFRAME_OPTION_SAMEORIGIN = "SAMEORIGIN";
|
private static final String XFRAME_OPTION_SAMEORIGIN = "SAMEORIGIN";
|
||||||
@@ -371,7 +367,7 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
* Listener to redirect to login page after session timeout. Close the
|
* Listener to redirect to login page after session timeout. Close the
|
||||||
* vaadin session, because it's is not possible to redirect in
|
* vaadin session, because it's is not possible to redirect in
|
||||||
* atmospehere.
|
* atmospehere.
|
||||||
*
|
*
|
||||||
* @return the servlet listener.
|
* @return the servlet listener.
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@@ -388,10 +384,9 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
if (confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) && confAllowFromUri == null) {
|
if (confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) && confAllowFromUri == null) {
|
||||||
// if allow-from option is specified but no allowFromUri throw
|
// if allow-from option is specified but no allowFromUri throw
|
||||||
// exception
|
// exception
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("hawkbit.server.security.xframe.option has been specified as ALLOW-FROM"
|
||||||
"hawkbit.server.security.xframe.option has been specified as ALLOW-FROM"
|
+ " but no hawkbit.server.security.xframe.option.allowfrom has been set, "
|
||||||
+ " but no hawkbit.server.security.xframe.option.allowfrom has been set, "
|
+ "please ensure to set allow from URIs");
|
||||||
+ "please ensure to set allow from URIs");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround regex: we need to exclude the URL /UI/HEARTBEAT here
|
// workaround regex: we need to exclude the URL /UI/HEARTBEAT here
|
||||||
@@ -400,23 +395,22 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
// vaadin-forum:
|
// vaadin-forum:
|
||||||
// https://vaadin.com/forum#!/thread/3200565.
|
// https://vaadin.com/forum#!/thread/3200565.
|
||||||
HttpSecurity httpSec = http.regexMatcher("(?!.*HEARTBEAT)^.*\\/UI.*$")
|
HttpSecurity httpSec = http.regexMatcher("(?!.*HEARTBEAT)^.*\\/UI.*$")
|
||||||
// disable as CSRF is handled by Vaadin
|
// disable as CSRF is handled by Vaadin
|
||||||
.csrf().disable();
|
.csrf().disable();
|
||||||
|
|
||||||
if (springSecurityProperties.isRequireSsl()) {
|
if (springSecurityProperties.isRequireSsl()) {
|
||||||
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
|
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
|
||||||
} else {
|
} else {
|
||||||
LOG.info("\"******************\\n** Requires HTTPS Security has been disabled for UI, should only use for developing purposes **\\n******************\"");
|
LOG.info(
|
||||||
|
"\"******************\\n** Requires HTTPS Security has been disabled for UI, should only use for developing purposes **\\n******************\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
// for UI integrator we allow frame integration on same origin
|
// for UI integrator we allow frame integration on same origin
|
||||||
httpSec.headers()
|
httpSec.headers()
|
||||||
.addHeaderWriter(
|
.addHeaderWriter(confXframeOption.equals(XFAME_OPTION_ALLOW_FROM)
|
||||||
confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) ? new XFrameOptionsHeaderWriter(
|
? new XFrameOptionsHeaderWriter(new StaticAllowFromStrategy(new URI(confAllowFromUri)))
|
||||||
new StaticAllowFromStrategy(new URI(confAllowFromUri)))
|
: new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption)))
|
||||||
: new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption)))
|
.contentTypeOptions().xssProtection().httpStrictTransportSecurity().and()
|
||||||
.contentTypeOptions().xssProtection().httpStrictTransportSecurity()
|
|
||||||
.and()
|
|
||||||
// UI
|
// UI
|
||||||
.authorizeRequests().antMatchers("/UI/login/**").permitAll().antMatchers("/UI/UIDL/**").permitAll()
|
.authorizeRequests().antMatchers("/UI/login/**").permitAll().antMatchers("/UI/UIDL/**").permitAll()
|
||||||
.anyRequest().authenticated().and()
|
.anyRequest().authenticated().and()
|
||||||
@@ -437,7 +431,7 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
* string does not match an option then
|
* string does not match an option then
|
||||||
* {@link XFrameOptionsMode#SAMEORIGIN} is returned
|
* {@link XFrameOptionsMode#SAMEORIGIN} is returned
|
||||||
*/
|
*/
|
||||||
private XFrameOptionsMode xframeOptionFromStr(@NotNull final String xframeOption) {
|
private static XFrameOptionsMode xframeOptionFromStr(@NotNull final String xframeOption) {
|
||||||
switch (xframeOption) {
|
switch (xframeOption) {
|
||||||
case XFRAME_OPTION_DENY:
|
case XFRAME_OPTION_DENY:
|
||||||
return XFrameOptionsMode.DENY;
|
return XFrameOptionsMode.DENY;
|
||||||
@@ -450,8 +444,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(final WebSecurity webSecurity) throws Exception {
|
public void configure(final WebSecurity webSecurity) throws Exception {
|
||||||
webSecurity.ignoring()
|
webSecurity.ignoring().antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**",
|
||||||
.antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**", "/docs/**");
|
"/docs/**");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,15 +476,15 @@ public class SecurityManagedConfiguration implements EnvironmentAware {
|
|||||||
http.csrf().disable();
|
http.csrf().disable();
|
||||||
http.anonymous().disable();
|
http.anonymous().disable();
|
||||||
|
|
||||||
http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN).addFilterBefore(
|
http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN)
|
||||||
downloadIdAuthenticationFilter, FilterSecurityInterceptor.class);
|
.addFilterBefore(downloadIdAuthenticationFilter, FilterSecurityInterceptor.class);
|
||||||
http.authorizeRequests().anyRequest().authenticated();
|
http.authorizeRequests().anyRequest().authenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration
|
auth.authenticationProvider(
|
||||||
.getRpTrustedIPs()));
|
new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -510,7 +504,7 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see org.vaadin.spring.security.web.authentication.
|
* @see org.vaadin.spring.security.web.authentication.
|
||||||
* SavedRequestAwareVaadinAuthenticationSuccessHandler
|
* SavedRequestAwareVaadinAuthenticationSuccessHandler
|
||||||
* #onAuthenticationSuccess(org.springframework.security.core.
|
* #onAuthenticationSuccess(org.springframework.security.core.
|
||||||
@@ -519,10 +513,10 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends
|
|||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(final Authentication authentication) throws Exception {
|
public void onAuthenticationSuccess(final Authentication authentication) throws Exception {
|
||||||
if (authentication.getClass().equals(TenantUserPasswordAuthenticationToken.class)) {
|
if (authentication.getClass().equals(TenantUserPasswordAuthenticationToken.class)) {
|
||||||
systemManagement.getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant()
|
systemManagement
|
||||||
.toString());
|
.getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant().toString());
|
||||||
} else if (authentication.getClass().equals(UsernamePasswordAuthenticationToken.class)) {
|
} else if (authentication.getClass().equals(UsernamePasswordAuthenticationToken.class)) {
|
||||||
// TODO: MECS-1078 vaadin4spring-ext-security does not give us the
|
// TODO: vaadin4spring-ext-security does not give us the
|
||||||
// fullyAuthenticatedToken
|
// fullyAuthenticatedToken
|
||||||
// in the GenericVaadinSecurity class. Only the token which has been
|
// in the GenericVaadinSecurity class. Only the token which has been
|
||||||
// created in the
|
// created in the
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-cache-redis</artifactId>
|
<artifactId>hawkbit-cache-redis</artifactId>
|
||||||
<name>hawkBit :: Redis Cache Manager</name>
|
<name>hawkBit :: Redis Cache Manager</name>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-core</artifactId>
|
<artifactId>hawkbit-core</artifactId>
|
||||||
<name>hawkBit :: Core</name>
|
<name>hawkBit :: Core</name>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ package org.eclipse.hawkbit.exception;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Generic Custom Exception to wrap the Runtime and checked exception
|
* Generic Custom Exception to wrap the Runtime and checked exception
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,6 @@ package org.eclipse.hawkbit.repository;
|
|||||||
*/
|
*/
|
||||||
public enum ActionStatusFields implements FieldNameProvider {
|
public enum ActionStatusFields implements FieldNameProvider {
|
||||||
|
|
||||||
/**
|
|
||||||
* The type field.
|
|
||||||
*/
|
|
||||||
TYPE("type"),
|
|
||||||
/**
|
/**
|
||||||
* The id field.
|
* The id field.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,16 +36,50 @@ public enum DistributionSetFields implements FieldNameProvider {
|
|||||||
/**
|
/**
|
||||||
* The id field.
|
* The id field.
|
||||||
*/
|
*/
|
||||||
ID("id");
|
ID("id"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tags field.
|
||||||
|
*/
|
||||||
|
TAG("tags.name"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sw type key field.
|
||||||
|
*/
|
||||||
|
TYPE("type.key"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadata.
|
||||||
|
*/
|
||||||
|
METADATA("metadata", "key", "value");
|
||||||
|
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
private String keyFieldName;
|
||||||
|
private String valueFieldName;
|
||||||
|
|
||||||
private DistributionSetFields(final String fieldName) {
|
private DistributionSetFields(final String fieldName) {
|
||||||
|
this(fieldName, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DistributionSetFields(final String fieldName, final String keyFieldName, final String valueFieldName) {
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.keyFieldName = keyFieldName;
|
||||||
|
this.valueFieldName = valueFieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueFieldName() {
|
||||||
|
return valueFieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKeyFieldName() {
|
||||||
|
return keyFieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFieldName() {
|
public String getFieldName() {
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,87 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface for declaring the name of the field described in the database
|
* An interface for declaring the name of the field described in the database
|
||||||
* which is used as string representation of the field, e.g. for sorting the
|
* which is used as string representation of the field, e.g. for sorting the
|
||||||
* fields over REST.
|
* fields over REST.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
|
||||||
public interface FieldNameProvider {
|
public interface FieldNameProvider {
|
||||||
|
/**
|
||||||
|
* Seperator for the sub attributes
|
||||||
|
*/
|
||||||
|
public static final String SUB_ATTRIBUTE_SEPERATOR = ".";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the string representation of the underlying persistence field
|
* @return the string representation of the underlying persistence field
|
||||||
* name e.g. in case of sorting. Never {@code null}.
|
* name e.g. in case of sorting. Never {@code null}.
|
||||||
*/
|
*/
|
||||||
String getFieldName();
|
String getFieldName();
|
||||||
|
|
||||||
|
default boolean containsSubEntityAttribute(final String propertyField) {
|
||||||
|
return FieldNameProvider.containsSubEntityAttribute(propertyField, getSubEntityAttributes());
|
||||||
|
};
|
||||||
|
|
||||||
|
default List<String> getSubEntityAttributes() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the database column for the key
|
||||||
|
*
|
||||||
|
* @return key fieldname
|
||||||
|
*/
|
||||||
|
default String getKeyFieldName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the database column for the value
|
||||||
|
*
|
||||||
|
* @return key fieldname
|
||||||
|
*/
|
||||||
|
default String getValueFieldName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the entity field a {@link Map}.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default boolean isMap() {
|
||||||
|
return getKeyFieldName() != null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a sub attribute exists.
|
||||||
|
*
|
||||||
|
* @param propertyField
|
||||||
|
* the sub property field.
|
||||||
|
* @param subEntityAttribues
|
||||||
|
* the list of available properties
|
||||||
|
* @return <true> property exists <false> not exists
|
||||||
|
*/
|
||||||
|
static boolean containsSubEntityAttribute(final String propertyField, final List<String> subEntityAttribues) {
|
||||||
|
if (subEntityAttribues.contains(propertyField)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (final String attribute : subEntityAttribues) {
|
||||||
|
final String[] graph = attribute.split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
||||||
|
|
||||||
|
for (final String subAttribute : graph) {
|
||||||
|
if (subAttribute.equalsIgnoreCase(propertyField)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,16 +36,38 @@ public enum SoftwareModuleFields implements FieldNameProvider {
|
|||||||
/**
|
/**
|
||||||
* The id field.
|
* The id field.
|
||||||
*/
|
*/
|
||||||
ID("id");
|
ID("id"),
|
||||||
|
/**
|
||||||
|
* The metadata.
|
||||||
|
*/
|
||||||
|
METADATA("metadata", "key", "value");
|
||||||
|
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
private String keyFieldName;
|
||||||
|
private String valueFieldName;
|
||||||
|
|
||||||
private SoftwareModuleFields(final String fieldName) {
|
private SoftwareModuleFields(final String fieldName) {
|
||||||
|
this(fieldName, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SoftwareModuleFields(final String fieldName, final String keyFieldName, final String valueFieldName) {
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.keyFieldName = keyFieldName;
|
||||||
|
this.valueFieldName = valueFieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFieldName() {
|
public String getFieldName() {
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKeyFieldName() {
|
||||||
|
return keyFieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValueFieldName() {
|
||||||
|
return valueFieldName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,22 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describing the fields of the Target model which can be used in the REST API
|
* Describing the fields of the Target model which can be used in the REST API
|
||||||
* e.g. for sorting etc.
|
* e.g. for sorting etc.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum TargetFields implements FieldNameProvider {
|
public enum TargetFields implements FieldNameProvider {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The controllerId field.
|
||||||
|
*/
|
||||||
|
ID("controllerId"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name field.
|
* The name field.
|
||||||
*/
|
*/
|
||||||
@@ -37,12 +44,49 @@ public enum TargetFields implements FieldNameProvider {
|
|||||||
/**
|
/**
|
||||||
* The ip-address field.
|
* The ip-address field.
|
||||||
*/
|
*/
|
||||||
IPADDRESS("targetInfo.ipAddress");
|
IPADDRESS("targetInfo.address"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attribute map of target info.
|
||||||
|
*/
|
||||||
|
ATTRIBUTE("targetInfo.controllerAttributes", true),
|
||||||
|
|
||||||
|
ASSIGNEDDS("assignedDistributionSet", "name", "version"),
|
||||||
|
/**
|
||||||
|
* The tags field.
|
||||||
|
*/
|
||||||
|
TAG("tags.name");
|
||||||
|
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
private List<String> subEntityAttribues;
|
||||||
|
private boolean mapField;
|
||||||
|
|
||||||
private TargetFields(final String fieldName) {
|
private TargetFields(final String fieldName) {
|
||||||
|
this(fieldName, false, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetFields(final String fieldName, final boolean isMapField) {
|
||||||
|
this(fieldName, isMapField, Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetFields(final String fieldName, final String... subEntityAttribues) {
|
||||||
|
this(fieldName, false, Arrays.asList(subEntityAttribues));
|
||||||
|
}
|
||||||
|
|
||||||
|
private TargetFields(final String fieldName, final boolean mapField, final List<String> subEntityAttribues) {
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.mapField = mapField;
|
||||||
|
this.subEntityAttribues = subEntityAttribues;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSubEntityAttributes() {
|
||||||
|
return subEntityAttribues;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMap() {
|
||||||
|
return mapField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-dmf-amqp</artifactId>
|
<artifactId>hawkbit-dmf-amqp</artifactId>
|
||||||
<name>hawkBit :: DMF Amqp</name>
|
<name>hawkBit :: DMF Amqp</name>
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public class AmqpConfiguration {
|
|||||||
final SimpleRabbitListenerContainerFactory containerFactory = new SimpleRabbitListenerContainerFactory();
|
final SimpleRabbitListenerContainerFactory containerFactory = new SimpleRabbitListenerContainerFactory();
|
||||||
containerFactory.setDefaultRequeueRejected(false);
|
containerFactory.setDefaultRequeueRejected(false);
|
||||||
containerFactory.setConnectionFactory(connectionFactory);
|
containerFactory.setConnectionFactory(connectionFactory);
|
||||||
|
containerFactory.setMissingQueuesFatal(amqpProperties.isMissingQueuesFatal());
|
||||||
return containerFactory;
|
return containerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.amqp;
|
package org.eclipse.hawkbit.amqp;
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,6 +25,26 @@ public class AmqpProperties {
|
|||||||
private String deadLetterQueue = "dmf_connector_deadletter";
|
private String deadLetterQueue = "dmf_connector_deadletter";
|
||||||
private String deadLetterExchange = "dmf.connector.deadletter";
|
private String deadLetterExchange = "dmf.connector.deadletter";
|
||||||
private String receiverQueue = "dmf_receiver";
|
private String receiverQueue = "dmf_receiver";
|
||||||
|
private boolean missingQueuesFatal = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is missingQueuesFatal enabled
|
||||||
|
*
|
||||||
|
* @see SimpleMessageListenerContainer#setMissingQueuesFatal
|
||||||
|
* @return the missingQueuesFatal <true> enabled <false> disabled
|
||||||
|
*/
|
||||||
|
public boolean isMissingQueuesFatal() {
|
||||||
|
return missingQueuesFatal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param missingQueuesFatal
|
||||||
|
* the missingQueuesFatal to set.
|
||||||
|
* @see SimpleMessageListenerContainer#setMissingQueuesFatal
|
||||||
|
*/
|
||||||
|
public void setMissingQueuesFatal(final boolean missingQueuesFatal) {
|
||||||
|
this.missingQueuesFatal = missingQueuesFatal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the dead letter exchange.
|
* Returns the dead letter exchange.
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit
|
|||||||
CONTROLLER_ID, 1l, IpUtil.createAmqpUri("mytest"));
|
CONTROLLER_ID, 1l, IpUtil.createAmqpUri("mytest"));
|
||||||
amqpMessageDispatcherService
|
amqpMessageDispatcherService
|
||||||
.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
|
.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
|
||||||
final Message sendMessage = createArgumentCapture(cancelTargetAssignmentDistributionSetEvent.getTargetAdress()
|
final Message sendMessage = createArgumentCapture(
|
||||||
.getHost());
|
cancelTargetAssignmentDistributionSetEvent.getTargetAdress().getHost());
|
||||||
assertCancelMessage(sendMessage);
|
assertCancelMessage(sendMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -200,8 +200,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T convertMessage(final Message message, final Class<T> clazz) {
|
private <T> T convertMessage(final Message message, final Class<T> clazz) {
|
||||||
message.getMessageProperties().getHeaders()
|
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
|
||||||
.put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, clazz.getTypeName());
|
clazz.getTypeName());
|
||||||
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
|
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-dmf-api</artifactId>
|
<artifactId>hawkbit-dmf-api</artifactId>
|
||||||
<name>hawkBit :: Device Management Federation API</name>
|
<name>hawkBit :: Device Management Federation API</name>
|
||||||
|
|||||||
@@ -22,6 +22,5 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public enum ActionStatus {
|
public enum ActionStatus {
|
||||||
|
|
||||||
|
|
||||||
DOWNLOAD, RETRIEVED, RUNNING, FINISHED, ERROR, WARNING, CANCELED, CANCEL_REJECTED;
|
DOWNLOAD, RETRIEVED, RUNNING, FINISHED, ERROR, WARNING, CANCELED, CANCEL_REJECTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-http-security</artifactId>
|
<artifactId>hawkbit-http-security</artifactId>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-repository</artifactId>
|
<artifactId>hawkbit-repository</artifactId>
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
|
|
||||||
if (translatedAccessException == null && ex instanceof TransactionSystemException) {
|
if (translatedAccessException == null && ex instanceof TransactionSystemException) {
|
||||||
final TransactionSystemException systemException = (TransactionSystemException) ex;
|
final TransactionSystemException systemException = (TransactionSystemException) ex;
|
||||||
translatedAccessException = translateEclipseLinkExceptionIfPossible((Exception) systemException
|
translatedAccessException = translateEclipseLinkExceptionIfPossible(
|
||||||
.getOriginalException());
|
(Exception) systemException.getOriginalException());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (translatedAccessException == null) {
|
if (translatedAccessException == null) {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
|||||||
* successful spring transaction commit.The class is thread safe.
|
* successful spring transaction commit.The class is thread safe.
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements
|
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter
|
||||||
AfterTransactionCommitExecutor {
|
implements AfterTransactionCommitExecutor {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class);
|
||||||
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
|
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
|
||||||
|
|
||||||
|
|||||||
@@ -198,10 +198,8 @@ public class DeploymentManagement {
|
|||||||
@CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true)
|
@CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true)
|
||||||
public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType,
|
public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType,
|
||||||
final long forcedTimestamp, @NotEmpty final String... targetIDs) {
|
final long forcedTimestamp, @NotEmpty final String... targetIDs) {
|
||||||
return assignDistributionSet(
|
return assignDistributionSet(dsID, Arrays.stream(targetIDs)
|
||||||
dsID,
|
.map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)).collect(Collectors.toList()));
|
||||||
Arrays.stream(targetIDs).map(t -> new TargetWithActionType(t, actionType, forcedTimestamp))
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,8 +224,8 @@ public class DeploymentManagement {
|
|||||||
final List<TargetWithActionType> targets) {
|
final List<TargetWithActionType> targets) {
|
||||||
final DistributionSet set = distributoinSetRepository.findOne(dsID);
|
final DistributionSet set = distributoinSetRepository.findOne(dsID);
|
||||||
if (set == null) {
|
if (set == null) {
|
||||||
throw new EntityNotFoundException(String.format("no %s with id %d found",
|
throw new EntityNotFoundException(
|
||||||
DistributionSet.class.getSimpleName(), dsID));
|
String.format("no %s with id %d found", DistributionSet.class.getSimpleName(), dsID));
|
||||||
}
|
}
|
||||||
|
|
||||||
return assignDistributionSetToTargets(set, targets);
|
return assignDistributionSetToTargets(set, targets);
|
||||||
@@ -251,8 +249,8 @@ public class DeploymentManagement {
|
|||||||
final List<TargetWithActionType> targetsWithActionType) {
|
final List<TargetWithActionType> targetsWithActionType) {
|
||||||
|
|
||||||
if (!set.isComplete()) {
|
if (!set.isComplete()) {
|
||||||
throw new IncompleteDistributionSetException("Distribution set of type " + set.getType().getKey()
|
throw new IncompleteDistributionSetException(
|
||||||
+ " is incomplete: " + set.getId());
|
"Distribution set of type " + set.getType().getKey() + " is incomplete: " + set.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> controllerIDs = targetsWithActionType.stream().map(TargetWithActionType::getTargetId)
|
final List<String> controllerIDs = targetsWithActionType.stream().map(TargetWithActionType::getTargetId)
|
||||||
@@ -260,8 +258,8 @@ public class DeploymentManagement {
|
|||||||
|
|
||||||
LOG.debug("assignDistribution({}) to {} targets", set, controllerIDs.size());
|
LOG.debug("assignDistribution({}) to {} targets", set, controllerIDs.size());
|
||||||
|
|
||||||
final Map<String, TargetWithActionType> targetsWithActionMap = targetsWithActionType.stream().collect(
|
final Map<String, TargetWithActionType> targetsWithActionMap = targetsWithActionType.stream()
|
||||||
Collectors.toMap(TargetWithActionType::getTargetId, Function.identity()));
|
.collect(Collectors.toMap(TargetWithActionType::getTargetId, Function.identity()));
|
||||||
|
|
||||||
// split tIDs length into max entries in-statement because many database
|
// split tIDs length into max entries in-statement because many database
|
||||||
// have constraint of
|
// have constraint of
|
||||||
@@ -271,12 +269,10 @@ public class DeploymentManagement {
|
|||||||
// we take the target only into account if the requested operation is no
|
// we take the target only into account if the requested operation is no
|
||||||
// duplicate of a
|
// duplicate of a
|
||||||
// previous one
|
// previous one
|
||||||
final List<Target> targets = Lists
|
final List<Target> targets = Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream()
|
||||||
.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT)
|
.map(ids -> targetRepository
|
||||||
.stream()
|
.findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId())))
|
||||||
.map(ids -> targetRepository.findAll(TargetSpecifications
|
.flatMap(t -> t.stream()).collect(Collectors.toList());
|
||||||
.hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId()))).flatMap(t -> t.stream())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (targets.isEmpty()) {
|
if (targets.isEmpty()) {
|
||||||
// detaching as it is not necessary to persist the set itself
|
// detaching as it is not necessary to persist the set itself
|
||||||
@@ -339,8 +335,8 @@ public class DeploymentManagement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// select updated targets in order to return them
|
// select updated targets in order to return them
|
||||||
final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult(targets.stream()
|
final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult(
|
||||||
.map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(),
|
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(),
|
||||||
controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()),
|
controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()),
|
||||||
targetManagement);
|
targetManagement);
|
||||||
|
|
||||||
@@ -353,11 +349,9 @@ public class DeploymentManagement {
|
|||||||
|
|
||||||
// send distribution set assignment event
|
// send distribution set assignment event
|
||||||
|
|
||||||
targets.stream()
|
targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId()))
|
||||||
.filter(t -> !!!targetIdsCancellList.contains(t.getId()))
|
.forEach(t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(),
|
||||||
.forEach(
|
softwareModules));
|
||||||
t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(),
|
|
||||||
softwareModules));
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -403,13 +397,13 @@ public class DeploymentManagement {
|
|||||||
activeActions.forEach(action -> {
|
activeActions.forEach(action -> {
|
||||||
action.setStatus(Status.CANCELING);
|
action.setStatus(Status.CANCELING);
|
||||||
// document that the status has been retrieved
|
// document that the status has been retrieved
|
||||||
actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(),
|
actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(),
|
||||||
"manual cancelation requested"));
|
"manual cancelation requested"));
|
||||||
|
|
||||||
cancelAssignDistributionSetEvent(action.getTarget(), action.getId());
|
cancelAssignDistributionSetEvent(action.getTarget(), action.getId());
|
||||||
|
|
||||||
cancelledTargetIds.add(action.getTarget().getId());
|
cancelledTargetIds.add(action.getTarget().getId());
|
||||||
});
|
});
|
||||||
actionRepository.save(activeActions);
|
actionRepository.save(activeActions);
|
||||||
|
|
||||||
return cancelledTargetIds;
|
return cancelledTargetIds;
|
||||||
@@ -417,9 +411,8 @@ public class DeploymentManagement {
|
|||||||
|
|
||||||
private DistributionSetAssignmentResult assignDistributionSetByTargetId(@NotNull final DistributionSet set,
|
private DistributionSetAssignmentResult assignDistributionSetByTargetId(@NotNull final DistributionSet set,
|
||||||
@NotEmpty final List<String> tIDs, final ActionType actionType, final long forcedTime) {
|
@NotEmpty final List<String> tIDs, final ActionType actionType, final long forcedTime) {
|
||||||
return assignDistributionSetToTargets(set,
|
return assignDistributionSetToTargets(set, tIDs.stream()
|
||||||
tIDs.stream().map(t -> new TargetWithActionType(t, actionType, forcedTime))
|
.map(t -> new TargetWithActionType(t, actionType, forcedTime)).collect(Collectors.toList()));
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,8 +480,8 @@ public class DeploymentManagement {
|
|||||||
|
|
||||||
return saveAction;
|
return saveAction;
|
||||||
} else {
|
} else {
|
||||||
throw new CancelActionNotAllowedException("Action [id: " + action.getId()
|
throw new CancelActionNotAllowedException(
|
||||||
+ "] is not active and cannot be canceled");
|
"Action [id: " + action.getId() + "] is not active and cannot be canceled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,13 +522,13 @@ public class DeploymentManagement {
|
|||||||
final Action mergedAction = entityManager.merge(action);
|
final Action mergedAction = entityManager.merge(action);
|
||||||
|
|
||||||
if (!mergedAction.isCancelingOrCanceled()) {
|
if (!mergedAction.isCancelingOrCanceled()) {
|
||||||
throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId()
|
throw new ForceQuitActionNotAllowedException(
|
||||||
+ "] is not canceled yet and cannot be force quit");
|
"Action [id: " + action.getId() + "] is not canceled yet and cannot be force quit");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mergedAction.isActive()) {
|
if (!mergedAction.isActive()) {
|
||||||
throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId()
|
throw new ForceQuitActionNotAllowedException(
|
||||||
+ "] is not active and cannot be force quit");
|
"Action [id: " + action.getId() + "] is not active and cannot be force quit");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.warn("action ({}) was still activ and has been force quite.", action);
|
LOG.warn("action ({}) was still activ and has been force quite.", action);
|
||||||
@@ -650,7 +643,8 @@ public class DeploymentManagement {
|
|||||||
return actionRepository.findAll(new Specification<Action>() {
|
return actionRepository.findAll(new Specification<Action>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query,
|
||||||
|
final CriteriaBuilder cb) {
|
||||||
return cb.and(specifiction.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target));
|
return cb.and(specifiction.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target));
|
||||||
}
|
}
|
||||||
}, pageable);
|
}, pageable);
|
||||||
@@ -752,7 +746,8 @@ public class DeploymentManagement {
|
|||||||
public Long countActionsByTarget(@NotNull final Specification<Action> spec, @NotNull final Target target) {
|
public Long countActionsByTarget(@NotNull final Specification<Action> spec, @NotNull final Target target) {
|
||||||
return actionRepository.count(new Specification<Action>() {
|
return actionRepository.count(new Specification<Action>() {
|
||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
|
public Predicate toPredicate(final Root<Action> root, final CriteriaQuery<?> query,
|
||||||
|
final CriteriaBuilder cb) {
|
||||||
return cb.and(spec.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target));
|
return cb.and(spec.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -818,8 +813,8 @@ public class DeploymentManagement {
|
|||||||
action.setStatus(Status.CANCELED);
|
action.setStatus(Status.CANCELED);
|
||||||
|
|
||||||
final Target target = action.getTarget();
|
final Target target = action.getTarget();
|
||||||
final List<Action> nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true)
|
final List<Action> nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true).stream()
|
||||||
.stream().filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList());
|
.filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList());
|
||||||
|
|
||||||
if (nextActiveActions.isEmpty()) {
|
if (nextActiveActions.isEmpty()) {
|
||||||
target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet());
|
target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet());
|
||||||
|
|||||||
@@ -219,7 +219,8 @@ public class DistributionSetManagement {
|
|||||||
* @return the found {@link DistributionSet}s
|
* @return the found {@link DistributionSet}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<DistributionSet> findDistributionSetListWithDetails(@NotEmpty final Collection<Long> distributionIdSet) {
|
public List<DistributionSet> findDistributionSetListWithDetails(
|
||||||
|
@NotEmpty final Collection<Long> distributionIdSet) {
|
||||||
return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet));
|
return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +398,8 @@ public class DistributionSetManagement {
|
|||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds, final SoftwareModule softwareModule) {
|
public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds,
|
||||||
|
final SoftwareModule softwareModule) {
|
||||||
final Set<SoftwareModule> softwareModules = new HashSet<SoftwareModule>();
|
final Set<SoftwareModule> softwareModules = new HashSet<SoftwareModule>();
|
||||||
softwareModules.add(softwareModule);
|
softwareModules.add(softwareModule);
|
||||||
ds.removeModule(softwareModule);
|
ds.removeModule(softwareModule);
|
||||||
@@ -429,9 +431,9 @@ public class DistributionSetManagement {
|
|||||||
// throw exception if user tries to update a DS type that is already in
|
// throw exception if user tries to update a DS type that is already in
|
||||||
// use
|
// use
|
||||||
if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) {
|
if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) {
|
||||||
throw new EntityReadOnlyException(String.format(
|
throw new EntityReadOnlyException(
|
||||||
"distribution set type %s set is already assigned to targets and cannot be changed",
|
String.format("distribution set type %s set is already assigned to targets and cannot be changed",
|
||||||
dsType.getName()));
|
dsType.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return distributionSetTypeRepository.save(dsType);
|
return distributionSetTypeRepository.save(dsType);
|
||||||
@@ -597,14 +599,16 @@ public class DistributionSetManagement {
|
|||||||
|
|
||||||
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
|
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
|
||||||
.setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build();
|
.setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build();
|
||||||
final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithInstalledTargets);
|
final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
|
||||||
|
filterWithInstalledTargets);
|
||||||
|
|
||||||
final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null)
|
final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null)
|
||||||
.setAssignedTargetId(assignedOrInstalled).build();
|
.setAssignedTargetId(assignedOrInstalled).build();
|
||||||
final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithAssignedTargets);
|
final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
|
||||||
|
filterWithAssignedTargets);
|
||||||
|
|
||||||
final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder
|
final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null)
|
||||||
.setInstalledTargetId(null).setAssignedTargetId(null).build();
|
.setAssignedTargetId(null).build();
|
||||||
// first fine the distribution sets filtered by the given filter
|
// first fine the distribution sets filtered by the given filter
|
||||||
// parameters
|
// parameters
|
||||||
final Page<DistributionSet> findDistributionSetsByFilters = findDistributionSetsByFilters(pageable,
|
final Page<DistributionSet> findDistributionSetsByFilters = findDistributionSetsByFilters(pageable,
|
||||||
@@ -654,8 +658,8 @@ public class DistributionSetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public DistributionSet findDistributionSetByNameAndVersion(@NotEmpty final String distributionName,
|
public DistributionSet findDistributionSetByNameAndVersion(@NotEmpty final String distributionName,
|
||||||
@NotEmpty final String version) {
|
@NotEmpty final String version) {
|
||||||
final Specification<DistributionSet> spec = DistributionSetSpecification.equalsNameAndVersionIgnoreCase(
|
final Specification<DistributionSet> spec = DistributionSetSpecification
|
||||||
distributionName, version);
|
.equalsNameAndVersionIgnoreCase(distributionName, version);
|
||||||
return distributionSetRepository.findOne(spec);
|
return distributionSetRepository.findOne(spec);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1009,17 +1013,17 @@ public class DistributionSetManagement {
|
|||||||
final Set<SoftwareModule> softwareModules) {
|
final Set<SoftwareModule> softwareModules) {
|
||||||
if (!new HashSet<SoftwareModule>(distributionSet.getModules()).equals(softwareModules)
|
if (!new HashSet<SoftwareModule>(distributionSet.getModules()).equals(softwareModules)
|
||||||
&& actionRepository.countByDistributionSet(distributionSet) > 0) {
|
&& actionRepository.countByDistributionSet(distributionSet) > 0) {
|
||||||
throw new EntityLockedException(String.format(
|
throw new EntityLockedException(
|
||||||
"distribution set %s:%s is already assigned to targets and cannot be changed",
|
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||||
distributionSet.getName(), distributionSet.getVersion()));
|
distributionSet.getName(), distributionSet.getVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) {
|
private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) {
|
||||||
if (actionRepository.countByDistributionSet(distributionSet) > 0) {
|
if (actionRepository.countByDistributionSet(distributionSet) > 0) {
|
||||||
throw new EntityLockedException(String.format(
|
throw new EntityLockedException(
|
||||||
"distribution set %s:%s is already assigned to targets and cannot be changed",
|
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||||
distributionSet.getName(), distributionSet.getVersion()));
|
distributionSet.getName(), distributionSet.getVersion()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1068,8 +1072,8 @@ public class DistributionSetManagement {
|
|||||||
|
|
||||||
private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
|
private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) {
|
||||||
if (distributionSetMetadataRepository.exists(metadataId)) {
|
if (distributionSetMetadataRepository.exists(metadataId)) {
|
||||||
throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataId.getKey()
|
throw new EntityAlreadyExistsException(
|
||||||
+ "' already exists");
|
"Metadata entry with key '" + metadataId.getKey() + "' already exists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1091,7 +1095,8 @@ public class DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
public List<DistributionSet> assignTag(@NotEmpty final Collection<Long> dsIds, @NotNull final DistributionSetTag tag) {
|
public List<DistributionSet> assignTag(@NotEmpty final Collection<Long> dsIds,
|
||||||
|
@NotNull final DistributionSetTag tag) {
|
||||||
final List<DistributionSet> allDs = findDistributionSetListWithDetails(dsIds);
|
final List<DistributionSet> allDs = findDistributionSetListWithDetails(dsIds);
|
||||||
|
|
||||||
allDs.forEach(ds -> ds.getTags().add(tag));
|
allDs.forEach(ds -> ds.getTags().add(tag));
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface DistributionSetTagRepository extends BaseEntityRepository<DistributionSetTag, Long>,
|
public interface DistributionSetTagRepository
|
||||||
JpaSpecificationExecutor<DistributionSetTag> {
|
extends BaseEntityRepository<DistributionSetTag, Long>, JpaSpecificationExecutor<DistributionSetTag> {
|
||||||
/**
|
/**
|
||||||
* deletes the {@link DistributionSet} with the given name.
|
* deletes the {@link DistributionSet} with the given name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -267,8 +267,8 @@ public class TagManagement {
|
|||||||
|
|
||||||
final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag);
|
final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware
|
afterCommit.afterCommit(
|
||||||
.getCurrentTenant(), save)));
|
() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,8 +292,8 @@ public class TagManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final List<DistributionSetTag> save = distributionSetTagRepository.save(distributionSetTags);
|
final List<DistributionSetTag> save = distributionSetTagRepository.save(distributionSetTags);
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware
|
afterCommit.afterCommit(
|
||||||
.getCurrentTenant(), save)));
|
() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save)));
|
||||||
|
|
||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,27 +19,26 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface TargetFilterQueryRepository extends
|
public interface TargetFilterQueryRepository
|
||||||
BaseEntityRepository<TargetFilterQuery, Long>,
|
extends BaseEntityRepository<TargetFilterQuery, Long>, JpaSpecificationExecutor<TargetFilterQuery> {
|
||||||
JpaSpecificationExecutor<TargetFilterQuery> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find customer target filter by name
|
* Find customer target filter by name
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return custom target filter
|
* @return custom target filter
|
||||||
*/
|
*/
|
||||||
TargetFilterQuery findByName(final String name);
|
TargetFilterQuery findByName(final String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find list of all custom target filters.
|
* Find list of all custom target filters.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
Page<TargetFilterQuery> findAll();
|
Page<TargetFilterQuery> findAll();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
<S extends TargetFilterQuery> S save(S entity);
|
<S extends TargetFilterQuery> S save(S entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,8 +205,7 @@ public class TargetManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public Slice<Target> findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery,
|
public Slice<Target> findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery,
|
||||||
@NotNull final Pageable pageable) {
|
@NotNull final Pageable pageable) {
|
||||||
return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class, entityManager),
|
return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class), pageable);
|
||||||
pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,7 +219,7 @@ public class TargetManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public Slice<Target> findTargetsAll(@NotNull final String targetFilterQuery, @NotNull final Pageable pageable) {
|
public Slice<Target> findTargetsAll(@NotNull final String targetFilterQuery, @NotNull final Pageable pageable) {
|
||||||
return findTargetsAll(RSQLUtility.parse(targetFilterQuery, TargetFields.class, entityManager), pageable);
|
return findTargetsAll(RSQLUtility.parse(targetFilterQuery, TargetFields.class), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -624,8 +623,8 @@ public class TargetManagement {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
public List<Target> assignTag(@NotEmpty final Collection<String> targetIds, @NotNull final TargetTag tag) {
|
public List<Target> assignTag(@NotEmpty final Collection<String> targetIds, @NotNull final TargetTag tag) {
|
||||||
final List<Target> allTargets = targetRepository.findAll(TargetSpecifications
|
final List<Target> allTargets = targetRepository
|
||||||
.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds));
|
||||||
|
|
||||||
allTargets.forEach(target -> target.getTags().add(tag));
|
allTargets.forEach(target -> target.getTags().add(tag));
|
||||||
final List<Target> save = targetRepository.save(allTargets);
|
final List<Target> save = targetRepository.save(allTargets);
|
||||||
@@ -679,8 +678,8 @@ public class TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) {
|
public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) {
|
||||||
final List<Target> allTargets = targetRepository.findAll(TargetSpecifications
|
final List<Target> allTargets = targetRepository
|
||||||
.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID)));
|
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID)));
|
||||||
final List<Target> unAssignTag = unAssignTag(allTargets, targetTag);
|
final List<Target> unAssignTag = unAssignTag(allTargets, targetTag);
|
||||||
return unAssignTag.isEmpty() ? null : unAssignTag.get(0);
|
return unAssignTag.isEmpty() ? null : unAssignTag.get(0);
|
||||||
}
|
}
|
||||||
@@ -905,8 +904,7 @@ public class TargetManagement {
|
|||||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
||||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
||||||
|
|
||||||
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
||||||
entityManager);
|
|
||||||
final List<Specification<Target>> specList = new ArrayList<>();
|
final List<Specification<Target>> specList = new ArrayList<>();
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
|
|
||||||
@@ -1080,8 +1078,7 @@ public class TargetManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) {
|
public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) {
|
||||||
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
||||||
entityManager);
|
|
||||||
return targetRepository.count(specs);
|
return targetRepository.count(specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1094,7 +1091,7 @@ public class TargetManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) {
|
public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) {
|
||||||
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class, entityManager);
|
final Specification<Target> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class);
|
||||||
return targetRepository.count(specs);
|
return targetRepository.count(specs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface TargetTagRepository extends BaseEntityRepository<TargetTag, Long>, JpaSpecificationExecutor<TargetTag> {
|
public interface TargetTagRepository
|
||||||
|
extends BaseEntityRepository<TargetTag, Long>, JpaSpecificationExecutor<TargetTag> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes the {@link TargetTag}s with the given tag names.
|
* deletes the {@link TargetTag}s with the given tag names.
|
||||||
*
|
*
|
||||||
* @param tagNames
|
* @param tagNames
|
||||||
* to be deleted
|
* to be deleted
|
||||||
* @return 1 if tag was deleted
|
* @return 1 if tag was deleted
|
||||||
@@ -37,7 +38,7 @@ public interface TargetTagRepository extends BaseEntityRepository<TargetTag, Lon
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* find {@link TargetTag} by its name.
|
* find {@link TargetTag} by its name.
|
||||||
*
|
*
|
||||||
* @param tagName
|
* @param tagName
|
||||||
* to filter on
|
* to filter on
|
||||||
* @return the {@link TargetTag} if found, otherwise null
|
* @return the {@link TargetTag} if found, otherwise null
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ import javax.persistence.UniqueConstraint;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distributionset_tag", indexes = { @Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Table(name = "sp_distributionset_tag", indexes = {
|
||||||
"name", "tenant" }, name = "uk_ds_tag"))
|
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
|
"name", "tenant" }, name = "uk_ds_tag") )
|
||||||
public class DistributionSetTag extends Tag {
|
public class DistributionSetTag extends Tag {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class DistributionSetType extends NamedEntity {
|
|||||||
private boolean deleted = false;
|
private boolean deleted = false;
|
||||||
|
|
||||||
public DistributionSetType() {
|
public DistributionSetType() {
|
||||||
//default public constructor
|
// default public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository.rsql;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -19,18 +18,13 @@ import java.util.stream.Collectors;
|
|||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.MapJoin;
|
||||||
import javax.persistence.criteria.Path;
|
import javax.persistence.criteria.Path;
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
import javax.persistence.metamodel.Attribute.PersistentAttributeType;
|
|
||||||
import javax.persistence.metamodel.ManagedType;
|
|
||||||
import javax.persistence.metamodel.Metamodel;
|
|
||||||
import javax.persistence.metamodel.PluralAttribute;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.FieldNameProvider;
|
import org.eclipse.hawkbit.repository.FieldNameProvider;
|
||||||
import org.eclipse.hawkbit.repository.FieldValueConverter;
|
import org.eclipse.hawkbit.repository.FieldValueConverter;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
@@ -104,20 +98,18 @@ public final class RSQLUtility {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
public static <A extends Enum<A> & FieldNameProvider, T> Specification<T> parse(final String rsql,
|
public static <A extends Enum<A> & FieldNameProvider, T> Specification<T> parse(final String rsql,
|
||||||
final Class<A> fieldNameProvider, final EntityManager entityManager) {
|
final Class<A> fieldNameProvider) {
|
||||||
return new RSQLSpecification<>(rsql, fieldNameProvider, entityManager);
|
return new RSQLSpecification<>(rsql, fieldNameProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class RSQLSpecification<A extends Enum<A> & FieldNameProvider, T> implements Specification<T> {
|
private static final class RSQLSpecification<A extends Enum<A> & FieldNameProvider, T> implements Specification<T> {
|
||||||
|
|
||||||
private final String rsql;
|
private final String rsql;
|
||||||
private final Class<A> enumType;
|
private final Class<A> enumType;
|
||||||
private final EntityManager entityManager;
|
|
||||||
|
|
||||||
private RSQLSpecification(final String rsql, final Class<A> enumType, final EntityManager entityManager) {
|
private RSQLSpecification(final String rsql, final Class<A> enumType) {
|
||||||
this.rsql = rsql;
|
this.rsql = rsql;
|
||||||
this.enumType = enumType;
|
this.enumType = enumType;
|
||||||
this.entityManager = entityManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -141,8 +133,7 @@ public final class RSQLUtility {
|
|||||||
throw new RSQLParameterSyntaxException(e);
|
throw new RSQLParameterSyntaxException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final JpqQueryRSQLVisitor<A, T> jpqQueryRSQLVisitor = new JpqQueryRSQLVisitor<>(root, cb, enumType,
|
final JpqQueryRSQLVisitor<A, T> jpqQueryRSQLVisitor = new JpqQueryRSQLVisitor<>(root, cb, enumType);
|
||||||
entityManager);
|
|
||||||
final List<Predicate> accept = rootNode.<List<Predicate>, String> accept(jpqQueryRSQLVisitor);
|
final List<Predicate> accept = rootNode.<List<Predicate>, String> accept(jpqQueryRSQLVisitor);
|
||||||
|
|
||||||
if (accept != null && !accept.isEmpty()) {
|
if (accept != null && !accept.isEmpty()) {
|
||||||
@@ -165,40 +156,18 @@ public final class RSQLUtility {
|
|||||||
* @param <T>
|
* @param <T>
|
||||||
* the entity type referenced by the root
|
* the entity type referenced by the root
|
||||||
*/
|
*/
|
||||||
private static final class JpqQueryRSQLVisitor<A extends Enum<A> & FieldNameProvider, T> implements
|
private static final class JpqQueryRSQLVisitor<A extends Enum<A> & FieldNameProvider, T>
|
||||||
RSQLVisitor<List<Predicate>, String> {
|
implements RSQLVisitor<List<Predicate>, String> {
|
||||||
public static final Character LIKE_WILDCARD = '*';
|
public static final Character LIKE_WILDCARD = '*';
|
||||||
|
|
||||||
static {
|
|
||||||
/**
|
|
||||||
* Property mapping are done in FieldNameProvider like
|
|
||||||
* TargetFields,SoftwareModuleFields etc.
|
|
||||||
*
|
|
||||||
* In addition to this mapping in PropertyMapper are done if we want
|
|
||||||
* to drill down on entity .
|
|
||||||
*
|
|
||||||
* For example : Drill down on distribution set of target entity are
|
|
||||||
* done by adding the mappings in PropertyMapper as below.
|
|
||||||
*
|
|
||||||
* User can now use assignedds.name and assignedds.version
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PropertyMapper.addNewMapping(Target.class, "assignedds", "assignedDistributionSet");
|
|
||||||
PropertyMapper.addNewMapping(DistributionSet.class, "name", "name");
|
|
||||||
PropertyMapper.addNewMapping(DistributionSet.class, "version", "version");
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Root<T> root;
|
private final Root<T> root;
|
||||||
private final CriteriaBuilder cb;
|
private final CriteriaBuilder cb;
|
||||||
private final Class<A> enumType;
|
private final Class<A> enumType;
|
||||||
private final EntityManager entityManager;
|
|
||||||
|
|
||||||
private JpqQueryRSQLVisitor(final Root<T> root, final CriteriaBuilder cb, final Class<A> enumType,
|
private JpqQueryRSQLVisitor(final Root<T> root, final CriteriaBuilder cb, final Class<A> enumType) {
|
||||||
final EntityManager entityManager) {
|
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.cb = cb;
|
this.cb = cb;
|
||||||
this.enumType = enumType;
|
this.enumType = enumType;
|
||||||
this.entityManager = entityManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -219,134 +188,143 @@ public final class RSQLUtility {
|
|||||||
return toSingleList(cb.conjunction());
|
return toSingleList(cb.conjunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> boolean isItAssociationType(final String property, final ManagedType<T> classMetadata) {
|
private List<Predicate> toSingleList(final Predicate predicate) {
|
||||||
return classMetadata.getAttribute(property).isAssociation();
|
return Collections.singletonList(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> Class<?> getPropertyType(final String property, final ManagedType<T> classMetadata) {
|
private String getAndValidatePropertyFieldName(final A propertyEnum, final ComparisonNode node) {
|
||||||
Class<?> propertyType;
|
String finalProperty = propertyEnum.getFieldName();
|
||||||
if (classMetadata.getAttribute(property).isCollection()) {
|
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||||
propertyType = ((PluralAttribute) classMetadata.getAttribute(property)).getBindableJavaType();
|
|
||||||
} else {
|
|
||||||
propertyType = classMetadata.getAttribute(property).getJavaType();
|
|
||||||
}
|
|
||||||
return propertyType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ManagedType<?> getClassMetaData(final String property, final ManagedType classMetadata,
|
validateMapParamter(propertyEnum, node, graph);
|
||||||
final Metamodel metaModel) {
|
|
||||||
if (isItAssociationType(property, classMetadata)) {
|
// sub entity need minium 1 dot
|
||||||
final Class<?> associationType = getPropertyType(property, classMetadata);
|
if (!propertyEnum.getSubEntityAttributes().isEmpty()) {
|
||||||
return metaModel.managedType(associationType);
|
if (graph.length < 2) {
|
||||||
} else {
|
throw createRSQLParameterUnsupportedException(node);
|
||||||
if (isItEmbeddedType(property, classMetadata)) {
|
|
||||||
final Class<?> embeddedType = getPropertyType(property, classMetadata);
|
|
||||||
return metaModel.managedType(embeddedType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return classMetadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> boolean isItEmbeddedType(final String property, final ManagedType<T> classMetadata) {
|
for (int i = 1; i < graph.length; i++) {
|
||||||
return classMetadata.getAttribute(property).getPersistentAttributeType() == PersistentAttributeType.EMBEDDED;
|
final String propertyField = graph[i];
|
||||||
}
|
finalProperty += FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + propertyField;
|
||||||
|
|
||||||
private String validatePropertyFieldName(final String propertyFieldName, final boolean isDefinedInEnum,
|
// the key of map is not in the graph
|
||||||
ManagedType classMetadata, final Metamodel metaModel, final ComparisonNode node) {
|
if (propertyEnum.isMap() && graph.length == (i + 1)) {
|
||||||
String finalProperty = propertyFieldName;
|
continue;
|
||||||
final String[] graph = propertyFieldName.split("\\.");
|
}
|
||||||
for (String property : graph) {
|
|
||||||
if (!isDefinedInEnum && PropertyMapper.getAllowedcolmns().containsKey(classMetadata.getJavaType())) {
|
if (!propertyEnum.containsSubEntityAttribute(propertyField)) {
|
||||||
if (PropertyMapper.getAllowedcolmns().get(classMetadata.getJavaType()).get(property) != null) {
|
throw createRSQLParameterUnsupportedException(node);
|
||||||
final String mappedValue = PropertyMapper.getAllowedcolmns().get(classMetadata.getJavaType())
|
|
||||||
.get(property);
|
|
||||||
finalProperty = finalProperty.replace(property, mappedValue);
|
|
||||||
property = mappedValue;
|
|
||||||
} else {
|
|
||||||
throw new RSQLParameterUnsupportedFieldException("The given search parameter field {"
|
|
||||||
+ node.getSelector() + "} does not exist, must be one of the following fields {"
|
|
||||||
+ getExpectedFieldList() + "}", new Exception());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
classMetadata = getClassMetaData(property, classMetadata, metaModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return finalProperty;
|
return finalProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path<Object> getFieldPath(final String finalProperty) {
|
private void validateMapParamter(final A propertyEnum, final ComparisonNode node, final String[] graph) {
|
||||||
|
if (!propertyEnum.isMap()) {
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!propertyEnum.getSubEntityAttributes().isEmpty()) {
|
||||||
|
throw new UnsupportedOperationException("Currently subentity attributes for maps are not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
// enum.key
|
||||||
|
final int minAttributeForMap = 2;
|
||||||
|
if (graph.length != minAttributeForMap) {
|
||||||
|
throw new RSQLParameterUnsupportedFieldException("The syntax of the given map search parameter field {"
|
||||||
|
+ node.getSelector() + "} is wrong. Syntax is: fieldname.keyname", new Exception());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RSQLParameterUnsupportedFieldException createRSQLParameterUnsupportedException(
|
||||||
|
final ComparisonNode node) {
|
||||||
|
return new RSQLParameterUnsupportedFieldException(
|
||||||
|
"The given search parameter field {" + node.getSelector()
|
||||||
|
+ "} does not exist, must be one of the following fields {" + getExpectedFieldList() + "}",
|
||||||
|
new Exception());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path<Object> getFieldPath(final A enumField, final String finalProperty) {
|
||||||
Path<Object> fieldPath = null;
|
Path<Object> fieldPath = null;
|
||||||
final String[] split = finalProperty.split("\\.");
|
final String[] split = finalProperty.split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||||
if (split.length == 0) {
|
if (split.length == 0) {
|
||||||
fieldPath = root.get(split[0]);
|
return root.get(split[0]);
|
||||||
} else {
|
}
|
||||||
for (final String fieldNameSplit : split) {
|
|
||||||
// hibernate workaround because cannot get attribute of an
|
for (int i = 0; i < split.length; i++) {
|
||||||
// PluralAttributePath, needs
|
final boolean isMapKeyField = enumField.isMap() && i == (split.length - 1);
|
||||||
// an implicit join.
|
if (isMapKeyField) {
|
||||||
// https://hibernate.atlassian.net/browse/HHH-7892
|
return fieldPath;
|
||||||
if (fieldPath == null && root.get(fieldNameSplit) != null
|
|
||||||
&& Collection.class.isAssignableFrom(root.get(fieldNameSplit).getJavaType())) {
|
|
||||||
fieldPath = root.join(fieldNameSplit);
|
|
||||||
} else {
|
|
||||||
fieldPath = (fieldPath != null) ? fieldPath.get(fieldNameSplit) : root.get(fieldNameSplit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String fieldNameSplit = split[i];
|
||||||
|
fieldPath = (fieldPath != null) ? fieldPath.get(fieldNameSplit) : root.get(fieldNameSplit);
|
||||||
}
|
}
|
||||||
return fieldPath;
|
return fieldPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Predicate> visit(final ComparisonNode node, final String param) {
|
public List<Predicate> visit(final ComparisonNode node, final String param) {
|
||||||
final Metamodel metaModel = entityManager.getMetamodel();
|
|
||||||
final ManagedType<?> classMetadata = metaModel.managedType(root.getJavaType());
|
|
||||||
String propertyFieldName = null;
|
|
||||||
Boolean isDefinedInEnum = Boolean.FALSE;
|
|
||||||
A fieldName = null;
|
A fieldName = null;
|
||||||
try {
|
try {
|
||||||
/**
|
fieldName = getFieldEnumByName(node);
|
||||||
* Get the property mapping from FieldNameProvider .If not
|
|
||||||
* available check in PropertyMapping.If not found throw
|
|
||||||
* RSQLParameterUnsupportedFieldException.
|
|
||||||
*/
|
|
||||||
fieldName = getFieldIdentifierByName(node);
|
|
||||||
propertyFieldName = fieldName.getFieldName();
|
|
||||||
isDefinedInEnum = Boolean.TRUE;
|
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
if (PropertyMapper.getAllowedcolmns().containsKey(classMetadata.getJavaType())) {
|
throw new RSQLParameterUnsupportedFieldException("The given search parameter field {"
|
||||||
propertyFieldName = node.getSelector();
|
+ node.getSelector() + "} does not exist, must be one of the following fields {"
|
||||||
} else {
|
+ Arrays.stream(enumType.getEnumConstants()).map(v -> v.name().toLowerCase())
|
||||||
throw new RSQLParameterUnsupportedFieldException("The given search parameter field {"
|
.collect(Collectors.toList())
|
||||||
+ node.getSelector()
|
+ "}", e);
|
||||||
+ "} does not exist, must be one of the following fields {"
|
|
||||||
+ Arrays.stream(enumType.getEnumConstants()).map(v -> v.name().toLowerCase())
|
|
||||||
.collect(Collectors.toList()) + "}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final String finalProperty = validatePropertyFieldName(propertyFieldName, isDefinedInEnum, classMetadata,
|
final String finalProperty = getAndValidatePropertyFieldName(fieldName, node);
|
||||||
metaModel, node);
|
|
||||||
|
|
||||||
final List<String> values = node.getArguments();
|
final List<String> values = node.getArguments();
|
||||||
final List<Object> transformedValue = new ArrayList<>();
|
final List<Object> transformedValue = new ArrayList<>();
|
||||||
final Path<Object> fieldPath = getFieldPath(finalProperty);
|
final Path<Object> fieldPath = getFieldPath(fieldName, finalProperty);
|
||||||
|
|
||||||
for (final String value : values) {
|
for (final String value : values) {
|
||||||
transformedValue.add(convertValueIfNecessary(node, fieldName, value, fieldPath));
|
transformedValue.add(convertValueIfNecessary(node, fieldName, value, fieldPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapToPredicate(node, fieldPath, node.getArguments(), transformedValue);
|
return mapToPredicate(node, fieldPath, node.getArguments(), transformedValue, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getExpectedFieldList() {
|
private List<String> getExpectedFieldList() {
|
||||||
final List<String> expectedFieldList = Arrays.stream(enumType.getEnumConstants())
|
final List<String> expectedFieldList = Arrays.stream(enumType.getEnumConstants())
|
||||||
.map(v -> v.name().toLowerCase()).collect(Collectors.toList());
|
.filter(enumField -> enumField.getSubEntityAttributes().isEmpty()).map(enumField -> {
|
||||||
expectedFieldList.add("assignedds.name");
|
final String enumFieldName = enumField.name().toLowerCase();
|
||||||
expectedFieldList.add("assignedds.version");
|
|
||||||
|
if (enumField.isMap()) {
|
||||||
|
return enumFieldName + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + "keyName";
|
||||||
|
}
|
||||||
|
|
||||||
|
return enumFieldName;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
final List<String> expectedSubFieldList = Arrays.stream(enumType.getEnumConstants())
|
||||||
|
.filter(enumField -> !enumField.getSubEntityAttributes().isEmpty()).flatMap(enumField -> {
|
||||||
|
final List<String> subEntity = enumField.getSubEntityAttributes().stream()
|
||||||
|
.map(fieldName -> enumField.name().toLowerCase()
|
||||||
|
+ FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + fieldName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
return subEntity.stream();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
expectedFieldList.addAll(expectedSubFieldList);
|
||||||
return expectedFieldList;
|
return expectedFieldList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private A getFieldIdentifierByName(final ComparisonNode node) {
|
private A getFieldEnumByName(final ComparisonNode node) {
|
||||||
final String enumName = node.getSelector().toUpperCase();
|
String enumName = node.getSelector();
|
||||||
|
final String[] graph = enumName.split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||||
|
if (graph.length != 0) {
|
||||||
|
enumName = graph[0];
|
||||||
|
}
|
||||||
LOGGER.debug("get fieldidentifier by name {} of enum type {}", enumName, enumType);
|
LOGGER.debug("get fieldidentifier by name {} of enum type {}", enumName, enumType);
|
||||||
return Enum.valueOf(enumType, enumName);
|
return Enum.valueOf(enumType, enumName.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
@@ -392,66 +370,94 @@ public final class RSQLUtility {
|
|||||||
javaType);
|
javaType);
|
||||||
LOGGER.debug("value cannot be transformed to an enum", e);
|
LOGGER.debug("value cannot be transformed to an enum", e);
|
||||||
|
|
||||||
throw new RSQLParameterUnsupportedFieldException("field {"
|
throw new RSQLParameterUnsupportedFieldException("field {" + node.getSelector()
|
||||||
+ node.getSelector()
|
+ "} must be one of the following values {" + Arrays.stream(tmpEnumType.getEnumConstants())
|
||||||
+ "} must be one of the following values {"
|
.map(v -> v.name().toLowerCase()).collect(Collectors.toList())
|
||||||
+ Arrays.stream(tmpEnumType.getEnumConstants()).map(v -> v.name().toLowerCase())
|
+ "}", e);
|
||||||
.collect(Collectors.toList()) + "}", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Predicate> mapToPredicate(final ComparisonNode node, final Path<Object> fieldPath,
|
private List<Predicate> mapToPredicate(final ComparisonNode node, Path<Object> fieldPath,
|
||||||
final List<String> values, final List<Object> transformedValues) {
|
final List<String> values, final List<Object> transformedValues, final A enumField) {
|
||||||
// only 'equal' and 'notEqual' can handle transformed value like
|
// only 'equal' and 'notEqual' can handle transformed value like
|
||||||
// enums. The JPA API
|
// enums. The JPA API
|
||||||
// cannot handle object types for greaterThan etc methods.
|
// cannot handle object types for greaterThan etc methods.
|
||||||
final Object transformedValue = transformedValues.get(0);
|
final Object transformedValue = transformedValues.get(0);
|
||||||
final String value = values.get(0);
|
final String value = values.get(0);
|
||||||
final List<Predicate> singleList;
|
final List<Predicate> singleList = new ArrayList<>();
|
||||||
|
|
||||||
|
final Predicate mapPredicate = mapToMapPredicate(node, fieldPath, enumField);
|
||||||
|
if (mapPredicate != null) {
|
||||||
|
singleList.add(mapPredicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldPath = getMapValueFieldPath(enumField, fieldPath);
|
||||||
|
|
||||||
switch (node.getOperator().getSymbol()) {
|
switch (node.getOperator().getSymbol()) {
|
||||||
case "=li=":
|
case "=li=":
|
||||||
singleList = toSingleList(cb.like(cb.upper(pathOfString(fieldPath)), transformedValue.toString()
|
singleList.add(cb.like(cb.upper(pathOfString(fieldPath)), transformedValue.toString().toUpperCase()));
|
||||||
.toUpperCase()));
|
|
||||||
break;
|
break;
|
||||||
case "==":
|
case "==":
|
||||||
singleList = getEqualToPredicate(transformedValue, fieldPath);
|
singleList.add(getEqualToPredicate(transformedValue, fieldPath));
|
||||||
break;
|
break;
|
||||||
case "!=":
|
case "!=":
|
||||||
singleList = toSingleList(cb.notEqual(fieldPath, transformedValue));
|
singleList.add(cb.notEqual(fieldPath, transformedValue));
|
||||||
break;
|
break;
|
||||||
case "=gt=":
|
case "=gt=":
|
||||||
singleList = toSingleList(cb.greaterThan(pathOfString(fieldPath), value));
|
singleList.add(cb.greaterThan(pathOfString(fieldPath), value));
|
||||||
break;
|
break;
|
||||||
case "=ge=":
|
case "=ge=":
|
||||||
singleList = toSingleList(cb.greaterThanOrEqualTo(pathOfString(fieldPath), value));
|
singleList.add(cb.greaterThanOrEqualTo(pathOfString(fieldPath), value));
|
||||||
break;
|
break;
|
||||||
case "=lt=":
|
case "=lt=":
|
||||||
singleList = toSingleList(cb.lessThan(pathOfString(fieldPath), value));
|
singleList.add(cb.lessThan(pathOfString(fieldPath), value));
|
||||||
break;
|
break;
|
||||||
case "=le=":
|
case "=le=":
|
||||||
singleList = toSingleList(cb.lessThanOrEqualTo(pathOfString(fieldPath), value));
|
singleList.add(cb.lessThanOrEqualTo(pathOfString(fieldPath), value));
|
||||||
break;
|
break;
|
||||||
case "=in=":
|
case "=in=":
|
||||||
singleList = toSingleList(fieldPath.in(transformedValues));
|
singleList.add(fieldPath.in(transformedValues));
|
||||||
break;
|
break;
|
||||||
case "=out=":
|
case "=out=":
|
||||||
singleList = toSingleList(cb.not(fieldPath.in(transformedValues)));
|
singleList.add(cb.not(fieldPath.in(transformedValues)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOGGER.info("operator symbol {} is either not supported or not implemented");
|
LOGGER.info("operator symbol {} is either not supported or not implemented");
|
||||||
singleList = Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
return singleList;
|
return Collections.unmodifiableList(singleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Predicate> getEqualToPredicate(final Object transformedValue, final Path<Object> fieldPath) {
|
/**
|
||||||
|
* @param enumField
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Path<Object> getMapValueFieldPath(final A enumField, final Path<Object> fieldPath) {
|
||||||
|
if (!enumField.isMap() || enumField.getValueFieldName() == null) {
|
||||||
|
return fieldPath;
|
||||||
|
}
|
||||||
|
return fieldPath.get(enumField.getValueFieldName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Predicate mapToMapPredicate(final ComparisonNode node, final Path<Object> fieldPath,
|
||||||
|
final A enumField) {
|
||||||
|
if (!enumField.isMap()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||||
|
final String keyValue = graph[graph.length - 1];
|
||||||
|
if (fieldPath instanceof MapJoin) {
|
||||||
|
return cb.equal(((MapJoin) fieldPath).key(), keyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cb.equal(fieldPath.get(enumField.getKeyFieldName()), keyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Predicate getEqualToPredicate(final Object transformedValue, final Path<Object> fieldPath) {
|
||||||
if (transformedValue instanceof String) {
|
if (transformedValue instanceof String) {
|
||||||
final String preFormattedValue = ((String) transformedValue).replace(LIKE_WILDCARD, '%');
|
final String preFormattedValue = ((String) transformedValue).replace(LIKE_WILDCARD, '%');
|
||||||
return toSingleList(cb.like(cb.upper(pathOfString(fieldPath)), preFormattedValue.toString()
|
return cb.like(cb.upper(pathOfString(fieldPath)), preFormattedValue.toString().toUpperCase());
|
||||||
.toUpperCase()));
|
|
||||||
} else {
|
|
||||||
return toSingleList(cb.equal(fieldPath, transformedValue));
|
|
||||||
}
|
}
|
||||||
|
return cb.equal(fieldPath, transformedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -473,8 +479,5 @@ public final class RSQLUtility {
|
|||||||
return childs;
|
return childs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate> toSingleList(final Predicate p) {
|
|
||||||
return Collections.singletonList(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,9 +151,10 @@ public final class DistributionSetSpecification {
|
|||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
||||||
final CriteriaBuilder cb) {
|
final CriteriaBuilder cb) {
|
||||||
final Predicate predicate = cb.or(
|
final Predicate predicate = cb
|
||||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.name)), subString.toLowerCase()),
|
.or(cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.name)), subString.toLowerCase()),
|
||||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.version)), subString.toLowerCase()),
|
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.version)),
|
||||||
|
subString.toLowerCase()),
|
||||||
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.description)),
|
cb.like(cb.lower(targetRoot.<String> get(DistributionSet_.description)),
|
||||||
subString.toLowerCase()));
|
subString.toLowerCase()));
|
||||||
return predicate;
|
return predicate;
|
||||||
@@ -215,7 +216,8 @@ public final class DistributionSetSpecification {
|
|||||||
* to be filtered on
|
* to be filtered on
|
||||||
* @return the {@link Specification}
|
* @return the {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<DistributionSet> equalsNameAndVersionIgnoreCase(final String name, final String version) {
|
public static Specification<DistributionSet> equalsNameAndVersionIgnoreCase(final String name,
|
||||||
|
final String version) {
|
||||||
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
final Specification<DistributionSet> spec = new Specification<DistributionSet>() {
|
||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<DistributionSet> targetRoot, final CriteriaQuery<?> query,
|
||||||
@@ -265,8 +267,8 @@ public final class DistributionSetSpecification {
|
|||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
||||||
final CriteriaBuilder cb) {
|
final CriteriaBuilder cb) {
|
||||||
final ListJoin<DistributionSet, TargetInfo> installedTargetJoin = dsRoot.join(
|
final ListJoin<DistributionSet, TargetInfo> installedTargetJoin = dsRoot
|
||||||
DistributionSet_.installedAtTargets, JoinType.INNER);
|
.join(DistributionSet_.installedAtTargets, JoinType.INNER);
|
||||||
final Join<TargetInfo, Target> targetJoin = installedTargetJoin.join(TargetInfo_.target);
|
final Join<TargetInfo, Target> targetJoin = installedTargetJoin.join(TargetInfo_.target);
|
||||||
return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId);
|
return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId);
|
||||||
}
|
}
|
||||||
@@ -287,8 +289,8 @@ public final class DistributionSetSpecification {
|
|||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<DistributionSet> dsRoot, final CriteriaQuery<?> query,
|
||||||
final CriteriaBuilder cb) {
|
final CriteriaBuilder cb) {
|
||||||
final ListJoin<DistributionSet, Target> assignedTargetJoin = dsRoot.join(
|
final ListJoin<DistributionSet, Target> assignedTargetJoin = dsRoot
|
||||||
DistributionSet_.assignedToTargets, JoinType.INNER);
|
.join(DistributionSet_.assignedToTargets, JoinType.INNER);
|
||||||
return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
|
return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ public final class TargetSpecifications {
|
|||||||
*
|
*
|
||||||
* @return the {@link Target} {@link Specification}
|
* @return the {@link Target} {@link Specification}
|
||||||
*/
|
*/
|
||||||
public static Specification<Target> byControllerIdWithStatusAndAssignedInJoin(final Collection<String> controllerIDs) {
|
public static Specification<Target> byControllerIdWithStatusAndAssignedInJoin(
|
||||||
|
final Collection<String> controllerIDs) {
|
||||||
final Specification<Target> spec = new Specification<Target>() {
|
final Specification<Target> spec = new Specification<Target>() {
|
||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
||||||
@@ -162,10 +163,11 @@ public final class TargetSpecifications {
|
|||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
||||||
final CriteriaBuilder cb) {
|
final CriteriaBuilder cb) {
|
||||||
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
final Join<Target, TargetInfo> targetInfoJoin = targetRoot.join(Target_.targetInfo);
|
||||||
final Predicate predicate = cb.or(cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet)
|
final Predicate predicate = cb.or(
|
||||||
.get(DistributionSet_.id), distributionId), cb.equal(
|
cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id),
|
||||||
targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(DistributionSet_.id),
|
distributionId),
|
||||||
distributionId));
|
cb.equal(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
||||||
|
.get(DistributionSet_.id), distributionId));
|
||||||
return predicate;
|
return predicate;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -189,12 +191,10 @@ public final class TargetSpecifications {
|
|||||||
@Override
|
@Override
|
||||||
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
public Predicate toPredicate(final Root<Target> targetRoot, final CriteriaQuery<?> query,
|
||||||
final CriteriaBuilder cb) {
|
final CriteriaBuilder cb) {
|
||||||
final Predicate predicate = cb.and(
|
final Predicate predicate = cb.and(targetRoot.get(Target_.controllerId).in(tIDs),
|
||||||
targetRoot.get(Target_.controllerId).in(tIDs),
|
cb.or(cb.notEqual(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet)
|
||||||
cb.or(cb.notEqual(
|
.get(DistributionSet_.id), distributionId),
|
||||||
targetRoot.<DistributionSet> get(Target_.assignedDistributionSet).get(
|
cb.isNull(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet))));
|
||||||
DistributionSet_.id), distributionId),
|
|
||||||
cb.isNull(targetRoot.<DistributionSet> get(Target_.assignedDistributionSet))));
|
|
||||||
return predicate;
|
return predicate;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see org.springframework.context.EnvironmentAware#setEnvironment(org.
|
* @see org.springframework.context.EnvironmentAware#setEnvironment(org.
|
||||||
* springframework.core.env. Environment)
|
* springframework.core.env. Environment)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -44,16 +44,16 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
|
||||||
import ru.yandex.qatools.allure.annotations.Issue;
|
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Issue;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class testing the functionality of triggering a deployment of
|
* Test class testing the functionality of triggering a deployment of
|
||||||
* {@link DistributionSet}s to {@link Target}s.
|
* {@link DistributionSet}s to {@link Target}s.
|
||||||
@@ -129,21 +129,19 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
final DistributionSet cancelDs = TestDataUtil.generateDistributionSet("Canceled DS", "1.0", softwareManagement,
|
final DistributionSet cancelDs = TestDataUtil.generateDistributionSet("Canceled DS", "1.0", softwareManagement,
|
||||||
distributionSetManagement, new ArrayList<DistributionSetTag>());
|
distributionSetManagement, new ArrayList<DistributionSetTag>());
|
||||||
|
|
||||||
final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2",
|
final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2", softwareManagement,
|
||||||
softwareManagement, distributionSetManagement, new ArrayList<DistributionSetTag>());
|
distributionSetManagement, new ArrayList<DistributionSetTag>());
|
||||||
|
|
||||||
List<Target> targets = targetManagement.createTargets(TestDataUtil
|
List<Target> targets = targetManagement
|
||||||
.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10));
|
.createTargets(TestDataUtil.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10));
|
||||||
|
|
||||||
targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedTargets();
|
targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedTargets();
|
||||||
targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedTargets();
|
targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedTargets();
|
||||||
|
|
||||||
targetManagement.findAllTargetIds().forEach(
|
targetManagement.findAllTargetIds().forEach(targetIdName -> {
|
||||||
targetIdName -> {
|
assertThat(deploymentManagement.findActiveActionsByTarget(
|
||||||
assertThat(
|
targetManagement.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2);
|
||||||
deploymentManagement.findActiveActionsByTarget(targetManagement
|
});
|
||||||
.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -164,8 +162,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
target = targetManagement.createTarget(target);
|
target = targetManagement.createTarget(target);
|
||||||
|
|
||||||
// check initial status
|
// check initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.UNKNOWN);
|
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
|
|
||||||
// assign the two sets in a row
|
// assign the two sets in a row
|
||||||
Action firstAction = assignSet(target, dsFirst);
|
Action firstAction = assignSet(target, dsFirst);
|
||||||
@@ -184,8 +182,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
|
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
|
||||||
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst);
|
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
// we cancel first -> back to installed
|
// we cancel first -> back to installed
|
||||||
deploymentManagement.cancelAction(firstAction,
|
deploymentManagement.cancelAction(firstAction,
|
||||||
@@ -196,10 +194,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
controllerManagement.addCancelActionStatus(
|
controllerManagement.addCancelActionStatus(
|
||||||
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
|
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
|
||||||
assertThat(actionStatusRepository.findAll()).hasSize(6);
|
assertThat(actionStatusRepository.findAll()).hasSize(6);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||||
dsInstalled);
|
.isEqualTo(dsInstalled);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -220,8 +218,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
target = targetManagement.createTarget(target);
|
target = targetManagement.createTarget(target);
|
||||||
|
|
||||||
// check initial status
|
// check initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.UNKNOWN);
|
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
|
|
||||||
// assign the two sets in a row
|
// assign the two sets in a row
|
||||||
Action firstAction = assignSet(target, dsFirst);
|
Action firstAction = assignSet(target, dsFirst);
|
||||||
@@ -240,8 +238,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
|
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
|
||||||
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond);
|
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
// we cancel second -> remain assigned until finished cancellation
|
// we cancel second -> remain assigned until finished cancellation
|
||||||
deploymentManagement.cancelAction(secondAction,
|
deploymentManagement.cancelAction(secondAction,
|
||||||
@@ -254,10 +252,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
controllerManagement.addCancelActionStatus(
|
controllerManagement.addCancelActionStatus(
|
||||||
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
|
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
|
||||||
// cancelled success -> back to dsInstalled
|
// cancelled success -> back to dsInstalled
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||||
dsInstalled);
|
.isEqualTo(dsInstalled);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -270,12 +268,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
target.getTargetInfo().setInstalledDistributionSet(dsInstalled);
|
target.getTargetInfo().setInstalledDistributionSet(dsInstalled);
|
||||||
target = targetManagement.createTarget(target);
|
target = targetManagement.createTarget(target);
|
||||||
|
|
||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement,
|
final DistributionSet ds = TestDataUtil
|
||||||
distributionSetManagement, true).setRequiredMigrationStep(true);
|
.generateDistributionSet("newDS", softwareManagement, distributionSetManagement, true)
|
||||||
|
.setRequiredMigrationStep(true);
|
||||||
|
|
||||||
// verify initial status
|
// verify initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.UNKNOWN);
|
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
|
|
||||||
Action assigningAction = assignSet(target, ds);
|
Action assigningAction = assignSet(target, ds);
|
||||||
|
|
||||||
@@ -295,10 +294,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
// verify
|
// verify
|
||||||
assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED);
|
assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||||
dsInstalled);
|
.isEqualTo(dsInstalled);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -311,12 +310,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
target.getTargetInfo().setInstalledDistributionSet(dsInstalled);
|
target.getTargetInfo().setInstalledDistributionSet(dsInstalled);
|
||||||
target = targetManagement.createTarget(target);
|
target = targetManagement.createTarget(target);
|
||||||
|
|
||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement,
|
final DistributionSet ds = TestDataUtil
|
||||||
distributionSetManagement, true).setRequiredMigrationStep(true);
|
.generateDistributionSet("newDS", softwareManagement, distributionSetManagement, true)
|
||||||
|
.setRequiredMigrationStep(true);
|
||||||
|
|
||||||
// verify initial status
|
// verify initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo(
|
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||||
TargetUpdateStatus.UNKNOWN);
|
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
|
|
||||||
final Action assigningAction = assignSet(target, ds);
|
final Action assigningAction = assignSet(target, ds);
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() });
|
deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() });
|
||||||
assertThat(
|
assertThat(
|
||||||
targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus())
|
targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet())
|
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet())
|
||||||
.isEqualTo(ds);
|
.isEqualTo(ds);
|
||||||
final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0);
|
final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0);
|
||||||
@@ -360,12 +360,12 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
eventBus.register(eventHandlerMock);
|
eventBus.register(eventHandlerMock);
|
||||||
|
|
||||||
final String myCtrlIDPref = "myCtrlID";
|
final String myCtrlIDPref = "myCtrlID";
|
||||||
final Iterable<Target> savedNakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
final Iterable<Target> savedNakedTargets = targetManagement
|
||||||
myCtrlIDPref, "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(10, myCtrlIDPref, "first description"));
|
||||||
|
|
||||||
final String myDeployedCtrlIDPref = "myDeployedCtrlID";
|
final String myDeployedCtrlIDPref = "myDeployedCtrlID";
|
||||||
final List<Target> savedDeployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20,
|
final List<Target> savedDeployedTargets = targetManagement
|
||||||
myDeployedCtrlIDPref, "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(20, myDeployedCtrlIDPref, "first description"));
|
||||||
|
|
||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
@@ -409,15 +409,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
final List<Target> targets = targetManagement.createTargets(TestDataUtil.generateTargets(10));
|
final List<Target> targets = targetManagement.createTargets(TestDataUtil.generateTargets(10));
|
||||||
|
|
||||||
final SoftwareModule ah = softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub",
|
final SoftwareModule ah = softwareManagement
|
||||||
"1.0.1", null, ""));
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||||
final SoftwareModule jvm = softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType,
|
final SoftwareModule jvm = softwareManagement
|
||||||
"oracle-jre", "1.7.2", null, ""));
|
.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||||
final SoftwareModule os = softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2",
|
final SoftwareModule os = softwareManagement
|
||||||
null, ""));
|
.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||||
|
|
||||||
final DistributionSet incomplete = distributionSetManagement.createDistributionSet(new DistributionSet(
|
final DistributionSet incomplete = distributionSetManagement.createDistributionSet(
|
||||||
"incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm)));
|
new DistributionSet("incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deploymentManagement.assignDistributionSet(incomplete, targets);
|
deploymentManagement.assignDistributionSet(incomplete, targets);
|
||||||
@@ -487,18 +487,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
final Iterable<Target> undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs);
|
final Iterable<Target> undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs);
|
||||||
|
|
||||||
// test that number of Targets
|
// test that number of Targets
|
||||||
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).isEqualTo(
|
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown())
|
||||||
deployedTargetsFromDB.spliterator().getExactSizeIfKnown()
|
.isEqualTo(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()
|
||||||
+ undeployedTargetsFromDB.spliterator().getExactSizeIfKnown());
|
+ undeployedTargetsFromDB.spliterator().getExactSizeIfKnown());
|
||||||
assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets);
|
assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets);
|
||||||
assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets);
|
assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets);
|
||||||
|
|
||||||
// test the content of different lists
|
// test the content of different lists
|
||||||
assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB);
|
assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB);
|
||||||
assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets).doesNotContain(
|
assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets)
|
||||||
Iterables.toArray(undeployedTargetsFromDB, Target.class));
|
.doesNotContain(Iterables.toArray(undeployedTargetsFromDB, Target.class));
|
||||||
assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets).doesNotContain(
|
assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets)
|
||||||
Iterables.toArray(deployedTargetsFromDB, Target.class));
|
.doesNotContain(Iterables.toArray(deployedTargetsFromDB, Target.class));
|
||||||
|
|
||||||
// For each of the 4 targets 1 distribution sets gets assigned
|
// For each of the 4 targets 1 distribution sets gets assigned
|
||||||
eventHandlerMock.getEvents(10, TimeUnit.SECONDS);
|
eventHandlerMock.getEvents(10, TimeUnit.SECONDS);
|
||||||
@@ -532,21 +532,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
// verifying the correctness of the assignments
|
// verifying the correctness of the assignments
|
||||||
for (final Target t : deployResWithDsA.getDeployedTargets()) {
|
for (final Target t : deployResWithDsA.getDeployedTargets()) {
|
||||||
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId());
|
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId());
|
||||||
assertThat(
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
.getInstalledDistributionSet()).isNull();
|
||||||
.getInstalledDistributionSet()).isNull();
|
|
||||||
}
|
}
|
||||||
for (final Target t : deployResWithDsB.getDeployedTargets()) {
|
for (final Target t : deployResWithDsB.getDeployedTargets()) {
|
||||||
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId());
|
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId());
|
||||||
assertThat(
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
.getInstalledDistributionSet()).isNull();
|
||||||
.getInstalledDistributionSet()).isNull();
|
|
||||||
}
|
}
|
||||||
for (final Target t : deployResWithDsC.getDeployedTargets()) {
|
for (final Target t : deployResWithDsC.getDeployedTargets()) {
|
||||||
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId());
|
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId());
|
||||||
assertThat(
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
.getInstalledDistributionSet()).isNull();
|
||||||
.getInstalledDistributionSet()).isNull();
|
|
||||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
}
|
}
|
||||||
@@ -559,9 +556,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
for (final Target t_ : updatedTsDsA) {
|
for (final Target t_ : updatedTsDsA) {
|
||||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
|
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
|
||||||
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
|
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
|
||||||
assertThat(
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
.getInstalledDistributionSet()).isEqualTo(dsA);
|
||||||
.getInstalledDistributionSet()).isEqualTo(dsA);
|
|
||||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0);
|
assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0);
|
||||||
@@ -571,8 +567,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
// remove updActB from
|
// remove updActB from
|
||||||
// activeActions, add a corresponding cancelAction and another
|
// activeActions, add a corresponding cancelAction and another
|
||||||
// UpdateAction for dsA
|
// UpdateAction for dsA
|
||||||
final Iterable<Target> deployed2DS = deploymentManagement.assignDistributionSet(dsA,
|
final Iterable<Target> deployed2DS = deploymentManagement
|
||||||
deployResWithDsB.getDeployedTargets()).getAssignedTargets();
|
.assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets();
|
||||||
final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
|
final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
|
||||||
|
|
||||||
assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets());
|
assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets());
|
||||||
@@ -581,9 +577,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
for (final Target t_ : deployed2DS) {
|
for (final Target t_ : deployed2DS) {
|
||||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
|
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
|
||||||
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
|
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
|
||||||
assertThat(
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
||||||
targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
|
.getInstalledDistributionSet()).isNull();
|
||||||
.getInstalledDistributionSet()).isNull();
|
|
||||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
@@ -640,8 +635,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
"blabla alles gut");
|
"blabla alles gut");
|
||||||
}
|
}
|
||||||
// try to delete again
|
// try to delete again
|
||||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs().toArray(
|
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs()
|
||||||
new Long[deploymentResult.getDistributionSetIDs().size()]));
|
.toArray(new Long[deploymentResult.getDistributionSetIDs().size()]));
|
||||||
// verify that the result is the same, even though distributionSet dsA
|
// verify that the result is the same, even though distributionSet dsA
|
||||||
// has been installed
|
// has been installed
|
||||||
// successfully and no activeAction is referring to created distribution
|
// successfully and no activeAction is referring to created distribution
|
||||||
@@ -676,8 +671,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
assertThat(targetManagement.countTargetsAll()).isNotZero();
|
assertThat(targetManagement.countTargetsAll()).isNotZero();
|
||||||
assertThat(actionStatusRepository.count()).isNotZero();
|
assertThat(actionStatusRepository.count()).isNotZero();
|
||||||
|
|
||||||
targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(
|
targetManagement
|
||||||
new Long[noOfUndeployedTargets]));
|
.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets]));
|
||||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets]));
|
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets]));
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).isZero();
|
assertThat(targetManagement.countTargetsAll()).isZero();
|
||||||
@@ -768,8 +763,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
targ = targs.iterator().next();
|
targ = targs.iterator().next();
|
||||||
|
|
||||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||||
assertEquals(TargetUpdateStatus.PENDING, targetManagement.findTargetByControllerID(targ.getControllerId())
|
assertEquals(TargetUpdateStatus.PENDING,
|
||||||
.getTargetInfo().getUpdateStatus());
|
targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus());
|
||||||
assertEquals(dsB, targ.getAssignedDistributionSet());
|
assertEquals(dsB, targ.getAssignedDistributionSet());
|
||||||
assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId())
|
assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId())
|
||||||
.getTargetInfo().getInstalledDistributionSet().getId());
|
.getTargetInfo().getInstalledDistributionSet().getId());
|
||||||
@@ -808,8 +803,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
|
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
// assign ds to create an action
|
// assign ds to create an action
|
||||||
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
|
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement
|
||||||
ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId());
|
.assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId());
|
||||||
final Action action = assignDistributionSet.getActions().get(0);
|
final Action action = assignDistributionSet.getActions().get(0);
|
||||||
// verify preparation
|
// verify preparation
|
||||||
Action findAction = deploymentManagement.findAction(action.getId());
|
Action findAction = deploymentManagement.findAction(action.getId());
|
||||||
@@ -831,8 +826,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
|
final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
// assign ds to create an action
|
// assign ds to create an action
|
||||||
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
|
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement
|
||||||
ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId());
|
.assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId());
|
||||||
final Action action = assignDistributionSet.getActions().get(0);
|
final Action action = assignDistributionSet.getActions().get(0);
|
||||||
// verify perparation
|
// verify perparation
|
||||||
Action findAction = deploymentManagement.findAction(action.getId());
|
Action findAction = deploymentManagement.findAction(action.getId());
|
||||||
@@ -874,11 +869,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
private DeploymentResult prepareComplexRepo(final String undeployedTargetPrefix, final int noOfUndeployedTargets,
|
private DeploymentResult prepareComplexRepo(final String undeployedTargetPrefix, final int noOfUndeployedTargets,
|
||||||
final String deployedTargetPrefix, final int noOfDeployedTargets, final int noOfDistributionSets,
|
final String deployedTargetPrefix, final int noOfDeployedTargets, final int noOfDistributionSets,
|
||||||
final String distributionSetPrefix) {
|
final String distributionSetPrefix) {
|
||||||
final Iterable<Target> nakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(
|
final Iterable<Target> nakedTargets = targetManagement.createTargets(
|
||||||
noOfUndeployedTargets, undeployedTargetPrefix, "first description"));
|
TestDataUtil.buildTargetFixtures(noOfUndeployedTargets, undeployedTargetPrefix, "first description"));
|
||||||
|
|
||||||
List<Target> deployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(
|
List<Target> deployedTargets = targetManagement.createTargets(
|
||||||
noOfDeployedTargets, deployedTargetPrefix, "first description"));
|
TestDataUtil.buildTargetFixtures(noOfDeployedTargets, deployedTargetPrefix, "first description"));
|
||||||
|
|
||||||
// creating 10 DistributionSets
|
// creating 10 DistributionSets
|
||||||
final List<DistributionSet> dsList = TestDataUtil.generateDistributionSets(distributionSetPrefix,
|
final List<DistributionSet> dsList = TestDataUtil.generateDistributionSets(distributionSetPrefix,
|
||||||
@@ -907,10 +902,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
found = true;
|
found = true;
|
||||||
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt);
|
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt);
|
||||||
assertThat(activeActionsByTarget).isNotEmpty();
|
assertThat(activeActionsByTarget).isNotEmpty();
|
||||||
assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()).as(
|
assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId())
|
||||||
"Action id in database and event do not match");
|
.as("Action id in database and event do not match");
|
||||||
assertThat(event.getSoftwareModules()).containsOnly(
|
assertThat(event.getSoftwareModules())
|
||||||
ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId());
|
assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId());
|
||||||
@@ -1078,8 +1073,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
latch.await(timeout, unit);
|
latch.await(timeout, unit);
|
||||||
final List<TargetAssignDistributionSetEvent> handledEvents = new LinkedList<TargetAssignDistributionSetEvent>(
|
final List<TargetAssignDistributionSetEvent> handledEvents = new LinkedList<TargetAssignDistributionSetEvent>(
|
||||||
events);
|
events);
|
||||||
assertThat(handledEvents).hasSize(expectedNumberOfEvents).as(
|
assertThat(handledEvents).hasSize(expectedNumberOfEvents)
|
||||||
"Did not receive the expected amount of events (" + expectedNumberOfEvents
|
.as("Did not receive the expected amount of events (" + expectedNumberOfEvents
|
||||||
+ ") within timeout. Received events are " + handledEvents);
|
+ ") within timeout. Received events are " + handledEvents);
|
||||||
return handledEvents;
|
return handledEvents;
|
||||||
}
|
}
|
||||||
@@ -1106,8 +1101,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
|
|||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
latch.await(timeout, unit);
|
latch.await(timeout, unit);
|
||||||
final List<CancelTargetAssignmentEvent> handledEvents = new LinkedList<CancelTargetAssignmentEvent>(events);
|
final List<CancelTargetAssignmentEvent> handledEvents = new LinkedList<CancelTargetAssignmentEvent>(events);
|
||||||
assertThat(handledEvents).hasSize(expectedNumberOfEvents).as(
|
assertThat(handledEvents).hasSize(expectedNumberOfEvents)
|
||||||
"Did not receive the expected amount of events (" + expectedNumberOfEvents
|
.as("Did not receive the expected amount of events (" + expectedNumberOfEvents
|
||||||
+ ") within timeout. Received events are " + handledEvents);
|
+ ") within timeout. Received events are " + handledEvents);
|
||||||
return handledEvents;
|
return handledEvents;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
new TenantUsage("tenant1").setTargets(100).setActions(200));
|
new TenantUsage("tenant1").setTargets(100).setActions(200));
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, final int updates)
|
private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets,
|
||||||
throws Exception {
|
final int updates) throws Exception {
|
||||||
final Random randomgen = new Random();
|
final Random randomgen = new Random();
|
||||||
final byte random[] = new byte[artifactSize];
|
final byte random[] = new byte[artifactSize];
|
||||||
randomgen.nextBytes(random);
|
randomgen.nextBytes(random);
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for {@link TagManagement}.
|
* Test class for {@link TagManagement}.
|
||||||
*
|
*
|
||||||
@@ -90,32 +90,34 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||||
|
|
||||||
// search for not deleted
|
// search for not deleted
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
Lists.newArrayList(tagA.getName()));
|
.setTagNames(Lists.newArrayList(tagA.getName()));
|
||||||
assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
assertEquals(
|
||||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||||
|
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
Lists.newArrayList(tagB.getName()));
|
.setTagNames(Lists.newArrayList(tagB.getName()));
|
||||||
assertEquals(dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
assertEquals(
|
||||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||||
|
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
Lists.newArrayList(tagC.getName()));
|
.setTagNames(Lists.newArrayList(tagC.getName()));
|
||||||
assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
assertEquals(
|
||||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||||
|
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
Lists.newArrayList(tagX.getName()));
|
.setTagNames(Lists.newArrayList(tagX.getName()));
|
||||||
assertEquals(0,
|
assertEquals(0, distributionSetManagement
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
|
||||||
.getTotalElements());
|
|
||||||
|
|
||||||
assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||||
|
|
||||||
@@ -127,23 +129,24 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
tagManagement.deleteDistributionSetTag(tagB.getName());
|
tagManagement.deleteDistributionSetTag(tagB.getName());
|
||||||
assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
Lists.newArrayList(tagA.getName()));
|
.setTagNames(Lists.newArrayList(tagA.getName()));
|
||||||
assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
assertEquals(
|
||||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||||
|
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
Lists.newArrayList(tagB.getName()));
|
.setTagNames(Lists.newArrayList(tagB.getName()));
|
||||||
assertEquals(0,
|
assertEquals(0, distributionSetManagement
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
|
||||||
.getTotalElements());
|
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames(
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
Lists.newArrayList(tagC.getName()));
|
.setTagNames(Lists.newArrayList(tagC.getName()));
|
||||||
assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
assertEquals(
|
||||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||||
|
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
}
|
}
|
||||||
@@ -206,8 +209,8 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
// check
|
// check
|
||||||
for (final Target target : targetRepository.findAll()) {
|
for (final Target target : targetRepository.findAll()) {
|
||||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()).doesNotContain(
|
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags())
|
||||||
toDelete);
|
.doesNotContain(toDelete);
|
||||||
}
|
}
|
||||||
assertThat(targetTagRepository.findOne(toDelete.getId())).isNull();
|
assertThat(targetTagRepository.findOne(toDelete.getId())).isNull();
|
||||||
assertThat(tagManagement.findAllTargetTags()).hasSize(19);
|
assertThat(tagManagement.findAllTargetTags()).hasSize(19);
|
||||||
@@ -278,8 +281,8 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
final DistributionSetTag toDelete = tags.iterator().next();
|
final DistributionSetTag toDelete = tags.iterator().next();
|
||||||
|
|
||||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()).contains(
|
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags())
|
||||||
toDelete);
|
.contains(toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
@@ -359,8 +362,8 @@ public class TagManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
final List<DistributionSet> sets = TestDataUtil.generateDistributionSets(20, softwareManagement,
|
final List<DistributionSet> sets = TestDataUtil.generateDistributionSets(20, softwareManagement,
|
||||||
distributionSetManagement);
|
distributionSetManagement);
|
||||||
final Iterable<DistributionSetTag> tags = tagManagement.createDistributionSetTags(TestDataUtil
|
final Iterable<DistributionSetTag> tags = tagManagement
|
||||||
.generateDistributionSetTags(20));
|
.createDistributionSetTags(TestDataUtil.generateDistributionSetTags(20));
|
||||||
|
|
||||||
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag));
|
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag));
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ public class TargetFilterQueryManagenmentTest extends AbstractIntegrationTest {
|
|||||||
final String newQuery = "status==UNKNOWN";
|
final String newQuery = "status==UNKNOWN";
|
||||||
targetFilterQuery.setQuery(newQuery);
|
targetFilterQuery.setQuery(newQuery);
|
||||||
targetFilterQueryManagement.updateTargetFilterQuery(targetFilterQuery);
|
targetFilterQueryManagement.updateTargetFilterQuery(targetFilterQuery);
|
||||||
assertEquals("Returns updated target filter query", newQuery, targetFilterQueryManagement
|
assertEquals("Returns updated target filter query", newQuery,
|
||||||
.findTargetFilterQueryByName(filterName).getQuery());
|
targetFilterQueryManagement.findTargetFilterQueryByName(filterName).getQuery());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
@Features("Component Tests - Repository")
|
@Features("Component Tests - Repository")
|
||||||
@Stories("Target Management")
|
@Stories("Target Management")
|
||||||
public class TargetManagementTest extends AbstractIntegrationTest {
|
public class TargetManagementTest extends AbstractIntegrationTest {
|
||||||
@@ -158,8 +158,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
|
|
||||||
final Action action = result.getActions().get(0);
|
final Action action = result.getActions().get(0);
|
||||||
action.setStatus(Status.FINISHED);
|
action.setStatus(Status.FINISHED);
|
||||||
controllerManagament.addUpdateActionStatus(new ActionStatus(action, Status.FINISHED,
|
controllerManagament.addUpdateActionStatus(
|
||||||
System.currentTimeMillis(), "message"), action);
|
new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action);
|
||||||
deploymentManagement.assignDistributionSet(set2.getId(), "4711");
|
deploymentManagement.assignDistributionSet(set2.getId(), "4711");
|
||||||
|
|
||||||
target = targetManagement.findTargetByControllerIDWithDetails("4711");
|
target = targetManagement.findTargetByControllerIDWithDetails("4711");
|
||||||
@@ -341,8 +341,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
targetManagement.deleteTargets(deletedTargetIDs);
|
targetManagement.deleteTargets(deletedTargetIDs);
|
||||||
|
|
||||||
allFound = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent();
|
allFound = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent();
|
||||||
assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del, allFound.spliterator()
|
assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del,
|
||||||
.getExactSizeIfKnown());
|
allFound.spliterator().getExactSizeIfKnown());
|
||||||
|
|
||||||
// verify that all undeleted are still found
|
// verify that all undeleted are still found
|
||||||
assertThat(allFound).doesNotContain(deletedTargets);
|
assertThat(allFound).doesNotContain(deletedTargets);
|
||||||
@@ -351,8 +351,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Stores target attributes and verfies existence in the repository.")
|
@Description("Stores target attributes and verfies existence in the repository.")
|
||||||
public void savingTargetControllerAttributes() {
|
public void savingTargetControllerAttributes() {
|
||||||
Iterable<Target> ts = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(100, "myCtrlID",
|
Iterable<Target> ts = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(100, "myCtrlID", "first description"));
|
||||||
|
|
||||||
final Map<String, String> attribs = new HashMap<String, String>();
|
final Map<String, String> attribs = new HashMap<String, String>();
|
||||||
attribs.put("a.b.c", "abc");
|
attribs.put("a.b.c", "abc");
|
||||||
@@ -438,8 +438,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
final Target tNoAttrib = targetManagement.findTargetByControllerID(tNoAttribl.getControllerId());
|
final Target tNoAttrib = targetManagement.findTargetByControllerID(tNoAttribl.getControllerId());
|
||||||
|
|
||||||
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
|
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
|
||||||
assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray()).doesNotContain(
|
assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray())
|
||||||
attribs2Del.toArray());
|
.doesNotContain(attribs2Del.toArray());
|
||||||
continue restTarget_;
|
continue restTarget_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,14 +452,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
Target t1 = TestDataUtil.buildTargetFixture("id-1", "blablub");
|
Target t1 = TestDataUtil.buildTargetFixture("id-1", "blablub");
|
||||||
final int noT2Tags = 4;
|
final int noT2Tags = 4;
|
||||||
final int noT1Tags = 3;
|
final int noT1Tags = 3;
|
||||||
final List<TargetTag> t1Tags = tagManagement.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT1Tags,
|
final List<TargetTag> t1Tags = tagManagement
|
||||||
"tag1"));
|
.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT1Tags, "tag1"));
|
||||||
t1.getTags().addAll(t1Tags);
|
t1.getTags().addAll(t1Tags);
|
||||||
t1 = targetManagement.createTarget(t1);
|
t1 = targetManagement.createTarget(t1);
|
||||||
|
|
||||||
Target t2 = TestDataUtil.buildTargetFixture("id-2", "blablub");
|
Target t2 = TestDataUtil.buildTargetFixture("id-2", "blablub");
|
||||||
final List<TargetTag> t2Tags = tagManagement.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT2Tags,
|
final List<TargetTag> t2Tags = tagManagement
|
||||||
"tag2"));
|
.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT2Tags, "tag2"));
|
||||||
t2.getTags().addAll(t2Tags);
|
t2.getTags().addAll(t2Tags);
|
||||||
t2 = targetManagement.createTarget(t2);
|
t2 = targetManagement.createTarget(t2);
|
||||||
|
|
||||||
@@ -475,18 +475,18 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests the assigment of tags to multiple targets.")
|
@Description("Tests the assigment of tags to multiple targets.")
|
||||||
public void targetTagBulkAssignments() {
|
public void targetTagBulkAssignments() {
|
||||||
final List<Target> tagATargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
final List<Target> tagATargets = targetManagement
|
||||||
"tagATargets", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagATargets", "first description"));
|
||||||
final List<Target> tagBTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
final List<Target> tagBTargets = targetManagement
|
||||||
"tagBTargets", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagBTargets", "first description"));
|
||||||
final List<Target> tagCTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
final List<Target> tagCTargets = targetManagement
|
||||||
"tagCTargets", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagCTargets", "first description"));
|
||||||
|
|
||||||
final List<Target> tagABTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
final List<Target> tagABTargets = targetManagement
|
||||||
"tagABTargets", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagABTargets", "first description"));
|
||||||
|
|
||||||
final List<Target> tagABCTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10,
|
final List<Target> tagABCTargets = targetManagement
|
||||||
"tagABCTargets", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(10, "tagABCTargets", "first description"));
|
||||||
|
|
||||||
final TargetTag tagA = tagManagement.createTargetTag(new TargetTag("A"));
|
final TargetTag tagA = tagManagement.createTargetTag(new TargetTag("A"));
|
||||||
final TargetTag tagB = tagManagement.createTargetTag(new TargetTag("B"));
|
final TargetTag tagB = tagManagement.createTargetTag(new TargetTag("B"));
|
||||||
@@ -534,12 +534,12 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
checkTargetHasNotTags(tagCTargets, tagA, tagB);
|
checkTargetHasNotTags(tagCTargets, tagA, tagB);
|
||||||
|
|
||||||
// check again target lists refreshed from DB
|
// check again target lists refreshed from DB
|
||||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A")).isEqualTo(
|
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A"))
|
||||||
targetWithTagA.size());
|
.isEqualTo(targetWithTagA.size());
|
||||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B")).isEqualTo(
|
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B"))
|
||||||
targetWithTagB.size());
|
.isEqualTo(targetWithTagB.size());
|
||||||
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C")).isEqualTo(
|
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C"))
|
||||||
targetWithTagC.size());
|
.isEqualTo(targetWithTagC.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -549,21 +549,21 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
final TargetTag targTagB = tagManagement.createTargetTag(new TargetTag("Targ-B-Tag"));
|
final TargetTag targTagB = tagManagement.createTargetTag(new TargetTag("Targ-B-Tag"));
|
||||||
final TargetTag targTagC = tagManagement.createTargetTag(new TargetTag("Targ-C-Tag"));
|
final TargetTag targTagC = tagManagement.createTargetTag(new TargetTag("Targ-C-Tag"));
|
||||||
|
|
||||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
final List<Target> targAs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||||
final List<Target> targBs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20, "target-id-B",
|
final List<Target> targBs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(20, "target-id-B", "first description"));
|
||||||
final List<Target> targCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(15, "target-id-C",
|
final List<Target> targCs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(15, "target-id-C", "first description"));
|
||||||
|
|
||||||
final List<Target> targABs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(12,
|
final List<Target> targABs = targetManagement
|
||||||
"target-id-AB", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(12, "target-id-AB", "first description"));
|
||||||
final List<Target> targACs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(13,
|
final List<Target> targACs = targetManagement
|
||||||
"target-id-AC", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(13, "target-id-AC", "first description"));
|
||||||
final List<Target> targBCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(7, "target-id-BC",
|
final List<Target> targBCs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(7, "target-id-BC", "first description"));
|
||||||
final List<Target> targABCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(17,
|
final List<Target> targABCs = targetManagement
|
||||||
"target-id-ABC", "first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(17, "target-id-ABC", "first description"));
|
||||||
|
|
||||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||||
targetManagement.toggleTagAssignment(targABs, targTagA);
|
targetManagement.toggleTagAssignment(targABs, targTagA);
|
||||||
@@ -610,29 +610,27 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
public void findTargetsByControllerIDsWithTags() {
|
public void findTargetsByControllerIDsWithTags() {
|
||||||
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag"));
|
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag"));
|
||||||
|
|
||||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
final List<Target> targAs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||||
|
|
||||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||||
|
|
||||||
assertThat(
|
assertThat(targetManagement.findTargetsByControllerIDsWithTags(
|
||||||
targetManagement.findTargetsByControllerIDsWithTags(targAs.stream()
|
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25);
|
||||||
.map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25);
|
|
||||||
|
|
||||||
// no lazy loading exception and tag correctly assigned
|
// no lazy loading exception and tag correctly assigned
|
||||||
assertThat(
|
assertThat(targetManagement
|
||||||
targetManagement
|
.findTargetsByControllerIDsWithTags(
|
||||||
.findTargetsByControllerIDsWithTags(
|
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))
|
||||||
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))
|
.stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList()))
|
||||||
.stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList()))
|
.containsOnly(true);
|
||||||
.containsOnly(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Test the optimized quere for retrieving all ID/name pairs of targets.")
|
@Description("Test the optimized quere for retrieving all ID/name pairs of targets.")
|
||||||
public void findAllTargetIdNamePaiss() {
|
public void findAllTargetIdNamePaiss() {
|
||||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
final List<Target> targAs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||||
final String[] createdTargetIds = targAs.stream().map(t -> t.getControllerId())
|
final String[] createdTargetIds = targAs.stream().map(t -> t.getControllerId())
|
||||||
.toArray(size -> new String[size]);
|
.toArray(size -> new String[size]);
|
||||||
|
|
||||||
@@ -648,15 +646,15 @@ public class TargetManagementTest extends AbstractIntegrationTest {
|
|||||||
public void findTargetsWithNoTag() {
|
public void findTargetsWithNoTag() {
|
||||||
|
|
||||||
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag"));
|
final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag"));
|
||||||
final List<Target> targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A",
|
final List<Target> targAs = targetManagement
|
||||||
"first description"));
|
.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description"));
|
||||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||||
|
|
||||||
targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-B", "first description"));
|
targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-B", "first description"));
|
||||||
|
|
||||||
final String[] tagNames = null;
|
final String[] tagNames = null;
|
||||||
final List<Target> targetsListWithNoTag = targetManagement.findTargetByFilters(new PageRequest(0, 500), null,
|
final List<Target> targetsListWithNoTag = targetManagement
|
||||||
null, null, Boolean.TRUE, tagNames).getContent();
|
.findTargetByFilters(new PageRequest(0, 500), null, null, null, Boolean.TRUE, tagNames).getContent();
|
||||||
|
|
||||||
// Total targets
|
// Total targets
|
||||||
assertEquals(50, targetManagement.findAllTargetIds().size());
|
assertEquals(50, targetManagement.findAllTargetIds().size());
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.repository.ActionFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter actions")
|
||||||
|
public class RSQLActionFieldsTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
private Target target;
|
||||||
|
private Action action;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setupBeforeTest() {
|
||||||
|
target = new Target("targetId123");
|
||||||
|
target.setDescription("targetId123");
|
||||||
|
targetManagement.createTarget(target);
|
||||||
|
action = new Action();
|
||||||
|
action.setActionType(ActionType.SOFT);
|
||||||
|
target.getActions().add(action);
|
||||||
|
action.setTarget(target);
|
||||||
|
actionRepository.save(action);
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
final Action newAction = new Action();
|
||||||
|
newAction.setActionType(ActionType.SOFT);
|
||||||
|
newAction.setActive(i % 2 == 0);
|
||||||
|
newAction.setTarget(target);
|
||||||
|
actionRepository.save(newAction);
|
||||||
|
target.getActions().add(newAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter action by id")
|
||||||
|
public void testFilterByParameterId() {
|
||||||
|
assertRSQLQuery(ActionFields.ID.name() + "==" + action.getId(), 1);
|
||||||
|
assertRSQLQuery(ActionFields.ID.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(ActionFields.ID.name() + "=in=(" + action.getId() + ",1000000)", 1);
|
||||||
|
assertRSQLQuery(ActionFields.ID.name() + "=out=(" + action.getId() + ",1000000)", 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test action by status")
|
||||||
|
public void testFilterByParameterStatus() {
|
||||||
|
assertRSQLQuery(ActionFields.STATUS.name() + "==pending", 5);
|
||||||
|
assertRSQLQuery(ActionFields.STATUS.name() + "=in=(pending)", 5);
|
||||||
|
assertRSQLQuery(ActionFields.STATUS.name() + "=out=(pending)", 6);
|
||||||
|
|
||||||
|
try {
|
||||||
|
assertRSQLQuery(ActionFields.STATUS.name() + "==true", 5);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
|
final Specification<Action> parse = RSQLUtility.parse(rsqlParam, ActionFields.class);
|
||||||
|
final Slice<Action> findEnitity = deploymentManagement.findActionsByTarget(parse, target,
|
||||||
|
new PageRequest(0, 100));
|
||||||
|
final long countAllEntities = deploymentManagement.countActionsByTarget(parse, target);
|
||||||
|
assertThat(findEnitity).isNotNull();
|
||||||
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter distribution set")
|
||||||
|
public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void seuptBeforeTest() {
|
||||||
|
|
||||||
|
final DistributionSet ds = TestDataUtil.generateDistributionSet("DS", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
ds.setDescription("DS");
|
||||||
|
ds.getMetadata().add(new DistributionSetMetadata("metaKey", ds, "metaValue"));
|
||||||
|
distributionSetManagement.updateDistributionSet(ds);
|
||||||
|
|
||||||
|
final DistributionSet ds2 = TestDataUtil
|
||||||
|
.generateDistributionSets("NewDS", 3, softwareManagement, distributionSetManagement).get(0);
|
||||||
|
|
||||||
|
ds2.setDescription("DS2");
|
||||||
|
ds2.getMetadata().add(new DistributionSetMetadata("metaKey", ds2, "value"));
|
||||||
|
distributionSetManagement.updateDistributionSet(ds2);
|
||||||
|
|
||||||
|
final DistributionSetTag targetTag = tagManagement.createDistributionSetTag(new DistributionSetTag("Tag1"));
|
||||||
|
tagManagement.createDistributionSetTag(new DistributionSetTag("Tag2"));
|
||||||
|
tagManagement.createDistributionSetTag(new DistributionSetTag("Tag3"));
|
||||||
|
tagManagement.createDistributionSetTag(new DistributionSetTag("Tag4"));
|
||||||
|
|
||||||
|
distributionSetManagement.assignTag(Arrays.asList(ds.getId(), ds2.getId()), targetTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by id")
|
||||||
|
public void testFilterByParameterId() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.ID.name() + "==*", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by name")
|
||||||
|
public void testFilterByParameterName() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.NAME.name() + "==DS", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.NAME.name() + "==*DS", 4);
|
||||||
|
assertRSQLQuery(DistributionSetFields.NAME.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(DistributionSetFields.NAME.name() + "=in=(DS,notexist)", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.NAME.name() + "=out=(DS,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by description")
|
||||||
|
public void testFilterByParameterDescription() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.DESCRIPTION.name() + "==DS", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.DESCRIPTION.name() + "==DS*", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.DESCRIPTION.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(DistributionSetFields.DESCRIPTION.name() + "=in=(DS,notexist)", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.DESCRIPTION.name() + "=out=(DS,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by version")
|
||||||
|
public void testFilterByParameterVersion() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.VERSION.name() + "==v1.0", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.VERSION.name() + "!=v1.0", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.VERSION.name() + "=in=(v1.0,v1.1)", 3);
|
||||||
|
assertRSQLQuery(DistributionSetFields.VERSION.name() + "=out=(v1.0,error)", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by complete property")
|
||||||
|
public void testFilterByAttribute() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==true", 4);
|
||||||
|
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=in=(true)", 4);
|
||||||
|
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=out=(true)", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by tag")
|
||||||
|
public void testFilterByTag() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.TAG.name() + "==Tag1", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TAG.name() + "==T*", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TAG.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TAG.name() + "=in=(Tag1,notexist)", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TAG.name() + "=out=(Tag1,notexist)", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by type")
|
||||||
|
public void testFilterByType() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.TYPE.name() + "==ecl_os_app_jvm", 4);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TYPE.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TYPE.name() + "=in=(ecl_os_app_jvm,ecl)", 4);
|
||||||
|
assertRSQLQuery(DistributionSetFields.TYPE.name() + "=out=(ecl_os_app_jvm)", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("")
|
||||||
|
public void testFilterByMetadata() {
|
||||||
|
assertRSQLQuery(DistributionSetFields.METADATA.name() + ".metaKey==metaValue", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.METADATA.name() + ".metaKey==*v*", 2);
|
||||||
|
assertRSQLQuery(DistributionSetFields.METADATA.name() + ".metaKey==noExist*", 0);
|
||||||
|
assertRSQLQuery(DistributionSetFields.METADATA.name() + ".metaKey=in=(metaValue,notexist)", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.METADATA.name() + ".metaKey=out=(metaValue,notexist)", 1);
|
||||||
|
assertRSQLQuery(DistributionSetFields.METADATA.name() + ".notExist==metaValue", 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||||
|
final Page<DistributionSet> find = distributionSetManagement.findDistributionSetsAll(
|
||||||
|
RSQLUtility.parse(rsqlParam, DistributionSetFields.class), new PageRequest(0, 100), false);
|
||||||
|
final long countAll = find.getTotalElements();
|
||||||
|
assertThat(find).isNotNull();
|
||||||
|
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter distribution set metadata")
|
||||||
|
public class RSQLDistributionSetMetadataFieldsTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
private Long distributionSetId;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setupBeforeTest() {
|
||||||
|
final DistributionSet distributionSet = TestDataUtil.generateDistributionSet("DS", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
distributionSetId = distributionSet.getId();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
final DistributionSetMetadata distributionSetMetadata = new DistributionSetMetadata("" + i, distributionSet,
|
||||||
|
"" + i);
|
||||||
|
distributionSet.getMetadata().add(distributionSetMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
distributionSetManagement.updateDistributionSet(distributionSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set metadata by key")
|
||||||
|
public void testFilterByParameterKey() {
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "==1", 1);
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "!=1", 4);
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "=in=(1,2)", 2);
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.KEY.name() + "=out=(1,2)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set metadata by value")
|
||||||
|
public void testFilterByParameterValue() {
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "==1", 1);
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "!=1", 4);
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "=in=(1,2)", 2);
|
||||||
|
assertRSQLQuery(DistributionSetMetadataFields.VALUE.name() + "=out=(1,2)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
|
final Page<DistributionSetMetadata> findEnitity = distributionSetManagement
|
||||||
|
.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
||||||
|
RSQLUtility.parse(rsqlParam, DistributionSetMetadataFields.class), new PageRequest(0, 100));
|
||||||
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
|
assertThat(findEnitity).isNotNull();
|
||||||
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter software module")
|
||||||
|
public class RSQLSoftwareModuleFieldTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void seuptBeforeTest() {
|
||||||
|
|
||||||
|
final SoftwareModule ah = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", "agent-hub", ""));
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", "aa", ""));
|
||||||
|
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", "aa", ""));
|
||||||
|
|
||||||
|
final SoftwareModule ah2 = softwareManagement
|
||||||
|
.createSoftwareModule(new SoftwareModule(appType, "agent-hub2", "1.0.1", "agent-hub2", ""));
|
||||||
|
|
||||||
|
final SoftwareModuleMetadata softwareModuleMetadata = new SoftwareModuleMetadata("metaKey", ah, "metaValue");
|
||||||
|
softwareManagement.createSoftwareModuleMetadata(softwareModuleMetadata);
|
||||||
|
ah.getMetadata().add(softwareModuleMetadata);
|
||||||
|
softwareManagement.updateSoftwareModule(ah);
|
||||||
|
|
||||||
|
final SoftwareModuleMetadata softwareModuleMetadata2 = new SoftwareModuleMetadata("metaKey", ah2, "value");
|
||||||
|
softwareManagement.createSoftwareModuleMetadata(softwareModuleMetadata2);
|
||||||
|
ah2.getMetadata().add(softwareModuleMetadata2);
|
||||||
|
softwareManagement.updateSoftwareModule(ah2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module by id")
|
||||||
|
public void testFilterByParameterId() {
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.ID.name() + "==*", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module by name")
|
||||||
|
public void testFilterByParameterName() {
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub*", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "=in=(agent-hub,notexist)", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.NAME.name() + "=out=(agent-hub,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module by description")
|
||||||
|
public void testFilterByParameterDescription() {
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==agent-hub", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "=in=(agent-hub,notexist)", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "=out=(agent-hub,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module by version")
|
||||||
|
public void testFilterByParameterVersion() {
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "==1.0.1", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "!=v1.0", 4);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "=in=(1.0.1,1.0.2)", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "=out=(1.0.1)", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module by type")
|
||||||
|
public void testFilterByType() {
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==application", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "=in=(application)", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "=out=(application)", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("")
|
||||||
|
public void testFilterByMetadata() {
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey==metaValue", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey==*v*", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey==noExist*", 0);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey=in=(metaValue,notexist)", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey=out=(metaValue,notexist)", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".notExist==metaValue", 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||||
|
final Page<SoftwareModule> find = softwareManagement.findSoftwareModulesByPredicate(
|
||||||
|
RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), new PageRequest(0, 100));
|
||||||
|
final long countAll = find.getTotalElements();
|
||||||
|
assertThat(find).isNotNull();
|
||||||
|
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
|
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter software module metadata")
|
||||||
|
public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
private Long softwareModuleId;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setupBeforeTest() {
|
||||||
|
final SoftwareModule softwareModule = softwareManagement.createSoftwareModule(
|
||||||
|
new SoftwareModule(TestDataUtil.findOrCreateSoftwareModuleType(softwareManagement, "application"),
|
||||||
|
"application", "1.0.0", "Desc", "vendor Limited, California"));
|
||||||
|
softwareModuleId = softwareModule.getId();
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
final SoftwareModuleMetadata metadata = new SoftwareModuleMetadata("" + i, softwareModule, "" + i);
|
||||||
|
softwareModule.getMetadata().add(metadata);
|
||||||
|
softwareModuleMetadataRepository.save(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
softwareManagement.updateSoftwareModule(softwareModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module metadata by key")
|
||||||
|
public void testFilterByParameterKey() {
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "==1", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "!=1", 4);
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "=in=(1,2)", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.KEY.name() + "=out=(1,2)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test fitler software module metadata status by value")
|
||||||
|
public void testFilterByParameterValue() {
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "==1", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "!=1", 4);
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "=in=(1,2)", 2);
|
||||||
|
assertRSQLQuery(SoftwareModuleMetadataFields.VALUE.name() + "=out=(1,2)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
|
final Page<SoftwareModuleMetadata> findEnitity = softwareManagement
|
||||||
|
.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
|
||||||
|
RSQLUtility.parse(rsqlParam, SoftwareModuleMetadataFields.class), new PageRequest(0, 100));
|
||||||
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
|
assertThat(findEnitity).isNotNull();
|
||||||
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter software module test type")
|
||||||
|
public class RSQLSoftwareModuleTypeFieldsTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module test type by id")
|
||||||
|
public void testFilterByParameterId() {
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==*", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module test type by name")
|
||||||
|
public void testFilterByParameterName() {
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "==ECL*", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module test type by description")
|
||||||
|
public void testFilterByParameterDescription() {
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==Updated*", 3);
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==noExist*", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module test type by key")
|
||||||
|
public void testFilterByParameterKey() {
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "==os", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "=in=(os)", 1);
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "=out=(os)", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter software module test type by max")
|
||||||
|
public void testFilterByMaxAssignment() {
|
||||||
|
assertRSQLQuery(SoftwareModuleTypeFields.MAX.name() + "==1", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||||
|
final Page<SoftwareModuleType> find = softwareManagement.findSoftwareModuleTypesByPredicate(
|
||||||
|
RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class), new PageRequest(0, 100));
|
||||||
|
final long countAll = find.getTotalElements();
|
||||||
|
assertThat(find).isNotNull();
|
||||||
|
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.repository.TagFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter target and distribution set tags")
|
||||||
|
public class RSQLTagFieldsTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void seuptBeforeTest() {
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
final TargetTag targetTag = new TargetTag("" + i, "" + i, i % 2 == 0 ? "red" : "blue");
|
||||||
|
tagManagement.createTargetTag(targetTag);
|
||||||
|
final DistributionSetTag distributionSetTag = new DistributionSetTag("" + i, "" + i,
|
||||||
|
i % 2 == 0 ? "red" : "blue");
|
||||||
|
tagManagement.createDistributionSetTag(distributionSetTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target tag by name")
|
||||||
|
public void testFilterTargetTagByParameterName() {
|
||||||
|
assertRSQLQueryTarget(TagFields.NAME.name() + "==1", 1);
|
||||||
|
assertRSQLQueryTarget(TagFields.NAME.name() + "==*", 5);
|
||||||
|
assertRSQLQueryTarget(TagFields.NAME.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQueryTarget(TagFields.NAME.name() + "=in=(1,notexist)", 1);
|
||||||
|
assertRSQLQueryTarget(TagFields.NAME.name() + "=out=(1,notexist)", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target tag by description")
|
||||||
|
public void testFilterTargetTagByParameterDescription() {
|
||||||
|
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==1", 1);
|
||||||
|
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==*", 5);
|
||||||
|
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "=in=(1,notexist)", 1);
|
||||||
|
assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "=out=(1,notexist)", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target tag by colour")
|
||||||
|
public void testFilterTargetTagByParameterColour() {
|
||||||
|
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==red", 3);
|
||||||
|
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==r*", 3);
|
||||||
|
assertRSQLQueryTarget(TagFields.COLOUR.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQueryTarget(TagFields.COLOUR.name() + "=in=(red,notexist)", 3);
|
||||||
|
assertRSQLQueryTarget(TagFields.COLOUR.name() + "=out=(red,notexist)", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set tag by name")
|
||||||
|
public void testFilterDistributionSetTagByParameterName() {
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==1", 1);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==*", 5);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "=in=(1,2)", 2);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.NAME.name() + "=out=(1,2)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by description")
|
||||||
|
public void testFilterDistributionSetTagByParameterDescription() {
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==1", 1);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==*", 5);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "=in=(1,2)", 2);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "=out=(1,2)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter distribution set by colour")
|
||||||
|
public void testFilterDistributionSetTagByParameterColour() {
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==red", 3);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==r*", 3);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "=in=(red,notexist)", 3);
|
||||||
|
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "=out=(red,notexist)", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
|
final Page<DistributionSetTag> findEnitity = tagManagement
|
||||||
|
.findAllDistributionSetTags(RSQLUtility.parse(rsqlParam, TagFields.class), new PageRequest(0, 100));
|
||||||
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
|
assertThat(findEnitity).isNotNull();
|
||||||
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQueryTarget(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
|
final Page<TargetTag> findEnitity = tagManagement
|
||||||
|
.findAllTargetTags(RSQLUtility.parse(rsqlParam, TagFields.class), new PageRequest(0, 100));
|
||||||
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
|
assertThat(findEnitity).isNotNull();
|
||||||
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
/**
|
||||||
|
* 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.rsql;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.AbstractIntegrationTest;
|
||||||
|
import org.eclipse.hawkbit.TestDataUtil;
|
||||||
|
import org.eclipse.hawkbit.repository.TargetFields;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
|
||||||
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
|
@Features("Component Tests - RSQL filtering")
|
||||||
|
@Stories("RSQL filter target")
|
||||||
|
public class RSQLTargetFieldTest extends AbstractIntegrationTest {
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void seuptBeforeTest() {
|
||||||
|
|
||||||
|
final DistributionSet ds = TestDataUtil.generateDistributionSet("AssignedDs", softwareManagement,
|
||||||
|
distributionSetManagement);
|
||||||
|
|
||||||
|
final Target target = new Target("targetId123");
|
||||||
|
target.setDescription("targetId123");
|
||||||
|
final TargetInfo targetInfo = new TargetInfo(target);
|
||||||
|
targetInfo.getControllerAttributes().put("revision", "1.1");
|
||||||
|
target.setTargetInfo(targetInfo);
|
||||||
|
target.getTargetInfo().setUpdateStatus(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
|
targetManagement.createTarget(target);
|
||||||
|
final Target target2 = new Target("targetId1234");
|
||||||
|
target2.setDescription("targetId1234");
|
||||||
|
final TargetInfo targetInfo2 = new TargetInfo(target2);
|
||||||
|
targetInfo2.getControllerAttributes().put("revision", "1.2");
|
||||||
|
target2.setTargetInfo(targetInfo2);
|
||||||
|
targetManagement.createTarget(target2);
|
||||||
|
targetManagement.createTarget(new Target("targetId1235"));
|
||||||
|
targetManagement.createTarget(new Target("targetId1236"));
|
||||||
|
|
||||||
|
final TargetTag targetTag = tagManagement.createTargetTag(new TargetTag("Tag1"));
|
||||||
|
tagManagement.createTargetTag(new TargetTag("Tag2"));
|
||||||
|
tagManagement.createTargetTag(new TargetTag("Tag3"));
|
||||||
|
tagManagement.createTargetTag(new TargetTag("Tag4"));
|
||||||
|
|
||||||
|
targetManagement.assignTag(Arrays.asList(target.getControllerId(), target2.getControllerId()), targetTag);
|
||||||
|
|
||||||
|
deploymentManagement.assignDistributionSet(ds.getId(), target.getControllerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by (controller) id")
|
||||||
|
public void testFilterByParameterId() {
|
||||||
|
assertRSQLQuery(TargetFields.ID.name() + "==targetId123", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ID.name() + "==target*", 4);
|
||||||
|
assertRSQLQuery(TargetFields.ID.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.ID.name() + "=in=(targetId123,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ID.name() + "=out=(targetId123,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by name")
|
||||||
|
public void testFilterByParameterName() {
|
||||||
|
assertRSQLQuery(TargetFields.NAME.name() + "==targetId123", 1);
|
||||||
|
assertRSQLQuery(TargetFields.NAME.name() + "==target*", 4);
|
||||||
|
assertRSQLQuery(TargetFields.NAME.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.NAME.name() + "=in=(targetId123,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.NAME.name() + "=out=(targetId123,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by description")
|
||||||
|
public void testFilterByParameterDescription() {
|
||||||
|
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==targetId123", 1);
|
||||||
|
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==target*", 2);
|
||||||
|
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "=in=(targetId123,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.DESCRIPTION.name() + "=out=(targetId123,notexist)", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by controller id")
|
||||||
|
public void testFilterByParameterControllerId() {
|
||||||
|
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==targetId123", 1);
|
||||||
|
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==target*", 4);
|
||||||
|
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "=in=(targetId123,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.CONTROLLERID.name() + "=out=(targetId123,notexist)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by status")
|
||||||
|
public void testFilterByParameterUpdateStatus() {
|
||||||
|
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==pending", 1);
|
||||||
|
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "!=pending", 3);
|
||||||
|
try {
|
||||||
|
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==noExist*", 0);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "=in=(pending,error)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "=out=(pending,error)", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by attribute")
|
||||||
|
public void testFilterByAttribute() {
|
||||||
|
assertRSQLQuery(TargetFields.ATTRIBUTE.name() + ".revision==1.1", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ATTRIBUTE.name() + ".revision==1*", 2);
|
||||||
|
assertRSQLQuery(TargetFields.ATTRIBUTE.name() + ".revision==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.ATTRIBUTE.name() + ".revision=in=(1.1,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ATTRIBUTE.name() + ".revision=out=(1.1)", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by assigned ds name")
|
||||||
|
public void testFilterByAssignedDsName() {
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==AssignedDs", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==A*", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name=in=(AssignedDs,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name=out=(AssignedDs,notexist)", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by assigned ds version")
|
||||||
|
public void testFilterByAssignedDsVersion() {
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==v1.0", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==*1*", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version=in=(v1.0,notexist)", 1);
|
||||||
|
assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version=out=(v1.0,notexist)", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Test filter target by tag")
|
||||||
|
public void testFilterByTag() {
|
||||||
|
assertRSQLQuery(TargetFields.TAG.name() + "==Tag1", 2);
|
||||||
|
assertRSQLQuery(TargetFields.TAG.name() + "==T*", 2);
|
||||||
|
assertRSQLQuery(TargetFields.TAG.name() + "==noExist*", 0);
|
||||||
|
assertRSQLQuery(TargetFields.TAG.name() + "=in=(Tag1,notexist)", 2);
|
||||||
|
assertRSQLQuery(TargetFields.TAG.name() + "=out=(Tag1,notexist)", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
|
||||||
|
final Page<Target> findTargetPage = targetManagement
|
||||||
|
.findTargetsAll(RSQLUtility.parse(rsqlParam, TargetFields.class), new PageRequest(0, 100));
|
||||||
|
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||||
|
assertThat(findTargetPage).isNotNull();
|
||||||
|
assertThat(countTargetsAll).isEqualTo(expcetedTargets);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,20 +6,18 @@
|
|||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.rest.resource;
|
package org.eclipse.hawkbit.repository.rsql;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Expression;
|
import javax.persistence.criteria.Expression;
|
||||||
@@ -27,27 +25,22 @@ import javax.persistence.criteria.Path;
|
|||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
import javax.persistence.metamodel.Attribute;
|
import javax.persistence.metamodel.Attribute;
|
||||||
import javax.persistence.metamodel.ManagedType;
|
|
||||||
import javax.persistence.metamodel.Metamodel;
|
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||||
import org.eclipse.hawkbit.repository.FieldNameProvider;
|
import org.eclipse.hawkbit.repository.FieldNameProvider;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
|
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
|
||||||
|
import org.eclipse.hawkbit.repository.TargetFields;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLParameterSyntaxException;
|
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLParameterUnsupportedFieldException;
|
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
@Features("Component Tests - Management RESTful API")
|
@Features("Component Tests - RSQL filtering")
|
||||||
@Stories("RSQL search utility")
|
@Stories("RSQL search utility")
|
||||||
// TODO: fully document tests -> @Description for long text and reasonable
|
// TODO: fully document tests -> @Description for long text and reasonable
|
||||||
// method name as short text
|
// method name as short text
|
||||||
@@ -60,33 +53,87 @@ public class RSQLUtilityTest {
|
|||||||
private CriteriaQuery<SoftwareModule> criteriaQueryMock;
|
private CriteriaQuery<SoftwareModule> criteriaQueryMock;
|
||||||
@Mock
|
@Mock
|
||||||
private CriteriaBuilder criteriaBuilderMock;
|
private CriteriaBuilder criteriaBuilderMock;
|
||||||
@Mock
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Metamodel metamodel;
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private ManagedType managedType;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Attribute attribute;
|
private Attribute attribute;
|
||||||
|
|
||||||
@Test(expected = RSQLParameterSyntaxException.class)
|
@Test
|
||||||
public void wrongRsqlSyntaxThrowSyntaxException() {
|
public void wrongRsqlSyntaxThrowSyntaxException() {
|
||||||
final String wrongRSQL = "name==abc;d";
|
final String wrongRSQL = "name==abc;d";
|
||||||
when(entityManager.getMetamodel()).thenReturn(metamodel);
|
try {
|
||||||
RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class, entityManager).toPredicate(baseSoftwareModuleRootMock,
|
RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterSyntaxException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RSQLParameterUnsupportedFieldException.class)
|
@Test
|
||||||
public void wrongFieldThrowUnsupportedFieldException() {
|
public void wrongFieldThrowUnsupportedFieldException() {
|
||||||
final String wrongRSQL = "unknownField==abc";
|
final String wrongRSQL = "unknownField==abc";
|
||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||||
doEntitySetup(SoftwareModule.class);
|
try {
|
||||||
RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class, entityManager).toPredicate(baseSoftwareModuleRootMock,
|
RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void wrongRsqlMapSyntaxThrowSyntaxException() {
|
||||||
|
String wrongRSQL = TargetFields.ATTRIBUTE + "==abc";
|
||||||
|
try {
|
||||||
|
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
|
||||||
|
criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
wrongRSQL = TargetFields.ATTRIBUTE + ".unkwon.wrong==abc";
|
||||||
|
try {
|
||||||
|
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
|
||||||
|
criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
wrongRSQL = DistributionSetFields.METADATA + "==abc";
|
||||||
|
try {
|
||||||
|
RSQLUtility.parse(wrongRSQL, DistributionSetFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void wrongRsqlSubEntitySyntaxThrowSyntaxException() {
|
||||||
|
String wrongRSQL = TargetFields.ASSIGNEDDS + "==abc";
|
||||||
|
try {
|
||||||
|
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
|
||||||
|
criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
wrongRSQL = TargetFields.ASSIGNEDDS + ".unknownField==abc";
|
||||||
|
try {
|
||||||
|
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
|
||||||
|
criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
wrongRSQL = TargetFields.ASSIGNEDDS + ".unknownField.ToMuch==abc";
|
||||||
|
try {
|
||||||
|
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
|
||||||
|
criteriaBuilderMock);
|
||||||
|
fail();
|
||||||
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -97,14 +144,12 @@ public class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.get("version")).thenReturn(baseSoftwareModuleRootMock);
|
when(baseSoftwareModuleRootMock.get("version")).thenReturn(baseSoftwareModuleRootMock);
|
||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(
|
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||||
mock(Predicate.class));
|
.thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
doEntitySetup(SoftwareModule.class);
|
|
||||||
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class, entityManager).toPredicate(
|
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verfication
|
// verfication
|
||||||
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
||||||
@@ -117,12 +162,11 @@ public class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(
|
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||||
mock(Predicate.class));
|
.thenReturn(mock(Predicate.class));
|
||||||
doEntitySetup(SoftwareModule.class);
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class, entityManager).toPredicate(
|
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verfication
|
// verfication
|
||||||
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
||||||
@@ -136,12 +180,11 @@ public class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(
|
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||||
mock(Predicate.class));
|
.thenReturn(mock(Predicate.class));
|
||||||
doEntitySetup(SoftwareModule.class);
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class, entityManager).toPredicate(
|
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verfication
|
// verfication
|
||||||
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
||||||
@@ -155,14 +198,13 @@ public class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock);
|
||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn(
|
when(criteriaBuilderMock.<String> greaterThanOrEqualTo(any(Expression.class), any(String.class)))
|
||||||
mock(Predicate.class));
|
.thenReturn(mock(Predicate.class));
|
||||||
when(criteriaBuilderMock.upper(eq(pathOfString(baseSoftwareModuleRootMock)))).thenReturn(
|
when(criteriaBuilderMock.upper(eq(pathOfString(baseSoftwareModuleRootMock))))
|
||||||
pathOfString(baseSoftwareModuleRootMock));
|
.thenReturn(pathOfString(baseSoftwareModuleRootMock));
|
||||||
doEntitySetup(SoftwareModule.class);
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class, entityManager).toPredicate(
|
RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
|
|
||||||
// verfication
|
// verfication
|
||||||
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
||||||
@@ -178,10 +220,9 @@ public class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) TestValueEnum.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) TestValueEnum.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
doEntitySetup(TestValueEnum.class);
|
|
||||||
// test
|
// test
|
||||||
RSQLUtility.parse(correctRsql, TestFieldEnum.class, entityManager).toPredicate(baseSoftwareModuleRootMock,
|
RSQLUtility.parse(correctRsql, TestFieldEnum.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
|
||||||
criteriaQueryMock, criteriaBuilderMock);
|
criteriaBuilderMock);
|
||||||
|
|
||||||
// verfication
|
// verfication
|
||||||
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
verify(criteriaBuilderMock, times(1)).and(any(Predicate.class));
|
||||||
@@ -196,11 +237,9 @@ public class RSQLUtilityTest {
|
|||||||
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) TestValueEnum.class);
|
when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) TestValueEnum.class);
|
||||||
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class));
|
||||||
|
|
||||||
doEntitySetup(TestValueEnum.class);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// test
|
// test
|
||||||
RSQLUtility.parse(correctRsql, TestFieldEnum.class, entityManager).toPredicate(baseSoftwareModuleRootMock,
|
RSQLUtility.parse(correctRsql, TestFieldEnum.class).toPredicate(baseSoftwareModuleRootMock,
|
||||||
criteriaQueryMock, criteriaBuilderMock);
|
criteriaQueryMock, criteriaBuilderMock);
|
||||||
fail("missing RSQLParameterUnsupportedFieldException for wrong enum value");
|
fail("missing RSQLParameterUnsupportedFieldException for wrong enum value");
|
||||||
} catch (final RSQLParameterUnsupportedFieldException e) {
|
} catch (final RSQLParameterUnsupportedFieldException e) {
|
||||||
@@ -208,22 +247,6 @@ public class RSQLUtilityTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doEntitySetup(final Class clasName) {
|
|
||||||
when(entityManager.getMetamodel()).thenReturn(metamodel);
|
|
||||||
when(metamodel.managedType(clasName)).thenReturn(managedType);
|
|
||||||
when(managedType.getJavaType()).thenReturn(clasName);
|
|
||||||
|
|
||||||
doAnswer(new Answer<Attribute>() {
|
|
||||||
@Override
|
|
||||||
public Attribute answer(final InvocationOnMock invocation) throws Throwable {
|
|
||||||
return attribute;
|
|
||||||
}
|
|
||||||
}).when(managedType).getAttribute(anyString());
|
|
||||||
|
|
||||||
when(attribute.isAssociation()).thenReturn(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <Y> Path<Y> pathOfString(final Path<?> path) {
|
private <Y> Path<Y> pathOfString(final Path<?> path) {
|
||||||
return (Path<Y>) path;
|
return (Path<Y>) path;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-rest-api</artifactId>
|
<artifactId>hawkbit-rest-api</artifactId>
|
||||||
<name>hawkBit :: REST API</name>
|
<name>hawkBit :: REST API</name>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-rest-resource</artifactId>
|
<artifactId>hawkbit-rest-resource</artifactId>
|
||||||
<name>hawkBit :: REST Resources</name>
|
<name>hawkBit :: REST Resources</name>
|
||||||
|
|||||||
@@ -138,13 +138,11 @@ public class ArtifactStoreController implements EnvironmentAware {
|
|||||||
|
|
||||||
private Action checkAndReportDownloadByTarget(final HttpServletRequest request, final String targetid,
|
private Action checkAndReportDownloadByTarget(final HttpServletRequest request, final String targetid,
|
||||||
final LocalArtifact artifact) {
|
final LocalArtifact artifact) {
|
||||||
final Target target = controllerManagement.updateLastTargetQuery(
|
final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(
|
||||||
targetid,
|
request, environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
|
||||||
IpUtil.getClientIpFromRequest(request,
|
|
||||||
environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
|
|
||||||
|
|
||||||
final Action action = controllerManagement.getActionForDownloadByTargetAndSoftwareModule(
|
final Action action = controllerManagement
|
||||||
target.getControllerId(), artifact.getSoftwareModule());
|
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), artifact.getSoftwareModule());
|
||||||
final String range = request.getHeader("Range");
|
final String range = request.getHeader("Range");
|
||||||
|
|
||||||
final ActionStatus actionStatus = new ActionStatus();
|
final ActionStatus actionStatus = new ActionStatus();
|
||||||
|
|||||||
@@ -163,9 +163,10 @@ public class RootController implements EnvironmentAware {
|
|||||||
System.currentTimeMillis(), IpUtil.getClientIpFromRequest(request, requestHeader));
|
System.currentTimeMillis(), IpUtil.getClientIpFromRequest(request, requestHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(DataConversionHelper.fromTarget(target,
|
return new ResponseEntity<>(
|
||||||
controllerManagement.findActionByTargetAndActive(target), controllerPollProperties.getPollingTime(),
|
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target),
|
||||||
tenantAware), HttpStatus.OK);
|
controllerPollProperties.getPollingTime(), tenantAware),
|
||||||
|
HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,8 +221,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
|
|
||||||
private Action checkAndLogDownload(final HttpServletRequest request, final Target target,
|
private Action checkAndLogDownload(final HttpServletRequest request, final Target target,
|
||||||
final SoftwareModule module) {
|
final SoftwareModule module) {
|
||||||
final Action action = controllerManagement.getActionForDownloadByTargetAndSoftwareModule(
|
final Action action = controllerManagement
|
||||||
target.getControllerId(), module);
|
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), module);
|
||||||
final String range = request.getHeader("Range");
|
final String range = request.getHeader("Range");
|
||||||
|
|
||||||
final ActionStatus statusMessage = new ActionStatus();
|
final ActionStatus statusMessage = new ActionStatus();
|
||||||
@@ -274,8 +275,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DataConversionHelper.writeMD5FileResponse(fileName, response, module.getLocalArtifactByFilename(fileName)
|
DataConversionHelper.writeMD5FileResponse(fileName, response,
|
||||||
.get());
|
module.getLocalArtifactByFilename(fileName).get());
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
LOG.error("Failed to stream MD5 File", e);
|
LOG.error("Failed to stream MD5 File", e);
|
||||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
@@ -301,7 +302,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
* the HTTP request injected by spring
|
* the HTTP request injected by spring
|
||||||
* @return the response
|
* @return the response
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION
|
||||||
|
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<DeploymentBase> getControllerBasedeploymentAction(
|
public ResponseEntity<DeploymentBase> getControllerBasedeploymentAction(
|
||||||
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
|
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
|
||||||
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
|
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
|
||||||
@@ -323,8 +325,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
|
|
||||||
final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
|
final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
|
||||||
|
|
||||||
final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()), new Deployment(handlingType,
|
final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()),
|
||||||
handlingType, chunks));
|
new Deployment(handlingType, handlingType, chunks));
|
||||||
|
|
||||||
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
|
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
|
||||||
|
|
||||||
@@ -388,8 +390,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid,
|
private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid, final Long actionid,
|
||||||
final Long actionid, final Action action) {
|
final Action action) {
|
||||||
|
|
||||||
final ActionStatus actionStatus = new ActionStatus();
|
final ActionStatus actionStatus = new ActionStatus();
|
||||||
actionStatus.setAction(action);
|
actionStatus.setAction(action);
|
||||||
@@ -430,8 +432,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
|
|
||||||
private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid,
|
private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid,
|
||||||
final Long actionid, final ActionStatus actionStatus) {
|
final Long actionid, final ActionStatus actionStatus) {
|
||||||
LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.",
|
LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", actionid,
|
||||||
actionid, targetid, feedback.getStatus().getExecution());
|
targetid, feedback.getStatus().getExecution());
|
||||||
actionStatus.setStatus(Status.RUNNING);
|
actionStatus.setStatus(Status.RUNNING);
|
||||||
// MECS-400: we should not use the unstructed message list for
|
// MECS-400: we should not use the unstructed message list for
|
||||||
// the server comment on the status.
|
// the server comment on the status.
|
||||||
@@ -463,7 +465,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
*
|
*
|
||||||
* @return status of the request
|
* @return status of the request
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/{targetid}/"
|
||||||
|
+ ControllerConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final ConfigData configData,
|
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final ConfigData configData,
|
||||||
@PathVariable final String targetid, final HttpServletRequest request) {
|
@PathVariable final String targetid, final HttpServletRequest request) {
|
||||||
controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(request, requestHeader));
|
controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(request, requestHeader));
|
||||||
@@ -485,7 +488,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
*
|
*
|
||||||
* @return the {@link Cancel} response
|
* @return the {@link Cancel} response
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION
|
||||||
|
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
|
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
|
||||||
@PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) {
|
@PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) {
|
||||||
LOG.debug("getControllerCancelAction({})", targetid);
|
LOG.debug("getControllerCancelAction({})", targetid);
|
||||||
@@ -500,8 +504,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.isCancelingOrCanceled()) {
|
if (action.isCancelingOrCanceled()) {
|
||||||
final Cancel cancel = new Cancel(String.valueOf(action.getId()), new CancelActionToStop(
|
final Cancel cancel = new Cancel(String.valueOf(action.getId()),
|
||||||
String.valueOf(action.getId())));
|
new CancelActionToStop(String.valueOf(action.getId())));
|
||||||
|
|
||||||
LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", targetid, cancel);
|
LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", targetid, cancel);
|
||||||
|
|
||||||
@@ -553,8 +557,8 @@ public class RootController implements EnvironmentAware {
|
|||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
controllerManagement.addCancelActionStatus(
|
controllerManagement
|
||||||
generateActionCancelStatus(feedback, target, feedback.getId(), action), action);
|
.addCancelActionStatus(generateActionCancelStatus(feedback, target, feedback.getId(), action), action);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public final class DistributionSetMapper {
|
|||||||
final DistributionSetType module = distributionSetManagement
|
final DistributionSetType module = distributionSetManagement
|
||||||
.findDistributionSetTypeByKey(distributionSetTypekey);
|
.findDistributionSetTypeByKey(distributionSetTypekey);
|
||||||
if (module == null) {
|
if (module == null) {
|
||||||
throw new EntityNotFoundException("DistributionSetType with key {" + distributionSetTypekey
|
throw new EntityNotFoundException(
|
||||||
+ "} does not exist");
|
"DistributionSetType with key {" + distributionSetTypekey + "} does not exist");
|
||||||
}
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
@@ -108,18 +108,18 @@ public final class DistributionSetMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dsRest.getApplication() != null) {
|
if (dsRest.getApplication() != null) {
|
||||||
result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(),
|
result.addModule(
|
||||||
softwareManagement));
|
findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(), softwareManagement));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dsRest.getRuntime() != null) {
|
if (dsRest.getRuntime() != null) {
|
||||||
result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement));
|
result.addModule(
|
||||||
|
findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dsRest.getModules() != null) {
|
if (dsRest.getModules() != null) {
|
||||||
dsRest.getModules().forEach(
|
dsRest.getModules().forEach(module -> result
|
||||||
module -> result.addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(),
|
.addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(), softwareManagement)));
|
||||||
softwareManagement)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -163,23 +163,22 @@ public final class DistributionSetMapper {
|
|||||||
response.setComplete(distributionSet.isComplete());
|
response.setComplete(distributionSet.isComplete());
|
||||||
response.setType(distributionSet.getType().getKey());
|
response.setType(distributionSet.getType().getKey());
|
||||||
|
|
||||||
distributionSet.getModules().forEach(
|
distributionSet.getModules()
|
||||||
module -> response.getModules().add(SoftwareModuleMapper.toResponse(module)));
|
.forEach(module -> response.getModules().add(SoftwareModuleMapper.toResponse(module)));
|
||||||
|
|
||||||
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
|
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
|
||||||
|
|
||||||
response.add(linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel(
|
response.add(
|
||||||
"self"));
|
linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel("self"));
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(linkTo(
|
||||||
methodOn(DistributionSetTypeResource.class).getDistributionSetType(distributionSet.getType().getId()))
|
methodOn(DistributionSetTypeResource.class).getDistributionSetType(distributionSet.getType().getId()))
|
||||||
.withRel("type"));
|
.withRel("type"));
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(linkTo(methodOn(DistributionSetResource.class).getMetadata(response.getDsId(),
|
||||||
methodOn(DistributionSetResource.class).getMetadata(response.getDsId(),
|
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
|
||||||
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
|
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null))
|
||||||
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel(
|
.withRel("metadata"));
|
||||||
"metadata"));
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||||
@@ -92,9 +90,6 @@ public class DistributionSetResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DistributionSetManagement distributionSetManagement;
|
private DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request of retrieving all {@link DistributionSet}s within
|
* Handles the GET request of retrieving all {@link DistributionSet}s within
|
||||||
* SP.
|
* SP.
|
||||||
@@ -130,7 +125,7 @@ public class DistributionSetResource {
|
|||||||
final Page<DistributionSet> findDsPage;
|
final Page<DistributionSet> findDsPage;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findDsPage = distributionSetManagement.findDistributionSetsAll(
|
findDsPage = distributionSetManagement.findDistributionSetsAll(
|
||||||
RSQLUtility.parse(rsqlParam, DistributionSetFields.class, entityManager), pageable, false);
|
RSQLUtility.parse(rsqlParam, DistributionSetFields.class), pageable, false);
|
||||||
} else {
|
} else {
|
||||||
findDsPage = distributionSetManagement.findDistributionSetsAll(pageable, false, null);
|
findDsPage = distributionSetManagement.findDistributionSetsAll(pageable, false, null);
|
||||||
}
|
}
|
||||||
@@ -281,7 +276,7 @@ public class DistributionSetResource {
|
|||||||
final Page<Target> targetsAssignedDS;
|
final Page<Target> targetsAssignedDS;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
targetsAssignedDS = targetManagement.findTargetByAssignedDistributionSet(distributionSetId,
|
targetsAssignedDS = targetManagement.findTargetByAssignedDistributionSet(distributionSetId,
|
||||||
RSQLUtility.parse(rsqlParam, TargetFields.class, entityManager), pageable);
|
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
|
||||||
} else {
|
} else {
|
||||||
targetsAssignedDS = targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable);
|
targetsAssignedDS = targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable);
|
||||||
}
|
}
|
||||||
@@ -331,7 +326,7 @@ public class DistributionSetResource {
|
|||||||
final Page<Target> targetsInstalledDS;
|
final Page<Target> targetsInstalledDS;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
targetsInstalledDS = targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
|
targetsInstalledDS = targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
|
||||||
RSQLUtility.parse(rsqlParam, TargetFields.class, entityManager), pageable);
|
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
|
||||||
} else {
|
} else {
|
||||||
targetsInstalledDS = targetManagement.findTargetByInstalledDistributionSet(distributionSetId, pageable);
|
targetsInstalledDS = targetManagement.findTargetByInstalledDistributionSet(distributionSetId, pageable);
|
||||||
}
|
}
|
||||||
@@ -410,7 +405,7 @@ public class DistributionSetResource {
|
|||||||
|
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
||||||
RSQLUtility.parse(rsqlParam, DistributionSetMetadataFields.class, entityManager), pageable);
|
RSQLUtility.parse(rsqlParam, DistributionSetMetadataFields.class), pageable);
|
||||||
} else {
|
} else {
|
||||||
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
||||||
pageable);
|
pageable);
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.rest.resource;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.TagFields;
|
import org.eclipse.hawkbit.repository.TagFields;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.TagManagement;
|
||||||
@@ -60,9 +58,6 @@ public class DistributionSetTagResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DistributionSetManagement distributionSetManagement;
|
private DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request of retrieving all DistributionSet tags.
|
* Handles the GET request of retrieving all DistributionSet tags.
|
||||||
*
|
*
|
||||||
@@ -102,8 +97,8 @@ public class DistributionSetTagResource {
|
|||||||
countTargetsAll = tagManagement.countTargetTags();
|
countTargetsAll = tagManagement.countTargetTags();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final Page<DistributionSetTag> findTargetPage = tagManagement.findAllDistributionSetTags(
|
final Page<DistributionSetTag> findTargetPage = tagManagement
|
||||||
RSQLUtility.parse(rsqlParam, TagFields.class, entityManager), pageable);
|
.findAllDistributionSetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
|
||||||
countTargetsAll = findTargetPage.getTotalElements();
|
countTargetsAll = findTargetPage.getTotalElements();
|
||||||
findTargetsAll = findTargetPage;
|
findTargetsAll = findTargetPage;
|
||||||
|
|
||||||
@@ -141,13 +136,13 @@ public class DistributionSetTagResource {
|
|||||||
* with status code 201 - Created. The Response Body are the created
|
* with status code 201 - Created. The Response Body are the created
|
||||||
* distribution set tags but without ResponseBody.
|
* distribution set tags but without ResponseBody.
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
|
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
||||||
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<TagsRest> createDistributionSetTags(@RequestBody final List<TagRequestBodyPut> tags) {
|
public ResponseEntity<TagsRest> createDistributionSetTags(@RequestBody final List<TagRequestBodyPut> tags) {
|
||||||
LOG.debug("creating {} ds tags", tags.size());
|
LOG.debug("creating {} ds tags", tags.size());
|
||||||
|
|
||||||
final List<DistributionSetTag> createdTags = tagManagement.createDistributionSetTags(TagMapper
|
final List<DistributionSetTag> createdTags = tagManagement
|
||||||
.mapDistributionSetTagFromRequest(tags));
|
.createDistributionSetTags(TagMapper.mapDistributionSetTagFromRequest(tags));
|
||||||
|
|
||||||
return new ResponseEntity<>(TagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
|
return new ResponseEntity<>(TagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
@@ -247,14 +242,14 @@ public class DistributionSetTagResource {
|
|||||||
|
|
||||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement.toggleTagAssignment(
|
final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement
|
||||||
findDistributionSetIds(assignedDSRequestBodies), tag.getName());
|
.toggleTagAssignment(findDistributionSetIds(assignedDSRequestBodies), tag.getName());
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest();
|
final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest();
|
||||||
tagAssigmentResultRest.setAssignedDistributionSets(DistributionSetMapper
|
tagAssigmentResultRest.setAssignedDistributionSets(
|
||||||
.toResponseDistributionSets(assigmentResult.getAssignedDs()));
|
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedDs()));
|
||||||
tagAssigmentResultRest.setUnassignedDistributionSets(DistributionSetMapper
|
tagAssigmentResultRest.setUnassignedDistributionSets(
|
||||||
.toResponseDistributionSets(assigmentResult.getUnassignedDs()));
|
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedDs()));
|
||||||
|
|
||||||
LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(),
|
LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(),
|
||||||
assigmentResult.getUnassigned());
|
assigmentResult.getUnassigned());
|
||||||
@@ -281,8 +276,8 @@ public class DistributionSetTagResource {
|
|||||||
LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId);
|
LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId);
|
||||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||||
|
|
||||||
final List<DistributionSet> assignedDs = distributionSetManagement.assignTag(
|
final List<DistributionSet> assignedDs = distributionSetManagement
|
||||||
findDistributionSetIds(assignedDSRequestBodies), tag);
|
.assignTag(findDistributionSetIds(assignedDSRequestBodies), tag);
|
||||||
LOG.debug("Assignd DistributionSet {}", assignedDs.size());
|
LOG.debug("Assignd DistributionSet {}", assignedDs.size());
|
||||||
return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK);
|
return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.rest.resource;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||||
@@ -62,9 +60,6 @@ public class DistributionSetTypeResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DistributionSetManagement distributionSetManagement;
|
private DistributionSetManagement distributionSetManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request of retrieving all {@link DistributionSetType}s
|
* Handles the GET request of retrieving all {@link DistributionSetType}s
|
||||||
* within SP.
|
* within SP.
|
||||||
@@ -105,7 +100,7 @@ public class DistributionSetTypeResource {
|
|||||||
Long countModulesAll;
|
Long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesByPredicate(
|
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesByPredicate(
|
||||||
RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class, entityManager), pageable);
|
RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class), pageable);
|
||||||
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(pageable);
|
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(pageable);
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ public final class SoftwareModuleMapper {
|
|||||||
smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
|
smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareModule sw, final List<MetadataRest> metadata) {
|
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareModule sw,
|
||||||
|
final List<MetadataRest> metadata) {
|
||||||
final List<SoftwareModuleMetadata> mappedList = new ArrayList<>(metadata.size());
|
final List<SoftwareModuleMetadata> mappedList = new ArrayList<>(metadata.size());
|
||||||
for (final MetadataRest metadataRest : metadata) {
|
for (final MetadataRest metadataRest : metadata) {
|
||||||
if (metadataRest.getKey() == null) {
|
if (metadataRest.getKey() == null) {
|
||||||
@@ -141,20 +142,19 @@ public final class SoftwareModuleMapper {
|
|||||||
response.setType(baseSofwareModule.getType().getKey());
|
response.setType(baseSofwareModule.getType().getKey());
|
||||||
response.setVendor(baseSofwareModule.getVendor());
|
response.setVendor(baseSofwareModule.getVendor());
|
||||||
|
|
||||||
response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId())).withRel(
|
response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId()))
|
||||||
RestConstants.SOFTWAREMODULE_V1_ARTIFACT));
|
.withRel(RestConstants.SOFTWAREMODULE_V1_ARTIFACT));
|
||||||
response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId())).withRel(
|
response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId()))
|
||||||
"self"));
|
.withRel("self"));
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(linkTo(
|
||||||
methodOn(SoftwareModuleTypeResource.class).getSoftwareModuleType(baseSofwareModule.getType().getId()))
|
methodOn(SoftwareModuleTypeResource.class).getSoftwareModuleType(baseSofwareModule.getType().getId()))
|
||||||
.withRel(RestConstants.SOFTWAREMODULE_V1_TYPE));
|
.withRel(RestConstants.SOFTWAREMODULE_V1_TYPE));
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(linkTo(methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(),
|
||||||
methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(),
|
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
|
||||||
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
|
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null))
|
||||||
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel(
|
.withRel("metadata"));
|
||||||
"metadata"));
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,13 +178,12 @@ public final class SoftwareModuleMapper {
|
|||||||
|
|
||||||
RestModelMapper.mapBaseToBase(artifactRest, artifact);
|
RestModelMapper.mapBaseToBase(artifactRest, artifact);
|
||||||
|
|
||||||
artifactRest.add(linkTo(
|
artifactRest.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(),
|
||||||
methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(),
|
artifact.getId())).withRel("self"));
|
||||||
artifact.getId())).withRel("self"));
|
|
||||||
|
|
||||||
if (artifact instanceof LocalArtifact) {
|
if (artifact instanceof LocalArtifact) {
|
||||||
artifactRest.add(linkTo(
|
artifactRest.add(
|
||||||
methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(),
|
linkTo(methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(),
|
||||||
artifact.getId(), null, null)).withRel("download"));
|
artifact.getId(), null, null)).withRel("download"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.rest.resource;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@@ -75,9 +74,6 @@ public class SoftwareModuleResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SoftwareManagement softwareManagement;
|
private SoftwareManagement softwareManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EntityManager entityManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles POST request for artifact upload.
|
* Handles POST request for artifact upload.
|
||||||
*
|
*
|
||||||
@@ -265,8 +261,8 @@ public class SoftwareModuleResource {
|
|||||||
final Slice<SoftwareModule> findModulesAll;
|
final Slice<SoftwareModule> findModulesAll;
|
||||||
Long countModulesAll;
|
Long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModulesAll = softwareManagement.findSoftwareModulesByPredicate(
|
findModulesAll = softwareManagement
|
||||||
RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class, entityManager), pageable);
|
.findSoftwareModulesByPredicate(RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable);
|
||||||
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModulesAll = softwareManagement.findSoftwareModulesAll(pageable);
|
findModulesAll = softwareManagement.findSoftwareModulesAll(pageable);
|
||||||
@@ -405,7 +401,7 @@ public class SoftwareModuleResource {
|
|||||||
|
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
|
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
|
||||||
RSQLUtility.parse(rsqlParam, SoftwareModuleMetadataFields.class, entityManager), pageable);
|
RSQLUtility.parse(rsqlParam, SoftwareModuleMetadataFields.class), pageable);
|
||||||
} else {
|
} else {
|
||||||
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
|
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class SoftwareModuleTypeResource {
|
|||||||
Long countModulesAll;
|
Long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModuleTypessAll = softwareManagement.findSoftwareModuleTypesByPredicate(
|
findModuleTypessAll = softwareManagement.findSoftwareModuleTypesByPredicate(
|
||||||
RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class, entityManager), pageable);
|
RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class), pageable);
|
||||||
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModuleTypessAll = softwareManagement.findSoftwareModuleTypesAll(pageable);
|
findModuleTypessAll = softwareManagement.findSoftwareModuleTypesAll(pageable);
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ public class SystemManagementResource {
|
|||||||
.setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes())
|
.setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes())
|
||||||
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
|
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
|
||||||
|
|
||||||
result.setTenantStats(report.getTenants().stream().map(tenant -> convertTenant(tenant))
|
result.setTenantStats(
|
||||||
.collect(Collectors.toList()));
|
report.getTenants().stream().map(tenant -> convertTenant(tenant)).collect(Collectors.toList()));
|
||||||
|
|
||||||
return ResponseEntity.ok(result);
|
return ResponseEntity.ok(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ final class TagMapper {
|
|||||||
|
|
||||||
response.add(linkTo(methodOn(TargetTagResource.class).getTargetTag(targetTag.getId())).withRel("self"));
|
response.add(linkTo(methodOn(TargetTagResource.class).getTargetTag(targetTag.getId())).withRel("self"));
|
||||||
|
|
||||||
response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId())).withRel(
|
response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId()))
|
||||||
"assignedTargets"));
|
.withRel("assignedTargets"));
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -83,13 +83,13 @@ final class TagMapper {
|
|||||||
|
|
||||||
mapTag(response, distributionSetTag);
|
mapTag(response, distributionSetTag);
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(
|
||||||
methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId())).withRel(
|
linkTo(methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId()))
|
||||||
"self"));
|
.withRel("self"));
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(linkTo(
|
||||||
methodOn(DistributionSetTagResource.class).getAssignedDistributionSets(distributionSetTag.getId()))
|
methodOn(DistributionSetTagResource.class).getAssignedDistributionSets(distributionSetTag.getId()))
|
||||||
.withRel("assignedDistributionSets"));
|
.withRel("assignedDistributionSets"));
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -97,8 +97,8 @@ final class TagMapper {
|
|||||||
static List<TargetTag> mapTargeTagFromRequest(final Iterable<TagRequestBodyPut> tags) {
|
static List<TargetTag> mapTargeTagFromRequest(final Iterable<TagRequestBodyPut> tags) {
|
||||||
final List<TargetTag> mappedList = new ArrayList<>();
|
final List<TargetTag> mappedList = new ArrayList<>();
|
||||||
for (final TagRequestBodyPut targetTagRest : tags) {
|
for (final TagRequestBodyPut targetTagRest : tags) {
|
||||||
mappedList.add(new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest
|
mappedList.add(
|
||||||
.getColour()));
|
new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour()));
|
||||||
}
|
}
|
||||||
return mappedList;
|
return mappedList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,13 +54,12 @@ final public class TargetMapper {
|
|||||||
.withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET));
|
.withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET));
|
||||||
response.add(linkTo(methodOn(TargetResource.class).getInstalledDistributionSet(response.getControllerId()))
|
response.add(linkTo(methodOn(TargetResource.class).getInstalledDistributionSet(response.getControllerId()))
|
||||||
.withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET));
|
.withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET));
|
||||||
response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId())).withRel(
|
response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId()))
|
||||||
RestConstants.TARGET_V1_ATTRIBUTES));
|
.withRel(RestConstants.TARGET_V1_ATTRIBUTES));
|
||||||
response.add(linkTo(
|
response.add(linkTo(methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0,
|
||||||
methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0,
|
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
|
||||||
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
|
ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null))
|
||||||
ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)).withRel(
|
.withRel(RestConstants.TARGET_V1_ACTIONS));
|
||||||
RestConstants.TARGET_V1_ACTIONS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,10 +74,10 @@ final public class TargetMapper {
|
|||||||
final PollStatus pollStatus = target.getTargetInfo().getPollStatus();
|
final PollStatus pollStatus = target.getTargetInfo().getPollStatus();
|
||||||
if (pollStatus != null) {
|
if (pollStatus != null) {
|
||||||
final PollStatusRest pollStatusRest = new PollStatusRest();
|
final PollStatusRest pollStatusRest = new PollStatusRest();
|
||||||
pollStatusRest.setLastRequestAt(Date.from(
|
pollStatusRest.setLastRequestAt(
|
||||||
pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
|
Date.from(pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
|
||||||
pollStatusRest.setNextExpectedRequestAt(Date.from(
|
pollStatusRest.setNextExpectedRequestAt(
|
||||||
pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
|
Date.from(pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
|
||||||
pollStatusRest.setOverdue(pollStatus.isOverdue());
|
pollStatusRest.setOverdue(pollStatus.isOverdue());
|
||||||
targetRest.setPollStatus(pollStatusRest);
|
targetRest.setPollStatus(pollStatusRest);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ public class TargetResource {
|
|||||||
final Slice<Target> findTargetsAll;
|
final Slice<Target> findTargetsAll;
|
||||||
final Long countTargetsAll;
|
final Long countTargetsAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
final Page<Target> findTargetPage = targetManagement.findTargetsAll(
|
final Page<Target> findTargetPage = targetManagement
|
||||||
RSQLUtility.parse(rsqlParam, TargetFields.class, entityManager), pageable);
|
.findTargetsAll(RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
|
||||||
countTargetsAll = findTargetPage.getTotalElements();
|
countTargetsAll = findTargetPage.getTotalElements();
|
||||||
findTargetsAll = findTargetPage;
|
findTargetsAll = findTargetPage;
|
||||||
} else {
|
} else {
|
||||||
@@ -159,8 +159,8 @@ public class TargetResource {
|
|||||||
* entities. In any failure the JsonResponseExceptionHandler is
|
* entities. In any failure the JsonResponseExceptionHandler is
|
||||||
* handling the response.
|
* handling the response.
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
|
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
||||||
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<TargetsRest> createTargets(@RequestBody final List<TargetRequestBody> targets) {
|
public ResponseEntity<TargetsRest> createTargets(@RequestBody final List<TargetRequestBody> targets) {
|
||||||
LOG.debug("creating {} targets", targets.size());
|
LOG.debug("creating {} targets", targets.size());
|
||||||
final Iterable<Target> createdTargets = targetManagement.createTargets(TargetMapper.fromRequest(targets));
|
final Iterable<Target> createdTargets = targetManagement.createTargets(TargetMapper.fromRequest(targets));
|
||||||
@@ -267,8 +267,7 @@ public class TargetResource {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json",
|
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json",
|
||||||
MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<ActionPagedList> getActionHistory(
|
public ResponseEntity<ActionPagedList> getActionHistory(@PathVariable final String targetId,
|
||||||
@PathVariable final String targetId,
|
|
||||||
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
|
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
|
||||||
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
|
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
|
||||||
@RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
|
@RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
|
||||||
@@ -284,7 +283,7 @@ public class TargetResource {
|
|||||||
final Slice<Action> activeActions;
|
final Slice<Action> activeActions;
|
||||||
final Long totalActionCount;
|
final Long totalActionCount;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
final Specification<Action> parse = RSQLUtility.parse(rsqlParam, ActionFields.class, entityManager);
|
final Specification<Action> parse = RSQLUtility.parse(rsqlParam, ActionFields.class);
|
||||||
activeActions = deploymentManagement.findActionsByTarget(parse, foundTarget, pageable);
|
activeActions = deploymentManagement.findActionsByTarget(parse, foundTarget, pageable);
|
||||||
totalActionCount = deploymentManagement.countActionsByTarget(parse, foundTarget);
|
totalActionCount = deploymentManagement.countActionsByTarget(parse, foundTarget);
|
||||||
} else {
|
} else {
|
||||||
@@ -292,8 +291,9 @@ public class TargetResource {
|
|||||||
totalActionCount = deploymentManagement.countActionsByTarget(foundTarget);
|
totalActionCount = deploymentManagement.countActionsByTarget(foundTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(new ActionPagedList(TargetMapper.toResponse(targetId, activeActions.getContent()),
|
return new ResponseEntity<>(
|
||||||
totalActionCount), HttpStatus.OK);
|
new ActionPagedList(TargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount),
|
||||||
|
HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,7 +308,8 @@ public class TargetResource {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}", produces = {
|
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}", produces = {
|
||||||
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<ActionRest> getAction(@PathVariable final String targetId, @PathVariable final Long actionId) {
|
public ResponseEntity<ActionRest> getAction(@PathVariable final String targetId,
|
||||||
|
@PathVariable final Long actionId) {
|
||||||
final Target target = findTargetWithExceptionIfNotFound(targetId);
|
final Target target = findTargetWithExceptionIfNotFound(targetId);
|
||||||
|
|
||||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||||
@@ -322,17 +323,16 @@ public class TargetResource {
|
|||||||
if (!action.isCancelingOrCanceled()) {
|
if (!action.isCancelingOrCanceled()) {
|
||||||
result.add(linkTo(
|
result.add(linkTo(
|
||||||
methodOn(DistributionSetResource.class).getDistributionSet(action.getDistributionSet().getId()))
|
methodOn(DistributionSetResource.class).getDistributionSet(action.getDistributionSet().getId()))
|
||||||
.withRel("distributionset"));
|
.withRel("distributionset"));
|
||||||
} else if (action.isCancelingOrCanceled()) {
|
} else if (action.isCancelingOrCanceled()) {
|
||||||
result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId())).withRel(
|
result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId()))
|
||||||
RestConstants.TARGET_V1_CANCELED_ACTION));
|
.withRel(RestConstants.TARGET_V1_CANCELED_ACTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
result.add(linkTo(
|
result.add(linkTo(methodOn(TargetResource.class).getActionStatusList(targetId, action.getId(), 0,
|
||||||
methodOn(TargetResource.class).getActionStatusList(targetId, action.getId(), 0,
|
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
|
||||||
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
|
ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC))
|
||||||
ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)).withRel(
|
.withRel(RestConstants.TARGET_V1_ACTION_STATUS));
|
||||||
RestConstants.TARGET_V1_ACTION_STATUS));
|
|
||||||
|
|
||||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@@ -394,8 +394,7 @@ public class TargetResource {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = {
|
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = {
|
||||||
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<ActionStatusPagedList> getActionStatusList(
|
public ResponseEntity<ActionStatusPagedList> getActionStatusList(@PathVariable final String targetId,
|
||||||
@PathVariable final String targetId,
|
|
||||||
@PathVariable final Long actionId,
|
@PathVariable final Long actionId,
|
||||||
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
|
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
|
||||||
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
|
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
|
||||||
@@ -416,8 +415,10 @@ public class TargetResource {
|
|||||||
final Page<ActionStatus> statusList = deploymentManagement.findActionStatusMessagesByActionInDescOrder(
|
final Page<ActionStatus> statusList = deploymentManagement.findActionStatusMessagesByActionInDescOrder(
|
||||||
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true);
|
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true);
|
||||||
|
|
||||||
return new ResponseEntity<>(new ActionStatusPagedList(TargetMapper.toActionStatusRestResponse(action,
|
return new ResponseEntity<>(
|
||||||
statusList.getContent()), statusList.getTotalElements()), HttpStatus.OK);
|
new ActionStatusPagedList(TargetMapper.toActionStatusRestResponse(action, statusList.getContent()),
|
||||||
|
statusList.getTotalElements()),
|
||||||
|
HttpStatus.OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,8 +437,8 @@ public class TargetResource {
|
|||||||
MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<DistributionSetRest> getAssignedDistributionSet(@PathVariable final String targetId) {
|
public ResponseEntity<DistributionSetRest> getAssignedDistributionSet(@PathVariable final String targetId) {
|
||||||
final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
|
final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
|
||||||
final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget
|
final DistributionSetRest distributionSetRest = DistributionSetMapper
|
||||||
.getAssignedDistributionSet());
|
.toResponse(findTarget.getAssignedDistributionSet());
|
||||||
final HttpStatus retStatus;
|
final HttpStatus retStatus;
|
||||||
if (distributionSetRest == null) {
|
if (distributionSetRest == null) {
|
||||||
retStatus = HttpStatus.NO_CONTENT;
|
retStatus = HttpStatus.NO_CONTENT;
|
||||||
@@ -466,8 +467,8 @@ public class TargetResource {
|
|||||||
@RequestBody final DistributionSetAssigmentRest dsId) {
|
@RequestBody final DistributionSetAssigmentRest dsId) {
|
||||||
|
|
||||||
findTargetWithExceptionIfNotFound(targetId);
|
findTargetWithExceptionIfNotFound(targetId);
|
||||||
final ActionType type = (dsId.getType() != null) ? RestResourceConversionHelper.convertActionType(dsId
|
final ActionType type = (dsId.getType() != null)
|
||||||
.getType()) : ActionType.FORCED;
|
? RestResourceConversionHelper.convertActionType(dsId.getType()) : ActionType.FORCED;
|
||||||
final Iterator<Target> changed = deploymentManagement
|
final Iterator<Target> changed = deploymentManagement
|
||||||
.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedTargets()
|
.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedTargets()
|
||||||
.iterator();
|
.iterator();
|
||||||
@@ -496,8 +497,8 @@ public class TargetResource {
|
|||||||
MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<DistributionSetRest> getInstalledDistributionSet(@PathVariable final String targetId) {
|
public ResponseEntity<DistributionSetRest> getInstalledDistributionSet(@PathVariable final String targetId) {
|
||||||
final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
|
final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
|
||||||
final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget.getTargetInfo()
|
final DistributionSetRest distributionSetRest = DistributionSetMapper
|
||||||
.getInstalledDistributionSet());
|
.toResponse(findTarget.getTargetInfo().getInstalledDistributionSet());
|
||||||
final HttpStatus retStatus;
|
final HttpStatus retStatus;
|
||||||
if (distributionSetRest == null) {
|
if (distributionSetRest == null) {
|
||||||
retStatus = HttpStatus.NO_CONTENT;
|
retStatus = HttpStatus.NO_CONTENT;
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ public class TargetTagResource {
|
|||||||
countTargetsAll = tagManagement.countTargetTags();
|
countTargetsAll = tagManagement.countTargetTags();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final Page<TargetTag> findTargetPage = tagManagement.findAllTargetTags(
|
final Page<TargetTag> findTargetPage = tagManagement
|
||||||
RSQLUtility.parse(rsqlParam, TagFields.class, entityManager), pageable);
|
.findAllTargetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
|
||||||
countTargetsAll = findTargetPage.getTotalElements();
|
countTargetsAll = findTargetPage.getTotalElements();
|
||||||
findTargetsAll = findTargetPage;
|
findTargetsAll = findTargetPage;
|
||||||
|
|
||||||
@@ -140,8 +140,8 @@ public class TargetTagResource {
|
|||||||
* with status code 201 - Created. The Response Body are the created
|
* with status code 201 - Created. The Response Body are the created
|
||||||
* target tags but without ResponseBody.
|
* target tags but without ResponseBody.
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
|
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
|
||||||
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
|
||||||
public ResponseEntity<TagsRest> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags) {
|
public ResponseEntity<TagsRest> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags) {
|
||||||
LOG.debug("creating {} target tags", tags.size());
|
LOG.debug("creating {} target tags", tags.size());
|
||||||
final List<TargetTag> createdTargetTags = tagManagement
|
final List<TargetTag> createdTargetTags = tagManagement
|
||||||
@@ -233,8 +233,8 @@ public class TargetTagResource {
|
|||||||
LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||||
|
|
||||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||||
final TargetTagAssigmentResult assigmentResult = targetManagement.toggleTagAssignment(
|
final TargetTagAssigmentResult assigmentResult = targetManagement
|
||||||
findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
|
.toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
|
||||||
|
|
||||||
final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest();
|
final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest();
|
||||||
tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedTargets()));
|
tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedTargets()));
|
||||||
@@ -259,8 +259,8 @@ public class TargetTagResource {
|
|||||||
@RequestBody final List<AssignedTargetRequestBody> assignedTargetRequestBodies) {
|
@RequestBody final List<AssignedTargetRequestBody> assignedTargetRequestBodies) {
|
||||||
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||||
final List<Target> assignedTarget = targetManagement.assignTag(
|
final List<Target> assignedTarget = targetManagement
|
||||||
findTargetControllerIds(assignedTargetRequestBodies), targetTag);
|
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTag);
|
||||||
return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK);
|
return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-security-core</artifactId>
|
<artifactId>hawkbit-security-core</artifactId>
|
||||||
<name>hawkBit :: Core Security</name>
|
<name>hawkBit :: Core Security</name>
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ public interface UserAuthenticationFilter {
|
|||||||
* servlet exception
|
* servlet exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
|
void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||||
ServletException;
|
throws IOException, ServletException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Filter#destroy()
|
* @see Filter#destroy()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-security-integration</artifactId>
|
<artifactId>hawkbit-security-integration</artifactId>
|
||||||
<name>hawkBit :: Security Integration</name>
|
<name>hawkBit :: Security Integration</name>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-test-report</artifactId>
|
<artifactId>hawkbit-test-report</artifactId>
|
||||||
<name>Hawkbit :: Test Report</name>
|
<name>Hawkbit :: Test Report</name>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.hawkbit</groupId>
|
<groupId>org.eclipse.hawkbit</groupId>
|
||||||
<artifactId>hawkbit-parent</artifactId>
|
<artifactId>hawkbit-parent</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>hawkbit-ui</artifactId>
|
<artifactId>hawkbit-ui</artifactId>
|
||||||
<name>hawkBit :: UI</name>
|
<name>hawkBit :: UI</name>
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
|||||||
if (userContext != null && userContext.getAuthentication() != null) {
|
if (userContext != null && userContext.getAuthentication() != null) {
|
||||||
final Object tenantAuthenticationDetails = userContext.getAuthentication().getDetails();
|
final Object tenantAuthenticationDetails = userContext.getAuthentication().getDetails();
|
||||||
if (tenantAuthenticationDetails instanceof TenantAwareAuthenticationDetails) {
|
if (tenantAuthenticationDetails instanceof TenantAwareAuthenticationDetails) {
|
||||||
return ((TenantAwareAuthenticationDetails) tenantAuthenticationDetails).getTenant().equalsIgnoreCase(
|
return ((TenantAwareAuthenticationDetails) tenantAuthenticationDetails).getTenant()
|
||||||
event.getTenant());
|
.equalsIgnoreCase(event.getTenant());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -176,8 +176,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
|
|||||||
contentVerticalLayout.setStyleName("main-content");
|
contentVerticalLayout.setStyleName("main-content");
|
||||||
contentVerticalLayout.setExpandRatio(content, 1.0F);
|
contentVerticalLayout.setExpandRatio(content, 1.0F);
|
||||||
setContent(rootLayout);
|
setContent(rootLayout);
|
||||||
final Resource resource = context.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme()
|
final Resource resource = context
|
||||||
+ "/layouts/footer.html");
|
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
|
||||||
try {
|
try {
|
||||||
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
|
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
|
||||||
customLayout.setSizeUndefined();
|
customLayout.setSizeUndefined();
|
||||||
|
|||||||
@@ -125,10 +125,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
|||||||
ui = UI.getCurrent();
|
ui = UI.getCurrent();
|
||||||
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
|
if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) {
|
||||||
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||||
populateArtifactDetails(
|
populateArtifactDetails(selectedSoftwareModule.getId(), HawkbitCommonUtil
|
||||||
selectedSoftwareModule.getId(),
|
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()));
|
||||||
HawkbitCommonUtil.getFormattedNameVersion(selectedSoftwareModule.getName(),
|
|
||||||
selectedSoftwareModule.getVersion()));
|
|
||||||
}
|
}
|
||||||
if (isMaximized()) {
|
if (isMaximized()) {
|
||||||
maximizedArtifactDetailsView();
|
maximizedArtifactDetailsView();
|
||||||
@@ -264,10 +262,10 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
|||||||
public Button generateCell(final Table source, final Object itemId, final Object columnId) {
|
public Button generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||||
final String fileName = (String) table.getContainerDataSource().getItem(itemId)
|
final String fileName = (String) table.getContainerDataSource().getItem(itemId)
|
||||||
.getItemProperty(PROVIDED_FILE_NAME).getValue();
|
.getItemProperty(PROVIDED_FILE_NAME).getValue();
|
||||||
final Button deleteIcon = SPUIComponentProvider.getButton(fileName + "-"
|
final Button deleteIcon = SPUIComponentProvider.getButton(
|
||||||
+ SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "", SPUILabelDefinitions.DISCARD,
|
fileName + "-" + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "",
|
||||||
ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O,
|
SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true,
|
||||||
SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class);
|
||||||
deleteIcon.setData(itemId);
|
deleteIcon.setData(itemId);
|
||||||
deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName));
|
deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName));
|
||||||
return deleteIcon;
|
return deleteIcon;
|
||||||
@@ -279,19 +277,17 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
|||||||
|
|
||||||
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.delete.artifact.confirmbox"),
|
final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.delete.artifact.confirmbox"),
|
||||||
i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"),
|
i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"),
|
||||||
i18n.get("button.cancel"),
|
i18n.get("button.cancel"), ok -> {
|
||||||
ok -> {
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
final ArtifactManagement artifactManagement = SpringContextHelper
|
final ArtifactManagement artifactManagement = SpringContextHelper
|
||||||
.getBean(ArtifactManagement.class);
|
.getBean(ArtifactManagement.class);
|
||||||
artifactManagement.deleteLocalArtifact(id);
|
artifactManagement.deleteLocalArtifact(id);
|
||||||
uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName));
|
uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName));
|
||||||
if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
|
if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
|
||||||
populateArtifactDetails(
|
populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(),
|
||||||
artifactUploadState.getSelectedBaseSwModuleId().get(),
|
HawkbitCommonUtil.getFormattedNameVersion(
|
||||||
HawkbitCommonUtil.getFormattedNameVersion(artifactUploadState
|
artifactUploadState.getSelectedBaseSoftwareModule().get().getName(),
|
||||||
.getSelectedBaseSoftwareModule().get().getName(), artifactUploadState
|
artifactUploadState.getSelectedBaseSoftwareModule().get().getVersion()));
|
||||||
.getSelectedBaseSoftwareModule().get().getVersion()));
|
|
||||||
} else {
|
} else {
|
||||||
populateArtifactDetails(null, null);
|
populateArtifactDetails(null, null);
|
||||||
}
|
}
|
||||||
@@ -469,8 +465,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
|||||||
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE) {
|
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE) {
|
||||||
ui.access(() -> {
|
ui.access(() -> {
|
||||||
if (softwareModuleEvent.getSoftwareModule() != null) {
|
if (softwareModuleEvent.getSoftwareModule() != null) {
|
||||||
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil
|
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(),
|
||||||
.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
|
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
|
||||||
softwareModuleEvent.getSoftwareModule().getVersion()));
|
softwareModuleEvent.getSoftwareModule().getVersion()));
|
||||||
} else {
|
} else {
|
||||||
populateArtifactDetails(null, null);
|
populateArtifactDetails(null, null);
|
||||||
@@ -480,8 +476,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
|||||||
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) {
|
if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) {
|
||||||
ui.access(() -> {
|
ui.access(() -> {
|
||||||
if (softwareModuleEvent.getSoftwareModule() != null) {
|
if (softwareModuleEvent.getSoftwareModule() != null) {
|
||||||
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil
|
populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(),
|
||||||
.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
|
HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(),
|
||||||
softwareModuleEvent.getSoftwareModule().getVersion()));
|
softwareModuleEvent.getSoftwareModule().getVersion()));
|
||||||
} else {
|
} else {
|
||||||
populateArtifactDetails(null, null);
|
populateArtifactDetails(null, null);
|
||||||
|
|||||||
@@ -150,7 +150,12 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean hasUpdatePermission() {
|
protected boolean hasUpdatePermission() {
|
||||||
return permChecker.hasUpdateDistributionPermission();
|
/**
|
||||||
|
* Footer layout should be displayed only when software modeule has
|
||||||
|
* delete permission.So update permission need not be checked in this
|
||||||
|
* case.
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -196,13 +201,13 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
}
|
}
|
||||||
if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
||||||
|
|
||||||
final String swModuleTypeName = sourceComponent.getId().replace(
|
final String swModuleTypeName = sourceComponent.getId()
|
||||||
SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
|
.replace(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
|
||||||
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
|
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
|
||||||
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
|
&& artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
|
||||||
.equalsIgnoreCase(swModuleTypeName)) {
|
.equalsIgnoreCase(swModuleTypeName)) {
|
||||||
notification.displayValidationError(i18n.get("message.swmodule.type.check.delete",
|
notification.displayValidationError(
|
||||||
new Object[] { swModuleTypeName }));
|
i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
|
||||||
} else {
|
} else {
|
||||||
deleteSWModuleType(swModuleTypeName);
|
deleteSWModuleType(swModuleTypeName);
|
||||||
updateSWActionCount();
|
updateSWActionCount();
|
||||||
@@ -361,15 +366,4 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
|
|
||||||
* hasReadPermission()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected boolean hasReadPermission() {
|
|
||||||
return permChecker.hasReadDistributionPermission();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,15 +100,14 @@ public class SoftwareModuleTable extends AbstractTable {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final SMFilterEvent filterEvent) {
|
void onEvent(final SMFilterEvent filterEvent) {
|
||||||
UI.getCurrent().access(
|
UI.getCurrent().access(() -> {
|
||||||
() -> {
|
|
||||||
|
|
||||||
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|
||||||
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|
||||||
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
|
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
|
||||||
refreshFilter();
|
refreshFilter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -139,8 +138,8 @@ public class SoftwareModuleTable extends AbstractTable {
|
|||||||
BaseSwModuleBeanQuery.class);
|
BaseSwModuleBeanQuery.class);
|
||||||
swQF.setQueryConfiguration(queryConfiguration);
|
swQF.setQueryConfiguration(queryConfiguration);
|
||||||
|
|
||||||
final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer container = new LazyQueryContainer(
|
||||||
SPUIDefinitions.PAGE_SIZE, "swId"), swQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF);
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,8 +206,8 @@ public class SoftwareModuleTable extends AbstractTable {
|
|||||||
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
|
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
|
||||||
artifactUploadState.setSelectedBaseSoftwareModule(baseSoftwareModule);
|
artifactUploadState.setSelectedBaseSoftwareModule(baseSoftwareModule);
|
||||||
artifactUploadState.setSelectedSoftwareModules(values);
|
artifactUploadState.setSelectedSoftwareModules(values);
|
||||||
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE,
|
eventBus.publish(this,
|
||||||
baseSoftwareModule));
|
new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
artifactUploadState.setSelectedBaseSwModuleId(null);
|
artifactUploadState.setSelectedBaseSwModuleId(null);
|
||||||
@@ -256,10 +255,10 @@ public class SoftwareModuleTable extends AbstractTable {
|
|||||||
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
|
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
|
||||||
if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) {
|
if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) {
|
||||||
artifactUploadState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId));
|
artifactUploadState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId));
|
||||||
}
|
}
|
||||||
@@ -283,10 +282,10 @@ public class SoftwareModuleTable extends AbstractTable {
|
|||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
||||||
columnList
|
columnList
|
||||||
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"),
|
columnList.add(
|
||||||
|
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||||
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
||||||
0.1F));
|
0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE,
|
|
||||||
i18n.get("header.modifiedDate"), 0.1F));
|
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
|
||||||
} else {
|
} else {
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F));
|
||||||
|
|||||||
@@ -211,14 +211,13 @@ public class SoftwareModuleDetailsTable extends Table {
|
|||||||
|
|
||||||
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet,
|
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet,
|
||||||
final Set<SoftwareModule> alreadyAssignedSwModules) {
|
final Set<SoftwareModule> alreadyAssignedSwModules) {
|
||||||
final SoftwareModule unAssignedSw = getSoftwareModule(
|
final SoftwareModule unAssignedSw = getSoftwareModule((Label) getContainerDataSource()
|
||||||
(Label) getContainerDataSource().getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE)
|
.getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE).getValue(), alreadyAssignedSwModules);
|
||||||
.getValue(), alreadyAssignedSwModules);
|
|
||||||
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
|
final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet,
|
||||||
unAssignedSw);
|
unAssignedSw);
|
||||||
manageDistUIState.setLastSelectedDistribution(newDistributionSet.getDistributionSetIdName());
|
manageDistUIState.setLastSelectedDistribution(newDistributionSet.getDistributionSetIdName());
|
||||||
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE,
|
eventBus.publish(this,
|
||||||
newDistributionSet));
|
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, newDistributionSet));
|
||||||
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION);
|
||||||
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));
|
uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName()));
|
||||||
}
|
}
|
||||||
@@ -251,8 +250,8 @@ public class SoftwareModuleDetailsTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Label createMandatoryLabel(final boolean mandatory) {
|
private Label createMandatoryLabel(final boolean mandatory) {
|
||||||
final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ") : HawkbitCommonUtil
|
final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ")
|
||||||
.getFormatedLabel(" ");
|
: HawkbitCommonUtil.getFormatedLabel(" ");
|
||||||
if (mandatory) {
|
if (mandatory) {
|
||||||
mandatoryLable.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
mandatoryLable.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
* Initialize.
|
* Initialize.
|
||||||
*/
|
*/
|
||||||
protected void init() {
|
protected void init() {
|
||||||
if (hasReadPermission() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) {
|
if (hasCountMessage() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) {
|
||||||
createComponents();
|
createComponents();
|
||||||
buildLayout();
|
buildLayout();
|
||||||
reload();
|
reload();
|
||||||
@@ -98,13 +98,16 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
hLayout.addComponent(bulkUploadStatusButton);
|
hLayout.addComponent(bulkUploadStatusButton);
|
||||||
hLayout.setComponentAlignment(bulkUploadStatusButton, Alignment.BOTTOM_LEFT);
|
hLayout.setComponentAlignment(bulkUploadStatusButton, Alignment.BOTTOM_LEFT);
|
||||||
}
|
}
|
||||||
addComponent(dropHintLayout);
|
if (dropHintLayout.getComponentCount() > 0) {
|
||||||
addComponent(hLayout);
|
addComponent(dropHintLayout);
|
||||||
setComponentAlignment(dropHintLayout, Alignment.BOTTOM_CENTER);
|
setComponentAlignment(dropHintLayout, Alignment.BOTTOM_CENTER);
|
||||||
setComponentAlignment(hLayout, Alignment.BOTTOM_CENTER);
|
}
|
||||||
|
if (hLayout.getComponentCount() > 0) {
|
||||||
|
addComponent(hLayout);
|
||||||
|
setComponentAlignment(hLayout, Alignment.BOTTOM_CENTER);
|
||||||
|
}
|
||||||
setStyleName("footer-layout");
|
setStyleName("footer-layout");
|
||||||
setWidth("100%");
|
setWidth("100%");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DragAndDropWrapper createDeleteWrapperLayout() {
|
private DragAndDropWrapper createDeleteWrapperLayout() {
|
||||||
@@ -155,21 +158,29 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setUploadStatusButtonCaption(final Long count) {
|
protected void setUploadStatusButtonCaption(final Long count) {
|
||||||
bulkUploadStatusButton.setCaption("<div class='unread'>" + count + "</div>");
|
if (null != bulkUploadStatusButton) {
|
||||||
|
bulkUploadStatusButton.setCaption("<div class='unread'>" + count + "</div>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void enableBulkUploadStatusButton() {
|
protected void enableBulkUploadStatusButton() {
|
||||||
bulkUploadStatusButton.setVisible(true);
|
if (null != bulkUploadStatusButton) {
|
||||||
|
bulkUploadStatusButton.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateUploadBtnIconToComplete() {
|
protected void updateUploadBtnIconToComplete() {
|
||||||
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
if (null != bulkUploadStatusButton) {
|
||||||
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
|
bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||||
|
bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateUploadBtnIconToProgressIndicator() {
|
protected void updateUploadBtnIconToProgressIndicator() {
|
||||||
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
if (null != bulkUploadStatusButton) {
|
||||||
bulkUploadStatusButton.setIcon(null);
|
bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE);
|
||||||
|
bulkUploadStatusButton.setIcon(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void actionButtonClicked() {
|
protected void actionButtonClicked() {
|
||||||
@@ -217,10 +228,12 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
* new count value.
|
* new count value.
|
||||||
*/
|
*/
|
||||||
protected void updateActionsCount(final int newCount) {
|
protected void updateActionsCount(final int newCount) {
|
||||||
if (newCount > 0) {
|
if (noActionBtn != null) {
|
||||||
noActionBtn.setCaption(getActionsButtonLabel() + "<div class='unread'>" + newCount + "</div>");
|
if (newCount > 0) {
|
||||||
} else {
|
noActionBtn.setCaption(getActionsButtonLabel() + "<div class='unread'>" + newCount + "</div>");
|
||||||
noActionBtn.setCaption(getNoActionsButtonLabel());
|
} else {
|
||||||
|
noActionBtn.setCaption(getNoActionsButtonLabel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,8 +256,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void hideBulkUploadStatusButton() {
|
protected void hideBulkUploadStatusButton() {
|
||||||
bulkUploadStatusButton.setCaption(null);
|
if (null != bulkUploadStatusButton) {
|
||||||
bulkUploadStatusButton.setVisible(false);
|
bulkUploadStatusButton.setCaption(null);
|
||||||
|
bulkUploadStatusButton.setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,6 +373,4 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
|
|||||||
|
|
||||||
protected abstract void showBulkUploadWindow();
|
protected abstract void showBulkUploadWindow();
|
||||||
|
|
||||||
protected abstract boolean hasReadPermission();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ public class DistributionTagToken extends AbstractTagToken {
|
|||||||
private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) {
|
private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) {
|
||||||
final Set<Long> distributionList = new HashSet<Long>();
|
final Set<Long> distributionList = new HashSet<Long>();
|
||||||
distributionList.add(selectedDS.getId());
|
distributionList.add(selectedDS.getId());
|
||||||
final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(
|
final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList,
|
||||||
distributionList, tagNameSelected);
|
tagNameSelected);
|
||||||
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
|
uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ public class SPUIErrorHandler extends DefaultErrorHandler {
|
|||||||
}
|
}
|
||||||
final Component errorOrgin = findAbstractComponent(event);
|
final Component errorOrgin = findAbstractComponent(event);
|
||||||
if (null != errorOrgin && errorOrgin.getUI() != null) {
|
if (null != errorOrgin && errorOrgin.getUI() != null) {
|
||||||
notification
|
notification.showNotification(style.toString(), i18n.get("caption.error"),
|
||||||
.showNotification(style.toString(), i18n.get("caption.error"), i18n.get("message.error.temp",
|
i18n.get("message.error.temp", new Object[] { exceptionName }), false,
|
||||||
new Object[] { exceptionName }), false, errorOrgin.getUI().getPage());
|
errorOrgin.getUI().getPage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,19 +178,19 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
||||||
madatoryLabel = getMandatoryLabel();
|
madatoryLabel = getMandatoryLabel();
|
||||||
|
|
||||||
typeName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " "
|
typeName = SPUIComponentProvider.getTextField("",
|
||||||
+ SPUIDefinitions.DIST_SET_TYPE_NAME, true, "", i18n.get("textfield.name"), true,
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_NAME, true, "",
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
typeName.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME);
|
typeName.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME);
|
||||||
|
|
||||||
typeKey = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " "
|
typeKey = SPUIComponentProvider.getTextField("",
|
||||||
+ SPUIDefinitions.DIST_SET_TYPE_KEY, true, "", i18n.get("textfield.key"), true,
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_KEY, true, "", i18n.get("textfield.key"),
|
||||||
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||||
typeKey.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY);
|
typeKey.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY);
|
||||||
|
|
||||||
typeDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " "
|
typeDesc = SPUIComponentProvider.getTextArea("",
|
||||||
+ SPUIDefinitions.DIST_SET_TYPE_DESC, false, "", i18n.get("textfield.description"),
|
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC, false, "",
|
||||||
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
|
||||||
|
|
||||||
typeDesc.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC);
|
typeDesc.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC);
|
||||||
typeDesc.setImmediate(true);
|
typeDesc.setImmediate(true);
|
||||||
@@ -492,12 +492,10 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
Item saveTblitem;
|
Item saveTblitem;
|
||||||
saveTblitem = sourceTablecontainer.addItem(selectedId);
|
saveTblitem = sourceTablecontainer.addItem(selectedId);
|
||||||
selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_NAME);
|
selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_NAME);
|
||||||
saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue(
|
saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue(selectedTable.getContainerDataSource()
|
||||||
selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_NAME)
|
.getItem(selectedId).getItemProperty(DIST_TYPE_NAME).getValue());
|
||||||
.getValue());
|
saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue(selectedTable.getContainerDataSource()
|
||||||
saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue(
|
.getItem(selectedId).getItemProperty(DIST_TYPE_DESCRIPTION).getValue());
|
||||||
selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_DESCRIPTION)
|
|
||||||
.getValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,9 +531,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
final double greenColorValue = color.getGreen();
|
final double greenColorValue = color.getGreen();
|
||||||
greenSlider.setValue(new Double(greenColorValue));
|
greenSlider.setValue(new Double(greenColorValue));
|
||||||
} catch (final ValueOutOfBoundsException e) {
|
} catch (final ValueOutOfBoundsException e) {
|
||||||
LOG.error(
|
LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + ","
|
||||||
"Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + ","
|
+ color.getBlue(), e);
|
||||||
+ color.getBlue(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,8 +618,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
|
|
||||||
private Boolean checkIsDuplicate(final DistributionSetType existingDistType) {
|
private Boolean checkIsDuplicate(final DistributionSetType existingDistType) {
|
||||||
if (existingDistType != null) {
|
if (existingDistType != null) {
|
||||||
uiNotification.displayValidationError(i18n.get("message.tag.duplicate.check",
|
uiNotification.displayValidationError(
|
||||||
new Object[] { existingDistType.getName() }));
|
i18n.get("message.tag.duplicate.check", new Object[] { existingDistType.getName() }));
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
@@ -630,8 +627,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
|
|
||||||
private Boolean checkIsDuplicateByKey(final DistributionSetType existingDistType) {
|
private Boolean checkIsDuplicateByKey(final DistributionSetType existingDistType) {
|
||||||
if (existingDistType != null) {
|
if (existingDistType != null) {
|
||||||
uiNotification.displayValidationError(i18n.get("message.type.key.duplicate.check",
|
uiNotification.displayValidationError(
|
||||||
new Object[] { existingDistType.getKey() }));
|
i18n.get("message.type.key.duplicate.check", new Object[] { existingDistType.getKey() }));
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
@@ -681,7 +678,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
newDistType = distributionSetManagement.createDistributionSetType(newDistType);
|
newDistType = distributionSetManagement.createDistributionSetType(newDistType);
|
||||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistType.getName() }));
|
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistType.getName() }));
|
||||||
closeWindow();
|
closeWindow();
|
||||||
eventBus.publish(this, new DistributionSetTypeEvent(DistributionSetTypeEnum.ADD_DIST_SET_TYPE, newDistType));
|
eventBus.publish(this,
|
||||||
|
new DistributionSetTypeEvent(DistributionSetTypeEnum.ADD_DIST_SET_TYPE, newDistType));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.missing.typenameorkey"));
|
uiNotification.displayValidationError(i18n.get("message.error.missing.typenameorkey"));
|
||||||
@@ -724,11 +722,11 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
}
|
}
|
||||||
updateDistSetType.setColour(getColorPickedSting());
|
updateDistSetType.setColour(getColorPickedSting());
|
||||||
distributionSetManagement.updateDistributionSetType(updateDistSetType);
|
distributionSetManagement.updateDistributionSetType(updateDistSetType);
|
||||||
uiNotification.displaySuccess(i18n.get("message.update.success",
|
uiNotification
|
||||||
new Object[] { updateDistSetType.getName() }));
|
.displaySuccess(i18n.get("message.update.success", new Object[] { updateDistSetType.getName() }));
|
||||||
closeWindow();
|
closeWindow();
|
||||||
eventBus.publish(this, new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE,
|
eventBus.publish(this,
|
||||||
updateDistSetType));
|
new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory"));
|
||||||
@@ -995,9 +993,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
||||||
final LazyQueryContainer disttypeContainer = HawkbitCommonUtil
|
final LazyQueryContainer disttypeContainer = HawkbitCommonUtil.createLazyQueryContainer(
|
||||||
.createLazyQueryContainer(new BeanQueryFactory<DistributionSetTypeBeanQuery>(
|
new BeanQueryFactory<DistributionSetTypeBeanQuery>(DistributionSetTypeBeanQuery.class));
|
||||||
DistributionSetTypeBeanQuery.class));
|
|
||||||
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
|
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
|
||||||
|
|
||||||
return disttypeContainer;
|
return disttypeContainer;
|
||||||
@@ -1049,8 +1046,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
|
|||||||
selectedTable.setEnabled(true);
|
selectedTable.setEnabled(true);
|
||||||
saveDistSetType.setEnabled(true);
|
saveDistSetType.setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
uiNotification.displayValidationError(selectedTypeTag.getName() + " "
|
uiNotification.displayValidationError(
|
||||||
+ i18n.get("message.error.dist.set.type.update"));
|
selectedTypeTag.getName() + " " + i18n.get("message.error.dist.set.type.update"));
|
||||||
distTypeSelectLayout.setEnabled(false);
|
distTypeSelectLayout.setEnabled(false);
|
||||||
selectedTable.setEnabled(false);
|
selectedTable.setEnabled(false);
|
||||||
saveDistSetType.setEnabled(false);
|
saveDistSetType.setEnabled(false);
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
private void showUnsavedAssignment() {
|
private void showUnsavedAssignment() {
|
||||||
Item item;
|
Item item;
|
||||||
final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = manageDistUIState.getAssignedList();
|
final Map<DistributionSetIdName, Set<SoftwareModuleIdName>> assignedList = manageDistUIState.getAssignedList();
|
||||||
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState
|
final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||||
.getLastSelectedDistribution().get().getId() : null;
|
? manageDistUIState.getLastSelectedDistribution().get().getId() : null;
|
||||||
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
|
Set<SoftwareModuleIdName> softwareModuleIdNameList = null;
|
||||||
|
|
||||||
for (final Map.Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
|
for (final Map.Entry<DistributionSetIdName, Set<SoftwareModuleIdName>> entry : assignedList.entrySet()) {
|
||||||
@@ -174,20 +174,18 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
.append("<I>");
|
.append("<I>");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assignedSWModule.put(
|
assignedSWModule.put(softwareModule.getType().getName(),
|
||||||
softwareModule.getType().getName(),
|
new StringBuilder().append("<I>").append(
|
||||||
new StringBuilder()
|
getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion()))
|
||||||
.append("<I>")
|
.append("<I>"));
|
||||||
.append(getUnsavedAssigedSwModule(softwareModule.getName(),
|
|
||||||
softwareModule.getVersion())).append("<I>"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
|
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
|
||||||
item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
|
item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.getItemProperty(SOFT_MODULE).setValue(
|
item.getItemProperty(SOFT_MODULE)
|
||||||
HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
|
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
|
||||||
assignSoftModuleButton(item, entry);
|
assignSoftModuleButton(item, entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -200,10 +198,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
* @param entry
|
* @param entry
|
||||||
*/
|
*/
|
||||||
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
|
private void assignSoftModuleButton(final Item item, final Map.Entry<String, StringBuilder> entry) {
|
||||||
if (permissionChecker.hasUpdateDistributionPermission()
|
if (permissionChecker.hasUpdateDistributionPermission() && distributionSetManagement
|
||||||
&& distributionSetManagement
|
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
|
||||||
.findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId())
|
.getAssignedTargets().isEmpty()) {
|
||||||
.getAssignedTargets().isEmpty()) {
|
|
||||||
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
|
final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true,
|
||||||
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||||
reassignSoftModule.setEnabled(false);
|
reassignSoftModule.setEnabled(false);
|
||||||
@@ -237,25 +234,20 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
* same type is dropped, then override with previous one.
|
* same type is dropped, then override with previous one.
|
||||||
*/
|
*/
|
||||||
if (module.getType().getMaxAssignments() == 1) {
|
if (module.getType().getMaxAssignments() == 1) {
|
||||||
assignedSWModule.put(
|
assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
|
||||||
module.getType().getName(),
|
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
|
||||||
new StringBuilder().append("<I>")
|
|
||||||
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion()))
|
|
||||||
.append("</I>"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assignedSWModule.put(
|
assignedSWModule.put(module.getType().getName(), new StringBuilder().append("<I>")
|
||||||
module.getType().getName(),
|
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
|
||||||
new StringBuilder().append("<I>")
|
|
||||||
.append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("</I>"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
|
for (final Map.Entry<String, StringBuilder> entry : assignedSWModule.entrySet()) {
|
||||||
final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
|
final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey());
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
item.getItemProperty(SOFT_MODULE).setValue(
|
item.getItemProperty(SOFT_MODULE)
|
||||||
HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
|
.setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString()));
|
||||||
assignSoftModuleButton(item, entry);
|
assignSoftModuleButton(item, entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -313,9 +305,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isMigrationRequired != null) {
|
if (isMigrationRequired != null) {
|
||||||
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
|
detailsTabLayout.addComponent(
|
||||||
i18n.get("checkbox.dist.migration.required"),
|
SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"),
|
||||||
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
|
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,7 +437,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
||||||
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|
||||||
|| distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
|
|| distributionTableEvent
|
||||||
|
.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
|
||||||
assignedSWModule.clear();
|
assignedSWModule.clear();
|
||||||
ui.access(() -> {
|
ui.access(() -> {
|
||||||
/**
|
/**
|
||||||
@@ -474,8 +467,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
.getDistributionSetIdName();
|
.getDistributionSetIdName();
|
||||||
if (distIdName.getId().equals(selectedDsModule.getId())
|
if (distIdName.getId().equals(selectedDsModule.getId())
|
||||||
&& distIdName.getName().equals(selectedDsModule.getName())) {
|
&& distIdName.getName().equals(selectedDsModule.getName())) {
|
||||||
selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule
|
selectedDsModule = distributionSetManagement
|
||||||
.getId());
|
.findDistributionSetByIdWithDetails(selectedDsModule.getId());
|
||||||
populteModule(selectedDsModule);
|
populteModule(selectedDsModule);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -484,7 +477,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
|
void onEvent(final SaveActionWindowEvent saveActionWindowEvent) {
|
||||||
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS || saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
|
if ((saveActionWindowEvent == SaveActionWindowEvent.SAVED_ASSIGNMENTS
|
||||||
|
|| saveActionWindowEvent == SaveActionWindowEvent.DISCARD_ALL_ASSIGNMENTS)
|
||||||
&& selectedDsModule != null) {
|
&& selectedDsModule != null) {
|
||||||
assignedSWModule.clear();
|
assignedSWModule.clear();
|
||||||
selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule.getId());
|
selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule.getId());
|
||||||
|
|||||||
@@ -162,15 +162,16 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||||
|
|
||||||
if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
|
if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) {
|
||||||
queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, manageDistUIState
|
queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE,
|
||||||
.getManageDistFilters().getClickedDistSetType());
|
manageDistUIState.getManageDistFilters().getClickedDistSetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<ManageDistBeanQuery>(
|
final BeanQueryFactory<ManageDistBeanQuery> distributionQF = new BeanQueryFactory<ManageDistBeanQuery>(
|
||||||
ManageDistBeanQuery.class);
|
ManageDistBeanQuery.class);
|
||||||
distributionQF.setQueryConfiguration(queryConfiguration);
|
distributionQF.setQueryConfiguration(queryConfiguration);
|
||||||
final LazyQueryContainer distContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer distContainer = new LazyQueryContainer(
|
||||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
|
||||||
|
distributionQF);
|
||||||
|
|
||||||
return distContainer;
|
return distContainer;
|
||||||
}
|
}
|
||||||
@@ -254,8 +255,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
|
|
||||||
final DistributionSet lastSelectedDistSet = distributionSetManagement
|
final DistributionSet lastSelectedDistSet = distributionSetManagement
|
||||||
.findDistributionSetByIdWithDetails(value.getId());
|
.findDistributionSetByIdWithDetails(value.getId());
|
||||||
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE,
|
eventBus.publish(this,
|
||||||
lastSelectedDistSet));
|
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
manageDistUIState.setSelectedDistributions(null);
|
manageDistUIState.setSelectedDistributions(null);
|
||||||
@@ -394,8 +395,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
|
private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) {
|
||||||
if (manageDistUIState.getLastSelectedDistribution().isPresent()
|
if (manageDistUIState.getLastSelectedDistribution().isPresent()
|
||||||
&& manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
|
&& manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) {
|
||||||
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE,
|
eventBus.publish(this,
|
||||||
softwareModule));
|
new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,8 +405,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
* @param softwareModule
|
* @param softwareModule
|
||||||
* @param softwareModuleIdName
|
* @param softwareModuleIdName
|
||||||
*/
|
*/
|
||||||
private void handleFirmwareCase(final Map<Long, Set<SoftwareModuleIdName>> map,
|
private void handleFirmwareCase(final Map<Long, Set<SoftwareModuleIdName>> map, final SoftwareModule softwareModule,
|
||||||
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
|
final SoftwareModuleIdName softwareModuleIdName) {
|
||||||
if (softwareModule.getType().getMaxAssignments() == 1) {
|
if (softwareModule.getType().getMaxAssignments() == 1) {
|
||||||
if (!map.containsKey(softwareModule.getType().getId())) {
|
if (!map.containsKey(softwareModule.getType().getId())) {
|
||||||
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
||||||
@@ -422,8 +423,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
* @param softwareModule
|
* @param softwareModule
|
||||||
* @param softwareModuleIdName
|
* @param softwareModuleIdName
|
||||||
*/
|
*/
|
||||||
private void handleSoftwareCase(final Map<Long, Set<SoftwareModuleIdName>> map,
|
private void handleSoftwareCase(final Map<Long, Set<SoftwareModuleIdName>> map, final SoftwareModule softwareModule,
|
||||||
final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) {
|
final SoftwareModuleIdName softwareModuleIdName) {
|
||||||
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) {
|
||||||
if (!map.containsKey(softwareModule.getType().getId())) {
|
if (!map.containsKey(softwareModule.getType().getId())) {
|
||||||
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
map.put(softwareModule.getType().getId(), new HashSet<SoftwareModuleIdName>());
|
||||||
@@ -547,14 +548,14 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(distributionSet.getId());
|
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(distributionSet.getId());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(distributionSet.getDescription());
|
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(distributionSet.getDescription());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(distributionSet.getVersion());
|
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(distributionSet.getVersion());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
|
||||||
HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
|
.setValue(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
|
||||||
HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
|
.setValue(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(distributionSet.isComplete());
|
item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(distributionSet.isComplete());
|
||||||
if (manageDistUIState.getSelectedDistributions().isPresent()) {
|
if (manageDistUIState.getSelectedDistributions().isPresent()) {
|
||||||
manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
|
manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId));
|
||||||
@@ -569,8 +570,8 @@ public class DistributionSetTable extends AbstractTable {
|
|||||||
if (propertyId == null) {
|
if (propertyId == null) {
|
||||||
// Styling for row
|
// Styling for row
|
||||||
final Item item = getItem(itemId);
|
final Item item = getItem(itemId);
|
||||||
final Boolean isComplete = (Boolean) item.getItemProperty(
|
final Boolean isComplete = (Boolean) item
|
||||||
SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue();
|
.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue();
|
||||||
if (!isComplete) {
|
if (!isComplete) {
|
||||||
return SPUIDefinitions.DISABLE_DISTRIBUTION;
|
return SPUIDefinitions.DISABLE_DISTRIBUTION;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 3494052985006132714L;
|
private static final long serialVersionUID = 3494052985006132714L;
|
||||||
|
|
||||||
private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(Arrays.asList(
|
private static final List<Object> DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(
|
||||||
DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG,
|
Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG,
|
||||||
DragEvent.SOFTWAREMODULE_TYPE_DRAG));
|
DragEvent.SOFTWAREMODULE_TYPE_DRAG));
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private I18N i18n;
|
private I18N i18n;
|
||||||
@@ -236,8 +236,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId,
|
final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId,
|
||||||
SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS);
|
SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS);
|
||||||
if (isDsTypeSelected(distTypeName)) {
|
if (isDsTypeSelected(distTypeName)) {
|
||||||
notification.displayValidationError(i18n.get("message.dist.type.check.delete",
|
notification
|
||||||
new Object[] { distTypeName }));
|
.displayValidationError(i18n.get("message.dist.type.check.delete", new Object[] { distTypeName }));
|
||||||
} else if (isDefaultDsType(distTypeName)) {
|
} else if (isDefaultDsType(distTypeName)) {
|
||||||
notification.displayValidationError(i18n.get("message.cannot.delete.default.dstype"));
|
notification.displayValidationError(i18n.get("message.cannot.delete.default.dstype"));
|
||||||
} else {
|
} else {
|
||||||
@@ -253,9 +253,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
* @return true if ds type is selected
|
* @return true if ds type is selected
|
||||||
*/
|
*/
|
||||||
private boolean isDsTypeSelected(final String distTypeName) {
|
private boolean isDsTypeSelected(final String distTypeName) {
|
||||||
return null != manageDistUIState.getManageDistFilters().getClickedDistSetType()
|
return null != manageDistUIState.getManageDistFilters().getClickedDistSetType() && manageDistUIState
|
||||||
&& manageDistUIState.getManageDistFilters().getClickedDistSetType().getName()
|
.getManageDistFilters().getClickedDistSetType().getName().equalsIgnoreCase(distTypeName);
|
||||||
.equalsIgnoreCase(distTypeName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processDeleteSWType(final String swTypeId) {
|
private void processDeleteSWType(final String swTypeId) {
|
||||||
@@ -265,8 +264,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
|
if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
|
||||||
&& manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
|
&& manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName()
|
||||||
.equalsIgnoreCase(swModuleTypeName)) {
|
.equalsIgnoreCase(swModuleTypeName)) {
|
||||||
notification.displayValidationError(i18n.get("message.swmodule.type.check.delete",
|
notification.displayValidationError(
|
||||||
new Object[] { swModuleTypeName }));
|
i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
|
||||||
} else {
|
} else {
|
||||||
manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
|
manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
|
||||||
updateDSActionCount();
|
updateDSActionCount();
|
||||||
@@ -541,14 +540,4 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
|||||||
return getCurrentDistributionSetType() != null && getCurrentDistributionSetType().getName().equals(dsTypeName);
|
return getCurrentDistributionSetType() != null && getCurrentDistributionSetType().getName().equals(dsTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout#
|
|
||||||
* hasReadPermission()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected boolean hasReadPermission() {
|
|
||||||
return permChecker.hasReadDistributionPermission();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,16 +119,15 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final SMFilterEvent filterEvent) {
|
void onEvent(final SMFilterEvent filterEvent) {
|
||||||
UI.getCurrent().access(
|
UI.getCurrent().access(() -> {
|
||||||
() -> {
|
|
||||||
|
|
||||||
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|
if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT
|
||||||
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE
|
||||||
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
|
|| filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) {
|
||||||
refreshFilter();
|
refreshFilter();
|
||||||
styleTableOnDistSelection();
|
styleTableOnDistSelection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
@@ -192,8 +191,8 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
SwModuleBeanQuery.class);
|
SwModuleBeanQuery.class);
|
||||||
swQF.setQueryConfiguration(queryConfiguration);
|
swQF.setQueryConfiguration(queryConfiguration);
|
||||||
|
|
||||||
final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer container = new LazyQueryContainer(
|
||||||
SPUIDefinitions.PAGE_SIZE, "swId"), swQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF);
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,8 +214,8 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true);
|
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true);
|
||||||
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
|
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
|
||||||
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, true);
|
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, true);
|
||||||
lazyContainer
|
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false,
|
||||||
.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
|
true);
|
||||||
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_COLOR, String.class, null, false, true);
|
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_COLOR, String.class, null, false, true);
|
||||||
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_SOFT_TYPE_ID, Long.class, null, false, true);
|
lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_SOFT_TYPE_ID, Long.class, null, false, true);
|
||||||
}
|
}
|
||||||
@@ -291,8 +290,8 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
manageDistUIState.setSelectedBaseSwModuleId(value);
|
manageDistUIState.setSelectedBaseSwModuleId(value);
|
||||||
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
|
final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value);
|
||||||
manageDistUIState.setSelectedSoftwareModules(values);
|
manageDistUIState.setSelectedSoftwareModules(values);
|
||||||
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE,
|
eventBus.publish(this,
|
||||||
baseSoftwareModule));
|
new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
manageDistUIState.setSelectedBaseSwModuleId(null);
|
manageDistUIState.setSelectedBaseSwModuleId(null);
|
||||||
@@ -318,10 +317,10 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
||||||
columnList
|
columnList
|
||||||
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"),
|
columnList.add(
|
||||||
|
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||||
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
||||||
0.1F));
|
0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE,
|
|
||||||
i18n.get("header.modifiedDate"), 0.1F));
|
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
|
||||||
} else {
|
} else {
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.7F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.7F));
|
||||||
@@ -380,9 +379,9 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
|
|
||||||
private void addTypeStyle(final Long tagId, final String color) {
|
private void addTypeStyle(final Long tagId, final String color) {
|
||||||
final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript();
|
final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript();
|
||||||
UI.getCurrent().access(
|
UI.getCurrent()
|
||||||
() -> javaScript.execute(HawkbitCommonUtil
|
.access(() -> javaScript.execute(
|
||||||
.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId
|
HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId
|
||||||
+ "{background-color:" + color + " !important;background-image:none !important }")));
|
+ "{background-color:" + color + " !important;background-image:none !important }")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,10 +443,10 @@ public class SwModuleTable extends AbstractTable {
|
|||||||
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
|
item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt()));
|
||||||
|
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(swModule.getType().getColour());
|
item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(swModule.getType().getColour());
|
||||||
if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) {
|
if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) {
|
||||||
|
|||||||
@@ -366,9 +366,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
|
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
|
||||||
if (validationFailed
|
if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query)
|
||||||
|| (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField
|
|| (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) {
|
||||||
.getValue().equals(oldFilterName)))) {
|
|
||||||
saveButton.setEnabled(false);
|
saveButton.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
if (hasSavePermission()) {
|
if (hasSavePermission()) {
|
||||||
@@ -469,8 +468,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
|||||||
targetFilterQuery.setName(nameTextField.getValue());
|
targetFilterQuery.setName(nameTextField.getValue());
|
||||||
targetFilterQuery.setQuery(queryTextField.getValue());
|
targetFilterQuery.setQuery(queryTextField.getValue());
|
||||||
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
|
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
|
||||||
notification.displaySuccess(i18n.get("message.create.filter.success",
|
notification.displaySuccess(
|
||||||
new Object[] { targetFilterQuery.getName() }));
|
i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
|
||||||
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
|
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
||||||
filterManagementUIState.setFilterQueryValue(null);
|
filterManagementUIState.setFilterQueryValue(null);
|
||||||
} else {
|
} else {
|
||||||
filterManagementUIState.getTfQuery().ifPresent(
|
filterManagementUIState.getTfQuery()
|
||||||
value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
|
.ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +121,9 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
targetQF.setQueryConfiguration(queryConfig);
|
targetQF.setQueryConfiguration(queryConfig);
|
||||||
|
|
||||||
// create lazy query container with lazy defination and query
|
// create lazy query container with lazy defination and query
|
||||||
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
|
||||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
|
||||||
|
targetQF);
|
||||||
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
||||||
|
|
||||||
return targetTableContainer;
|
return targetTableContainer;
|
||||||
@@ -182,12 +183,12 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
columnList.add(
|
||||||
0.1F));
|
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n
|
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
|
||||||
.get("header.assigned.ds"), 0.125F));
|
i18n.get("header.assigned.ds"), 0.125F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n
|
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
|
||||||
.get("header.installed.ds"), 0.125F));
|
i18n.get("header.installed.ds"), 0.125F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
|
||||||
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.target.status"), 0.1F));
|
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.target.status"), 0.1F));
|
||||||
return columnList;
|
return columnList;
|
||||||
@@ -195,8 +196,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
|||||||
|
|
||||||
private Component getStatusIcon(final Object itemId) {
|
private Component getStatusIcon(final Object itemId) {
|
||||||
final Item row1 = getItem(itemId);
|
final Item row1 = getItem(itemId);
|
||||||
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty(
|
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
|
||||||
SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
||||||
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
||||||
label.setContentMode(ContentMode.HTML);
|
label.setContentMode(ContentMode.HTML);
|
||||||
if (targetStatus == TargetUpdateStatus.PENDING) {
|
if (targetStatus == TargetUpdateStatus.PENDING) {
|
||||||
|
|||||||
@@ -99,11 +99,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
Slice<Target> targetBeans;
|
Slice<Target> targetBeans;
|
||||||
final List<ProxyTarget> proxyTargetBeans = new ArrayList<>();
|
final List<ProxyTarget> proxyTargetBeans = new ArrayList<>();
|
||||||
if (!Strings.isNullOrEmpty(filterQuery)) {
|
if (!Strings.isNullOrEmpty(filterQuery)) {
|
||||||
targetBeans = targetManagement.findTargetsAll(filterQuery, new PageRequest(startIndex
|
targetBeans = targetManagement.findTargetsAll(filterQuery,
|
||||||
/ SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
|
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
|
||||||
} else {
|
} else {
|
||||||
targetBeans = targetManagement.findTargetsAll(new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE,
|
targetBeans = targetManagement.findTargetsAll(
|
||||||
SPUIDefinitions.PAGE_SIZE, sort));
|
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Target targ : targetBeans) {
|
for (final Target targ : targetBeans) {
|
||||||
@@ -135,8 +135,8 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
|||||||
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
|
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
|
||||||
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
|
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
|
||||||
prxyTarget.setTargetInfo(targ.getTargetInfo());
|
prxyTarget.setTargetInfo(targ.getTargetInfo());
|
||||||
prxyTarget.setPollStatusToolTip(HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo()
|
prxyTarget.setPollStatusToolTip(
|
||||||
.getPollStatus(), getI18N()));
|
HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N()));
|
||||||
proxyTargetBeans.add(prxyTarget);
|
proxyTargetBeans.add(prxyTarget);
|
||||||
}
|
}
|
||||||
return proxyTargetBeans;
|
return proxyTargetBeans;
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public final class FilterQueryValidation {
|
|||||||
public static List<String> processExpectedTokens(final List<Integer> expectedTokens) {
|
public static List<String> processExpectedTokens(final List<Integer> expectedTokens) {
|
||||||
final List<String> expectToken = new ArrayList<>();
|
final List<String> expectToken = new ArrayList<>();
|
||||||
if (expectedTokens.size() == 2 && expectedTokens.contains(9) && expectedTokens.contains(4)) {
|
if (expectedTokens.size() == 2 && expectedTokens.contains(9) && expectedTokens.contains(4)) {
|
||||||
final List<String> expectedFieldList = Arrays.stream(TargetFields.values())
|
final List<String> expectedFieldList = Arrays.stream(TargetFields.values()).map(v -> v.name().toLowerCase())
|
||||||
.map(v -> v.name().toLowerCase()).collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
expectToken.addAll(expectedFieldList);
|
expectToken.addAll(expectedFieldList);
|
||||||
expectToken.add("assignedds.name");
|
expectToken.add("assignedds.name");
|
||||||
expectToken.add("assignedds.version");
|
expectToken.add("assignedds.version");
|
||||||
|
|||||||
@@ -112,11 +112,11 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
|
|||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
if (Strings.isNullOrEmpty(searchText)) {
|
if (Strings.isNullOrEmpty(searchText)) {
|
||||||
firstPageTargetFilter = getTargetFilterQueryManagement().findAllTargetFilterQuery(
|
firstPageTargetFilter = getTargetFilterQueryManagement()
|
||||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort));
|
.findAllTargetFilterQuery(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort));
|
||||||
} else {
|
} else {
|
||||||
firstPageTargetFilter = getTargetFilterQueryManagement().findTargetFilterQueryByFilters(
|
firstPageTargetFilter = getTargetFilterQueryManagement()
|
||||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), searchText);
|
.findTargetFilterQueryByFilters(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), searchText);
|
||||||
}
|
}
|
||||||
final long size = firstPageTargetFilter.getTotalElements();
|
final long size = firstPageTargetFilter.getTotalElements();
|
||||||
|
|
||||||
|
|||||||
@@ -103,15 +103,14 @@ public class TargetFilterTable extends Table {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final CustomFilterUIEvent filterEvent) {
|
void onEvent(final CustomFilterUIEvent filterEvent) {
|
||||||
UI.getCurrent().access(
|
UI.getCurrent().access(() -> {
|
||||||
() -> {
|
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
|
||||||
if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT
|
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|
||||||
|| filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE
|
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|
||||||
|| filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY
|
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
|
||||||
|| filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) {
|
refreshContainer();
|
||||||
refreshContainer();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,8 +125,8 @@ public class TargetFilterTable extends Table {
|
|||||||
|
|
||||||
targetQF.setQueryConfiguration(queryConfig);
|
targetQF.setQueryConfiguration(queryConfig);
|
||||||
// create lazy query container with lazy defination and query
|
// create lazy query container with lazy defination and query
|
||||||
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(
|
||||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF);
|
||||||
targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
||||||
|
|
||||||
return targetFilterContainer;
|
return targetFilterContainer;
|
||||||
@@ -136,8 +135,8 @@ public class TargetFilterTable extends Table {
|
|||||||
|
|
||||||
private Map<String, Object> prepareQueryConfigFilters() {
|
private Map<String, Object> prepareQueryConfigFilters() {
|
||||||
final Map<String, Object> queryConfig = new HashMap<String, Object>();
|
final Map<String, Object> queryConfig = new HashMap<String, Object>();
|
||||||
filterManagementUIState.getCustomFilterSearchText().ifPresent(
|
filterManagementUIState.getCustomFilterSearchText()
|
||||||
value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
.ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
|
||||||
return queryConfig;
|
return queryConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +205,8 @@ public class TargetFilterTable extends Table {
|
|||||||
* of the deleted custom filter.
|
* of the deleted custom filter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
notification.displaySuccess(i18n.get("message.delete.filter.success",
|
notification.displaySuccess(
|
||||||
new Object[] { deletedFilterName }));
|
i18n.get("message.delete.filter.success", new Object[] { deletedFilterName }));
|
||||||
refreshContainer();
|
refreshContainer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -201,14 +201,16 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
|||||||
private void buildPasswordField() {
|
private void buildPasswordField() {
|
||||||
password = new PasswordField(i18n.get("label.login.password"));
|
password = new PasswordField(i18n.get("label.login.password"));
|
||||||
password.setIcon(FontAwesome.LOCK);
|
password.setIcon(FontAwesome.LOCK);
|
||||||
password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD);
|
password.addStyleName(
|
||||||
|
ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD);
|
||||||
password.setId("login-password");
|
password.setId("login-password");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildUserField() {
|
private void buildUserField() {
|
||||||
username = new TextField(i18n.get("label.login.username"));
|
username = new TextField(i18n.get("label.login.username"));
|
||||||
username.setIcon(FontAwesome.USER);
|
username.setIcon(FontAwesome.USER);
|
||||||
username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD);
|
username.addStyleName(
|
||||||
|
ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD);
|
||||||
username.setId("login-username");
|
username.setId("login-username");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,8 +218,8 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware
|
|||||||
if (multiTenancyIndicator.isMultiTenancySupported()) {
|
if (multiTenancyIndicator.isMultiTenancySupported()) {
|
||||||
tenant = new TextField(i18n.get("label.login.tenant"));
|
tenant = new TextField(i18n.get("label.login.tenant"));
|
||||||
tenant.setIcon(FontAwesome.DATABASE);
|
tenant.setIcon(FontAwesome.DATABASE);
|
||||||
tenant.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " "
|
tenant.addStyleName(
|
||||||
+ LOGIN_TEXTFIELD);
|
ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD);
|
||||||
tenant.addStyleName("uppercase");
|
tenant.addStyleName("uppercase");
|
||||||
tenant.setId("login-tenant");
|
tenant.setId("login-tenant");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
|
|||||||
void onEvent(final DistributionTableEvent event) {
|
void onEvent(final DistributionTableEvent event) {
|
||||||
if (event.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MINIMIZED) {
|
if (event.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MINIMIZED) {
|
||||||
minimizeDistTable();
|
minimizeDistTable();
|
||||||
} else if (event.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MAXIMIZED) {
|
} else if (event
|
||||||
|
.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MAXIMIZED) {
|
||||||
maximizeDistTable();
|
maximizeDistTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,13 +207,18 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Boolean showFooterLayout() {
|
private Boolean showFooterLayout() {
|
||||||
if ((permChecker.hasDeleteDistributionPermission() || permChecker.hasDeleteTargetPermission())
|
if (permChecker.hasTargetReadPermission()
|
||||||
|| (permChecker.hasReadDistributionPermission() && permChecker.hasUpdateTargetPermission())) {
|
|| (permChecker.hasDeleteDistributionPermission() || permChecker.hasDeleteTargetPermission())
|
||||||
|
|| hasDeploymentPermission()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasDeploymentPermission() {
|
||||||
|
return permChecker.hasReadDistributionPermission() && permChecker.hasUpdateTargetPermission();
|
||||||
|
}
|
||||||
|
|
||||||
private void displayTargetWidgetsOnly() {
|
private void displayTargetWidgetsOnly() {
|
||||||
mainLayout.setColumns(3);
|
mainLayout.setColumns(3);
|
||||||
mainLayout.setRows(2);
|
mainLayout.setRows(2);
|
||||||
|
|||||||
@@ -190,8 +190,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
saveDistribution.addClickListener(event -> saveDistribution());
|
saveDistribution.addClickListener(event -> saveDistribution());
|
||||||
|
|
||||||
/* close button */
|
/* close button */
|
||||||
discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "",
|
discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true,
|
||||||
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
|
||||||
discardDistribution.addClickListener(event -> discardDistribution());
|
discardDistribution.addClickListener(event -> discardDistribution());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +206,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
DistributionSetTypeBeanQuery.class);
|
DistributionSetTypeBeanQuery.class);
|
||||||
dtQF.setQueryConfiguration(queryConfig);
|
dtQF.setQueryConfiguration(queryConfig);
|
||||||
|
|
||||||
final LazyQueryContainer disttypeContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer disttypeContainer = new LazyQueryContainer(
|
||||||
SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF);
|
||||||
|
|
||||||
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
|
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
|
||||||
|
|
||||||
@@ -219,8 +219,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType getDefaultDistributionSetType() {
|
private DistributionSetType getDefaultDistributionSetType() {
|
||||||
final TenantMetaData tenantMetaData = tenantMetaDataRepository.findByTenantIgnoreCase(systemManagement
|
final TenantMetaData tenantMetaData = tenantMetaDataRepository
|
||||||
.currentTenant());
|
.findByTenantIgnoreCase(systemManagement.currentTenant());
|
||||||
return tenantMetaData.getDefaultDsType();
|
return tenantMetaData.getDefaultDsType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,12 +259,12 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
|
notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success",
|
||||||
new Object[] { currentDS.getName(), currentDS.getVersion() }));
|
new Object[] { currentDS.getName(), currentDS.getVersion() }));
|
||||||
// update table row+details layout
|
// update table row+details layout
|
||||||
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION,
|
eventBus.publish(this,
|
||||||
currentDS));
|
new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, currentDS));
|
||||||
} catch (final EntityAlreadyExistsException entityAlreadyExistsException) {
|
} catch (final EntityAlreadyExistsException entityAlreadyExistsException) {
|
||||||
LOG.error("Update distribution failed {}", entityAlreadyExistsException);
|
LOG.error("Update distribution failed {}", entityAlreadyExistsException);
|
||||||
notificationMessage.displayValidationError(i18n.get("message.distribution.no.update",
|
notificationMessage.displayValidationError(
|
||||||
currentDS.getName() + ":" + currentDS.getVersion()));
|
i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion()));
|
||||||
}
|
}
|
||||||
closeThisWindow();
|
closeThisWindow();
|
||||||
}
|
}
|
||||||
@@ -361,8 +361,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
|
|||||||
if (existingDs != null && (!editDistribution || editDistribution && !existingDs.getId().equals(editDistId))) {
|
if (existingDs != null && (!editDistribution || editDistribution && !existingDs.getId().equals(editDistId))) {
|
||||||
distNameTextField.addStyleName("v-textfield-error");
|
distNameTextField.addStyleName("v-textfield-error");
|
||||||
distVersionTextField.addStyleName("v-textfield-error");
|
distVersionTextField.addStyleName("v-textfield-error");
|
||||||
notificationMessage.displayValidationError(i18n.get("message.duplicate.dist",
|
notificationMessage.displayValidationError(
|
||||||
new Object[] { existingDs.getName(), existingDs.getVersion() }));
|
i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() }));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
|||||||
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
|
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
|
||||||
// Add sort
|
// Add sort
|
||||||
for (int distId = 1; distId < sortPropertyIds.length; distId++) {
|
for (int distId = 1; distId < sortPropertyIds.length; distId++) {
|
||||||
sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId]));
|
sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC,
|
||||||
|
(String) sortPropertyIds[distId]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,8 +113,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
|||||||
pinnedControllerId);
|
pinnedControllerId);
|
||||||
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
|
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
|
||||||
// if no search filters available
|
// if no search filters available
|
||||||
distBeans = getDistributionSetManagement().findDistributionSetsAll(
|
distBeans = getDistributionSetManagement()
|
||||||
new OffsetBasedPageRequest(startIndex, count, sort), false, true);
|
.findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, true);
|
||||||
} else {
|
} else {
|
||||||
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||||
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
|
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
|
||||||
@@ -134,8 +135,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
|||||||
proxyDistribution.setDescription(distributionSet.getDescription());
|
proxyDistribution.setDescription(distributionSet.getDescription());
|
||||||
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
|
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
|
||||||
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
|
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
|
||||||
proxyDistribution.setNameVersion(HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(),
|
proxyDistribution.setNameVersion(
|
||||||
distributionSet.getVersion()));
|
HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
|
||||||
proxyDistributions.add(proxyDistribution);
|
proxyDistributions.add(proxyDistribution);
|
||||||
}
|
}
|
||||||
return proxyDistributions;
|
return proxyDistributions;
|
||||||
@@ -154,8 +155,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
|
|||||||
pinnedControllerId);
|
pinnedControllerId);
|
||||||
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
|
} else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) {
|
||||||
// if no search filters available
|
// if no search filters available
|
||||||
firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsAll(
|
firstPageDistributionSets = getDistributionSetManagement()
|
||||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true);
|
.findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true);
|
||||||
} else {
|
} else {
|
||||||
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false)
|
||||||
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
|
.setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked)
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
|
|||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
void onEvent(final DistributionTableEvent distributionTableEvent) {
|
||||||
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|
if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE
|
||||||
|| distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
|
|| distributionTableEvent
|
||||||
|
.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) {
|
||||||
ui.access(() -> {
|
ui.access(() -> {
|
||||||
/**
|
/**
|
||||||
* distributionTableEvent.getDistributionSet() is null when
|
* distributionTableEvent.getDistributionSet() is null when
|
||||||
@@ -175,8 +176,8 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Boolean onLoadIsTableRowSelected() {
|
protected Boolean onLoadIsTableRowSelected() {
|
||||||
return !(managementUIState.getSelectedDsIdName().isPresent() && managementUIState.getSelectedDsIdName().get()
|
return !(managementUIState.getSelectedDsIdName().isPresent()
|
||||||
.isEmpty());
|
&& managementUIState.getSelectedDsIdName().get().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -289,9 +290,9 @@ public class DistributionDetails extends AbstractTableDetailsLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isMigrationRequired != null) {
|
if (isMigrationRequired != null) {
|
||||||
detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel(
|
detailsTabLayout.addComponent(
|
||||||
i18n.get("checkbox.dist.migration.required"),
|
SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"),
|
||||||
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
|
isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,13 +191,12 @@ public class DistributionTable extends AbstractTable {
|
|||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||||
void onEvent(final ManagementUIEvent managementUIEvent) {
|
void onEvent(final ManagementUIEvent managementUIEvent) {
|
||||||
UI.getCurrent().access(
|
UI.getCurrent().access(() -> {
|
||||||
() -> {
|
if (managementUIEvent == ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG
|
||||||
if (managementUIEvent == ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG
|
|| managementUIEvent == ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG) {
|
||||||
|| managementUIEvent == ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG) {
|
refreshFilter();
|
||||||
refreshFilter();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -226,8 +225,8 @@ public class DistributionTable extends AbstractTable {
|
|||||||
managementUIState.getDistributionTableFilters().getPinnedTargetId()
|
managementUIState.getDistributionTableFilters().getPinnedTargetId()
|
||||||
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value));
|
.ifPresent(value -> queryConfiguration.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value));
|
||||||
final List<String> list = new ArrayList<String>();
|
final List<String> list = new ArrayList<String>();
|
||||||
queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getDistributionTableFilters()
|
queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG,
|
||||||
.isNoTagSelected());
|
managementUIState.getDistributionTableFilters().isNoTagSelected());
|
||||||
if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) {
|
if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) {
|
||||||
list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags());
|
list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags());
|
||||||
}
|
}
|
||||||
@@ -235,8 +234,9 @@ public class DistributionTable extends AbstractTable {
|
|||||||
final BeanQueryFactory<DistributionBeanQuery> distributionQF = new BeanQueryFactory<DistributionBeanQuery>(
|
final BeanQueryFactory<DistributionBeanQuery> distributionQF = new BeanQueryFactory<DistributionBeanQuery>(
|
||||||
DistributionBeanQuery.class);
|
DistributionBeanQuery.class);
|
||||||
distributionQF.setQueryConfiguration(queryConfiguration);
|
distributionQF.setQueryConfiguration(queryConfiguration);
|
||||||
final LazyQueryContainer distributionContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
final LazyQueryContainer distributionContainer = new LazyQueryContainer(
|
||||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF);
|
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
|
||||||
|
distributionQF);
|
||||||
return distributionContainer;
|
return distributionContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,8 +321,8 @@ public class DistributionTable extends AbstractTable {
|
|||||||
managementUIState.setLastSelectedDsIdName(value);
|
managementUIState.setLastSelectedDsIdName(value);
|
||||||
final DistributionSet lastSelectedDistSet = distributionSetManagement
|
final DistributionSet lastSelectedDistSet = distributionSetManagement
|
||||||
.findDistributionSetByIdWithDetails(value.getId());
|
.findDistributionSetByIdWithDetails(value.getId());
|
||||||
eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE,
|
eventBus.publish(this,
|
||||||
lastSelectedDistSet));
|
new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
managementUIState.setSelectedDsIdName(null);
|
managementUIState.setSelectedDsIdName(null);
|
||||||
@@ -422,15 +422,15 @@ public class DistributionTable extends AbstractTable {
|
|||||||
private void assignTargetTag(final DragAndDropEvent event) {
|
private void assignTargetTag(final DragAndDropEvent event) {
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
final Object distItemId = dropData.getItemIdOver();
|
final Object distItemId = dropData.getItemIdOver();
|
||||||
final String targetTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent()
|
final String targetTagName = HawkbitCommonUtil.removePrefix(
|
||||||
.getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
// get all the targets assigned to the tag
|
// get all the targets assigned to the tag
|
||||||
// assign dist to those targets
|
// assign dist to those targets
|
||||||
final List<Target> assignedTargets = targetService.findTargetsByTag(targetTagName);
|
final List<Target> assignedTargets = targetService.findTargetsByTag(targetTagName);
|
||||||
if (!assignedTargets.isEmpty()) {
|
if (!assignedTargets.isEmpty()) {
|
||||||
final Set<TargetIdName> targetDetailsList = new HashSet<TargetIdName>();
|
final Set<TargetIdName> targetDetailsList = new HashSet<TargetIdName>();
|
||||||
assignedTargets.forEach(target -> targetDetailsList.add(new TargetIdName(target.getId(), target
|
assignedTargets.forEach(target -> targetDetailsList
|
||||||
.getControllerId(), target.getName())));
|
.add(new TargetIdName(target.getId(), target.getControllerId(), target.getName())));
|
||||||
assignTargetToDs(getItem(distItemId), targetDetailsList);
|
assignTargetToDs(getItem(distItemId), targetDetailsList);
|
||||||
} else {
|
} else {
|
||||||
notification.displaySuccess(i18n.get("message.no.targets.assiged.fortag", new Object[] { targetTagName }));
|
notification.displaySuccess(i18n.get("message.no.targets.assiged.fortag", new Object[] { targetTagName }));
|
||||||
@@ -461,7 +461,8 @@ public class DistributionTable extends AbstractTable {
|
|||||||
final Long distId = (Long) item.getItemProperty("id").getValue();
|
final Long distId = (Long) item.getItemProperty("id").getValue();
|
||||||
final String distName = (String) item.getItemProperty("name").getValue();
|
final String distName = (String) item.getItemProperty("name").getValue();
|
||||||
final String distVersion = (String) item.getItemProperty("version").getValue();
|
final String distVersion = (String) item.getItemProperty("version").getValue();
|
||||||
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion);
|
final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName,
|
||||||
|
distVersion);
|
||||||
showOrHidePopupAndNotification(validate(targetDetailsList, distributionSetIdName));
|
showOrHidePopupAndNotification(validate(targetDetailsList, distributionSetIdName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -513,8 +514,8 @@ public class DistributionTable extends AbstractTable {
|
|||||||
|
|
||||||
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
|
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
|
||||||
if (tagData.equals(targetNoTagData)) {
|
if (tagData.equals(targetNoTagData)) {
|
||||||
notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned",
|
notification.displayValidationError(
|
||||||
new Object[] { i18n.get("label.no.tag.assigned") }));
|
i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") }));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -529,7 +530,8 @@ public class DistributionTable extends AbstractTable {
|
|||||||
* @param distName
|
* @param distName
|
||||||
* @return String as indicator
|
* @return String as indicator
|
||||||
*/
|
*/
|
||||||
private String validate(final Set<TargetIdName> targetDetailsList, final DistributionSetIdName distributionSetIdName) {
|
private String validate(final Set<TargetIdName> targetDetailsList,
|
||||||
|
final DistributionSetIdName distributionSetIdName) {
|
||||||
String pendingActionMessage = null;
|
String pendingActionMessage = null;
|
||||||
for (final TargetIdName trgtNameId : targetDetailsList) {
|
for (final TargetIdName trgtNameId : targetDetailsList) {
|
||||||
if (null != trgtNameId) {
|
if (null != trgtNameId) {
|
||||||
@@ -581,18 +583,18 @@ public class DistributionTable extends AbstractTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateDistributionInTable(final DistributionSet editedDs) {
|
private void updateDistributionInTable(final DistributionSet editedDs) {
|
||||||
final Item item = getContainerDataSource().getItem(
|
final Item item = getContainerDataSource()
|
||||||
new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
|
.getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(editedDs.getName());
|
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(editedDs.getName());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(editedDs.getVersion());
|
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(editedDs.getVersion());
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
|
||||||
HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy()));
|
.setValue(HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
|
||||||
HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy()));
|
.setValue(HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue(
|
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
|
||||||
SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt()));
|
.setValue(SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt()));
|
||||||
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(editedDs.getDescription());
|
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(editedDs.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,8 +611,8 @@ public class DistributionTable extends AbstractTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void styleDistributionTableOnPinning() {
|
private void styleDistributionTableOnPinning() {
|
||||||
final Target targetObj = targetService.findTargetByControllerIDWithDetails(managementUIState
|
final Target targetObj = targetService.findTargetByControllerIDWithDetails(
|
||||||
.getDistributionTableFilters().getPinnedTargetId().get());
|
managementUIState.getDistributionTableFilters().getPinnedTargetId().get());
|
||||||
|
|
||||||
if (targetObj != null) {
|
if (targetObj != null) {
|
||||||
final DistributionSet assignedDistribution = targetObj.getAssignedDistributionSet();
|
final DistributionSet assignedDistribution = targetObj.getAssignedDistributionSet();
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user