From 2f0bf6629fba9b83e32391ed1aa6579ee43b00a3 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 27 Jan 2016 10:12:11 +0100 Subject: [PATCH] Reapplied hawkBit code formatter. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that from Luna to Mars Eclipse changed how the code formatter handles lines breaks in certain cases. This is now the “Mars” variant. --- .../repository/MongoConfiguration.java | 6 +- .../scheduling/ExecutorAutoConfiguration.java | 19 +- .../SecurityManagedConfiguration.java | 98 ++++----- .../exception/SpServerRtException.java | 2 +- .../repository/SoftwareModuleFields.java | 2 +- .../AmqpMessageDispatcherServiceTest.java | 8 +- .../hawkbit/dmf/json/model/ActionStatus.java | 1 - .../ExceptionMappingAspectHandler.java | 4 +- ...ansactionCommitDefaultServiceExecutor.java | 4 +- .../repository/DeploymentManagement.java | 77 ++++--- .../repository/DistributionSetManagement.java | 45 ++-- .../DistributionSetTagRepository.java | 4 +- .../hawkbit/repository/TagManagement.java | 8 +- .../TargetFilterQueryRepository.java | 37 ++-- .../hawkbit/repository/TargetManagement.java | 62 +++--- .../repository/TargetTagRepository.java | 7 +- .../repository/model/DistributionSetTag.java | 5 +- .../repository/model/DistributionSetType.java | 2 +- .../hawkbit/repository/rsql/RSQLUtility.java | 51 +++-- .../DistributionSetSpecification.java | 18 +- .../specifications/TargetSpecifications.java | 22 +- .../repository/DeploymentManagementTest.java | 197 +++++++++--------- .../repository/SystemManagementTest.java | 4 +- .../hawkbit/repository/TagManagementTest.java | 79 +++---- .../TargetFilterQueryManagenmentTest.java | 4 +- .../repository/TargetManagementTest.java | 120 ++++++----- .../controller/ArtifactStoreController.java | 10 +- .../hawkbit/controller/RootController.java | 44 ++-- .../rest/resource/DistributionSetMapper.java | 35 ++-- .../resource/DistributionSetResource.java | 3 - .../resource/DistributionSetTagResource.java | 31 ++- .../resource/DistributionSetTypeResource.java | 2 - .../rest/resource/SoftwareModuleMapper.java | 31 ++- .../rest/resource/SoftwareModuleResource.java | 27 +-- .../resource/SystemManagementResource.java | 4 +- .../hawkbit/rest/resource/TagMapper.java | 16 +- .../hawkbit/rest/resource/TargetMapper.java | 21 +- .../hawkbit/rest/resource/TargetResource.java | 55 ++--- .../rest/resource/TargetTagResource.java | 16 +- .../rest/resource/RSQLUtilityTest.java | 20 +- .../UserAuthenticationFilter.java | 4 +- .../org/eclipse/hawkbit/ui/HawkbitUI.java | 8 +- .../details/ArtifactDetailsLayout.java | 34 ++- .../footer/SMDeleteActionsLayout.java | 8 +- .../smtable/SoftwareModuleTable.java | 37 ++-- .../SoftwareModuleDetailsTable.java | 13 +- .../tagdetails/DistributionTagToken.java | 4 +- .../ui/components/SPUIErrorHandler.java | 6 +- .../CreateUpdateDistSetTypeLayout.java | 61 +++--- .../dstable/DistributionSetDetails.java | 58 +++--- .../dstable/DistributionSetTable.java | 45 ++-- .../footer/DSDeleteActionsLayout.java | 19 +- .../distributions/smtable/SwModuleTable.java | 49 +++-- .../CreateOrUpdateFilterHeader.java | 9 +- .../CreateOrUpdateFilterTable.java | 25 +-- .../CustomTargetBeanQuery.java | 12 +- .../FilterQueryValidation.java | 4 +- .../TargetFilterBeanQuery.java | 8 +- .../filtermanagement/TargetFilterTable.java | 29 ++- .../eclipse/hawkbit/ui/login/LoginView.java | 10 +- .../hawkbit/ui/management/DeploymentView.java | 3 +- .../DistributionAddUpdateWindowLayout.java | 24 +-- .../dstable/DistributionBeanQuery.java | 15 +- .../dstable/DistributionDetails.java | 13 +- .../management/dstable/DistributionTable.java | 68 +++--- ...eateUpdateDistributionTagLayoutWindow.java | 4 +- .../dstag/DistributionTagBeanQuery.java | 8 +- .../dstag/DistributionTagButtons.java | 5 +- .../event/DistributionTagDropEvent.java | 8 +- .../management/footer/CountMessageLabel.java | 17 +- .../footer/DeleteActionsLayout.java | 9 +- .../ManangementConfirmationWindowLayout.java | 80 ++++--- .../management/tag/CreateUpdateTagLayout.java | 18 +- .../management/tag/SpColorPickerPreview.java | 6 +- .../targettable/BulkUploadHandler.java | 13 +- .../targettable/TargetBeanQuery.java | 4 +- .../TargetBulkUpdateWindowLayout.java | 9 +- .../management/targettable/TargetTable.java | 102 ++++----- .../targettable/TargetTableHeader.java | 13 +- .../CreateUpdateTargetTagLayout.java | 4 +- .../targettag/TargetFilterQueryButtons.java | 7 +- .../targettag/TargetTagFilterButtonClick.java | 4 +- .../targettag/TargetTagFilterButtons.java | 9 +- .../hawkbit/ui/menu/DashboardMenu.java | 8 +- .../hawkbit/ui/utils/HawkbitCommonUtil.java | 80 ++++--- 85 files changed, 1066 insertions(+), 1109 deletions(-) diff --git a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java index 602af6f54..3f203f94f 100644 --- a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java +++ b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java @@ -92,7 +92,7 @@ public class MongoConfiguration extends AbstractMongoConfiguration { * * Based on MongoProperties#builder method. */ - private Builder createBuilderOutOfOptions(final MongoClientOptions options) { + private static Builder createBuilderOutOfOptions(final MongoClientOptions options) { final Builder builder = MongoClientOptions.builder(); if (options != null) { builder.alwaysUseMBeans(options.isAlwaysUseMBeans()); @@ -108,8 +108,8 @@ public class MongoConfiguration extends AbstractMongoConfiguration { builder.socketFactory(options.getSocketFactory()); builder.socketKeepAlive(options.isSocketKeepAlive()); builder.socketTimeout(options.getSocketTimeout()); - builder.threadsAllowedToBlockForConnectionMultiplier(options - .getThreadsAllowedToBlockForConnectionMultiplier()); + builder.threadsAllowedToBlockForConnectionMultiplier( + options.getThreadsAllowedToBlockForConnectionMultiplier()); builder.writeConcern(options.getWriteConcern()); } return builder; diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java index f626e94b5..f8a86d1bc 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.autoconfigure.scheduling; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Executor; -import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -46,19 +45,15 @@ public class ExecutorAutoConfiguration { @Bean @ConditionalOnMissingBean public Executor asyncExecutor() { - final BlockingQueue blockingQueue = new ArrayBlockingQueue( + final BlockingQueue blockingQueue = new ArrayBlockingQueue<>( asyncConfigurerProperties.getQueuesize()); - final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( - asyncConfigurerProperties.getCorethreads(), asyncConfigurerProperties.getMaxthreads(), - asyncConfigurerProperties.getIdletimeout(), TimeUnit.MILLISECONDS, blockingQueue, + final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(asyncConfigurerProperties.getCorethreads(), + asyncConfigurerProperties.getMaxthreads(), asyncConfigurerProperties.getIdletimeout(), + TimeUnit.MILLISECONDS, blockingQueue, new ThreadFactoryBuilder().setNameFormat("central-executor-pool-%d").build()); - threadPoolExecutor.setRejectedExecutionHandler(new RejectedExecutionHandler() { - @Override - public void rejectedExecution(final Runnable r, final java.util.concurrent.ThreadPoolExecutor executor) { - LOGGER.warn("Reject runnable for centralExecutorService, reached limit of queue size {}", executor - .getQueue().size()); - } - }); + threadPoolExecutor.setRejectedExecutionHandler((r, executor) -> LOGGER.warn( + "Reject runnable for centralExecutorService, reached limit of queue size {}", + executor.getQueue().size())); return new DelegatingSecurityContextExecutor(threadPoolExecutor); } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java index 63e1e8ad1..ca55f1711 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -159,35 +159,27 @@ public class SecurityManagedConfiguration implements EnvironmentAware { } 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( - "controllerAnonymousFilter", "anonymous", Collections.singletonList(new SimpleGrantedAuthority( - SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS))); + "controllerAnonymousFilter", "anonymous", Collections.singletonList( + new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS))); anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource); httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and() .securityContext().disable().anonymous().authenticationFilter(anoymousFilter); } else { - httpSec.addFilter(securityHeaderFilter) - .addFilter(securityTokenFilter) - .addFilter(gatewaySecurityTokenFilter) - .antMatcher("/*/controller/**") - .anonymous() - .disable() - .authorizeRequests() - .anyRequest() - .authenticated() - .and() - .exceptionHandling() - .authenticationEntryPoint( - (request, response, authException) -> response.setStatus(HttpStatus.UNAUTHORIZED - .value())).and().sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS); + httpSec.addFilter(securityHeaderFilter).addFilter(securityTokenFilter) + .addFilter(gatewaySecurityTokenFilter).antMatcher("/*/controller/**").anonymous().disable() + .authorizeRequests().anyRequest().authenticated().and().exceptionHandling() + .authenticationEntryPoint((request, response, authException) -> response + .setStatus(HttpStatus.UNAUTHORIZED.value())) + .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); } } /* * (non-Javadoc) - * + * * @see * org.springframework.security.config.annotation.web.configuration. * WebSecurityConfigurerAdapter @@ -196,8 +188,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware { */ @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { - auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration - .getRpTrustedIPs())); + auth.authenticationProvider( + new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs())); } } @@ -212,10 +204,12 @@ public class SecurityManagedConfiguration implements EnvironmentAware { public FilterRegistrationBean dosFilter() { final FilterRegistrationBean filterRegBean = new FilterRegistrationBean(); - filterRegBean.setFilter(new DosFilter(environment - .getProperty("security.dos.filter.maxRead", Integer.class, 200), environment.getProperty( - "security.dos.filter.maxWrite", Integer.class, 50), environment - .getProperty("security.dos.filter.whitelist"), environment.getProperty("security.clients.blacklist"), + filterRegBean + .setFilter( + new DosFilter(environment.getProperty("security.dos.filter.maxRead", Integer.class, 200), + 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"))); filterRegBean.addUrlPatterns("/{tenant}/controller/v1/*", "/rest/*"); return filterRegBean; @@ -301,7 +295,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware { }, RequestHeaderAuthenticationFilter.class) .addFilterAfter( new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement), - RequestHeaderAuthenticationFilter.class).authorizeRequests().anyRequest().authenticated() + RequestHeaderAuthenticationFilter.class) + .authorizeRequests().anyRequest().authenticated() .antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**") .hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**") .hasAnyAuthority(SpPermission.SYSTEM_DIAG); @@ -310,12 +305,13 @@ public class SecurityManagedConfiguration implements EnvironmentAware { /** * {@link WebSecurityConfigurer} for external (management) access. - * + * */ @Configuration @Order(400) @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_SAMEORIGIN = "SAMEORIGIN"; @@ -371,7 +367,7 @@ public class SecurityManagedConfiguration implements EnvironmentAware { * Listener to redirect to login page after session timeout. Close the * vaadin session, because it's is not possible to redirect in * atmospehere. - * + * * @return the servlet listener. */ @Bean @@ -388,10 +384,9 @@ public class SecurityManagedConfiguration implements EnvironmentAware { if (confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) && confAllowFromUri == null) { // if allow-from option is specified but no allowFromUri throw // exception - throw new IllegalStateException( - "hawkbit.server.security.xframe.option has been specified as ALLOW-FROM" - + " but no hawkbit.server.security.xframe.option.allowfrom has been set, " - + "please ensure to set allow from URIs"); + throw new IllegalStateException("hawkbit.server.security.xframe.option has been specified as ALLOW-FROM" + + " but no hawkbit.server.security.xframe.option.allowfrom has been set, " + + "please ensure to set allow from URIs"); } // workaround regex: we need to exclude the URL /UI/HEARTBEAT here @@ -400,23 +395,22 @@ public class SecurityManagedConfiguration implements EnvironmentAware { // vaadin-forum: // https://vaadin.com/forum#!/thread/3200565. HttpSecurity httpSec = http.regexMatcher("(?!.*HEARTBEAT)^.*\\/UI.*$") - // disable as CSRF is handled by Vaadin + // disable as CSRF is handled by Vaadin .csrf().disable(); if (springSecurityProperties.isRequireSsl()) { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } 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 httpSec.headers() - .addHeaderWriter( - confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) ? new XFrameOptionsHeaderWriter( - new StaticAllowFromStrategy(new URI(confAllowFromUri))) - : new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption))) - .contentTypeOptions().xssProtection().httpStrictTransportSecurity() - .and() + .addHeaderWriter(confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) + ? new XFrameOptionsHeaderWriter(new StaticAllowFromStrategy(new URI(confAllowFromUri))) + : new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption))) + .contentTypeOptions().xssProtection().httpStrictTransportSecurity().and() // UI .authorizeRequests().antMatchers("/UI/login/**").permitAll().antMatchers("/UI/UIDL/**").permitAll() .anyRequest().authenticated().and() @@ -437,7 +431,7 @@ public class SecurityManagedConfiguration implements EnvironmentAware { * string does not match an option then * {@link XFrameOptionsMode#SAMEORIGIN} is returned */ - private XFrameOptionsMode xframeOptionFromStr(@NotNull final String xframeOption) { + private static XFrameOptionsMode xframeOptionFromStr(@NotNull final String xframeOption) { switch (xframeOption) { case XFRAME_OPTION_DENY: return XFrameOptionsMode.DENY; @@ -450,8 +444,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware { @Override public void configure(final WebSecurity webSecurity) throws Exception { - webSecurity.ignoring() - .antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**", "/docs/**"); + webSecurity.ignoring().antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**", + "/docs/**"); } } @@ -482,15 +476,15 @@ public class SecurityManagedConfiguration implements EnvironmentAware { http.csrf().disable(); http.anonymous().disable(); - http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN).addFilterBefore( - downloadIdAuthenticationFilter, FilterSecurityInterceptor.class); + http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN) + .addFilterBefore(downloadIdAuthenticationFilter, FilterSecurityInterceptor.class); http.authorizeRequests().anyRequest().authenticated(); } @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { - auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration - .getRpTrustedIPs())); + auth.authenticationProvider( + new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs())); } } @@ -510,7 +504,7 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends /* * (non-Javadoc) - * + * * @see org.vaadin.spring.security.web.authentication. * SavedRequestAwareVaadinAuthenticationSuccessHandler * #onAuthenticationSuccess(org.springframework.security.core. @@ -519,10 +513,10 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends @Override public void onAuthenticationSuccess(final Authentication authentication) throws Exception { if (authentication.getClass().equals(TenantUserPasswordAuthenticationToken.class)) { - systemManagement.getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant() - .toString()); + systemManagement + .getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant().toString()); } 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 // in the GenericVaadinSecurity class. Only the token which has been // created in the diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java index 1e316f562..a605f7745 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java @@ -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 * */ diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleFields.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleFields.java index 33fa638a2..bff9b1f74 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleFields.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleFields.java @@ -36,7 +36,7 @@ public enum SoftwareModuleFields implements FieldNameProvider { /** * The id field. */ - ID("id"), + ID("id"), /** * The metadata. */ diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 778f196e9..c423b76bf 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -155,8 +155,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit CONTROLLER_ID, 1l, IpUtil.createAmqpUri("mytest")); amqpMessageDispatcherService .targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent); - final Message sendMessage = createArgumentCapture(cancelTargetAssignmentDistributionSetEvent.getTargetAdress() - .getHost()); + final Message sendMessage = createArgumentCapture( + cancelTargetAssignmentDistributionSetEvent.getTargetAdress().getHost()); assertCancelMessage(sendMessage); } @@ -200,8 +200,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit @SuppressWarnings("unchecked") private T convertMessage(final Message message, final Class clazz) { - message.getMessageProperties().getHeaders() - .put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, clazz.getTypeName()); + message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, + clazz.getTypeName()); return (T) rabbitTemplate.getMessageConverter().fromMessage(message); } diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java index 12e80139a..c31ab83f3 100644 --- a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java +++ b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java @@ -22,6 +22,5 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; @JsonIgnoreProperties(ignoreUnknown = true) public enum ActionStatus { - DOWNLOAD, RETRIEVED, RUNNING, FINISHED, ERROR, WARNING, CANCELED, CANCEL_REJECTED; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java index bcb96f45d..75145778e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java @@ -96,8 +96,8 @@ public class ExceptionMappingAspectHandler implements Ordered { if (translatedAccessException == null && ex instanceof TransactionSystemException) { final TransactionSystemException systemException = (TransactionSystemException) ex; - translatedAccessException = translateEclipseLinkExceptionIfPossible((Exception) systemException - .getOriginalException()); + translatedAccessException = translateEclipseLinkExceptionIfPossible( + (Exception) systemException.getOriginalException()); } if (translatedAccessException == null) { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java index 9b66178ba..38ad38345 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java @@ -23,8 +23,8 @@ import org.springframework.transaction.support.TransactionSynchronizationManager * successful spring transaction commit.The class is thread safe. */ @Service -public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements - AfterTransactionCommitExecutor { +public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter + implements AfterTransactionCommitExecutor { private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class); private static final ThreadLocal> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>(); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 0288c83a5..b8b8610cd 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -198,10 +198,8 @@ public class DeploymentManagement { @CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true) public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType, final long forcedTimestamp, @NotEmpty final String... targetIDs) { - return assignDistributionSet( - dsID, - Arrays.stream(targetIDs).map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)) - .collect(Collectors.toList())); + return assignDistributionSet(dsID, Arrays.stream(targetIDs) + .map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)).collect(Collectors.toList())); } /** @@ -226,8 +224,8 @@ public class DeploymentManagement { final List targets) { final DistributionSet set = distributoinSetRepository.findOne(dsID); if (set == null) { - throw new EntityNotFoundException(String.format("no %s with id %d found", - DistributionSet.class.getSimpleName(), dsID)); + throw new EntityNotFoundException( + String.format("no %s with id %d found", DistributionSet.class.getSimpleName(), dsID)); } return assignDistributionSetToTargets(set, targets); @@ -251,8 +249,8 @@ public class DeploymentManagement { final List targetsWithActionType) { if (!set.isComplete()) { - throw new IncompleteDistributionSetException("Distribution set of type " + set.getType().getKey() - + " is incomplete: " + set.getId()); + throw new IncompleteDistributionSetException( + "Distribution set of type " + set.getType().getKey() + " is incomplete: " + set.getId()); } final List controllerIDs = targetsWithActionType.stream().map(TargetWithActionType::getTargetId) @@ -260,8 +258,8 @@ public class DeploymentManagement { LOG.debug("assignDistribution({}) to {} targets", set, controllerIDs.size()); - final Map targetsWithActionMap = targetsWithActionType.stream().collect( - Collectors.toMap(TargetWithActionType::getTargetId, Function.identity())); + final Map targetsWithActionMap = targetsWithActionType.stream() + .collect(Collectors.toMap(TargetWithActionType::getTargetId, Function.identity())); // split tIDs length into max entries in-statement because many database // have constraint of @@ -271,12 +269,10 @@ public class DeploymentManagement { // we take the target only into account if the requested operation is no // duplicate of a // previous one - final List targets = Lists - .partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT) - .stream() - .map(ids -> targetRepository.findAll(TargetSpecifications - .hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId()))).flatMap(t -> t.stream()) - .collect(Collectors.toList()); + final List targets = Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream() + .map(ids -> targetRepository + .findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId()))) + .flatMap(t -> t.stream()).collect(Collectors.toList()); if (targets.isEmpty()) { // 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 - final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult(targets.stream() - .map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), + final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()), targetManagement); @@ -353,11 +349,9 @@ public class DeploymentManagement { // send distribution set assignment event - targets.stream() - .filter(t -> !!!targetIdsCancellList.contains(t.getId())) - .forEach( - t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(), - softwareModules)); + targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId())) + .forEach(t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(), + softwareModules)); return result; } @@ -403,13 +397,13 @@ public class DeploymentManagement { activeActions.forEach(action -> { action.setStatus(Status.CANCELING); // document that the status has been retrieved - actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(), - "manual cancelation requested")); + actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(), + "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); return cancelledTargetIds; @@ -417,9 +411,8 @@ public class DeploymentManagement { private DistributionSetAssignmentResult assignDistributionSetByTargetId(@NotNull final DistributionSet set, @NotEmpty final List tIDs, final ActionType actionType, final long forcedTime) { - return assignDistributionSetToTargets(set, - tIDs.stream().map(t -> new TargetWithActionType(t, actionType, forcedTime)) - .collect(Collectors.toList())); + return assignDistributionSetToTargets(set, tIDs.stream() + .map(t -> new TargetWithActionType(t, actionType, forcedTime)).collect(Collectors.toList())); } /** @@ -487,8 +480,8 @@ public class DeploymentManagement { return saveAction; } else { - throw new CancelActionNotAllowedException("Action [id: " + action.getId() - + "] is not active and cannot be canceled"); + throw new CancelActionNotAllowedException( + "Action [id: " + action.getId() + "] is not active and cannot be canceled"); } } @@ -529,13 +522,13 @@ public class DeploymentManagement { final Action mergedAction = entityManager.merge(action); if (!mergedAction.isCancelingOrCanceled()) { - throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId() - + "] is not canceled yet and cannot be force quit"); + throw new ForceQuitActionNotAllowedException( + "Action [id: " + action.getId() + "] is not canceled yet and cannot be force quit"); } if (!mergedAction.isActive()) { - throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId() - + "] is not active and cannot be force quit"); + throw new ForceQuitActionNotAllowedException( + "Action [id: " + action.getId() + "] is not active and cannot be force quit"); } LOG.warn("action ({}) was still activ and has been force quite.", action); @@ -650,7 +643,8 @@ public class DeploymentManagement { return actionRepository.findAll(new Specification() { @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { + public Predicate toPredicate(final Root root, final CriteriaQuery query, + final CriteriaBuilder cb) { return cb.and(specifiction.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target)); } }, pageable); @@ -752,7 +746,8 @@ public class DeploymentManagement { public Long countActionsByTarget(@NotNull final Specification spec, @NotNull final Target target) { return actionRepository.count(new Specification() { @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { + public Predicate toPredicate(final Root root, final CriteriaQuery query, + final CriteriaBuilder cb) { 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); final Target target = action.getTarget(); - final List nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true) - .stream().filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList()); + final List nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true).stream() + .filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList()); if (nextActiveActions.isEmpty()) { target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet()); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index d4b7ac55e..0a3838354 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -219,7 +219,8 @@ public class DistributionSetManagement { * @return the found {@link DistributionSet}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public List findDistributionSetListWithDetails(@NotEmpty final Collection distributionIdSet) { + public List findDistributionSetListWithDetails( + @NotEmpty final Collection distributionIdSet) { return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet)); } @@ -397,7 +398,8 @@ public class DistributionSetManagement { @Modifying @Transactional @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 softwareModules = new HashSet(); softwareModules.add(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 // use if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) { - throw new EntityReadOnlyException(String.format( - "distribution set type %s set is already assigned to targets and cannot be changed", - dsType.getName())); + throw new EntityReadOnlyException( + String.format("distribution set type %s set is already assigned to targets and cannot be changed", + dsType.getName())); } return distributionSetTypeRepository.save(dsType); @@ -597,14 +599,16 @@ public class DistributionSetManagement { final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder .setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build(); - final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithInstalledTargets); + final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( + filterWithInstalledTargets); final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null) .setAssignedTargetId(assignedOrInstalled).build(); - final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithAssignedTargets); + final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( + filterWithAssignedTargets); - final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder - .setInstalledTargetId(null).setAssignedTargetId(null).build(); + final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null) + .setAssignedTargetId(null).build(); // first fine the distribution sets filtered by the given filter // parameters final Page findDistributionSetsByFilters = findDistributionSetsByFilters(pageable, @@ -654,8 +658,8 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSet findDistributionSetByNameAndVersion(@NotEmpty final String distributionName, @NotEmpty final String version) { - final Specification spec = DistributionSetSpecification.equalsNameAndVersionIgnoreCase( - distributionName, version); + final Specification spec = DistributionSetSpecification + .equalsNameAndVersionIgnoreCase(distributionName, version); return distributionSetRepository.findOne(spec); } @@ -1009,17 +1013,17 @@ public class DistributionSetManagement { final Set softwareModules) { if (!new HashSet(distributionSet.getModules()).equals(softwareModules) && actionRepository.countByDistributionSet(distributionSet) > 0) { - throw new EntityLockedException(String.format( - "distribution set %s:%s is already assigned to targets and cannot be changed", - distributionSet.getName(), distributionSet.getVersion())); + throw new EntityLockedException( + String.format("distribution set %s:%s is already assigned to targets and cannot be changed", + distributionSet.getName(), distributionSet.getVersion())); } } private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) { if (actionRepository.countByDistributionSet(distributionSet) > 0) { - throw new EntityLockedException(String.format( - "distribution set %s:%s is already assigned to targets and cannot be changed", - distributionSet.getName(), distributionSet.getVersion())); + throw new EntityLockedException( + String.format("distribution set %s:%s is already assigned to targets and cannot be changed", + distributionSet.getName(), distributionSet.getVersion())); } } @@ -1068,8 +1072,8 @@ public class DistributionSetManagement { private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) { if (distributionSetMetadataRepository.exists(metadataId)) { - throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataId.getKey() - + "' already exists"); + throw new EntityAlreadyExistsException( + "Metadata entry with key '" + metadataId.getKey() + "' already exists"); } } @@ -1091,7 +1095,8 @@ public class DistributionSetManagement { @Transactional @NotNull @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) - public List assignTag(@NotEmpty final Collection dsIds, @NotNull final DistributionSetTag tag) { + public List assignTag(@NotEmpty final Collection dsIds, + @NotNull final DistributionSetTag tag) { final List allDs = findDistributionSetListWithDetails(dsIds); allDs.forEach(ds -> ds.getTags().add(tag)); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java index e09db5cb2..c00713fc4 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java @@ -24,8 +24,8 @@ import org.springframework.transaction.annotation.Transactional; * */ @Transactional(readOnly = true) -public interface DistributionSetTagRepository extends BaseEntityRepository, - JpaSpecificationExecutor { +public interface DistributionSetTagRepository + extends BaseEntityRepository, JpaSpecificationExecutor { /** * deletes the {@link DistributionSet} with the given name. * diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java index d0cfea0a3..4d8b4ff5c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java @@ -267,8 +267,8 @@ public class TagManagement { final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag); - afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware - .getCurrentTenant(), save))); + afterCommit.afterCommit( + () -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save))); return save; } @@ -292,8 +292,8 @@ public class TagManagement { } } final List save = distributionSetTagRepository.save(distributionSetTags); - afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware - .getCurrentTenant(), save))); + afterCommit.afterCommit( + () -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save))); return save; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java index e78b02286..b9bfcc8b6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java @@ -19,27 +19,26 @@ import org.springframework.transaction.annotation.Transactional; * */ @Transactional(readOnly = true) -public interface TargetFilterQueryRepository extends - BaseEntityRepository, - JpaSpecificationExecutor { +public interface TargetFilterQueryRepository + extends BaseEntityRepository, JpaSpecificationExecutor { - /** - * Find customer target filter by name - * - * @param name - * @return custom target filter - */ - TargetFilterQuery findByName(final String name); + /** + * Find customer target filter by name + * + * @param name + * @return custom target filter + */ + TargetFilterQuery findByName(final String name); - /** - * Find list of all custom target filters. - */ - @Override - Page findAll(); + /** + * Find list of all custom target filters. + */ + @Override + Page findAll(); - @Override - @Modifying - @Transactional - S save(S entity); + @Override + @Modifying + @Transactional + S save(S entity); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index fcc644d18..e7483fdd5 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -350,9 +350,9 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) public Page findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID, final Specification spec, @NotNull final Pageable pageReq) { - return targetRepository.findAll((Specification) (root, query, cb) -> cb.and(TargetSpecifications - .hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb), spec.toPredicate(root, - query, cb)), pageReq); + return targetRepository.findAll((Specification) (root, query, cb) -> cb.and( + TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb), + spec.toPredicate(root, query, cb)), pageReq); } /** @@ -389,9 +389,9 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) public Page findTargetByInstalledDistributionSet(final Long distributionSetId, final Specification spec, final Pageable pageable) { - return targetRepository.findAll((Specification) (root, query, cb) -> cb.and(TargetSpecifications - .hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb), spec.toPredicate(root, - query, cb)), pageable); + return targetRepository.findAll((Specification) (root, query, cb) -> cb.and( + TargetSpecifications.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb), + spec.toPredicate(root, query, cb)), pageable); } /** @@ -486,8 +486,8 @@ public class TargetManagement { specList.add(TargetSpecifications.hasTargetUpdateStatus(status, fetch)); } if (installedOrAssignedDistributionSetId != null) { - specList.add(TargetSpecifications - .hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId)); + specList.add( + TargetSpecifications.hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId)); } if (!Strings.isNullOrEmpty(searchText)) { specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText)); @@ -559,8 +559,8 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final List targets, @NotNull final TargetTag tag) { - return toggleTagAssignment(targets.stream().map(target -> target.getControllerId()) - .collect(Collectors.toList()), tag.getName()); + return toggleTagAssignment( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName()); } /** @@ -583,8 +583,8 @@ public class TargetManagement { @NotNull final String tagName) { final TargetTag tag = targetTagRepository.findByNameEquals(tagName); final List alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds); - final List allTargets = targetRepository.findAll(TargetSpecifications - .byControllerIdWithStatusAndTagsInJoin(targetIds)); + final List allTargets = targetRepository + .findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds)); // all are already assigned -> unassign if (alreadyAssignedTargets.size() == allTargets.size()) { @@ -623,8 +623,8 @@ public class TargetManagement { @NotNull @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) public List assignTag(@NotEmpty final Collection targetIds, @NotNull final TargetTag tag) { - final List allTargets = targetRepository.findAll(TargetSpecifications - .byControllerIdWithStatusAndTagsInJoin(targetIds)); + final List allTargets = targetRepository + .findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds)); allTargets.forEach(target -> target.getTags().add(tag)); final List save = targetRepository.save(allTargets); @@ -678,8 +678,8 @@ public class TargetManagement { @Transactional @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) { - final List allTargets = targetRepository.findAll(TargetSpecifications - .byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID))); + final List allTargets = targetRepository + .findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID))); final List unAssignTag = unAssignTag(allTargets, targetTag); return unAssignTag.isEmpty() ? null : unAssignTag.get(0); } @@ -740,19 +740,20 @@ public class TargetManagement { // select case expression to retrieve the case value as a column to be // able to order based on // this column, installed first,... - final Expression selectCase = cb - .selectCase() + final Expression selectCase = cb.selectCase() .when(cb.equal(targetInfo.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id), orderByDistributionId), 1) .when(cb.equal(targetRoot.get(Target_.assignedDistributionSet).get(DistributionSet_.id), - orderByDistributionId), 2).otherwise(100); + orderByDistributionId), 2) + .otherwise(100); // multiselect statement order by the select case and controllerId query.distinct(true); // build the specifications and then to predicates necessary by the // given filters final Predicate[] specificationsForMultiSelect = specificationsToPredicate( buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId, - selectTargetWithNoTag, true, filterByTagNames), targetRoot, query, cb); + selectTargetWithNoTag, true, filterByTagNames), + targetRoot, query, cb); // if we have some predicates then add it to the where clause of the // multiselect @@ -826,9 +827,8 @@ public class TargetManagement { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(TargetIdName.class); final Root targetRoot = query.from(Target.class); - return entityManager.createQuery( - query.multiselect(targetRoot.get(Target_.id), targetRoot.get(Target_.controllerId), - targetRoot.get(Target_.name))).getResultList(); + return entityManager.createQuery(query.multiselect(targetRoot.get(Target_.id), + targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name))).getResultList(); } @@ -870,7 +870,8 @@ public class TargetManagement { final Predicate[] specificationsForMultiSelect = specificationsToPredicate( buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId, - selectTargetWithNoTag, false, filterByTagNames), targetRoot, multiselect, cb); + selectTargetWithNoTag, false, filterByTagNames), + targetRoot, multiselect, cb); // if we have some predicates then add it to the where clause of the // multiselect @@ -1000,16 +1001,17 @@ public class TargetManagement { * to be created. * @return the created {@link Target}s * - * @throws {@link EntityAlreadyExistsException} of one of the given targets - * already exist. + * @throws {@link + * EntityAlreadyExistsException} of one of the given targets + * already exist. */ @Modifying @Transactional @NotNull @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) public List createTargets(@NotNull final List targets) { - if (targetRepository.countByControllerIdIn(targets.stream().map(target -> target.getControllerId()) - .collect(Collectors.toList())) > 0) { + if (targetRepository.countByControllerIdIn( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) { throw new EntityAlreadyExistsException(); } final List savedTargets = new ArrayList<>(); @@ -1041,8 +1043,8 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) public List createTargets(@NotNull final Collection targets, @NotNull final TargetUpdateStatus status, final long lastTargetQuery, final URI address) { - if (targetRepository.countByControllerIdIn(targets.stream().map(target -> target.getControllerId()) - .collect(Collectors.toList())) > 0) { + if (targetRepository.countByControllerIdIn( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) { throw new EntityAlreadyExistsException(); } final List savedTargets = new ArrayList<>(); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java index 09459adbe..a81ed81ab 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java @@ -22,11 +22,12 @@ import org.springframework.transaction.annotation.Transactional; * */ @Transactional(readOnly = true) -public interface TargetTagRepository extends BaseEntityRepository, JpaSpecificationExecutor { +public interface TargetTagRepository + extends BaseEntityRepository, JpaSpecificationExecutor { /** * deletes the {@link TargetTag}s with the given tag names. - * + * * @param tagNames * to be deleted * @return 1 if tag was deleted @@ -37,7 +38,7 @@ public interface TargetTagRepository extends BaseEntityRepository * the entity type referenced by the root */ - private static final class JpqQueryRSQLVisitor & FieldNameProvider, T> implements - RSQLVisitor, String> { + private static final class JpqQueryRSQLVisitor & FieldNameProvider, T> + implements RSQLVisitor, String> { public static final Character LIKE_WILDCARD = '*'; private final Root root; @@ -239,9 +239,11 @@ public final class RSQLUtility { } } - 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() + "}", + 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()); } @@ -271,10 +273,10 @@ public final class RSQLUtility { fieldName = getFieldEnumByName(node); } catch (final IllegalArgumentException e) { throw new RSQLParameterUnsupportedFieldException("The given search parameter field {" - + node.getSelector() - + "} does not exist, must be one of the following fields {" + + node.getSelector() + "} does not exist, must be one of the following fields {" + Arrays.stream(enumType.getEnumConstants()).map(v -> v.name().toLowerCase()) - .collect(Collectors.toList()) + "}", e); + .collect(Collectors.toList()) + + "}", e); } final String finalProperty = getAndValidatePropertyFieldName(fieldName, node); @@ -302,20 +304,15 @@ public final class RSQLUtility { return enumFieldName; }).collect(Collectors.toList()); - final List expectedSubFieldList = Arrays - .stream(enumType.getEnumConstants()) - .filter(enumField -> !enumField.getSubEntityAttributes().isEmpty()) - .flatMap( - enumField -> { - final List subEntity = enumField - .getSubEntityAttributes() - .stream() - .map(fieldName -> enumField.name().toLowerCase() - + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + fieldName) - .collect(Collectors.toList()); + final List expectedSubFieldList = Arrays.stream(enumType.getEnumConstants()) + .filter(enumField -> !enumField.getSubEntityAttributes().isEmpty()).flatMap(enumField -> { + final List subEntity = enumField.getSubEntityAttributes().stream() + .map(fieldName -> enumField.name().toLowerCase() + + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + fieldName) + .collect(Collectors.toList()); - return subEntity.stream(); - }).collect(Collectors.toList()); + return subEntity.stream(); + }).collect(Collectors.toList()); expectedFieldList.addAll(expectedSubFieldList); return expectedFieldList; } @@ -373,11 +370,10 @@ public final class RSQLUtility { javaType); LOGGER.debug("value cannot be transformed to an enum", e); - throw new RSQLParameterUnsupportedFieldException("field {" - + node.getSelector() - + "} must be one of the following values {" - + Arrays.stream(tmpEnumType.getEnumConstants()).map(v -> v.name().toLowerCase()) - .collect(Collectors.toList()) + "}", e); + throw new RSQLParameterUnsupportedFieldException("field {" + node.getSelector() + + "} must be one of the following values {" + Arrays.stream(tmpEnumType.getEnumConstants()) + .map(v -> v.name().toLowerCase()).collect(Collectors.toList()) + + "}", e); } } @@ -442,7 +438,8 @@ public final class RSQLUtility { return fieldPath.get(enumField.getValueFieldName()); } - private Predicate mapToMapPredicate(final ComparisonNode node, final Path fieldPath, final A enumField) { + private Predicate mapToMapPredicate(final ComparisonNode node, final Path fieldPath, + final A enumField) { if (!enumField.isMap()) { return null; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java index c5b77a413..4150229c6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java @@ -151,9 +151,10 @@ public final class DistributionSetSpecification { @Override public Predicate toPredicate(final Root targetRoot, final CriteriaQuery query, final CriteriaBuilder cb) { - final Predicate predicate = cb.or( - cb.like(cb.lower(targetRoot. get(DistributionSet_.name)), subString.toLowerCase()), - cb.like(cb.lower(targetRoot. get(DistributionSet_.version)), subString.toLowerCase()), + final Predicate predicate = cb + .or(cb.like(cb.lower(targetRoot. get(DistributionSet_.name)), subString.toLowerCase()), + cb.like(cb.lower(targetRoot. get(DistributionSet_.version)), + subString.toLowerCase()), cb.like(cb.lower(targetRoot. get(DistributionSet_.description)), subString.toLowerCase())); return predicate; @@ -215,7 +216,8 @@ public final class DistributionSetSpecification { * to be filtered on * @return the {@link Specification} */ - public static Specification equalsNameAndVersionIgnoreCase(final String name, final String version) { + public static Specification equalsNameAndVersionIgnoreCase(final String name, + final String version) { final Specification spec = new Specification() { @Override public Predicate toPredicate(final Root targetRoot, final CriteriaQuery query, @@ -265,8 +267,8 @@ public final class DistributionSetSpecification { @Override public Predicate toPredicate(final Root dsRoot, final CriteriaQuery query, final CriteriaBuilder cb) { - final ListJoin installedTargetJoin = dsRoot.join( - DistributionSet_.installedAtTargets, JoinType.INNER); + final ListJoin installedTargetJoin = dsRoot + .join(DistributionSet_.installedAtTargets, JoinType.INNER); final Join targetJoin = installedTargetJoin.join(TargetInfo_.target); return cb.equal(targetJoin.get(Target_.controllerId), installedTargetId); } @@ -287,8 +289,8 @@ public final class DistributionSetSpecification { @Override public Predicate toPredicate(final Root dsRoot, final CriteriaQuery query, final CriteriaBuilder cb) { - final ListJoin assignedTargetJoin = dsRoot.join( - DistributionSet_.assignedToTargets, JoinType.INNER); + final ListJoin assignedTargetJoin = dsRoot + .join(DistributionSet_.assignedToTargets, JoinType.INNER); return cb.equal(assignedTargetJoin.get(Target_.controllerId), assignedTargetId); } }; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java index 0c91a1cce..fb0e5740e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java @@ -77,7 +77,8 @@ public final class TargetSpecifications { * * @return the {@link Target} {@link Specification} */ - public static Specification byControllerIdWithStatusAndAssignedInJoin(final Collection controllerIDs) { + public static Specification byControllerIdWithStatusAndAssignedInJoin( + final Collection controllerIDs) { final Specification spec = new Specification() { @Override public Predicate toPredicate(final Root targetRoot, final CriteriaQuery query, @@ -162,10 +163,11 @@ public final class TargetSpecifications { public Predicate toPredicate(final Root targetRoot, final CriteriaQuery query, final CriteriaBuilder cb) { final Join targetInfoJoin = targetRoot.join(Target_.targetInfo); - final Predicate predicate = cb.or(cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet) - .get(DistributionSet_.id), distributionId), cb.equal( - targetRoot. get(Target_.assignedDistributionSet).get(DistributionSet_.id), - distributionId)); + final Predicate predicate = cb.or( + cb.equal(targetInfoJoin.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id), + distributionId), + cb.equal(targetRoot. get(Target_.assignedDistributionSet) + .get(DistributionSet_.id), distributionId)); return predicate; } }; @@ -189,12 +191,10 @@ public final class TargetSpecifications { @Override public Predicate toPredicate(final Root targetRoot, final CriteriaQuery query, final CriteriaBuilder cb) { - final Predicate predicate = cb.and( - targetRoot.get(Target_.controllerId).in(tIDs), - cb.or(cb.notEqual( - targetRoot. get(Target_.assignedDistributionSet).get( - DistributionSet_.id), distributionId), - cb.isNull(targetRoot. get(Target_.assignedDistributionSet)))); + final Predicate predicate = cb.and(targetRoot.get(Target_.controllerId).in(tIDs), + cb.or(cb.notEqual(targetRoot. get(Target_.assignedDistributionSet) + .get(DistributionSet_.id), distributionId), + cb.isNull(targetRoot. get(Target_.assignedDistributionSet)))); return predicate; } }; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 8583522df..46747cd9c 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -44,16 +44,16 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; 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.Lists; import com.google.common.eventbus.EventBus; 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 * {@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, distributionSetManagement, new ArrayList()); - final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2", - softwareManagement, distributionSetManagement, new ArrayList()); + final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2", softwareManagement, + distributionSetManagement, new ArrayList()); - List targets = targetManagement.createTargets(TestDataUtil - .generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10)); + List targets = targetManagement + .createTargets(TestDataUtil.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10)); targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedTargets(); targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedTargets(); - targetManagement.findAllTargetIds().forEach( - targetIdName -> { - assertThat( - deploymentManagement.findActiveActionsByTarget(targetManagement - .findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2); - }); + targetManagement.findAllTargetIds().forEach(targetIdName -> { + assertThat(deploymentManagement.findActiveActionsByTarget( + targetManagement.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2); + }); } @Test @@ -164,8 +162,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { target = targetManagement.createTarget(target); // check initial status - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.UNKNOWN); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.UNKNOWN); // assign the two sets in a row Action firstAction = assignSet(target, dsFirst); @@ -184,8 +182,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction); assertThat(actionStatusRepository.findAll()).hasSize(4); assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.PENDING); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.PENDING); // we cancel first -> back to installed deploymentManagement.cancelAction(firstAction, @@ -196,10 +194,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { controllerManagement.addCancelActionStatus( new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction); assertThat(actionStatusRepository.findAll()).hasSize(6); - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo( - dsInstalled); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.IN_SYNC); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) + .isEqualTo(dsInstalled); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.IN_SYNC); } @Test @@ -220,8 +218,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { target = targetManagement.createTarget(target); // check initial status - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.UNKNOWN); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.UNKNOWN); // assign the two sets in a row Action firstAction = assignSet(target, dsFirst); @@ -240,8 +238,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction); assertThat(actionStatusRepository.findAll()).hasSize(4); assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.PENDING); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.PENDING); // we cancel second -> remain assigned until finished cancellation deploymentManagement.cancelAction(secondAction, @@ -254,10 +252,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { controllerManagement.addCancelActionStatus( new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction); // cancelled success -> back to dsInstalled - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo( - dsInstalled); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.IN_SYNC); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) + .isEqualTo(dsInstalled); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.IN_SYNC); } @Test @@ -270,12 +268,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { target.getTargetInfo().setInstalledDistributionSet(dsInstalled); target = targetManagement.createTarget(target); - final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement, - distributionSetManagement, true).setRequiredMigrationStep(true); + final DistributionSet ds = TestDataUtil + .generateDistributionSet("newDS", softwareManagement, distributionSetManagement, true) + .setRequiredMigrationStep(true); // verify initial status - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.UNKNOWN); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.UNKNOWN); Action assigningAction = assignSet(target, ds); @@ -295,10 +294,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // verify assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED); - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo( - dsInstalled); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.IN_SYNC); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) + .isEqualTo(dsInstalled); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.IN_SYNC); } @Test @@ -311,12 +310,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { target.getTargetInfo().setInstalledDistributionSet(dsInstalled); target = targetManagement.createTarget(target); - final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement, - distributionSetManagement, true).setRequiredMigrationStep(true); + final DistributionSet ds = TestDataUtil + .generateDistributionSet("newDS", softwareManagement, distributionSetManagement, true) + .setRequiredMigrationStep(true); // verify initial status - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( - TargetUpdateStatus.UNKNOWN); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) + .isEqualTo(TargetUpdateStatus.UNKNOWN); final Action assigningAction = assignSet(target, ds); @@ -337,7 +337,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() }); assertThat( targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .isEqualTo(TargetUpdateStatus.PENDING); assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet()) .isEqualTo(ds); final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0); @@ -360,12 +360,12 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { eventBus.register(eventHandlerMock); final String myCtrlIDPref = "myCtrlID"; - final Iterable savedNakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, - myCtrlIDPref, "first description")); + final Iterable savedNakedTargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(10, myCtrlIDPref, "first description")); final String myDeployedCtrlIDPref = "myDeployedCtrlID"; - final List savedDeployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20, - myDeployedCtrlIDPref, "first description")); + final List savedDeployedTargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(20, myDeployedCtrlIDPref, "first description")); final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); @@ -409,15 +409,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final List targets = targetManagement.createTargets(TestDataUtil.generateTargets(10)); - final SoftwareModule ah = softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub", - "1.0.1", null, "")); - final SoftwareModule jvm = softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, - "oracle-jre", "1.7.2", null, "")); - final SoftwareModule os = softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", - null, "")); + final SoftwareModule ah = softwareManagement + .createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, "")); + final SoftwareModule jvm = softwareManagement + .createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, "")); + final SoftwareModule os = softwareManagement + .createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, "")); - final DistributionSet incomplete = distributionSetManagement.createDistributionSet(new DistributionSet( - "incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm))); + final DistributionSet incomplete = distributionSetManagement.createDistributionSet( + new DistributionSet("incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm))); try { deploymentManagement.assignDistributionSet(incomplete, targets); @@ -487,18 +487,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Iterable undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs); // test that number of Targets - assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).isEqualTo( - deployedTargetsFromDB.spliterator().getExactSizeIfKnown() + assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()) + .isEqualTo(deployedTargetsFromDB.spliterator().getExactSizeIfKnown() + undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()); assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets); assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets); // test the content of different lists assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB); - assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets).doesNotContain( - Iterables.toArray(undeployedTargetsFromDB, Target.class)); - assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets).doesNotContain( - Iterables.toArray(deployedTargetsFromDB, Target.class)); + assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets) + .doesNotContain(Iterables.toArray(undeployedTargetsFromDB, Target.class)); + assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets) + .doesNotContain(Iterables.toArray(deployedTargetsFromDB, Target.class)); // For each of the 4 targets 1 distribution sets gets assigned eventHandlerMock.getEvents(10, TimeUnit.SECONDS); @@ -532,21 +532,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // verifying the correctness of the assignments for (final Target t : deployResWithDsA.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId()); - assertThat( - targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); } for (final Target t : deployResWithDsB.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId()); - assertThat( - targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); } for (final Target t : deployResWithDsC.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId()); - assertThat( - targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); } @@ -559,9 +556,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { for (final Target t_ : updatedTsDsA) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA); - assertThat( - targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isEqualTo(dsA); + assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isEqualTo(dsA); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.IN_SYNC); assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0); @@ -571,8 +567,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // remove updActB from // activeActions, add a corresponding cancelAction and another // UpdateAction for dsA - final Iterable deployed2DS = deploymentManagement.assignDistributionSet(dsA, - deployResWithDsB.getDeployedTargets()).getAssignedTargets(); + final Iterable deployed2DS = deploymentManagement + .assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets(); final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1); assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets()); @@ -581,9 +577,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { for (final Target t_ : deployed2DS) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA); - assertThat( - targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); @@ -640,8 +635,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { "blabla alles gut"); } // try to delete again - distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs().toArray( - new Long[deploymentResult.getDistributionSetIDs().size()])); + distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs() + .toArray(new Long[deploymentResult.getDistributionSetIDs().size()])); // verify that the result is the same, even though distributionSet dsA // has been installed // successfully and no activeAction is referring to created distribution @@ -676,8 +671,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { assertThat(targetManagement.countTargetsAll()).isNotZero(); assertThat(actionStatusRepository.count()).isNotZero(); - targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray( - new Long[noOfUndeployedTargets])); + targetManagement + .deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets])); targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets])); assertThat(targetManagement.countTargetsAll()).isZero(); @@ -768,8 +763,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { targ = targs.iterator().next(); assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size()); - assertEquals(TargetUpdateStatus.PENDING, targetManagement.findTargetByControllerID(targ.getControllerId()) - .getTargetInfo().getUpdateStatus()); + assertEquals(TargetUpdateStatus.PENDING, + targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus()); assertEquals(dsB, targ.getAssignedDistributionSet()); assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()) .getTargetInfo().getInstalledDistributionSet().getId()); @@ -808,8 +803,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement); // assign ds to create an action - final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet( - ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId()); + final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement + .assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId()); final Action action = assignDistributionSet.getActions().get(0); // verify preparation Action findAction = deploymentManagement.findAction(action.getId()); @@ -831,8 +826,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement); // assign ds to create an action - final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet( - ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId()); + final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement + .assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId()); final Action action = assignDistributionSet.getActions().get(0); // verify perparation Action findAction = deploymentManagement.findAction(action.getId()); @@ -874,11 +869,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { private DeploymentResult prepareComplexRepo(final String undeployedTargetPrefix, final int noOfUndeployedTargets, final String deployedTargetPrefix, final int noOfDeployedTargets, final int noOfDistributionSets, final String distributionSetPrefix) { - final Iterable nakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures( - noOfUndeployedTargets, undeployedTargetPrefix, "first description")); + final Iterable nakedTargets = targetManagement.createTargets( + TestDataUtil.buildTargetFixtures(noOfUndeployedTargets, undeployedTargetPrefix, "first description")); - List deployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures( - noOfDeployedTargets, deployedTargetPrefix, "first description")); + List deployedTargets = targetManagement.createTargets( + TestDataUtil.buildTargetFixtures(noOfDeployedTargets, deployedTargetPrefix, "first description")); // creating 10 DistributionSets final List dsList = TestDataUtil.generateDistributionSets(distributionSetPrefix, @@ -907,10 +902,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { found = true; final List activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt); assertThat(activeActionsByTarget).isNotEmpty(); - assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()).as( - "Action id in database and event do not match"); - assertThat(event.getSoftwareModules()).containsOnly( - ds.getModules().toArray(new SoftwareModule[ds.getModules().size()])); + assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()) + .as("Action id in database and event do not match"); + assertThat(event.getSoftwareModules()) + .containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()])); } } assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId()); @@ -1078,8 +1073,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { latch.await(timeout, unit); final List handledEvents = new LinkedList( events); - assertThat(handledEvents).hasSize(expectedNumberOfEvents).as( - "Did not receive the expected amount of events (" + expectedNumberOfEvents + assertThat(handledEvents).hasSize(expectedNumberOfEvents) + .as("Did not receive the expected amount of events (" + expectedNumberOfEvents + ") within timeout. Received events are " + handledEvents); return handledEvents; } @@ -1106,8 +1101,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { throws InterruptedException { latch.await(timeout, unit); final List handledEvents = new LinkedList(events); - assertThat(handledEvents).hasSize(expectedNumberOfEvents).as( - "Did not receive the expected amount of events (" + expectedNumberOfEvents + assertThat(handledEvents).hasSize(expectedNumberOfEvents) + .as("Did not receive the expected amount of events (" + expectedNumberOfEvents + ") within timeout. Received events are " + handledEvents); return handledEvents; } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java index 5e686cded..cdb76fd8d 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java @@ -96,8 +96,8 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB { new TenantUsage("tenant1").setTargets(100).setActions(200)); } - private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, final int updates) - throws Exception { + private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, + final int updates) throws Exception { final Random randomgen = new Random(); final byte random[] = new byte[artifactSize]; randomgen.nextBytes(random); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java index fdc7d9ea2..9c1a9b66e 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java @@ -25,12 +25,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag; import org.junit.Test; import org.slf4j.LoggerFactory; +import com.google.common.collect.Lists; + import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; -import com.google.common.collect.Lists; - /** * Test class for {@link TagManagement}. * @@ -90,32 +90,34 @@ public class TagManagementTest extends AbstractIntegrationTest { DistributionSetFilterBuilder distributionSetFilterBuilder; // search for not deleted - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( - Lists.newArrayList(tagA.getName())); - assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() - + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) + .setTagNames(Lists.newArrayList(tagA.getName())); + assertEquals( + dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( - Lists.newArrayList(tagB.getName())); - assertEquals(dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() - + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) + .setTagNames(Lists.newArrayList(tagB.getName())); + assertEquals( + dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( - Lists.newArrayList(tagC.getName())); - assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() - + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) + .setTagNames(Lists.newArrayList(tagC.getName())); + assertEquals( + dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( - Lists.newArrayList(tagX.getName())); - assertEquals(0, - distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) - .getTotalElements()); + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) + .setTagNames(Lists.newArrayList(tagX.getName())); + assertEquals(0, distributionSetManagement + .findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements()); assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); @@ -127,23 +129,24 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.deleteDistributionSetTag(tagB.getName()); assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames( - Lists.newArrayList(tagA.getName())); - assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() - + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) + .setTagNames(Lists.newArrayList(tagA.getName())); + assertEquals( + dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames( - Lists.newArrayList(tagB.getName())); - assertEquals(0, - distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) - .getTotalElements()); + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) + .setTagNames(Lists.newArrayList(tagB.getName())); + assertEquals(0, distributionSetManagement + .findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames( - Lists.newArrayList(tagC.getName())); - assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() - + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) + .setTagNames(Lists.newArrayList(tagC.getName())); + assertEquals( + dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); } @@ -206,8 +209,8 @@ public class TagManagementTest extends AbstractIntegrationTest { // check for (final Target target : targetRepository.findAll()) { - assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()).doesNotContain( - toDelete); + assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()) + .doesNotContain(toDelete); } assertThat(targetTagRepository.findOne(toDelete.getId())).isNull(); assertThat(tagManagement.findAllTargetTags()).hasSize(19); @@ -278,8 +281,8 @@ public class TagManagementTest extends AbstractIntegrationTest { final DistributionSetTag toDelete = tags.iterator().next(); for (final DistributionSet set : distributionSetRepository.findAll()) { - assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()).contains( - toDelete); + assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) + .contains(toDelete); } // delete @@ -359,8 +362,8 @@ public class TagManagementTest extends AbstractIntegrationTest { final List sets = TestDataUtil.generateDistributionSets(20, softwareManagement, distributionSetManagement); - final Iterable tags = tagManagement.createDistributionSetTags(TestDataUtil - .generateDistributionSetTags(20)); + final Iterable tags = tagManagement + .createDistributionSetTags(TestDataUtil.generateDistributionSetTags(20)); tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag)); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java index 7479bdac7..73528ca5b 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java @@ -73,8 +73,8 @@ public class TargetFilterQueryManagenmentTest extends AbstractIntegrationTest { final String newQuery = "status==UNKNOWN"; targetFilterQuery.setQuery(newQuery); targetFilterQueryManagement.updateTargetFilterQuery(targetFilterQuery); - assertEquals("Returns updated target filter query", newQuery, targetFilterQueryManagement - .findTargetFilterQueryByName(filterName).getQuery()); + assertEquals("Returns updated target filter query", newQuery, + targetFilterQueryManagement.findTargetFilterQueryByName(filterName).getQuery()); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index 8f88b3216..a7b8e673f 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -44,12 +44,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag; import org.junit.Test; 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.Features; import ru.yandex.qatools.allure.annotations.Stories; -import com.google.common.collect.Iterables; - @Features("Component Tests - Repository") @Stories("Target Management") public class TargetManagementTest extends AbstractIntegrationTest { @@ -158,8 +158,8 @@ public class TargetManagementTest extends AbstractIntegrationTest { final Action action = result.getActions().get(0); action.setStatus(Status.FINISHED); - controllerManagament.addUpdateActionStatus(new ActionStatus(action, Status.FINISHED, - System.currentTimeMillis(), "message"), action); + controllerManagament.addUpdateActionStatus( + new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action); deploymentManagement.assignDistributionSet(set2.getId(), "4711"); target = targetManagement.findTargetByControllerIDWithDetails("4711"); @@ -341,8 +341,8 @@ public class TargetManagementTest extends AbstractIntegrationTest { targetManagement.deleteTargets(deletedTargetIDs); allFound = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent(); - assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del, allFound.spliterator() - .getExactSizeIfKnown()); + assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del, + allFound.spliterator().getExactSizeIfKnown()); // verify that all undeleted are still found assertThat(allFound).doesNotContain(deletedTargets); @@ -351,8 +351,8 @@ public class TargetManagementTest extends AbstractIntegrationTest { @Test @Description("Stores target attributes and verfies existence in the repository.") public void savingTargetControllerAttributes() { - Iterable ts = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(100, "myCtrlID", - "first description")); + Iterable ts = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(100, "myCtrlID", "first description")); final Map attribs = new HashMap(); attribs.put("a.b.c", "abc"); @@ -438,8 +438,8 @@ public class TargetManagementTest extends AbstractIntegrationTest { final Target tNoAttrib = targetManagement.findTargetByControllerID(tNoAttribl.getControllerId()); if (tNoAttrib.getControllerId().equals(target.getControllerId())) { - assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray()).doesNotContain( - attribs2Del.toArray()); + assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray()) + .doesNotContain(attribs2Del.toArray()); continue restTarget_; } } @@ -452,14 +452,14 @@ public class TargetManagementTest extends AbstractIntegrationTest { Target t1 = TestDataUtil.buildTargetFixture("id-1", "blablub"); final int noT2Tags = 4; final int noT1Tags = 3; - final List t1Tags = tagManagement.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT1Tags, - "tag1")); + final List t1Tags = tagManagement + .createTargetTags(TestDataUtil.buildTargetTagFixtures(noT1Tags, "tag1")); t1.getTags().addAll(t1Tags); t1 = targetManagement.createTarget(t1); Target t2 = TestDataUtil.buildTargetFixture("id-2", "blablub"); - final List t2Tags = tagManagement.createTargetTags(TestDataUtil.buildTargetTagFixtures(noT2Tags, - "tag2")); + final List t2Tags = tagManagement + .createTargetTags(TestDataUtil.buildTargetTagFixtures(noT2Tags, "tag2")); t2.getTags().addAll(t2Tags); t2 = targetManagement.createTarget(t2); @@ -475,18 +475,18 @@ public class TargetManagementTest extends AbstractIntegrationTest { @Test @Description("Tests the assigment of tags to multiple targets.") public void targetTagBulkAssignments() { - final List tagATargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, - "tagATargets", "first description")); - final List tagBTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, - "tagBTargets", "first description")); - final List tagCTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, - "tagCTargets", "first description")); + final List tagATargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(10, "tagATargets", "first description")); + final List tagBTargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(10, "tagBTargets", "first description")); + final List tagCTargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(10, "tagCTargets", "first description")); - final List tagABTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, - "tagABTargets", "first description")); + final List tagABTargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(10, "tagABTargets", "first description")); - final List tagABCTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, - "tagABCTargets", "first description")); + final List tagABCTargets = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(10, "tagABCTargets", "first description")); final TargetTag tagA = tagManagement.createTargetTag(new TargetTag("A")); final TargetTag tagB = tagManagement.createTargetTag(new TargetTag("B")); @@ -534,12 +534,12 @@ public class TargetManagementTest extends AbstractIntegrationTest { checkTargetHasNotTags(tagCTargets, tagA, tagB); // check again target lists refreshed from DB - assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A")).isEqualTo( - targetWithTagA.size()); - assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B")).isEqualTo( - targetWithTagB.size()); - assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C")).isEqualTo( - targetWithTagC.size()); + assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A")) + .isEqualTo(targetWithTagA.size()); + assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B")) + .isEqualTo(targetWithTagB.size()); + assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C")) + .isEqualTo(targetWithTagC.size()); } @Test @@ -549,21 +549,21 @@ public class TargetManagementTest extends AbstractIntegrationTest { final TargetTag targTagB = tagManagement.createTargetTag(new TargetTag("Targ-B-Tag")); final TargetTag targTagC = tagManagement.createTargetTag(new TargetTag("Targ-C-Tag")); - final List targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", - "first description")); - final List targBs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20, "target-id-B", - "first description")); - final List targCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(15, "target-id-C", - "first description")); + final List targAs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description")); + final List targBs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(20, "target-id-B", "first description")); + final List targCs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(15, "target-id-C", "first description")); - final List targABs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(12, - "target-id-AB", "first description")); - final List targACs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(13, - "target-id-AC", "first description")); - final List targBCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(7, "target-id-BC", - "first description")); - final List targABCs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(17, - "target-id-ABC", "first description")); + final List targABs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(12, "target-id-AB", "first description")); + final List targACs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(13, "target-id-AC", "first description")); + final List targBCs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(7, "target-id-BC", "first description")); + final List targABCs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(17, "target-id-ABC", "first description")); targetManagement.toggleTagAssignment(targAs, targTagA); targetManagement.toggleTagAssignment(targABs, targTagA); @@ -610,29 +610,27 @@ public class TargetManagementTest extends AbstractIntegrationTest { public void findTargetsByControllerIDsWithTags() { final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag")); - final List targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", - "first description")); + final List targAs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description")); targetManagement.toggleTagAssignment(targAs, targTagA); - assertThat( - targetManagement.findTargetsByControllerIDsWithTags(targAs.stream() - .map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25); + assertThat(targetManagement.findTargetsByControllerIDsWithTags( + targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25); // no lazy loading exception and tag correctly assigned - assertThat( - targetManagement - .findTargetsByControllerIDsWithTags( - targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) - .stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList())) - .containsOnly(true); + assertThat(targetManagement + .findTargetsByControllerIDsWithTags( + targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) + .stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList())) + .containsOnly(true); } @Test @Description("Test the optimized quere for retrieving all ID/name pairs of targets.") public void findAllTargetIdNamePaiss() { - final List targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", - "first description")); + final List targAs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description")); final String[] createdTargetIds = targAs.stream().map(t -> t.getControllerId()) .toArray(size -> new String[size]); @@ -648,15 +646,15 @@ public class TargetManagementTest extends AbstractIntegrationTest { public void findTargetsWithNoTag() { final TargetTag targTagA = tagManagement.createTargetTag(new TargetTag("Targ-A-Tag")); - final List targAs = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", - "first description")); + final List targAs = targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-A", "first description")); targetManagement.toggleTagAssignment(targAs, targTagA); targetManagement.createTargets(TestDataUtil.buildTargetFixtures(25, "target-id-B", "first description")); final String[] tagNames = null; - final List targetsListWithNoTag = targetManagement.findTargetByFilters(new PageRequest(0, 500), null, - null, null, Boolean.TRUE, tagNames).getContent(); + final List targetsListWithNoTag = targetManagement + .findTargetByFilters(new PageRequest(0, 500), null, null, null, Boolean.TRUE, tagNames).getContent(); // Total targets assertEquals(50, targetManagement.findAllTargetIds().size()); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java index ae72a5cb2..05fd6c492 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java @@ -138,13 +138,11 @@ public class ArtifactStoreController implements EnvironmentAware { private Action checkAndReportDownloadByTarget(final HttpServletRequest request, final String targetid, final LocalArtifact artifact) { - final Target target = controllerManagement.updateLastTargetQuery( - targetid, - IpUtil.getClientIpFromRequest(request, - environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For"))); + final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest( + request, environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For"))); - final Action action = controllerManagement.getActionForDownloadByTargetAndSoftwareModule( - target.getControllerId(), artifact.getSoftwareModule()); + final Action action = controllerManagement + .getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), artifact.getSoftwareModule()); final String range = request.getHeader("Range"); final ActionStatus actionStatus = new ActionStatus(); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java index bec137f91..8246dd430 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java @@ -163,9 +163,10 @@ public class RootController implements EnvironmentAware { System.currentTimeMillis(), IpUtil.getClientIpFromRequest(request, requestHeader)); } - return new ResponseEntity<>(DataConversionHelper.fromTarget(target, - controllerManagement.findActionByTargetAndActive(target), controllerPollProperties.getPollingTime(), - tenantAware), HttpStatus.OK); + return new ResponseEntity<>( + DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target), + controllerPollProperties.getPollingTime(), tenantAware), + HttpStatus.OK); } /** @@ -220,8 +221,8 @@ public class RootController implements EnvironmentAware { private Action checkAndLogDownload(final HttpServletRequest request, final Target target, final SoftwareModule module) { - final Action action = controllerManagement.getActionForDownloadByTargetAndSoftwareModule( - target.getControllerId(), module); + final Action action = controllerManagement + .getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), module); final String range = request.getHeader("Range"); final ActionStatus statusMessage = new ActionStatus(); @@ -274,8 +275,8 @@ public class RootController implements EnvironmentAware { } try { - DataConversionHelper.writeMD5FileResponse(fileName, response, module.getLocalArtifactByFilename(fileName) - .get()); + DataConversionHelper.writeMD5FileResponse(fileName, response, + module.getLocalArtifactByFilename(fileName).get()); } catch (final IOException e) { LOG.error("Failed to stream MD5 File", e); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); @@ -301,7 +302,8 @@ public class RootController implements EnvironmentAware { * the HTTP request injected by spring * @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 getControllerBasedeploymentAction( @PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId, @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 DeploymentBase base = new DeploymentBase(Long.toString(action.getId()), new Deployment(handlingType, - handlingType, chunks)); + final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()), + new Deployment(handlingType, handlingType, chunks)); 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, - final Long actionid, final Action action) { + private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid, final Long actionid, + final Action action) { final ActionStatus actionStatus = new ActionStatus(); actionStatus.setAction(action); @@ -430,8 +432,8 @@ public class RootController implements EnvironmentAware { private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid, final Long actionid, final ActionStatus actionStatus) { - LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", - actionid, targetid, feedback.getStatus().getExecution()); + LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", actionid, + targetid, feedback.getStatus().getExecution()); actionStatus.setStatus(Status.RUNNING); // MECS-400: we should not use the unstructed message list for // the server comment on the status. @@ -463,7 +465,8 @@ public class RootController implements EnvironmentAware { * * @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 putConfigData(@Valid @RequestBody final ConfigData configData, @PathVariable final String targetid, final HttpServletRequest request) { controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(request, requestHeader)); @@ -485,7 +488,8 @@ public class RootController implements EnvironmentAware { * * @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 getControllerCancelAction(@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) { LOG.debug("getControllerCancelAction({})", targetid); @@ -500,8 +504,8 @@ public class RootController implements EnvironmentAware { } if (action.isCancelingOrCanceled()) { - final Cancel cancel = new Cancel(String.valueOf(action.getId()), new CancelActionToStop( - String.valueOf(action.getId()))); + final Cancel cancel = new Cancel(String.valueOf(action.getId()), + new CancelActionToStop(String.valueOf(action.getId()))); 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); } - controllerManagement.addCancelActionStatus( - generateActionCancelStatus(feedback, target, feedback.getId(), action), action); + controllerManagement + .addCancelActionStatus(generateActionCancelStatus(feedback, target, feedback.getId(), action), action); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java index 95924721e..830b47798 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java @@ -57,8 +57,8 @@ public final class DistributionSetMapper { final DistributionSetType module = distributionSetManagement .findDistributionSetTypeByKey(distributionSetTypekey); if (module == null) { - throw new EntityNotFoundException("DistributionSetType with key {" + distributionSetTypekey - + "} does not exist"); + throw new EntityNotFoundException( + "DistributionSetType with key {" + distributionSetTypekey + "} does not exist"); } return module; } @@ -108,18 +108,18 @@ public final class DistributionSetMapper { } if (dsRest.getApplication() != null) { - result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(), - softwareManagement)); + result.addModule( + findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(), softwareManagement)); } if (dsRest.getRuntime() != null) { - result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement)); + result.addModule( + findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement)); } if (dsRest.getModules() != null) { - dsRest.getModules().forEach( - module -> result.addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(), - softwareManagement))); + dsRest.getModules().forEach(module -> result + .addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(), softwareManagement))); } return result; @@ -163,23 +163,22 @@ public final class DistributionSetMapper { response.setComplete(distributionSet.isComplete()); response.setType(distributionSet.getType().getKey()); - distributionSet.getModules().forEach( - module -> response.getModules().add(SoftwareModuleMapper.toResponse(module))); + distributionSet.getModules() + .forEach(module -> response.getModules().add(SoftwareModuleMapper.toResponse(module))); response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); - response.add(linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel( - "self")); + response.add( + linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel("self")); response.add(linkTo( methodOn(DistributionSetTypeResource.class).getDistributionSetType(distributionSet.getType().getId())) - .withRel("type")); + .withRel("type")); - response.add(linkTo( - methodOn(DistributionSetResource.class).getMetadata(response.getDsId(), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel( - "metadata")); + response.add(linkTo(methodOn(DistributionSetResource.class).getMetadata(response.getDsId(), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) + .withRel("metadata")); return response; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java index 4f1365747..b0a245915 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java @@ -13,8 +13,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import javax.persistence.EntityManager; - import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetFields; @@ -92,7 +90,6 @@ public class DistributionSetResource { @Autowired private DistributionSetManagement distributionSetManagement; - /** * Handles the GET request of retrieving all {@link DistributionSet}s within * SP. diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java index 18de23dd9..99e22436e 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java @@ -11,8 +11,6 @@ package org.eclipse.hawkbit.rest.resource; import java.util.List; import java.util.stream.Collectors; -import javax.persistence.EntityManager; - import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.TagFields; import org.eclipse.hawkbit.repository.TagManagement; @@ -60,7 +58,6 @@ public class DistributionSetTagResource { @Autowired private DistributionSetManagement distributionSetManagement; - /** * Handles the GET request of retrieving all DistributionSet tags. * @@ -100,8 +97,8 @@ public class DistributionSetTagResource { countTargetsAll = tagManagement.countTargetTags(); } else { - final Page findTargetPage = tagManagement.findAllDistributionSetTags( - RSQLUtility.parse(rsqlParam, TagFields.class), pageable); + final Page findTargetPage = tagManagement + .findAllDistributionSetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable); countTargetsAll = findTargetPage.getTotalElements(); findTargetsAll = findTargetPage; @@ -139,13 +136,13 @@ public class DistributionSetTagResource { * with status code 201 - Created. The Response Body are the created * distribution set tags but without ResponseBody. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createDistributionSetTags(@RequestBody final List tags) { LOG.debug("creating {} ds tags", tags.size()); - final List createdTags = tagManagement.createDistributionSetTags(TagMapper - .mapDistributionSetTagFromRequest(tags)); + final List createdTags = tagManagement + .createDistributionSetTags(TagMapper.mapDistributionSetTagFromRequest(tags)); return new ResponseEntity<>(TagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED); } @@ -245,14 +242,14 @@ public class DistributionSetTagResource { final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); - final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement.toggleTagAssignment( - findDistributionSetIds(assignedDSRequestBodies), tag.getName()); + final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement + .toggleTagAssignment(findDistributionSetIds(assignedDSRequestBodies), tag.getName()); final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest(); - tagAssigmentResultRest.setAssignedDistributionSets(DistributionSetMapper - .toResponseDistributionSets(assigmentResult.getAssignedDs())); - tagAssigmentResultRest.setUnassignedDistributionSets(DistributionSetMapper - .toResponseDistributionSets(assigmentResult.getUnassignedDs())); + tagAssigmentResultRest.setAssignedDistributionSets( + DistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedDs())); + tagAssigmentResultRest.setUnassignedDistributionSets( + DistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedDs())); LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(), assigmentResult.getUnassigned()); @@ -279,8 +276,8 @@ public class DistributionSetTagResource { LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId); final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); - final List assignedDs = distributionSetManagement.assignTag( - findDistributionSetIds(assignedDSRequestBodies), tag); + final List assignedDs = distributionSetManagement + .assignTag(findDistributionSetIds(assignedDSRequestBodies), tag); LOG.debug("Assignd DistributionSet {}", assignedDs.size()); return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java index 6242b6acd..19cf94f04 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java @@ -10,8 +10,6 @@ package org.eclipse.hawkbit.rest.resource; import java.util.List; -import javax.persistence.EntityManager; - import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeFields; import org.eclipse.hawkbit.repository.SoftwareManagement; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java index d8fc120fc..947c216dd 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java @@ -60,7 +60,8 @@ public final class SoftwareModuleMapper { smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor()); } - static List fromRequestSwMetadata(final SoftwareModule sw, final List metadata) { + static List fromRequestSwMetadata(final SoftwareModule sw, + final List metadata) { final List mappedList = new ArrayList<>(metadata.size()); for (final MetadataRest metadataRest : metadata) { if (metadataRest.getKey() == null) { @@ -141,20 +142,19 @@ public final class SoftwareModuleMapper { response.setType(baseSofwareModule.getType().getKey()); response.setVendor(baseSofwareModule.getVendor()); - response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId())).withRel( - RestConstants.SOFTWAREMODULE_V1_ARTIFACT)); - response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId())).withRel( - "self")); + response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId())) + .withRel(RestConstants.SOFTWAREMODULE_V1_ARTIFACT)); + response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId())) + .withRel("self")); response.add(linkTo( methodOn(SoftwareModuleTypeResource.class).getSoftwareModuleType(baseSofwareModule.getType().getId())) - .withRel(RestConstants.SOFTWAREMODULE_V1_TYPE)); + .withRel(RestConstants.SOFTWAREMODULE_V1_TYPE)); - response.add(linkTo( - methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel( - "metadata")); + response.add(linkTo(methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) + .withRel("metadata")); return response; } @@ -178,13 +178,12 @@ public final class SoftwareModuleMapper { RestModelMapper.mapBaseToBase(artifactRest, artifact); - artifactRest.add(linkTo( - methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(), - artifact.getId())).withRel("self")); + artifactRest.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(), + artifact.getId())).withRel("self")); if (artifact instanceof LocalArtifact) { - artifactRest.add(linkTo( - methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(), + artifactRest.add( + linkTo(methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId(), null, null)).withRel("download")); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java index 43228d365..5c60334cd 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java @@ -261,8 +261,8 @@ public class SoftwareModuleResource { final Slice findModulesAll; Long countModulesAll; if (rsqlParam != null) { - findModulesAll = softwareManagement.findSoftwareModulesByPredicate( - RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable); + findModulesAll = softwareManagement + .findSoftwareModulesByPredicate(RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable); countModulesAll = ((Page) findModulesAll).getTotalElements(); } else { findModulesAll = softwareManagement.findSoftwareModulesAll(pageable); @@ -303,8 +303,8 @@ public class SoftwareModuleResource { * failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createSoftwareModules( @RequestBody final List softwareModules) { LOG.debug("creating {} softwareModules", softwareModules.size()); @@ -383,8 +383,7 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - public ResponseEntity getMetadata( - @PathVariable final Long softwareModuleId, + public ResponseEntity getMetadata(@PathVariable final Long softwareModuleId, @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_SORTING, required = false) final String sortParam, @@ -407,8 +406,10 @@ public class SoftwareModuleResource { metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable); } - return new ResponseEntity<>(new MetadataRestPageList(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage - .getContent()), metaDataPage.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new MetadataRestPageList(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()), + metaDataPage.getTotalElements()), + HttpStatus.OK); } /** @@ -421,7 +422,8 @@ public class SoftwareModuleResource { * @return status OK if get request is successful with the value of the meta * data */ - @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE }) + @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getMetadataValue(@PathVariable final Long softwareModuleId, @PathVariable final String metadataKey) { // check if distribution set exists otherwise throw exception @@ -481,8 +483,8 @@ public class SoftwareModuleResource { * the created meta data */ @RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/metadata", consumes = { - MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, - "application/hal+json" }) + MediaType.APPLICATION_JSON_VALUE, + "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) public ResponseEntity> createMetadata(@PathVariable final Long softwareModuleId, @RequestBody final List metadataRest) { // check if software module exists otherwise throw exception immediately @@ -495,7 +497,8 @@ public class SoftwareModuleResource { } - private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId, final Long artifactId) { + private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId, + final Long artifactId) { final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId); if (module == null) { throw new EntityNotFoundException("SoftwareModule with Id {" + softwareModuleId + "} does not exist"); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java index b083fe456..7213eae6d 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java @@ -86,8 +86,8 @@ public class SystemManagementResource { .setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes()) .setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size()); - result.setTenantStats(report.getTenants().stream().map(tenant -> convertTenant(tenant)) - .collect(Collectors.toList())); + result.setTenantStats( + report.getTenants().stream().map(tenant -> convertTenant(tenant)).collect(Collectors.toList())); return ResponseEntity.ok(result); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java index 2f9e77090..80a06ab2d 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java @@ -55,8 +55,8 @@ final class TagMapper { response.add(linkTo(methodOn(TargetTagResource.class).getTargetTag(targetTag.getId())).withRel("self")); - response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId())).withRel( - "assignedTargets")); + response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId())) + .withRel("assignedTargets")); return response; } @@ -83,13 +83,13 @@ final class TagMapper { mapTag(response, distributionSetTag); - response.add(linkTo( - methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId())).withRel( - "self")); + response.add( + linkTo(methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId())) + .withRel("self")); response.add(linkTo( methodOn(DistributionSetTagResource.class).getAssignedDistributionSets(distributionSetTag.getId())) - .withRel("assignedDistributionSets")); + .withRel("assignedDistributionSets")); return response; } @@ -97,8 +97,8 @@ final class TagMapper { static List mapTargeTagFromRequest(final Iterable tags) { final List mappedList = new ArrayList<>(); for (final TagRequestBodyPut targetTagRest : tags) { - mappedList.add(new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest - .getColour())); + mappedList.add( + new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour())); } return mappedList; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java index f2234b2a9..a79e136cb 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java @@ -54,13 +54,12 @@ final public class TargetMapper { .withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET)); response.add(linkTo(methodOn(TargetResource.class).getInstalledDistributionSet(response.getControllerId())) .withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET)); - response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId())).withRel( - RestConstants.TARGET_V1_ATTRIBUTES)); - response.add(linkTo( - methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0, - RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, - ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)).withRel( - RestConstants.TARGET_V1_ACTIONS)); + response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId())) + .withRel(RestConstants.TARGET_V1_ATTRIBUTES)); + response.add(linkTo(methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0, + RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, + ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)) + .withRel(RestConstants.TARGET_V1_ACTIONS)); } /** @@ -75,10 +74,10 @@ final public class TargetMapper { final PollStatus pollStatus = target.getTargetInfo().getPollStatus(); if (pollStatus != null) { final PollStatusRest pollStatusRest = new PollStatusRest(); - pollStatusRest.setLastRequestAt(Date.from( - pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); - pollStatusRest.setNextExpectedRequestAt(Date.from( - pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); + pollStatusRest.setLastRequestAt( + Date.from(pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); + pollStatusRest.setNextExpectedRequestAt( + Date.from(pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); pollStatusRest.setOverdue(pollStatus.isOverdue()); targetRest.setPollStatus(pollStatusRest); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java index b15845d3a..7b78b0f21 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java @@ -134,8 +134,8 @@ public class TargetResource { final Slice findTargetsAll; final Long countTargetsAll; if (rsqlParam != null) { - final Page findTargetPage = targetManagement.findTargetsAll( - RSQLUtility.parse(rsqlParam, TargetFields.class), pageable); + final Page findTargetPage = targetManagement + .findTargetsAll(RSQLUtility.parse(rsqlParam, TargetFields.class), pageable); countTargetsAll = findTargetPage.getTotalElements(); findTargetsAll = findTargetPage; } else { @@ -159,8 +159,8 @@ public class TargetResource { * entities. In any failure the JsonResponseExceptionHandler is * handling the response. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createTargets(@RequestBody final List targets) { LOG.debug("creating {} targets", targets.size()); final Iterable createdTargets = targetManagement.createTargets(TargetMapper.fromRequest(targets)); @@ -267,8 +267,7 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getActionHistory( - @PathVariable final String targetId, + public ResponseEntity getActionHistory(@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_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @@ -292,8 +291,9 @@ public class TargetResource { totalActionCount = deploymentManagement.countActionsByTarget(foundTarget); } - return new ResponseEntity<>(new ActionPagedList(TargetMapper.toResponse(targetId, activeActions.getContent()), - totalActionCount), HttpStatus.OK); + return new ResponseEntity<>( + 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 = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getAction(@PathVariable final String targetId, @PathVariable final Long actionId) { + public ResponseEntity getAction(@PathVariable final String targetId, + @PathVariable final Long actionId) { final Target target = findTargetWithExceptionIfNotFound(targetId); final Action action = findActionWithExceptionIfNotFound(actionId); @@ -322,17 +323,16 @@ public class TargetResource { if (!action.isCancelingOrCanceled()) { result.add(linkTo( methodOn(DistributionSetResource.class).getDistributionSet(action.getDistributionSet().getId())) - .withRel("distributionset")); + .withRel("distributionset")); } else if (action.isCancelingOrCanceled()) { - result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId())).withRel( - RestConstants.TARGET_V1_CANCELED_ACTION)); + result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId())) + .withRel(RestConstants.TARGET_V1_CANCELED_ACTION)); } - result.add(linkTo( - methodOn(TargetResource.class).getActionStatusList(targetId, action.getId(), 0, - RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, - ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)).withRel( - RestConstants.TARGET_V1_ACTION_STATUS)); + result.add(linkTo(methodOn(TargetResource.class).getActionStatusList(targetId, action.getId(), 0, + RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, + ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)) + .withRel(RestConstants.TARGET_V1_ACTION_STATUS)); return new ResponseEntity<>(result, HttpStatus.OK); } @@ -394,8 +394,7 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity getActionStatusList( - @PathVariable final String targetId, + public ResponseEntity getActionStatusList(@PathVariable final String targetId, @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_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @@ -416,8 +415,10 @@ public class TargetResource { final Page statusList = deploymentManagement.findActionStatusMessagesByActionInDescOrder( new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true); - return new ResponseEntity<>(new ActionStatusPagedList(TargetMapper.toActionStatusRestResponse(action, - statusList.getContent()), statusList.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new ActionStatusPagedList(TargetMapper.toActionStatusRestResponse(action, statusList.getContent()), + statusList.getTotalElements()), + HttpStatus.OK); } @@ -436,8 +437,8 @@ public class TargetResource { MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getAssignedDistributionSet(@PathVariable final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); - final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget - .getAssignedDistributionSet()); + final DistributionSetRest distributionSetRest = DistributionSetMapper + .toResponse(findTarget.getAssignedDistributionSet()); final HttpStatus retStatus; if (distributionSetRest == null) { retStatus = HttpStatus.NO_CONTENT; @@ -466,8 +467,8 @@ public class TargetResource { @RequestBody final DistributionSetAssigmentRest dsId) { findTargetWithExceptionIfNotFound(targetId); - final ActionType type = (dsId.getType() != null) ? RestResourceConversionHelper.convertActionType(dsId - .getType()) : ActionType.FORCED; + final ActionType type = (dsId.getType() != null) + ? RestResourceConversionHelper.convertActionType(dsId.getType()) : ActionType.FORCED; final Iterator changed = deploymentManagement .assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedTargets() .iterator(); @@ -496,8 +497,8 @@ public class TargetResource { MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getInstalledDistributionSet(@PathVariable final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); - final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget.getTargetInfo() - .getInstalledDistributionSet()); + final DistributionSetRest distributionSetRest = DistributionSetMapper + .toResponse(findTarget.getTargetInfo().getInstalledDistributionSet()); final HttpStatus retStatus; if (distributionSetRest == null) { retStatus = HttpStatus.NO_CONTENT; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java index c0d5c7c32..ef10efbad 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java @@ -102,8 +102,8 @@ public class TargetTagResource { countTargetsAll = tagManagement.countTargetTags(); } else { - final Page findTargetPage = tagManagement.findAllTargetTags( - RSQLUtility.parse(rsqlParam, TagFields.class), pageable); + final Page findTargetPage = tagManagement + .findAllTargetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable); countTargetsAll = findTargetPage.getTotalElements(); findTargetsAll = findTargetPage; @@ -140,8 +140,8 @@ public class TargetTagResource { * with status code 201 - Created. The Response Body are the created * target tags but without ResponseBody. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createTargetTags(@RequestBody final List tags) { LOG.debug("creating {} target tags", tags.size()); final List createdTargetTags = tagManagement @@ -233,8 +233,8 @@ public class TargetTagResource { LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); final TargetTag targetTag = findTargetTagById(targetTagId); - final TargetTagAssigmentResult assigmentResult = targetManagement.toggleTagAssignment( - findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName()); + final TargetTagAssigmentResult assigmentResult = targetManagement + .toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName()); final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest(); tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedTargets())); @@ -259,8 +259,8 @@ public class TargetTagResource { @RequestBody final List assignedTargetRequestBodies) { LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); final TargetTag targetTag = findTargetTagById(targetTagId); - final List assignedTarget = targetManagement.assignTag( - findTargetControllerIds(assignedTargetRequestBodies), targetTag); + final List assignedTarget = targetManagement + .assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTag); return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK); } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java index 076c03c80..c23c52bc5 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java @@ -147,8 +147,8 @@ public class RSQLUtilityTest { when(baseSoftwareModuleRootMock.get("version")).thenReturn(baseSoftwareModuleRootMock); when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class); when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class)); - when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn( - mock(Predicate.class)); + when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))) + .thenReturn(mock(Predicate.class)); // test RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock, @@ -165,8 +165,8 @@ public class RSQLUtilityTest { when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock); when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class); when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class)); - when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn( - mock(Predicate.class)); + when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))) + .thenReturn(mock(Predicate.class)); // test RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); @@ -183,8 +183,8 @@ public class RSQLUtilityTest { when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock); when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class); when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class)); - when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn( - mock(Predicate.class)); + when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))) + .thenReturn(mock(Predicate.class)); // test RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); @@ -201,10 +201,10 @@ public class RSQLUtilityTest { when(baseSoftwareModuleRootMock.get("name")).thenReturn(baseSoftwareModuleRootMock); when(baseSoftwareModuleRootMock.getJavaType()).thenReturn((Class) SoftwareModule.class); when(criteriaBuilderMock.equal(any(Root.class), anyString())).thenReturn(mock(Predicate.class)); - when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))).thenReturn( - mock(Predicate.class)); - when(criteriaBuilderMock.upper(eq(pathOfString(baseSoftwareModuleRootMock)))).thenReturn( - pathOfString(baseSoftwareModuleRootMock)); + when(criteriaBuilderMock. greaterThanOrEqualTo(any(Expression.class), any(String.class))) + .thenReturn(mock(Predicate.class)); + when(criteriaBuilderMock.upper(eq(pathOfString(baseSoftwareModuleRootMock)))) + .thenReturn(pathOfString(baseSoftwareModuleRootMock)); // test RSQLUtility.parse(correctRsql, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java index b9f690337..ecd980b03 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java @@ -52,8 +52,8 @@ public interface UserAuthenticationFilter { * servlet exception */ - void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, - ServletException; + void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException; /** * @see Filter#destroy() diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java index 967f82121..1c81610e2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java @@ -125,8 +125,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { if (userContext != null && userContext.getAuthentication() != null) { final Object tenantAuthenticationDetails = userContext.getAuthentication().getDetails(); if (tenantAuthenticationDetails instanceof TenantAwareAuthenticationDetails) { - return ((TenantAwareAuthenticationDetails) tenantAuthenticationDetails).getTenant().equalsIgnoreCase( - event.getTenant()); + return ((TenantAwareAuthenticationDetails) tenantAuthenticationDetails).getTenant() + .equalsIgnoreCase(event.getTenant()); } } return false; @@ -176,8 +176,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener { contentVerticalLayout.setStyleName("main-content"); contentVerticalLayout.setExpandRatio(content, 1.0F); setContent(rootLayout); - final Resource resource = context.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() - + "/layouts/footer.html"); + final Resource resource = context + .getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html"); try { final CustomLayout customLayout = new CustomLayout(resource.getInputStream()); customLayout.setSizeUndefined(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java index 1dbf90e65..d0ba20db6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java @@ -125,10 +125,8 @@ public class ArtifactDetailsLayout extends VerticalLayout { ui = UI.getCurrent(); if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) { final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - populateArtifactDetails( - selectedSoftwareModule.getId(), - HawkbitCommonUtil.getFormattedNameVersion(selectedSoftwareModule.getName(), - selectedSoftwareModule.getVersion())); + populateArtifactDetails(selectedSoftwareModule.getId(), HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion())); } if (isMaximized()) { maximizedArtifactDetailsView(); @@ -264,10 +262,10 @@ public class ArtifactDetailsLayout extends VerticalLayout { public Button generateCell(final Table source, final Object itemId, final Object columnId) { final String fileName = (String) table.getContainerDataSource().getItem(itemId) .getItemProperty(PROVIDED_FILE_NAME).getValue(); - final Button deleteIcon = SPUIComponentProvider.getButton(fileName + "-" - + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "", SPUILabelDefinitions.DISCARD, - ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O, - SPUIButtonStyleSmallNoBorder.class); + final Button deleteIcon = SPUIComponentProvider.getButton( + fileName + "-" + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "", + SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true, + FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class); deleteIcon.setData(itemId); deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName)); return deleteIcon; @@ -279,19 +277,17 @@ public class ArtifactDetailsLayout extends VerticalLayout { 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("button.cancel"), - ok -> { + i18n.get("button.cancel"), ok -> { if (ok) { final ArtifactManagement artifactManagement = SpringContextHelper .getBean(ArtifactManagement.class); artifactManagement.deleteLocalArtifact(id); uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName)); if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { - populateArtifactDetails( - artifactUploadState.getSelectedBaseSwModuleId().get(), - HawkbitCommonUtil.getFormattedNameVersion(artifactUploadState - .getSelectedBaseSoftwareModule().get().getName(), artifactUploadState - .getSelectedBaseSoftwareModule().get().getVersion())); + populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(), + HawkbitCommonUtil.getFormattedNameVersion( + artifactUploadState.getSelectedBaseSoftwareModule().get().getName(), + artifactUploadState.getSelectedBaseSoftwareModule().get().getVersion())); } else { populateArtifactDetails(null, null); } @@ -469,8 +465,8 @@ public class ArtifactDetailsLayout extends VerticalLayout { if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE) { ui.access(() -> { if (softwareModuleEvent.getSoftwareModule() != null) { - populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil - .getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), + populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), + HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), softwareModuleEvent.getSoftwareModule().getVersion())); } else { populateArtifactDetails(null, null); @@ -480,8 +476,8 @@ public class ArtifactDetailsLayout extends VerticalLayout { if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) { ui.access(() -> { if (softwareModuleEvent.getSoftwareModule() != null) { - populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil - .getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), + populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), + HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), softwareModuleEvent.getSoftwareModule().getVersion())); } else { populateArtifactDetails(null, null); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java index f101fe7f8..841256da4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java @@ -201,13 +201,13 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { } if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { - final String swModuleTypeName = sourceComponent.getId().replace( - SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); + final String swModuleTypeName = sourceComponent.getId() + .replace(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() .equalsIgnoreCase(swModuleTypeName)) { - notification.displayValidationError(i18n.get("message.swmodule.type.check.delete", - new Object[] { swModuleTypeName })); + notification.displayValidationError( + i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); } else { deleteSWModuleType(swModuleTypeName); updateSWActionCount(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index 9c3c9bdbc..a4f8a8f70 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -100,15 +100,14 @@ public class SoftwareModuleTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final SMFilterEvent filterEvent) { - UI.getCurrent().access( - () -> { + UI.getCurrent().access(() -> { - if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - refreshFilter(); - } - }); + if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { + refreshFilter(); + } + }); } /* @@ -139,8 +138,8 @@ public class SoftwareModuleTable extends AbstractTable { BaseSwModuleBeanQuery.class); swQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, "swId"), swQF); + final LazyQueryContainer container = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); return container; } @@ -207,8 +206,8 @@ public class SoftwareModuleTable extends AbstractTable { final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value); artifactUploadState.setSelectedBaseSoftwareModule(baseSoftwareModule); artifactUploadState.setSelectedSoftwareModules(values); - eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, - baseSoftwareModule)); + eventBus.publish(this, + new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule)); } } else { artifactUploadState.setSelectedBaseSwModuleId(null); @@ -256,10 +255,10 @@ public class SoftwareModuleTable extends AbstractTable { item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor()); item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy()); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) { 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_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)); - 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)); } else { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java index 4ff06d57d..8def18034 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java @@ -211,14 +211,13 @@ public class SoftwareModuleDetailsTable extends Table { private void unassignSW(final ClickEvent event, final DistributionSet distributionSet, final Set alreadyAssignedSwModules) { - final SoftwareModule unAssignedSw = getSoftwareModule( - (Label) getContainerDataSource().getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE) - .getValue(), alreadyAssignedSwModules); + final SoftwareModule unAssignedSw = getSoftwareModule((Label) getContainerDataSource() + .getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE).getValue(), alreadyAssignedSwModules); final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet, unAssignedSw); manageDistUIState.setLastSelectedDistribution(newDistributionSet.getDistributionSetIdName()); - eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, - newDistributionSet)); + eventBus.publish(this, + new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, newDistributionSet)); eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION); uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName())); } @@ -251,8 +250,8 @@ public class SoftwareModuleDetailsTable extends Table { } private Label createMandatoryLabel(final boolean mandatory) { - final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ") : HawkbitCommonUtil - .getFormatedLabel(" "); + final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ") + : HawkbitCommonUtil.getFormatedLabel(" "); if (mandatory) { mandatoryLable.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java index b4fe3767d..ebcd097c3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java @@ -131,8 +131,8 @@ public class DistributionTagToken extends AbstractTagToken { private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) { final Set distributionList = new HashSet(); distributionList.add(selectedDS.getId()); - final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment( - distributionList, tagNameSelected); + final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList, + tagNameSelected); uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n)); return result; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java index 13fd73818..e3d4881f0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java @@ -57,9 +57,9 @@ public class SPUIErrorHandler extends DefaultErrorHandler { } final Component errorOrgin = findAbstractComponent(event); if (null != errorOrgin && errorOrgin.getUI() != null) { - notification - .showNotification(style.toString(), i18n.get("caption.error"), i18n.get("message.error.temp", - new Object[] { exceptionName }), false, errorOrgin.getUI().getPage()); + notification.showNotification(style.toString(), i18n.get("caption.error"), + i18n.get("message.error.temp", new Object[] { exceptionName }), false, + errorOrgin.getUI().getPage()); } } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index fb29975c7..3cd1764e3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -178,19 +178,19 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null); madatoryLabel = getMandatoryLabel(); - typeName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " - + SPUIDefinitions.DIST_SET_TYPE_NAME, true, "", i18n.get("textfield.name"), true, - SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); + typeName = SPUIComponentProvider.getTextField("", + ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_NAME, true, "", + i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); typeName.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME); - typeKey = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " - + SPUIDefinitions.DIST_SET_TYPE_KEY, true, "", i18n.get("textfield.key"), true, - SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); + typeKey = SPUIComponentProvider.getTextField("", + ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_KEY, true, "", i18n.get("textfield.key"), + true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); typeKey.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY); - typeDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " - + SPUIDefinitions.DIST_SET_TYPE_DESC, false, "", i18n.get("textfield.description"), - SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); + typeDesc = SPUIComponentProvider.getTextArea("", + ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC, false, "", + i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); typeDesc.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC); typeDesc.setImmediate(true); @@ -492,12 +492,10 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co Item saveTblitem; saveTblitem = sourceTablecontainer.addItem(selectedId); selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_NAME); - saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue( - selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_NAME) - .getValue()); - saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue( - selectedTable.getContainerDataSource().getItem(selectedId).getItemProperty(DIST_TYPE_DESCRIPTION) - .getValue()); + saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue(selectedTable.getContainerDataSource() + .getItem(selectedId).getItemProperty(DIST_TYPE_NAME).getValue()); + saveTblitem.getItemProperty(DIST_TYPE_DESCRIPTION).setValue(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(); greenSlider.setValue(new Double(greenColorValue)); } catch (final ValueOutOfBoundsException e) { - LOG.error( - "Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + "," - + color.getBlue(), e); + LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + "," + + color.getBlue(), e); } } @@ -621,8 +618,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co private Boolean checkIsDuplicate(final DistributionSetType existingDistType) { if (existingDistType != null) { - uiNotification.displayValidationError(i18n.get("message.tag.duplicate.check", - new Object[] { existingDistType.getName() })); + uiNotification.displayValidationError( + i18n.get("message.tag.duplicate.check", new Object[] { existingDistType.getName() })); return Boolean.TRUE; } return Boolean.FALSE; @@ -630,8 +627,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co private Boolean checkIsDuplicateByKey(final DistributionSetType existingDistType) { if (existingDistType != null) { - uiNotification.displayValidationError(i18n.get("message.type.key.duplicate.check", - new Object[] { existingDistType.getKey() })); + uiNotification.displayValidationError( + i18n.get("message.type.key.duplicate.check", new Object[] { existingDistType.getKey() })); return Boolean.TRUE; } return Boolean.FALSE; @@ -681,7 +678,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co newDistType = distributionSetManagement.createDistributionSetType(newDistType); uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistType.getName() })); closeWindow(); - eventBus.publish(this, new DistributionSetTypeEvent(DistributionSetTypeEnum.ADD_DIST_SET_TYPE, newDistType)); + eventBus.publish(this, + new DistributionSetTypeEvent(DistributionSetTypeEnum.ADD_DIST_SET_TYPE, newDistType)); } else { uiNotification.displayValidationError(i18n.get("message.error.missing.typenameorkey")); @@ -724,11 +722,11 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co } updateDistSetType.setColour(getColorPickedSting()); distributionSetManagement.updateDistributionSetType(updateDistSetType); - uiNotification.displaySuccess(i18n.get("message.update.success", - new Object[] { updateDistSetType.getName() })); + uiNotification + .displaySuccess(i18n.get("message.update.success", new Object[] { updateDistSetType.getName() })); closeWindow(); - eventBus.publish(this, new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, - updateDistSetType)); + eventBus.publish(this, + new DistributionSetTypeEvent(DistributionSetTypeEnum.UPDATE_DIST_SET_TYPE, updateDistSetType)); } else { uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory")); @@ -995,9 +993,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co * @return */ private LazyQueryContainer getDistSetTypeLazyQueryContainer() { - final LazyQueryContainer disttypeContainer = HawkbitCommonUtil - .createLazyQueryContainer(new BeanQueryFactory( - DistributionSetTypeBeanQuery.class)); + final LazyQueryContainer disttypeContainer = HawkbitCommonUtil.createLazyQueryContainer( + new BeanQueryFactory(DistributionSetTypeBeanQuery.class)); disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true); return disttypeContainer; @@ -1049,8 +1046,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co selectedTable.setEnabled(true); saveDistSetType.setEnabled(true); } else { - uiNotification.displayValidationError(selectedTypeTag.getName() + " " - + i18n.get("message.error.dist.set.type.update")); + uiNotification.displayValidationError( + selectedTypeTag.getName() + " " + i18n.get("message.error.dist.set.type.update")); distTypeSelectLayout.setEnabled(false); selectedTable.setEnabled(false); saveDistSetType.setEnabled(false); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java index 5bb38f5f6..c62adba2b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java @@ -154,8 +154,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { private void showUnsavedAssignment() { Item item; final Map> assignedList = manageDistUIState.getAssignedList(); - final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent() ? manageDistUIState - .getLastSelectedDistribution().get().getId() : null; + final Long selectedDistId = manageDistUIState.getLastSelectedDistribution().isPresent() + ? manageDistUIState.getLastSelectedDistribution().get().getId() : null; Set softwareModuleIdNameList = null; for (final Map.Entry> entry : assignedList.entrySet()) { @@ -174,20 +174,18 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { .append(""); } else { - assignedSWModule.put( - softwareModule.getType().getName(), - new StringBuilder() - .append("") - .append(getUnsavedAssigedSwModule(softwareModule.getName(), - softwareModule.getVersion())).append("")); + assignedSWModule.put(softwareModule.getType().getName(), + new StringBuilder().append("").append( + getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion())) + .append("")); } } for (final Map.Entry entry : assignedSWModule.entrySet()) { item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey()); if (item != null) { - item.getItemProperty(SOFT_MODULE).setValue( - HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); + item.getItemProperty(SOFT_MODULE) + .setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); assignSoftModuleButton(item, entry); } @@ -200,10 +198,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { * @param entry */ private void assignSoftModuleButton(final Item item, final Map.Entry entry) { - if (permissionChecker.hasUpdateDistributionPermission() - && distributionSetManagement - .findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId()) - .getAssignedTargets().isEmpty()) { + if (permissionChecker.hasUpdateDistributionPermission() && distributionSetManagement + .findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId()) + .getAssignedTargets().isEmpty()) { final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); reassignSoftModule.setEnabled(false); @@ -237,25 +234,20 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { * same type is dropped, then override with previous one. */ if (module.getType().getMaxAssignments() == 1) { - assignedSWModule.put( - module.getType().getName(), - new StringBuilder().append("") - .append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())) - .append("")); + assignedSWModule.put(module.getType().getName(), new StringBuilder().append("") + .append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("")); } } else { - assignedSWModule.put( - module.getType().getName(), - new StringBuilder().append("") - .append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("")); + assignedSWModule.put(module.getType().getName(), new StringBuilder().append("") + .append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append("")); } for (final Map.Entry entry : assignedSWModule.entrySet()) { final Item item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey()); if (item != null) { - item.getItemProperty(SOFT_MODULE).setValue( - HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); + item.getItemProperty(SOFT_MODULE) + .setValue(HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); assignSoftModuleButton(item, entry); } @@ -313,9 +305,9 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { } if (isMigrationRequired != null) { - detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel( - i18n.get("checkbox.dist.migration.required"), - isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no"))); + detailsTabLayout.addComponent( + SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"), + 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) void onEvent(final DistributionTableEvent distributionTableEvent) { if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE - || distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) { + || distributionTableEvent + .getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) { assignedSWModule.clear(); ui.access(() -> { /** @@ -474,8 +467,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { .getDistributionSetIdName(); if (distIdName.getId().equals(selectedDsModule.getId()) && distIdName.getName().equals(selectedDsModule.getName())) { - selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule - .getId()); + selectedDsModule = distributionSetManagement + .findDistributionSetByIdWithDetails(selectedDsModule.getId()); populteModule(selectedDsModule); } }); @@ -484,7 +477,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { @EventBusListenerMethod(scope = EventScope.SESSION) 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) { assignedSWModule.clear(); selectedDsModule = distributionSetManagement.findDistributionSetByIdWithDetails(selectedDsModule.getId()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index 519c8f244..107ed0299 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -162,15 +162,16 @@ public class DistributionSetTable extends AbstractTable { .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value)); if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) { - queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, manageDistUIState - .getManageDistFilters().getClickedDistSetType()); + queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, + manageDistUIState.getManageDistFilters().getClickedDistSetType()); } final BeanQueryFactory distributionQF = new BeanQueryFactory( ManageDistBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer distContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); + final LazyQueryContainer distContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), + distributionQF); return distContainer; } @@ -254,8 +255,8 @@ public class DistributionSetTable extends AbstractTable { final DistributionSet lastSelectedDistSet = distributionSetManagement .findDistributionSetByIdWithDetails(value.getId()); - eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, - lastSelectedDistSet)); + eventBus.publish(this, + new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet)); } } else { manageDistUIState.setSelectedDistributions(null); @@ -394,8 +395,8 @@ public class DistributionSetTable extends AbstractTable { private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) { if (manageDistUIState.getLastSelectedDistribution().isPresent() && manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) { - eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, - softwareModule)); + eventBus.publish(this, + new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule)); } } @@ -404,8 +405,8 @@ public class DistributionSetTable extends AbstractTable { * @param softwareModule * @param softwareModuleIdName */ - private void handleFirmwareCase(final Map> map, - final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) { + private void handleFirmwareCase(final Map> map, final SoftwareModule softwareModule, + final SoftwareModuleIdName softwareModuleIdName) { if (softwareModule.getType().getMaxAssignments() == 1) { if (!map.containsKey(softwareModule.getType().getId())) { map.put(softwareModule.getType().getId(), new HashSet()); @@ -422,8 +423,8 @@ public class DistributionSetTable extends AbstractTable { * @param softwareModule * @param softwareModuleIdName */ - private void handleSoftwareCase(final Map> map, - final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) { + private void handleSoftwareCase(final Map> map, final SoftwareModule softwareModule, + final SoftwareModuleIdName softwareModuleIdName) { if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) { if (!map.containsKey(softwareModule.getType().getId())) { map.put(softwareModule.getType().getId(), new HashSet()); @@ -547,14 +548,14 @@ public class DistributionSetTable extends AbstractTable { item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(distributionSet.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(distributionSet.getDescription()); item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(distributionSet.getVersion()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue( - HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue( - HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY) + .setValue(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) + .setValue(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(distributionSet.isComplete()); if (manageDistUIState.getSelectedDistributions().isPresent()) { manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId)); @@ -569,8 +570,8 @@ public class DistributionSetTable extends AbstractTable { if (propertyId == null) { // Styling for row final Item item = getItem(itemId); - final Boolean isComplete = (Boolean) item.getItemProperty( - SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue(); + final Boolean isComplete = (Boolean) item + .getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue(); if (!isComplete) { return SPUIDefinitions.DISABLE_DISTRIBUTION; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java index f8a8c4cb4..dbb1be48c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java @@ -61,9 +61,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { private static final long serialVersionUID = 3494052985006132714L; - private static final List DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(Arrays.asList( - DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG, - DragEvent.SOFTWAREMODULE_TYPE_DRAG)); + private static final List DISPLAY_DROP_HINT_EVENTS = new ArrayList<>( + Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG, + DragEvent.SOFTWAREMODULE_TYPE_DRAG)); @Autowired private I18N i18n; @@ -236,8 +236,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId, SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS); if (isDsTypeSelected(distTypeName)) { - notification.displayValidationError(i18n.get("message.dist.type.check.delete", - new Object[] { distTypeName })); + notification + .displayValidationError(i18n.get("message.dist.type.check.delete", new Object[] { distTypeName })); } else if (isDefaultDsType(distTypeName)) { notification.displayValidationError(i18n.get("message.cannot.delete.default.dstype")); } else { @@ -253,9 +253,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { * @return true if ds type is selected */ private boolean isDsTypeSelected(final String distTypeName) { - return null != manageDistUIState.getManageDistFilters().getClickedDistSetType() - && manageDistUIState.getManageDistFilters().getClickedDistSetType().getName() - .equalsIgnoreCase(distTypeName); + return null != manageDistUIState.getManageDistFilters().getClickedDistSetType() && manageDistUIState + .getManageDistFilters().getClickedDistSetType().getName().equalsIgnoreCase(distTypeName); } private void processDeleteSWType(final String swTypeId) { @@ -265,8 +264,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() .equalsIgnoreCase(swModuleTypeName)) { - notification.displayValidationError(i18n.get("message.swmodule.type.check.delete", - new Object[] { swModuleTypeName })); + notification.displayValidationError( + i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); } else { manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName); updateDSActionCount(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index fca9d8392..17ee9b8af 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -119,16 +119,15 @@ public class SwModuleTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final SMFilterEvent filterEvent) { - UI.getCurrent().access( - () -> { + UI.getCurrent().access(() -> { - if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - refreshFilter(); - styleTableOnDistSelection(); - } - }); + if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { + refreshFilter(); + styleTableOnDistSelection(); + } + }); } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -192,8 +191,8 @@ public class SwModuleTable extends AbstractTable { SwModuleBeanQuery.class); swQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, "swId"), swQF); + final LazyQueryContainer container = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); 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_LAST_MODIFIED_BY, String.class, null, false, true); lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, true); - lazyContainer - .addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); + lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, 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); } @@ -291,8 +290,8 @@ public class SwModuleTable extends AbstractTable { manageDistUIState.setSelectedBaseSwModuleId(value); final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value); manageDistUIState.setSelectedSoftwareModules(values); - eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, - baseSoftwareModule)); + eventBus.publish(this, + new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule)); } } else { 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_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)); - 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)); } else { 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) { final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript(); - UI.getCurrent().access( - () -> javaScript.execute(HawkbitCommonUtil - .getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId + UI.getCurrent() + .access(() -> javaScript.execute( + HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId + "{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_CREATED_BY).setValue(swModule.getCreatedBy()); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(swModule.getType().getColour()); if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java index 967ceee1c..6ac11b833 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java @@ -343,9 +343,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } private void enableDisableSaveButton(final boolean validationFailed, final String query) { - if (validationFailed - || (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField - .getValue().equals(oldFilterName)))) { + if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query) + || (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) { saveButton.setEnabled(false); } else { if (hasSavePermission()) { @@ -444,8 +443,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button targetFilterQuery.setName(nameTextField.getValue()); targetFilterQuery.setQuery(queryTextField.getValue()); targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery); - notification.displaySuccess(i18n.get("message.create.filter.success", - new Object[] { targetFilterQuery.getName() })); + notification.displaySuccess( + i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() })); eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index 8538014d5..c122b19ac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -100,8 +100,8 @@ public class CreateOrUpdateFilterTable extends Table { if (filterManagementUIState.isCreateFilterViewDisplayed()) { filterManagementUIState.setFilterQueryValue(null); } else { - filterManagementUIState.getTfQuery().ifPresent( - value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); + filterManagementUIState.getTfQuery() + .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); } } @@ -117,8 +117,9 @@ public class CreateOrUpdateFilterTable extends Table { targetQF.setQueryConfiguration(queryConfig); // create lazy query container with lazy defination and query - final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF); + final LazyQueryContainer targetTableContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), + targetQF); targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); return targetTableContainer; @@ -178,12 +179,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_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_DATE, i18n.get("header.modifiedDate"), - 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n - .get("header.assigned.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n - .get("header.installed.ds"), 0.125F)); + columnList.add( + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, + i18n.get("header.assigned.ds"), 0.125F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + 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.STATUS_ICON, i18n.get("header.target.status"), 0.1F)); return columnList; @@ -191,8 +192,8 @@ public class CreateOrUpdateFilterTable extends Table { private Component getStatusIcon(final Object itemId) { final Item row1 = getItem(itemId); - final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty( - SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); + final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 + .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); label.setContentMode(ContentMode.HTML); if (targetStatus == TargetUpdateStatus.PENDING) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java index b5ada7f30..6cc44ce9f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java @@ -99,11 +99,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery { Slice targetBeans; final List proxyTargetBeans = new ArrayList<>(); if (!Strings.isNullOrEmpty(filterQuery)) { - targetBeans = targetManagement.findTargetsAll(filterQuery, new PageRequest(startIndex - / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); + targetBeans = targetManagement.findTargetsAll(filterQuery, + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); } else { - targetBeans = targetManagement.findTargetsAll(new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, - SPUIDefinitions.PAGE_SIZE, sort)); + targetBeans = targetManagement.findTargetsAll( + new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); } for (final Target targ : targetBeans) { @@ -135,8 +135,8 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery { prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); prxyTarget.setTargetInfo(targ.getTargetInfo()); - prxyTarget.setPollStatusToolTip(HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo() - .getPollStatus(), getI18N())); + prxyTarget.setPollStatusToolTip( + HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); proxyTargetBeans.add(prxyTarget); } return proxyTargetBeans; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java index 9a17c6e12..385cb9be1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java @@ -106,8 +106,8 @@ public final class FilterQueryValidation { public static List processExpectedTokens(final List expectedTokens) { final List expectToken = new ArrayList<>(); if (expectedTokens.size() == 2 && expectedTokens.contains(9) && expectedTokens.contains(4)) { - final List expectedFieldList = Arrays.stream(TargetFields.values()) - .map(v -> v.name().toLowerCase()).collect(Collectors.toList()); + final List expectedFieldList = Arrays.stream(TargetFields.values()).map(v -> v.name().toLowerCase()) + .collect(Collectors.toList()); expectToken.addAll(expectedFieldList); expectToken.add("assignedds.name"); expectToken.add("assignedds.version"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java index 6cc76da82..023400139 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java @@ -112,11 +112,11 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery @Override public int size() { if (Strings.isNullOrEmpty(searchText)) { - firstPageTargetFilter = getTargetFilterQueryManagement().findAllTargetFilterQuery( - new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); + firstPageTargetFilter = getTargetFilterQueryManagement() + .findAllTargetFilterQuery(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); } else { - firstPageTargetFilter = getTargetFilterQueryManagement().findTargetFilterQueryByFilters( - new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), searchText); + firstPageTargetFilter = getTargetFilterQueryManagement() + .findTargetFilterQueryByFilters(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), searchText); } final long size = firstPageTargetFilter.getTotalElements(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java index 2a709271d..765ce13a2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java @@ -103,15 +103,14 @@ public class TargetFilterTable extends Table { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final CustomFilterUIEvent filterEvent) { - UI.getCurrent().access( - () -> { - if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT - || filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE - || filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY - || filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) { - refreshContainer(); - } - }); + UI.getCurrent().access(() -> { + if (filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT + || filterEvent == CustomFilterUIEvent.FILTER_BY_CUST_FILTER_TEXT_REMOVE + || filterEvent == CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY + || filterEvent == CustomFilterUIEvent.UPDATED_TARGET_FILTER_QUERY) { + refreshContainer(); + } + }); } /** @@ -126,8 +125,8 @@ public class TargetFilterTable extends Table { targetQF.setQueryConfiguration(queryConfig); // create lazy query container with lazy defination and query - final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF); + final LazyQueryContainer targetFilterContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF); targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); return targetFilterContainer; @@ -136,8 +135,8 @@ public class TargetFilterTable extends Table { private Map prepareQueryConfigFilters() { final Map queryConfig = new HashMap(); - filterManagementUIState.getCustomFilterSearchText().ifPresent( - value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + filterManagementUIState.getCustomFilterSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); return queryConfig; } @@ -206,8 +205,8 @@ public class TargetFilterTable extends Table { * of the deleted custom filter. */ - notification.displaySuccess(i18n.get("message.delete.filter.success", - new Object[] { deletedFilterName })); + notification.displaySuccess( + i18n.get("message.delete.filter.success", new Object[] { deletedFilterName })); refreshContainer(); } }); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java index b43e2c1b3..9beeff56a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java @@ -201,14 +201,16 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware private void buildPasswordField() { password = new PasswordField(i18n.get("label.login.password")); 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"); } private void buildUserField() { username = new TextField(i18n.get("label.login.username")); 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"); } @@ -216,8 +218,8 @@ public class LoginView extends VerticalLayout implements View, EnvironmentAware if (multiTenancyIndicator.isMultiTenancySupported()) { tenant = new TextField(i18n.get("label.login.tenant")); tenant.setIcon(FontAwesome.DATABASE); - tenant.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " - + LOGIN_TEXTFIELD); + tenant.addStyleName( + ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD); tenant.addStyleName("uppercase"); tenant.setId("login-tenant"); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java index 78f1a0530..9069858aa 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java @@ -110,7 +110,8 @@ public class DeploymentView extends VerticalLayout implements View, BrowserWindo void onEvent(final DistributionTableEvent event) { if (event.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MINIMIZED) { minimizeDistTable(); - } else if (event.getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MAXIMIZED) { + } else if (event + .getDistributionComponentEvent() == DistributionTableEvent.DistributionComponentEvent.MAXIMIZED) { maximizeDistTable(); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index b7eb7d708..bcfc6de4a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -190,8 +190,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { saveDistribution.addClickListener(event -> saveDistribution()); /* close button */ - discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", - true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true, + FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); discardDistribution.addClickListener(event -> discardDistribution()); } @@ -206,8 +206,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { DistributionSetTypeBeanQuery.class); dtQF.setQueryConfiguration(queryConfig); - final LazyQueryContainer disttypeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF); + final LazyQueryContainer disttypeContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF); disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true); @@ -219,8 +219,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { } private DistributionSetType getDefaultDistributionSetType() { - final TenantMetaData tenantMetaData = tenantMetaDataRepository.findByTenantIgnoreCase(systemManagement - .currentTenant()); + final TenantMetaData tenantMetaData = tenantMetaDataRepository + .findByTenantIgnoreCase(systemManagement.currentTenant()); return tenantMetaData.getDefaultDsType(); } @@ -259,12 +259,12 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success", new Object[] { currentDS.getName(), currentDS.getVersion() })); // update table row+details layout - eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, - currentDS)); + eventBus.publish(this, + new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, currentDS)); } catch (final EntityAlreadyExistsException entityAlreadyExistsException) { LOG.error("Update distribution failed {}", entityAlreadyExistsException); - notificationMessage.displayValidationError(i18n.get("message.distribution.no.update", - currentDS.getName() + ":" + currentDS.getVersion())); + notificationMessage.displayValidationError( + i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion())); } closeThisWindow(); } @@ -361,8 +361,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { if (existingDs != null && (!editDistribution || editDistribution && !existingDs.getId().equals(editDistId))) { distNameTextField.addStyleName("v-textfield-error"); distVersionTextField.addStyleName("v-textfield-error"); - notificationMessage.displayValidationError(i18n.get("message.duplicate.dist", - new Object[] { existingDs.getName(), existingDs.getVersion() })); + notificationMessage.displayValidationError( + i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() })); return false; } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java index 522f111c1..fa7130d23 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java @@ -84,7 +84,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort 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 pinnedControllerId); } else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) { // if no search filters available - distBeans = getDistributionSetManagement().findDistributionSetsAll( - new OffsetBasedPageRequest(startIndex, count, sort), false, true); + distBeans = getDistributionSetManagement() + .findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, true); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) @@ -134,8 +135,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); - proxyDistribution.setNameVersion(HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), - distributionSet.getVersion())); + proxyDistribution.setNameVersion( + HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); proxyDistributions.add(proxyDistribution); } return proxyDistributions; @@ -154,8 +155,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery pinnedControllerId); } else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) { // if no search filters available - firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsAll( - new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true); + firstPageDistributionSets = getDistributionSetManagement() + .findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java index 487282f75..54d549055 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java @@ -95,7 +95,8 @@ public class DistributionDetails extends AbstractTableDetailsLayout { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final DistributionTableEvent distributionTableEvent) { if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE - || distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) { + || distributionTableEvent + .getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) { ui.access(() -> { /** * distributionTableEvent.getDistributionSet() is null when @@ -175,8 +176,8 @@ public class DistributionDetails extends AbstractTableDetailsLayout { */ @Override protected Boolean onLoadIsTableRowSelected() { - return !(managementUIState.getSelectedDsIdName().isPresent() && managementUIState.getSelectedDsIdName().get() - .isEmpty()); + return !(managementUIState.getSelectedDsIdName().isPresent() + && managementUIState.getSelectedDsIdName().get().isEmpty()); } /* @@ -289,9 +290,9 @@ public class DistributionDetails extends AbstractTableDetailsLayout { } if (isMigrationRequired != null) { - detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel( - i18n.get("checkbox.dist.migration.required"), - isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no"))); + detailsTabLayout.addComponent( + SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"), + isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no"))); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index 588c61f75..225407b84 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -191,13 +191,12 @@ public class DistributionTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final ManagementUIEvent managementUIEvent) { - UI.getCurrent().access( - () -> { - if (managementUIEvent == ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG - || managementUIEvent == ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG) { - refreshFilter(); - } - }); + UI.getCurrent().access(() -> { + if (managementUIEvent == ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG + || managementUIEvent == ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG) { + refreshFilter(); + } + }); } /* @@ -226,8 +225,8 @@ public class DistributionTable extends AbstractTable { managementUIState.getDistributionTableFilters().getPinnedTargetId() .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value)); final List list = new ArrayList(); - queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getDistributionTableFilters() - .isNoTagSelected()); + queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, + managementUIState.getDistributionTableFilters().isNoTagSelected()); if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) { list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags()); } @@ -235,8 +234,9 @@ public class DistributionTable extends AbstractTable { final BeanQueryFactory distributionQF = new BeanQueryFactory( DistributionBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer distributionContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); + final LazyQueryContainer distributionContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), + distributionQF); return distributionContainer; } @@ -321,8 +321,8 @@ public class DistributionTable extends AbstractTable { managementUIState.setLastSelectedDsIdName(value); final DistributionSet lastSelectedDistSet = distributionSetManagement .findDistributionSetByIdWithDetails(value.getId()); - eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, - lastSelectedDistSet)); + eventBus.publish(this, + new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet)); } } else { managementUIState.setSelectedDsIdName(null); @@ -422,15 +422,15 @@ public class DistributionTable extends AbstractTable { private void assignTargetTag(final DragAndDropEvent event) { final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object distItemId = dropData.getItemIdOver(); - final String targetTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent() - .getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); + final String targetTagName = HawkbitCommonUtil.removePrefix( + event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); // get all the targets assigned to the tag // assign dist to those targets final List assignedTargets = targetService.findTargetsByTag(targetTagName); if (!assignedTargets.isEmpty()) { final Set targetDetailsList = new HashSet(); - assignedTargets.forEach(target -> targetDetailsList.add(new TargetIdName(target.getId(), target - .getControllerId(), target.getName()))); + assignedTargets.forEach(target -> targetDetailsList + .add(new TargetIdName(target.getId(), target.getControllerId(), target.getName()))); assignTargetToDs(getItem(distItemId), targetDetailsList); } else { 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 String distName = (String) item.getItemProperty("name").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)); } } @@ -513,8 +514,8 @@ public class DistributionTable extends AbstractTable { private Boolean isNoTagButton(final String tagData, final String targetNoTagData) { if (tagData.equals(targetNoTagData)) { - notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", - new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError( + i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); return true; } return false; @@ -529,7 +530,8 @@ public class DistributionTable extends AbstractTable { * @param distName * @return String as indicator */ - private String validate(final Set targetDetailsList, final DistributionSetIdName distributionSetIdName) { + private String validate(final Set targetDetailsList, + final DistributionSetIdName distributionSetIdName) { String pendingActionMessage = null; for (final TargetIdName trgtNameId : targetDetailsList) { if (null != trgtNameId) { @@ -581,18 +583,18 @@ public class DistributionTable extends AbstractTable { } private void updateDistributionInTable(final DistributionSet editedDs) { - final Item item = getContainerDataSource().getItem( - new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion())); + final Item item = getContainerDataSource() + .getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion())); item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(editedDs.getName()); item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(editedDs.getVersion()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue( - HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue( - HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY) + .setValue(HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) + .setValue(HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(editedDs.getDescription()); } @@ -609,8 +611,8 @@ public class DistributionTable extends AbstractTable { } private void styleDistributionTableOnPinning() { - final Target targetObj = targetService.findTargetByControllerIDWithDetails(managementUIState - .getDistributionTableFilters().getPinnedTargetId().get()); + final Target targetObj = targetService.findTargetByControllerIDWithDetails( + managementUIState.getDistributionTableFilters().getPinnedTargetId().get()); if (targetObj != null) { final DistributionSet assignedDistribution = targetObj.getAssignedDistributionSet(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java index f711ac7cd..210509623 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java @@ -280,8 +280,8 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo private Boolean checkIsDuplicate(final DistributionSetTag existingDistTag) { if (existingDistTag != null) { - uiNotification.displayValidationError(i18n.get("message.tag.duplicate.check", - new Object[] { existingDistTag.getName() })); + uiNotification.displayValidationError( + i18n.get("message.tag.duplicate.check", new Object[] { existingDistTag.getName() })); return Boolean.TRUE; } return Boolean.FALSE; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java index 133264a68..1df06e603 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java @@ -56,8 +56,8 @@ public class DistributionTagBeanQuery extends AbstractBeanQuery { @Override public int size() { - firstPageDsTag = getTagManagement().findAllDistributionSetTags( - new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); + firstPageDsTag = getTagManagement() + .findAllDistributionSetTags(new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); long size = firstPageDsTag.getTotalElements(); if (size > Integer.MAX_VALUE) { size = Integer.MAX_VALUE; @@ -79,8 +79,8 @@ public class DistributionTagBeanQuery extends AbstractBeanQuery { if (startIndex == 0 && firstPageDsTag != null) { dsTagBeans = firstPageDsTag; } else { - dsTagBeans = getTagManagement().findAllDistributionSetTags( - new OffsetBasedPageRequest(startIndex, count, sort)); + dsTagBeans = getTagManagement() + .findAllDistributionSetTags(new OffsetBasedPageRequest(startIndex, count, sort)); } for (final DistributionSetTag tag : dsTagBeans) { final ProxyTag proxyTargetTag = new ProxyTag(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java index e4680a0c8..9866ba577 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java @@ -131,9 +131,8 @@ public class DistributionTagButtons extends AbstractFilterButtons { final BeanQueryFactory tagQF = new BeanQueryFactory( DistributionTagBeanQuery.class); tagQF.setQueryConfiguration(queryConfig); - final LazyQueryContainer tagContainer = HawkbitCommonUtil - .createDSLazyQueryContainer(new BeanQueryFactory( - DistributionTagBeanQuery.class)); + final LazyQueryContainer tagContainer = HawkbitCommonUtil.createDSLazyQueryContainer( + new BeanQueryFactory(DistributionTagBeanQuery.class)); return tagContainer; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java index 3f05f14c1..6370a9883 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java @@ -90,8 +90,8 @@ public class DistributionTagDropEvent implements DropHandler { private Boolean isNoTagAssigned(final DragAndDropEvent event) { final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString(); if (tagName.equals(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON)) { - notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", - new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError( + i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); return false; } return true; @@ -176,8 +176,8 @@ public class DistributionTagDropEvent implements DropHandler { SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); final List tagsClickedList = distFilterParameters.getDistSetTags(); - final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment( - distributionList, distTagName); + final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList, + distTagName); notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n)); if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java index 574457c6b..7ff9f53e4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java @@ -151,12 +151,13 @@ public class CountMessageLabel extends Label { filterMesgBuf.append(getStatusMsg(targFilParams.getClickedStatusTargetTags(), status)); filterMesgBuf .append(getTagsMsg(targFilParams.isNoTagSelected(), targFilParams.getClickedTargetTags(), tags)); - filterMesgBuf.append(getSerachMsg(targFilParams.getSearchText().isPresent() ? targFilParams.getSearchText() - .get() : null, text)); - filterMesgBuf.append(getDistMsg(targFilParams.getDistributionSet().isPresent() ? targFilParams - .getDistributionSet().get() : null, dists)); - filterMesgBuf.append(getCustomFilterMsg(targFilParams.getTargetFilterQuery().isPresent() ? targFilParams - .getTargetFilterQuery().get() : null, custom)); + filterMesgBuf.append(getSerachMsg( + targFilParams.getSearchText().isPresent() ? targFilParams.getSearchText().get() : null, text)); + filterMesgBuf.append(getDistMsg( + targFilParams.getDistributionSet().isPresent() ? targFilParams.getDistributionSet().get() : null, + dists)); + filterMesgBuf.append(getCustomFilterMsg(targFilParams.getTargetFilterQuery().isPresent() + ? targFilParams.getTargetFilterQuery().get() : null, custom)); final String filterMesageChk = filterMesgBuf.toString().trim(); String filterMesage = filterMesageChk; if (filterMesage.endsWith(",")) { @@ -237,8 +238,8 @@ public class CountMessageLabel extends Label { * @return String as msg. */ private static String getTagsMsg(final Boolean noTargetTagSelected, final List tags, final String param) { - return tags.isEmpty() && (noTargetTagSelected == null || !noTargetTagSelected.booleanValue()) ? HawkbitCommonUtil.SP_STRING_SPACE - : param; + return tags.isEmpty() && (noTargetTagSelected == null || !noTargetTagSelected.booleanValue()) + ? HawkbitCommonUtil.SP_STRING_SPACE : param; } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java index 9473ea783..ec35463d7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java @@ -160,9 +160,9 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { void onEvent(final TargetTableEvent event) { if (!managementUIState.isTargetTableMaximized()) { if (TargetComponentEvent.BULK_TARGET_CREATED == event.getTargetComponentEvent()) { - this.getUI().access( - () -> setUploadStatusButtonCaption(managementUIState.getTargetTableFilters().getBulkUpload() - .getFailedUploadCount() + this.getUI() + .access(() -> setUploadStatusButtonCaption(managementUIState.getTargetTableFilters() + .getBulkUpload().getFailedUploadCount() + managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount())); } else if (TargetComponentEvent.BULK_UPLOAD_COMPLETED == event.getTargetComponentEvent()) { this.getUI().access(() -> updateUploadBtnIconToComplete()); @@ -581,7 +581,8 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { if (failedCount != 0 || successCount != 0) { setUploadStatusButtonCaption(failedCount + successCount); enableBulkUploadStatusButton(); - if (Math.abs(managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue() - 1) < 0.00001) { + if (Math.abs(managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue() + - 1) < 0.00001) { updateUploadBtnIconToComplete(); } else { updateUploadBtnIconToProgressIndicator(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java index b3fd122fa..8f91bf336 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java @@ -155,20 +155,18 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin assignmnetTab.getTable().setContainerDataSource(getAssignmentsTableContainer()); // Add the discard action column - assignmnetTab.getTable().addGeneratedColumn( - DISCARD_CHANGES, - (source, itemId, columnId) -> { - final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY); - style.append(' '); - style.append(SPUIStyleDefinitions.REDICON); - final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, - style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class); - deleteIcon.setData(itemId); - deleteIcon.setImmediate(true); - deleteIcon.addClickListener(event -> discardAssignment( - (TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab)); - return deleteIcon; - }); + assignmnetTab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> { + final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY); + style.append(' '); + style.append(SPUIStyleDefinitions.REDICON); + final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, + style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class); + deleteIcon.setData(itemId); + deleteIcon.setImmediate(true); + deleteIcon.addClickListener(event -> discardAssignment( + (TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab)); + return deleteIcon; + }); // set the visible columns final List visibleColumnIds = new ArrayList<>(); @@ -203,8 +201,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin final ActionType actionType = ((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout .getActionTypeOptionGroup().getValue()).getActionType(); final long forcedTimeStamp = (((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout - .getActionTypeOptionGroup().getValue()) == ActionTypeOption.AUTO_FORCED) ? actionTypeOptionGroupLayout - .getForcedTimeDateField().getValue().getTime() : Action.NO_FORCE_TIME; + .getActionTypeOptionGroup().getValue()) == ActionTypeOption.AUTO_FORCED) + ? actionTypeOptionGroupLayout.getForcedTimeDateField().getValue().getTime() + : Action.NO_FORCE_TIME; final Map> saveAssignedList = new HashMap>(); @@ -320,9 +319,8 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin saveTblitem.getItemProperty(TARGET_NAME).setValue(entry.getKey().getName()); - saveTblitem.getItemProperty(DISTRIBUTION_NAME).setValue( - HawkbitCommonUtil.getDistributionNameAndVersion(entry.getValue().getName(), entry.getValue() - .getVersion())); + saveTblitem.getItemProperty(DISTRIBUTION_NAME).setValue(HawkbitCommonUtil + .getDistributionNameAndVersion(entry.getValue().getName(), entry.getValue().getVersion())); saveTblitem.getItemProperty(TARGET_ID).setValue(entry.getKey().getControllerId()); saveTblitem.getItemProperty(DIST_ID).setValue(entry.getValue().getId()); @@ -346,18 +344,16 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin tab.getTable().setContainerDataSource(getTargetModuleTableContainer()); /* Add the discard action column */ - tab.getTable().addGeneratedColumn( - DISCARD_CHANGES, - (source, itemId, columnId) -> { - final Button deletestargetIcon = SPUIComponentProvider.getButton("", "", - SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, - true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class); - deletestargetIcon.setData(itemId); - deletestargetIcon.setImmediate(true); - deletestargetIcon.addClickListener(event -> discardTargetDelete( - (TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); - return deletestargetIcon; - }); + tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> { + final Button deletestargetIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, + ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY, + SPUIButtonStyleSmallNoBorder.class); + deletestargetIcon.setData(itemId); + deletestargetIcon.setImmediate(true); + deletestargetIcon.addClickListener(event -> discardTargetDelete( + (TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); + return deletestargetIcon; + }); /* set the visible columns */ final List visibleColumnIds = new ArrayList<>(); @@ -393,18 +389,16 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin tab.getTable().setContainerDataSource(getDSModuleTableContainer()); /* Add the discard action column */ - tab.getTable().addGeneratedColumn( - DISCARD_CHANGES, - (source, itemId, columnId) -> { - final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, - ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY, - SPUIButtonStyleSmallNoBorder.class); - deletesDsIcon.setData(itemId); - deletesDsIcon.setImmediate(true); - deletesDsIcon.addClickListener(event -> discardDSDelete( - (DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); - return deletesDsIcon; - }); + tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> { + final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, + ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY, + SPUIButtonStyleSmallNoBorder.class); + deletesDsIcon.setData(itemId); + deletesDsIcon.setImmediate(true); + deletesDsIcon.addClickListener(event -> discardDSDelete( + (DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); + return deletesDsIcon; + }); /* set the visible columns */ final List visibleColumnIds = new ArrayList<>(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java index b360757cb..d253859b1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java @@ -288,15 +288,16 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTagNw)) { if (null != tagNameComboBox.getValue()) { - final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue() - .toString()); + final TargetTag targetTagSelected = tagManagement + .findTargetTag(tagNameComboBox.getValue().toString()); if (null != targetTagSelected) { - selectedColor = targetTagSelected.getColour() != null ? rgbToColorConverter(targetTagSelected - .getColour()) : rgbToColorConverter(DEFAULT_COLOR); + selectedColor = targetTagSelected.getColour() != null + ? rgbToColorConverter(targetTagSelected.getColour()) + : rgbToColorConverter(DEFAULT_COLOR); } else { - final DistributionSetTag distTag = tagManagement.findDistributionSetTag(tagNameComboBox - .getValue().toString()); + final DistributionSetTag distTag = tagManagement + .findDistributionSetTag(tagNameComboBox.getValue().toString()); selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour()) : rgbToColorConverter(DEFAULT_COLOR); } @@ -470,9 +471,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C final double greenColorValue = color.getGreen(); greenSlider.setValue(new Double(greenColorValue)); } catch (final ValueOutOfBoundsException e) { - LOG.error( - "Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + "," - + color.getBlue(), e); + LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + "," + + color.getBlue(), e); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java index 171bede01..29db56009 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java @@ -23,9 +23,9 @@ import com.vaadin.ui.components.colorpicker.ColorPickerPreview; * * * - * Tag ColorPicker Preview field CssLayout cannot be removed because of - * the deep inheritance issue, since protected method fireEvent() of the - * superclass of CssLayout is used in textChange() overridden method + * Tag ColorPicker Preview field CssLayout cannot be removed because of the deep + * inheritance issue, since protected method fireEvent() of the superclass of + * CssLayout is used in textChange() overridden method * * */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java index be026f1bb..8ba60ec51 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java @@ -66,8 +66,8 @@ import com.vaadin.ui.Upload.SucceededListener; * * */ -public class BulkUploadHandler extends CustomComponent implements SucceededListener, FailedListener, Receiver, - StartedListener { +public class BulkUploadHandler extends CustomComponent + implements SucceededListener, FailedListener, Receiver, StartedListener { /** * * @@ -215,8 +215,8 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe try { LOG.info("Bulk file upload started"); final double totalFileSize = getTotalNumberOfLines(); - reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile), - Charset.defaultCharset())); + reader = new BufferedReader( + new InputStreamReader(new FileInputStream(tempFile), Charset.defaultCharset())); /** * Once control is in upload succeeded method automatically * upload button is re-enabled. To disable the button firing @@ -431,8 +431,9 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe if (tagManagement.findTargetTagById(tagData.getId()) == null) { deletedTags.add(tagData.getName()); } else { - targetManagement.toggleTagAssignment(managementUIState.getTargetTableFilters().getBulkUpload() - .getTargetsCreated(), tagData.getName()); + targetManagement.toggleTagAssignment( + managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated(), + tagData.getName()); } } if (!deletedTags.isEmpty()) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index 226b0c27c..be98ef3bc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -151,8 +151,8 @@ public class TargetBeanQuery extends AbstractBeanQuery { prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); prxyTarget.setTargetInfo(targ.getTargetInfo()); - prxyTarget.setPollStatusToolTip(HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo() - .getPollStatus(), getI18N())); + prxyTarget.setPollStatusToolTip( + HawkbitCommonUtil.getPollStatusToolTip(prxyTarget.getTargetInfo().getPollStatus(), getI18N())); proxyTargetBeans.add(prxyTarget); } return proxyTargetBeans; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java index abf552cb0..72174a0c5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java @@ -242,8 +242,8 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent { final Map queryConfiguration = new HashMap<>(); final List list = new ArrayList<>(); - queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getDistributionTableFilters() - .isNoTagSelected()); + queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, + managementUIState.getDistributionTableFilters().isNoTagSelected()); if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) { list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags()); @@ -253,8 +253,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent { final BeanQueryFactory distributionQF = new BeanQueryFactory<>( DistributionBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer distributionContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); + final LazyQueryContainer distributionContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), + distributionQF); return distributionContainer; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 59999a552..41d8ecab6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -215,13 +215,12 @@ public class TargetTable extends AbstractTable implements Handler { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final ManagementUIEvent managementUIEvent) { - UI.getCurrent().access( - () -> { - if (managementUIEvent == ManagementUIEvent.UNASSIGN_TARGET_TAG - || managementUIEvent == ManagementUIEvent.ASSIGN_TARGET_TAG) { - refreshFilter(); - } - }); + UI.getCurrent().access(() -> { + if (managementUIEvent == ManagementUIEvent.UNASSIGN_TARGET_TAG + || managementUIEvent == ManagementUIEvent.ASSIGN_TARGET_TAG) { + refreshFilter(); + } + }); } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -276,8 +275,9 @@ public class TargetTable extends AbstractTable implements Handler { targetQF.setQueryConfiguration(queryConfig); // create lazy query container with lazy defination and query - final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF); + final LazyQueryContainer targetTableContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), + targetQF); targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); return targetTableContainer; @@ -365,8 +365,8 @@ public class TargetTable extends AbstractTable implements Handler { final TargetIdName lastSelectedItem = getLastSelectedItem(values); managementUIState.setSelectedTargetIdName(values); managementUIState.setLastSelectedTargetIdName(lastSelectedItem); - final Target target = targetManagement.findTargetByControllerIDWithDetails(lastSelectedItem - .getControllerId()); + final Target target = targetManagement + .findTargetByControllerIDWithDetails(lastSelectedItem.getControllerId()); eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, target)); } else { managementUIState.setSelectedTargetIdName(null); @@ -400,10 +400,10 @@ public class TargetTable extends AbstractTable implements Handler { 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_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)); - 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)); } else { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8f)); @@ -622,7 +622,8 @@ public class TargetTable extends AbstractTable implements Handler { private void doAssignments(final DragAndDropEvent event) { if (event.getTransferable().getSourceComponent() instanceof Table) { dsToTargetAssignment(event); - } else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper && isNoTagAssigned(event)) { + } else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper + && isNoTagAssigned(event)) { tagAssignment(event); } @@ -632,8 +633,8 @@ public class TargetTable extends AbstractTable implements Handler { final String tagName = ((DragAndDropWrapper) (event.getTransferable().getSourceComponent())).getData() .toString(); if (tagName.equals(SPUIDefinitions.TARGET_TAG_BUTTON)) { - notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", - new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError( + i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); return false; } return true; @@ -684,8 +685,8 @@ public class TargetTable extends AbstractTable implements Handler { private Boolean validateTable(final Component compsource, final TableTransferable transferable) { final Table source = (Table) compsource; - if (!(source.getId().equals(SPUIComponetIdProvider.DIST_TABLE_ID) || source.getId().startsWith( - SPUIDefinitions.TARGET_TAG_ID_PREFIXS))) { + if (!(source.getId().equals(SPUIComponetIdProvider.DIST_TABLE_ID) + || source.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS))) { notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG)); return false; } else if (!permChecker.hasUpdateTargetPermission()) { @@ -713,8 +714,8 @@ public class TargetTable extends AbstractTable implements Handler { private Boolean validateDragAndDropWrapper(final Component compsource) { final DragAndDropWrapper wrapperSource = (DragAndDropWrapper) compsource; - final String tagName = HawkbitCommonUtil - .removePrefix(compsource.getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); + final String tagName = HawkbitCommonUtil.removePrefix(compsource.getId(), + SPUIDefinitions.TARGET_TAG_ID_PREFIXS); if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) { if ("NO TAG".equals(tagName)) { notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG)); @@ -740,8 +741,9 @@ public class TargetTable extends AbstractTable implements Handler { if (null != distributionNameId) { if (managementUIState.getAssignedList().keySet().contains(targetId) && managementUIState.getAssignedList().get(targetId).equals(distributionNameId)) { - message = getPendingActionMessage(message, HawkbitCommonUtil.getDistributionNameAndVersion( - distributionNameId.getName(), distributionNameId.getVersion()), + message = getPendingActionMessage(message, + HawkbitCommonUtil.getDistributionNameAndVersion(distributionNameId.getName(), + distributionNameId.getVersion()), targetId.getControllerId()); } else { managementUIState.getAssignedList().put(targetId, distributionNameId); @@ -807,13 +809,13 @@ public class TargetTable extends AbstractTable implements Handler { * registered for the target last query column. That listener will * update the latest query date for this target in the tooltip. */ - item.getItemProperty(SPUILabelDefinitions.LAST_QUERY_DATE).setValue( - updatedTarget.getTargetInfo().getLastTargetQuery()); + item.getItemProperty(SPUILabelDefinitions.LAST_QUERY_DATE) + .setValue(updatedTarget.getTargetInfo().getLastTargetQuery()); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue( - HawkbitCommonUtil.getIMUser(updatedTarget.getLastModifiedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( - SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) + .setValue(HawkbitCommonUtil.getIMUser(updatedTarget.getLastModifiedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) + .setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription()); /* @@ -821,8 +823,8 @@ public class TargetTable extends AbstractTable implements Handler { * registered for the target update status. That listener will * update the new status icon showing for this target in the table. */ - item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue( - updatedTarget.getTargetInfo().getUpdateStatus()); + item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS) + .setValue(updatedTarget.getTargetInfo().getUpdateStatus()); } } @@ -852,9 +854,8 @@ public class TargetTable extends AbstractTable implements Handler { } private String getTargetTableStyle(final Long assignedDistributionSetId, final Long installedDistributionSetId) { - final Long distPinned = managementUIState.getTargetTableFilters().getPinnedDistId().isPresent() ? managementUIState - .getTargetTableFilters().getPinnedDistId().get() - : null; + final Long distPinned = managementUIState.getTargetTableFilters().getPinnedDistId().isPresent() + ? managementUIState.getTargetTableFilters().getPinnedDistId().get() : null; if (null != distPinned && distPinned.equals(installedDistributionSetId)) { return SPUIDefinitions.HIGHTLIGHT_GREEN; @@ -873,10 +874,10 @@ public class TargetTable extends AbstractTable implements Handler { private String createTargetTableStyle(final Object itemId, final Object propertyId) { if (null == propertyId) { final Item item = getItem(itemId); - final Long assignedDistributionSetId = (Long) item.getItemProperty( - SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_ID).getValue(); - final Long installedDistributionSetId = (Long) item.getItemProperty( - SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID).getValue(); + final Long assignedDistributionSetId = (Long) item + .getItemProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_ID).getValue(); + final Long installedDistributionSetId = (Long) item + .getItemProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID).getValue(); return getTargetTableStyle(assignedDistributionSetId, installedDistributionSetId); } return null; @@ -935,8 +936,8 @@ public class TargetTable extends AbstractTable implements Handler { final Item item = targetContainer.getItem(targetIdName); item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus()); item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName()); - item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).setValue( - HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n)); + item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP) + .setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n)); } private boolean isLastSelectedTarget(final TargetIdName targetIdName) { @@ -994,8 +995,8 @@ public class TargetTable extends AbstractTable implements Handler { filters.add(new TargetSearchTextFilter(target, targetTableFilters.getSearchText().get())); } filters.add(new TargetStatusFilter(targetTableFilters.getClickedStatusTargetTags())); - filters.add(new TargetTagFilter(target, targetTableFilters.getClickedTargetTags(), targetTableFilters - .isNoTagSelected())); + filters.add(new TargetTagFilter(target, targetTableFilters.getClickedTargetTags(), + targetTableFilters.isNoTagSelected())); filters.add(new CustomTargetFilter(targetTableFilters.getTargetFilterQuery())); return filters; } @@ -1004,8 +1005,8 @@ public class TargetTable extends AbstractTable implements Handler { * Select all rows in the table. */ public void selectAll() { - final PageRequest pageRequest = new OffsetBasedPageRequest(0, size(), new Sort( - SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt")); + final PageRequest pageRequest = new OffsetBasedPageRequest(0, size(), + new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt")); List targetIdList; // is custom filter selected if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) { @@ -1017,9 +1018,8 @@ public class TargetTable extends AbstractTable implements Handler { } private List getTargetIdsBySimpleFilters(final PageRequest pageRequest) { - final Long filterByDistId = managementUIState.getTargetTableFilters().getDistributionSet().isPresent() ? managementUIState - .getTargetTableFilters().getDistributionSet().get().getId() - : null; + final Long filterByDistId = managementUIState.getTargetTableFilters().getDistributionSet().isPresent() + ? managementUIState.getTargetTableFilters().getDistributionSet().get().getId() : null; final List statusList = new ArrayList(); if (isFilteredByStatus()) { statusList.addAll(managementUIState.getTargetTableFilters().getClickedStatusTargetTags()); @@ -1028,8 +1028,8 @@ public class TargetTable extends AbstractTable implements Handler { if (isFilteredByTags()) { tagList.addAll(managementUIState.getTargetTableFilters().getClickedTargetTags()); } - String searchText = managementUIState.getTargetTableFilters().getSearchText().isPresent() ? managementUIState - .getTargetTableFilters().getSearchText().get() : null; + String searchText = managementUIState.getTargetTableFilters().getSearchText().isPresent() + ? managementUIState.getTargetTableFilters().getSearchText().get() : null; if (!Strings.isNullOrEmpty(searchText)) { searchText = String.format("%%%s%%", searchText); } @@ -1114,8 +1114,8 @@ public class TargetTable extends AbstractTable implements Handler { final Long pinnedDistId) { final long size; if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) { - size = targetManagement.countTargetByTargetFilterQuery(managementUIState.getTargetTableFilters() - .getTargetFilterQuery().get()); + size = targetManagement.countTargetByTargetFilterQuery( + managementUIState.getTargetTableFilters().getTargetFilterQuery().get()); } else if (!anyFilterSelected(status, pinnedDistId, noTagClicked, targetTags, searchText)) { size = totalTargetsCount; } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java index d1a49b899..a1b094f99 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -141,9 +141,8 @@ public class TargetTableHeader extends AbstractTableHeader { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final TargetTableEvent event) { if (TargetComponentEvent.BULK_TARGET_CREATED == event.getTargetComponentEvent()) { - this.getUI().access( - () -> targetBulkUpdateWindow.setProgressBarValue(managementUIState.getTargetTableFilters() - .getBulkUpload().getProgressBarCurrentValue())); + this.getUI().access(() -> targetBulkUpdateWindow.setProgressBarValue( + managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue())); } else if (TargetComponentEvent.BULK_UPLOAD_COMPLETED == event.getTargetComponentEvent()) { this.getUI().access(() -> targetBulkUpdateWindow.onUploadCompletion()); } else if (TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED == event.getTargetComponentEvent()) { @@ -264,8 +263,8 @@ public class TargetTableHeader extends AbstractTableHeader { } private String getSearchText() { - return managementUIState.getTargetTableFilters().getSearchText().isPresent() ? managementUIState - .getTargetTableFilters().getSearchText().get() : null; + return managementUIState.getTargetTableFilters().getSearchText().isPresent() + ? managementUIState.getTargetTableFilters().getSearchText().get() : null; } @Override @@ -395,8 +394,8 @@ public class TargetTableHeader extends AbstractTableHeader { private Set getDropppedDistributionDetails(final TableTransferable transferable) { @SuppressWarnings("unchecked") - final Set distSelected = HawkbitCommonUtil.getSelectedDSDetails(transferable - .getSourceComponent()); + final Set distSelected = HawkbitCommonUtil + .getSelectedDSDetails(transferable.getSourceComponent()); final Set distributionIdSet = new HashSet(); if (!distSelected.contains(transferable.getData("itemId"))) { distributionIdSet.add((DistributionSetIdName) transferable.getData("itemId")); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java index 6b7562d17..51ac77f10 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java @@ -155,8 +155,8 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { private Boolean checkIsDuplicate(final TargetTag existingTag) { if (existingTag != null) { - uiNotification.displayValidationError(i18n.get("message.tag.duplicate.check", - new Object[] { existingTag.getName() })); + uiNotification.displayValidationError( + i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() })); return Boolean.TRUE; } return Boolean.FALSE; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java index 8d82d3220..1e6ad800a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java @@ -100,7 +100,8 @@ public class TargetFilterQueryButtons extends Table { } protected LazyQueryContainer createButtonsLazyQueryContainer() { - final BeanQueryFactory queryFactory = new BeanQueryFactory<>(TargetFilterBeanQuery.class); + final BeanQueryFactory queryFactory = new BeanQueryFactory<>( + TargetFilterBeanQuery.class); final Map queryConfig = new HashMap<>(); queryFactory.setQueryConfiguration(queryConfig); return new LazyQueryContainer(new LazyQueryDefinition(true, 20, "id"), queryFactory); @@ -145,8 +146,8 @@ public class TargetFilterQueryButtons extends Table { } private Button createFilterButton(final Long id, final String name, final Object itemId) { - final Button button = SPUIComponentProvider - .getButton("", name, name, "", false, null, SPUITagButtonStyle.class); + final Button button = SPUIComponentProvider.getButton("", name, name, "", false, null, + SPUITagButtonStyle.class); button.addStyleName("custom-filter-button"); button.setId(name); if (id != null) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java index 6e33b8280..a5a6b4b91 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java @@ -55,8 +55,8 @@ public class TargetTagFilterButtonClick extends AbstractFilterMultiButtonClick i eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG); } } else { - if (null != managementUIState.getTargetTableFilters().getClickedTargetTags() - && managementUIState.getTargetTableFilters().getClickedTargetTags().contains(clickedButton.getId())) { + if (null != managementUIState.getTargetTableFilters().getClickedTargetTags() && managementUIState + .getTargetTableFilters().getClickedTargetTags().contains(clickedButton.getId())) { managementUIState.getTargetTableFilters().getClickedTargetTags().remove(clickedButton.getId()); eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java index d6876a0b6..c9a2c945c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -166,9 +166,8 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { @Override protected boolean isClickedByDefault(final Long buttonId) { final TargetTag newTagClickedObj = tagMgmtService.findTargetTagById(buttonId); - return managementUIState.getTargetTableFilters().getClickedTargetTags() != null - && managementUIState.getTargetTableFilters().getClickedTargetTags() - .contains(newTagClickedObj.getName()); + return managementUIState.getTargetTableFilters().getClickedTargetTags() != null && managementUIState + .getTargetTableFilters().getClickedTargetTags().contains(newTagClickedObj.getName()); } @Override @@ -223,8 +222,8 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { private Boolean isNoTagAssigned(final DragAndDropEvent event) { final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString(); if (tagName.equals(SPUIDefinitions.TARGET_TAG_BUTTON)) { - notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", - new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError( + i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); return false; } return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java index a83208a30..44ec9ea40 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java @@ -206,15 +206,15 @@ public final class DashboardMenu extends CustomComponent implements EnvironmentA && (((UserPrincipal) user).getFirstname() != null || ((UserPrincipal) user).getLastname() != null)) { settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n" + concateFNameLName(((UserPrincipal) user).getFirstname(), ((UserPrincipal) user).getLastname())); - settingsItem.setDescription(((UserPrincipal) user).getFirstname() + " / " - + ((UserPrincipal) user).getLastname()); + settingsItem.setDescription( + ((UserPrincipal) user).getFirstname() + " / " + ((UserPrincipal) user).getLastname()); } else if (user instanceof UserPrincipal) { if (((UserPrincipal) user).getLoginname().length() > 10) { settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n" + ((UserPrincipal) user).getLoginname().substring(0, 10) + ".."); } else { - settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n" - + ((UserPrincipal) user).getLoginname()); + settingsItem.setText( + trimTanent(((UserPrincipal) user).getTenant()) + "\n" + ((UserPrincipal) user).getLoginname()); } settingsItem.setDescription(((UserPrincipal) user).getLoginname()); } else if (user != null) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 49eb6498a..4e073c829 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -26,8 +26,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.TargetIdName; -import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.ui.management.dstable.DistributionTable; import org.eclipse.hawkbit.ui.management.targettable.TargetTable; @@ -432,12 +432,10 @@ public final class HawkbitCommonUtil { public static String getPollStatusToolTip(final PollStatus pollStatus, final I18N i18N) { if (pollStatus != null && pollStatus.getLastPollDate() != null && pollStatus.isOverdue()) { final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone(); - return "Overdue for " - + SPDateTimeUtil.getDurationFormattedString( - pollStatus.getOverdueDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant() - .toEpochMilli(), - pollStatus.getCurrentDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant() - .toEpochMilli(), i18N); + return "Overdue for " + SPDateTimeUtil.getDurationFormattedString( + pollStatus.getOverdueDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant().toEpochMilli(), + pollStatus.getCurrentDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant().toEpochMilli(), + i18N); } return null; } @@ -479,8 +477,8 @@ public final class HawkbitCommonUtil { * @return extra height required to increase. */ public static float findRequiredExtraHeight(final float newBrowserHeight) { - return newBrowserHeight > SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT ? newBrowserHeight - - SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT : 0; + return newBrowserHeight > SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT + ? newBrowserHeight - SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT : 0; } /** @@ -491,8 +489,8 @@ public final class HawkbitCommonUtil { * @return float heigth of software module table */ public static float findRequiredSwModuleExtraHeight(final float newBrowserHeight) { - return newBrowserHeight > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT ? newBrowserHeight - - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT : 0; + return newBrowserHeight > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT + ? newBrowserHeight - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT : 0; } /** @@ -503,8 +501,8 @@ public final class HawkbitCommonUtil { * @return float width of software module table */ public static float findRequiredSwModuleExtraWidth(final float newBrowserWidth) { - return newBrowserWidth > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH ? newBrowserWidth - - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH : 0; + return newBrowserWidth > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH + ? newBrowserWidth - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH : 0; } /** @@ -566,8 +564,8 @@ public final class HawkbitCommonUtil { * @return extra width required to be increased. */ public static float findExtraWidth(final float newBrowserWidth) { - return newBrowserWidth > SPUIDefinitions.REQ_MIN_BROWSER_WIDTH ? newBrowserWidth - - SPUIDefinitions.REQ_MIN_BROWSER_WIDTH : 0; + return newBrowserWidth > SPUIDefinitions.REQ_MIN_BROWSER_WIDTH + ? newBrowserWidth - SPUIDefinitions.REQ_MIN_BROWSER_WIDTH : 0; } /** @@ -700,12 +698,12 @@ public final class HawkbitCommonUtil { final StringBuilder exeJS = new StringBuilder(DRAG_COUNT_ELEMENT).append(JS_DRAG_COUNT_REM_CHILD); final String currentTheme = UI.getCurrent().getTheme(); if (count > 1) { - exeJS.append(COUNT_STYLE) - .append(COUNT_STYLE_ID) + exeJS.append(COUNT_STYLE).append(COUNT_STYLE_ID) .append(" countStyle.innerHTML = '." + currentTheme + " tbody.v-drag-element tr:after { content:\"" + count + "\";top:-15px } ." + currentTheme + " tr.v-drag-element:after { content:\"" + count + CLOSE_BRACE_NOSEMICOLON + "." + currentTheme - + " table.v-drag-element:after{ content:\"" + count + CLOSE_BRACE).append(APPEND_CHILD); + + " table.v-drag-element:after{ content:\"" + count + CLOSE_BRACE) + .append(APPEND_CHILD); } return exeJS.toString(); } @@ -900,9 +898,8 @@ public final class HawkbitCommonUtil { final int unassignedCount = result.getUnassigned(); if (assignedCount == 1) { - formMsg.append( - i18n.get("message.target.assigned.one", new Object[] { - result.getAssignedTargets().get(0).getName(), targTagName })).append("
"); + formMsg.append(i18n.get("message.target.assigned.one", + new Object[] { result.getAssignedTargets().get(0).getName(), targTagName })).append("
"); } else if (assignedCount > 1) { formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName })) @@ -916,9 +913,8 @@ public final class HawkbitCommonUtil { } if (unassignedCount == 1) { - formMsg.append( - i18n.get("message.target.unassigned.one", new Object[] { - result.getUnassignedTargets().get(0).getName(), targTagName })).append("
"); + formMsg.append(i18n.get("message.target.unassigned.one", + new Object[] { result.getUnassignedTargets().get(0).getName(), targTagName })).append("
"); } else if (unassignedCount > 1) { formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName })) @@ -948,9 +944,8 @@ public final class HawkbitCommonUtil { final int unassignedCount = result.getUnassigned(); if (assignedCount == 1) { - formMsg.append( - i18n.get("message.target.assigned.one", new Object[] { result.getAssignedDs().get(0).getName(), - targTagName })).append("
"); + formMsg.append(i18n.get("message.target.assigned.one", + new Object[] { result.getAssignedDs().get(0).getName(), targTagName })).append("
"); } else if (assignedCount > 1) { formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName })) @@ -964,9 +959,8 @@ public final class HawkbitCommonUtil { } if (unassignedCount == 1) { - formMsg.append( - i18n.get("message.target.unassigned.one", new Object[] { result.getUnassignedDs().get(0).getName(), - targTagName })).append("
"); + formMsg.append(i18n.get("message.target.unassigned.one", + new Object[] { result.getUnassignedDs().get(0).getName(), targTagName })).append("
"); } else if (unassignedCount > 1) { formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName })) .append("
"); @@ -987,8 +981,8 @@ public final class HawkbitCommonUtil { final BeanQueryFactory queryFactory) { final Map queryConfig = new HashMap(); queryFactory.setQueryConfiguration(queryConfig); - final LazyQueryContainer typeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, 20, - SPUILabelDefinitions.VAR_NAME), queryFactory); + final LazyQueryContainer typeContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory); return typeContainer; } @@ -1046,10 +1040,10 @@ public final class HawkbitCommonUtil { 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_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)); - 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)); } else if (isShowPinColumn) { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.7f)); @@ -1097,9 +1091,7 @@ public final class HawkbitCommonUtil { */ public static String changeToNewSelectedPreviewColor(final String colorPickedPreview) { final StringBuilder scriptBuilder = new StringBuilder(); - scriptBuilder - .append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT) - .append(NEW_PREVIEW_COLOR_CREATE_SCRIPT) + scriptBuilder.append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT).append(NEW_PREVIEW_COLOR_CREATE_SCRIPT) .append("var newColorPreviewStyle = \".v-app .new-tag-name{ border: solid 3px ") .append(colorPickedPreview) .append(" !important; width:138px; margin-left:2px !important; box-shadow:none !important; } \"; ") @@ -1119,9 +1111,7 @@ public final class HawkbitCommonUtil { */ public static String getPreviewButtonColorScript(final String color) { final StringBuilder scriptBuilder = new StringBuilder(); - scriptBuilder - .append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT) - .append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT) + scriptBuilder.append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT).append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT) .append("var tagColorPreviewStyle = \".v-app .tag-color-preview{ height: 15px !important; padding: 0 10px !important; border: 0px !important; margin-left:12px !important; margin-top: 4px !important; border-width: 0 !important; background: ") .append(color) .append(" } .v-app .tag-color-preview:after{ border-color: none !important; box-shadow:none !important;} \"; ") @@ -1220,8 +1210,8 @@ public final class HawkbitCommonUtil { false, false); targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID, Long.class, null, false, false); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, - "", false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "", + false, true); targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, "", false, true); targetTableContainer.addContainerProperty(SPUILabelDefinitions.LAST_QUERY_DATE, Date.class, null, false, false); @@ -1251,8 +1241,8 @@ public final class HawkbitCommonUtil { public static void applyStatusLblStyle(final Table targetTable, final Button pinBtn, final Object itemId) { final Item item = targetTable.getItem(itemId); if (item != null) { - final TargetUpdateStatus updateStatus = (TargetUpdateStatus) item.getItemProperty( - SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); + final TargetUpdateStatus updateStatus = (TargetUpdateStatus) item + .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); pinBtn.removeStyleName("statusIconRed statusIconBlue statusIconGreen statusIconYellow statusIconLightBlue"); if (updateStatus == TargetUpdateStatus.ERROR) { pinBtn.addStyleName("statusIconRed");