Merge branch 'master' into fix_NplusOne_query_on_ui

Conflicts:
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java


Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-04 20:16:26 +02:00
35 changed files with 159 additions and 70 deletions

View File

@@ -22,14 +22,17 @@ import org.springframework.context.annotation.Import;
@SpringBootApplication @SpringBootApplication
@Import({ RepositoryApplicationConfiguration.class }) @Import({ RepositoryApplicationConfiguration.class })
@EnableHawkbitManagedSecurityConfiguration @EnableHawkbitManagedSecurityConfiguration
// Exception squid:S1118 - Spring boot standard behavior
@SuppressWarnings({ "squid:S1118" })
public class Start { public class Start {
/** /**
* Main method to start the spring-boot application. * Main method to start the spring-boot application.
* *
* @param args * @param args
* the VM arguments. * the VM arguments.
*/ */
// Exception squid:S2095 - Spring boot standard behavior
@SuppressWarnings({ "squid:S2095" })
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(Start.class, args); SpringApplication.run(Start.class, args);
} }

View File

@@ -21,8 +21,6 @@ import com.vaadin.spring.annotation.EnableVaadin;
/** /**
* The main-method to start the Spring-Boot application. * The main-method to start the Spring-Boot application.
* *
*
*
*/ */
@SpringBootApplication @SpringBootApplication
@EnableVaadin @EnableVaadin
@@ -46,6 +44,8 @@ public class DeviceSimulator {
* @param args * @param args
* the args * the args
*/ */
// Exception squid:S2095 - Spring boot standard behavior
@SuppressWarnings({ "squid:S2095" })
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(DeviceSimulator.class, args); SpringApplication.run(DeviceSimulator.class, args);
} }

View File

@@ -88,6 +88,8 @@ public class SpReceiverService extends ReceiverService {
if (eventHeader == null) { if (eventHeader == null) {
logAndThrowMessageError(message, "Event Topic is not set"); logAndThrowMessageError(message, "Event Topic is not set");
} }
// Exception squid:S2259 - Checked before
@SuppressWarnings({ "squid:S2259" })
final EventTopic eventTopic = EventTopic.valueOf(eventHeader.toString()); final EventTopic eventTopic = EventTopic.valueOf(eventHeader.toString());
switch (eventTopic) { switch (eventTopic) {
case DOWNLOAD_AND_INSTALL: case DOWNLOAD_AND_INSTALL:

View File

@@ -4,16 +4,20 @@ The hawkBit example application is a standalone spring-boot application with an
We have have described several options for you to get access to the example. We have have described several options for you to get access to the example.
## Try out the example application in our hawkBit sandbox on Bluemix ## Try out the example application in our hawkBit sandbox on Bluemix
- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI - try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI (username: admin, passwd: admin)
- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header) - try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header; username: admin, passwd: admin)
- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE - try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE (authentication disabled)
## On your own workstation ## On your own workstation
### Run ### Run
``` ```
java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar
``` ```
_(Note: you have to add the JDBC driver also to your class path if you intend to use another database than H2.)_
Or: Or:
``` ```
run org eclipse.hawkbit.app.Start run org eclipse.hawkbit.app.Start
``` ```

View File

@@ -26,6 +26,8 @@ import org.springframework.context.annotation.Import;
@EnableHawkbitManagedSecurityConfiguration @EnableHawkbitManagedSecurityConfiguration
@EnableRestResources @EnableRestResources
@EnableDirectDeviceApi @EnableDirectDeviceApi
// Exception squid:S1118 - Spring boot standard behavior
@SuppressWarnings({ "squid:S1118" })
public class Start { public class Start {
/** /**
@@ -34,6 +36,8 @@ public class Start {
* @param args * @param args
* the VM arguments. * the VM arguments.
*/ */
// Exception squid:S2095 - Spring boot standard behavior
@SuppressWarnings({ "squid:S2095" })
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(Start.class, args); SpringApplication.run(Start.class, args);
} }

View File

@@ -18,8 +18,9 @@ import com.google.common.collect.Lists;
/** /**
* Builder pattern for building {@link DistributionSetRequestBodyPost}. * Builder pattern for building {@link DistributionSetRequestBodyPost}.
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class DistributionSetBuilder { public class DistributionSetBuilder {
private String name; private String name;
private String version; private String version;
private String type; private String type;

View File

@@ -21,8 +21,9 @@ import com.google.common.collect.Lists;
* Builder pattern for building {@link DistributionSetTypeRequestBodyPost}. * Builder pattern for building {@link DistributionSetTypeRequestBodyPost}.
* *
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class DistributionSetTypeBuilder { public class DistributionSetTypeBuilder {
private String key; private String key;
private String name; private String name;
private final List<SoftwareModuleTypeAssigmentRest> mandatorymodules = Lists.newArrayList(); private final List<SoftwareModuleTypeAssigmentRest> mandatorymodules = Lists.newArrayList();

View File

@@ -17,6 +17,8 @@ import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody;
* Builder pattern for building {@link RolloutRestRequestBody}. * Builder pattern for building {@link RolloutRestRequestBody}.
* *
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class RolloutBuilder { public class RolloutBuilder {
private String name; private String name;

View File

@@ -21,6 +21,8 @@ import com.google.common.collect.Lists;
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}. * Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
* *
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class SoftwareModuleBuilder { public class SoftwareModuleBuilder {
private String name; private String name;

View File

@@ -21,6 +21,8 @@ import com.google.common.collect.Lists;
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}. * Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
* *
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class SoftwareModuleTypeBuilder { public class SoftwareModuleTypeBuilder {
private String key; private String key;

View File

@@ -19,6 +19,8 @@ import com.google.common.collect.Lists;
* Builder pattern for building {@link TagRequestBodyPut}. * Builder pattern for building {@link TagRequestBodyPut}.
* *
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class TagBuilder { public class TagBuilder {
private String name; private String name;

View File

@@ -21,6 +21,8 @@ import com.google.common.collect.Lists;
* Builder pattern for building {@link TargetRequestBody}. * Builder pattern for building {@link TargetRequestBody}.
* *
*/ */
// Exception squid:S1701 - builder pattern
@SuppressWarnings({ "squid:S1701" })
public class TargetBuilder { public class TargetBuilder {
private String controllerId; private String controllerId;

View File

@@ -71,6 +71,8 @@ public class MongoConfiguration extends AbstractMongoConfiguration {
@Override @Override
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
// Closed by pre-destroy
@SuppressWarnings({ "squid:S2095" })
public Mongo mongo() throws UnknownHostException { public Mongo mongo() throws UnknownHostException {
final MongoClientURI uri = new MongoClientURI(properties.getUri(), createBuilderOutOfOptions(options)); final MongoClientURI uri = new MongoClientURI(properties.getUri(), createBuilderOutOfOptions(options));

View File

@@ -22,11 +22,10 @@ import org.springframework.core.io.support.ResourcePatternResolver;
* This resource bundles using specified basenames, to resource loading. This * This resource bundles using specified basenames, to resource loading. This
* MessageSource implementation supports more than 1 properties file with the * MessageSource implementation supports more than 1 properties file with the
* same name. All properties files will be merged. * same name. All properties files will be merged.
*
*
*
*/ */
public class DistributedResourceBundleMessageSource extends ReloadableResourceBundleMessageSource { public class DistributedResourceBundleMessageSource extends ReloadableResourceBundleMessageSource {
// Exception squid:S2387 - Follows our upper case convention
@SuppressWarnings({ "squid:S2387" })
private static final Logger LOGGER = LoggerFactory.getLogger(DistributedResourceBundleMessageSource.class); private static final Logger LOGGER = LoggerFactory.getLogger(DistributedResourceBundleMessageSource.class);
private static final String PROPERTIES_SUFFIX = ".properties"; private static final String PROPERTIES_SUFFIX = ".properties";
private ResourceLoader resourceLoader; private ResourceLoader resourceLoader;

View File

@@ -39,6 +39,8 @@ public class TenantConfigurationPollingDurationValidator implements TenantConfig
} }
@Override @Override
// Exception squid:S1166 - Hide origin exception
@SuppressWarnings({ "squid:S1166" })
public void validate(final Object tenantConfigurationObject) { public void validate(final Object tenantConfigurationObject) {
TenantConfigurationValidator.super.validate(tenantConfigurationObject); TenantConfigurationValidator.super.validate(tenantConfigurationObject);
final String tenantConfigurationString = (String) tenantConfigurationObject; final String tenantConfigurationString = (String) tenantConfigurationObject;

View File

@@ -19,6 +19,7 @@ import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder; import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder; import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
import org.eclipse.hawkbit.repository.model.helper.TenantAwareHolder; import org.eclipse.hawkbit.repository.model.helper.TenantAwareHolder;
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
import org.eclipse.hawkbit.security.SecurityTokenGenerator; import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -54,8 +55,8 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
* directly, e.g. JPA entities. * directly, e.g. JPA entities.
*/ */
@Bean @Bean
public TenantConfigurationManagement tenantConfigurationManagement() { public TenantConfigurationManagementHolder tenantConfigurationManagementHolder() {
return TenantConfigurationManagement.getInstance(); return TenantConfigurationManagementHolder.getInstance();
} }
/** /**

View File

@@ -90,6 +90,8 @@ public class ExceptionMappingAspectHandler implements Ordered {
+ " || execution( * org.eclipse.hawkbit.controller.*.*(..)) " + " || execution( * org.eclipse.hawkbit.controller.*.*(..)) "
+ " || execution( * org.eclipse.hawkbit.rest.resource.*.*(..)) " + " || execution( * org.eclipse.hawkbit.rest.resource.*.*(..)) "
+ " || execution( * org.eclipse.hawkbit.service.*.*(..)) )", throwing = "ex") + " || execution( * org.eclipse.hawkbit.service.*.*(..)) )", throwing = "ex")
// Exception squid:S00112 - Is aspectJ proxy
@SuppressWarnings({ "squid:S00112" })
public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable { public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable {
LOG.trace("exception occured", ex); LOG.trace("exception occured", ex);
Exception translatedAccessException = translateEclipseLinkExceptionIfPossible(ex); Exception translatedAccessException = translateEclipseLinkExceptionIfPossible(ex);

View File

@@ -20,9 +20,9 @@ import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
import org.eclipse.hawkbit.repository.TargetRepository; import org.eclipse.hawkbit.repository.TargetRepository;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo; import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -67,6 +67,8 @@ public class EntityChangeEventListener {
* {@link ProceedingJoinPoint#proceed()} * {@link ProceedingJoinPoint#proceed()}
*/ */
@Around("execution(* org.eclipse.hawkbit.repository.TargetInfoRepository.save(..))") @Around("execution(* org.eclipse.hawkbit.repository.TargetInfoRepository.save(..))")
// Exception squid:S00112 - Is aspectJ proxy
@SuppressWarnings({ "squid:S00112" })
public Object targetCreated(final ProceedingJoinPoint joinpoint) throws Throwable { public Object targetCreated(final ProceedingJoinPoint joinpoint) throws Throwable {
final boolean isNew = isTargetInfoNew(joinpoint.getArgs()[0]); final boolean isNew = isTargetInfoNew(joinpoint.getArgs()[0]);
final Object result = joinpoint.proceed(); final Object result = joinpoint.proceed();
@@ -92,6 +94,8 @@ public class EntityChangeEventListener {
* {@link ProceedingJoinPoint#proceed()} * {@link ProceedingJoinPoint#proceed()}
*/ */
@Around("execution(* org.eclipse.hawkbit.repository.TargetRepository.deleteByIdIn(..))") @Around("execution(* org.eclipse.hawkbit.repository.TargetRepository.deleteByIdIn(..))")
// Exception squid:S00112 - Is aspectJ proxy
@SuppressWarnings({ "squid:S00112" })
public Object targetDeletedById(final ProceedingJoinPoint joinpoint) throws Throwable { public Object targetDeletedById(final ProceedingJoinPoint joinpoint) throws Throwable {
final String currentTenant = tenantAware.getCurrentTenant(); final String currentTenant = tenantAware.getCurrentTenant();
final Object result = joinpoint.proceed(); final Object result = joinpoint.proceed();
@@ -111,8 +115,9 @@ public class EntityChangeEventListener {
* in case exception happens in the * in case exception happens in the
* {@link ProceedingJoinPoint#proceed()} * {@link ProceedingJoinPoint#proceed()}
*/ */
@SuppressWarnings("unchecked")
@Around("execution(* org.eclipse.hawkbit.repository.TargetRepository.delete(..))") @Around("execution(* org.eclipse.hawkbit.repository.TargetRepository.delete(..))")
// Exception squid:S00112 - Is aspectJ proxy
@SuppressWarnings({ "squid:S00112", "unchecked" })
public Object targetDeleted(final ProceedingJoinPoint joinpoint) throws Throwable { public Object targetDeleted(final ProceedingJoinPoint joinpoint) throws Throwable {
final String currentTenant = tenantAware.getCurrentTenant(); final String currentTenant = tenantAware.getCurrentTenant();
final Object result = joinpoint.proceed(); final Object result = joinpoint.proceed();

View File

@@ -29,6 +29,8 @@ public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSyn
private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>(); private static final ThreadLocal<List<Runnable>> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>();
@Override @Override
// Exception squid:S1217 - Is aspectJ proxy
@SuppressWarnings({ "squid:S1217" })
public void afterCommit() { public void afterCommit() {
final List<Runnable> afterCommitRunnables = THREAD_LOCAL_RUNNABLES.get(); final List<Runnable> afterCommitRunnables = THREAD_LOCAL_RUNNABLES.get();
LOGGER.debug("Transaction successfully committed, executing {} runnables", afterCommitRunnables.size()); LOGGER.debug("Transaction successfully committed, executing {} runnables", afterCommitRunnables.size());
@@ -60,6 +62,7 @@ public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSyn
} }
@Override @Override
@SuppressWarnings({ "squid:S1217" })
public void afterCompletion(final int status) { public void afterCompletion(final int status) {
final String transactionStatus = status == STATUS_COMMITTED ? "COMMITTED" : "ROLLEDBACK"; final String transactionStatus = status == STATUS_COMMITTED ? "COMMITTED" : "ROLLEDBACK";
LOGGER.debug("Transaction completed after commit with status {}", transactionStatus); LOGGER.debug("Transaction completed after commit with status {}", transactionStatus);

View File

@@ -198,6 +198,9 @@ public class DeploymentManagement {
@Transactional @Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
@CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true) @CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true)
// Exception squid:S2095: see
// https://jira.sonarsource.com/browse/SONARJAVA-1478
@SuppressWarnings({ "squid:S2095" })
public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType, public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType,
final long forcedTimestamp, @NotEmpty final String... targetIDs) { final long forcedTimestamp, @NotEmpty final String... targetIDs) {
return assignDistributionSet(dsID, Arrays.stream(targetIDs) return assignDistributionSet(dsID, Arrays.stream(targetIDs)

View File

@@ -341,6 +341,8 @@ public class SystemManagement {
*/ */
private class CurrentTenantKeyGenerator implements KeyGenerator { private class CurrentTenantKeyGenerator implements KeyGenerator {
@Override @Override
// Exception squid:S923 - override
@SuppressWarnings({ "squid:S923" })
public Object generate(final Object target, final Method method, final Object... params) { public Object generate(final Object target, final Method method, final Object... params) {
final String initialTenantCreation = createInitialTenant.get(); final String initialTenantCreation = createInitialTenant.get();
if (initialTenantCreation == null) { if (initialTenantCreation == null) {

View File

@@ -24,6 +24,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -32,10 +33,9 @@ import org.springframework.validation.annotation.Validated;
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Validated @Validated
@Service
public class TenantConfigurationManagement implements EnvironmentAware { public class TenantConfigurationManagement implements EnvironmentAware {
private static final TenantConfigurationManagement INSTANCE = new TenantConfigurationManagement();
@Autowired @Autowired
private TenantConfigurationRepository tenantConfigurationRepository; private TenantConfigurationRepository tenantConfigurationRepository;
@@ -46,16 +46,6 @@ public class TenantConfigurationManagement implements EnvironmentAware {
private Environment environment; private Environment environment;
/**
* Get Singleton instance, needed for classes which are not managed in
* Spring context
*
* @return singleton instance of TenantConfigurationManagement
*/
public static TenantConfigurationManagement getInstance() {
return INSTANCE;
}
/** /**
* Retrieves a configuration value from the e.g. tenant overwritten * Retrieves a configuration value from the e.g. tenant overwritten
* configuration values or in case the tenant does not a have a specific * configuration values or in case the tenant does not a have a specific

View File

@@ -38,7 +38,7 @@ import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper; import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.persistence.annotations.CascadeOnDelete; import org.eclipse.persistence.annotations.CascadeOnDelete;
@@ -246,11 +246,12 @@ public class TargetInfo implements Persistable<Long>, Serializable {
return null; return null;
} }
final Duration pollTime = DurationHelper.formattedStringToDuration(TenantConfigurationManagement.getInstance() final Duration pollTime = DurationHelper.formattedStringToDuration(
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue()); TenantConfigurationManagementHolder.getInstance().getTenantConfigurationManagement()
final Duration overdueTime = DurationHelper.formattedStringToDuration(TenantConfigurationManagement .getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue());
.getInstance().getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class) final Duration overdueTime = DurationHelper.formattedStringToDuration(TenantConfigurationManagementHolder
.getValue()); .getInstance().getTenantConfigurationManagement()
.getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class).getValue());
final LocalDateTime currentDate = LocalDateTime.now(); final LocalDateTime currentDate = LocalDateTime.now();
final LocalDateTime lastPollDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastTargetQuery), final LocalDateTime lastPollDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastTargetQuery),
ZoneId.systemDefault()); ZoneId.systemDefault());

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.model.helper;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.springframework.beans.factory.annotation.Autowired;
/**
* A singleton bean which holds {@link TenantConfigurationManagement} service
* and makes it accessible to beans which are not managed by spring, e.g. JPA
* entities.
*/
public final class TenantConfigurationManagementHolder {
private static final TenantConfigurationManagementHolder INSTANCE = new TenantConfigurationManagementHolder();
@Autowired
private TenantConfigurationManagement tenantConfiguration;
private TenantConfigurationManagementHolder() {
}
/**
* @return the singleton {@link TenantConfigurationManagementHolder}
* instance
*/
public static TenantConfigurationManagementHolder getInstance() {
return INSTANCE;
}
/**
* @return the {@link TenantConfigurationManagement} service
*/
public TenantConfigurationManagement getTenantConfigurationManagement() {
return tenantConfiguration;
}
}

View File

@@ -66,10 +66,6 @@ import cz.jirutka.rsql.parser.ast.RSQLVisitor;
* <li>name==targetId1,description==plugAndPlay,updateStatus==UNKNOWN</li> * <li>name==targetId1,description==plugAndPlay,updateStatus==UNKNOWN</li>
* <li>name==targetId1 or description==plugAndPlay or updateStatus==UNKNOWN</li> * <li>name==targetId1 or description==plugAndPlay or updateStatus==UNKNOWN</li>
* </ul> * </ul>
*
*
*
*
*/ */
public final class RSQLUtility { public final class RSQLUtility {
@@ -279,6 +275,9 @@ public final class RSQLUtility {
} }
@Override @Override
// Exception squid:S2095 - see
// https://jira.sonarsource.com/browse/SONARJAVA-1478
@SuppressWarnings({ "squid:S2095" })
public List<Predicate> visit(final ComparisonNode node, final String param) { public List<Predicate> visit(final ComparisonNode node, final String param) {
A fieldName = null; A fieldName = null;
try { try {
@@ -304,6 +303,9 @@ public final class RSQLUtility {
return mapToPredicate(node, fieldPath, node.getArguments(), transformedValue, fieldName); return mapToPredicate(node, fieldPath, node.getArguments(), transformedValue, fieldName);
} }
// Exception squid:S2095 - see
// https://jira.sonarsource.com/browse/SONARJAVA-1478
@SuppressWarnings({ "squid:S2095" })
private List<String> getExpectedFieldList() { private List<String> getExpectedFieldList() {
final List<String> expectedFieldList = Arrays.stream(enumType.getEnumConstants()) final List<String> expectedFieldList = Arrays.stream(enumType.getEnumConstants())
.filter(enumField -> enumField.getSubEntityAttributes().isEmpty()).map(enumField -> { .filter(enumField -> enumField.getSubEntityAttributes().isEmpty()).map(enumField -> {
@@ -390,7 +392,9 @@ public final class RSQLUtility {
} }
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) // Exception squid:S2095 - see
// https://jira.sonarsource.com/browse/SONARJAVA-1478
@SuppressWarnings({ "rawtypes", "unchecked", "squid:S2095" })
private Object transformEnumValue(final ComparisonNode node, final String value, private Object transformEnumValue(final ComparisonNode node, final String value,
final Class<? extends Object> javaType) { final Class<? extends Object> javaType) {
final Class<? extends Enum> tmpEnumType = (Class<? extends Enum>) javaType; final Class<? extends Enum> tmpEnumType = (Class<? extends Enum>) javaType;

View File

@@ -19,12 +19,10 @@ import org.springframework.security.core.GrantedAuthority;
* *
*/ */
public class TenantUserPasswordAuthenticationToken extends UsernamePasswordAuthenticationToken { public class TenantUserPasswordAuthenticationToken extends UsernamePasswordAuthenticationToken {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Exception squid:S1948 - no need to be Serializable
@SuppressWarnings({ "squid:S1948" })
final Object tenant; final Object tenant;
/** /**

View File

@@ -37,6 +37,8 @@ public class UiProperties {
/** /**
* Demo user password. * Demo user password.
*/ */
// Exception squid:S2068 - Empty password
@SuppressWarnings({ "squid:S2068" })
private String password = ""; private String password = "";
public String getPassword() { public String getPassword() {
@@ -64,6 +66,7 @@ public class UiProperties {
} }
} }
/** /**
* Links to potentially other systems (e.g. support, user management, * Links to potentially other systems (e.g. support, user management,
* documentation etc.). * documentation etc.).
@@ -227,6 +230,7 @@ public class UiProperties {
} }
} }
/** /**
* Configuration of login view. * Configuration of login view.
* *

View File

@@ -37,20 +37,12 @@ import com.vaadin.ui.Upload.SucceededListener;
* {@link StreamVariable} upload variants. * {@link StreamVariable} upload variants.
* *
* The handler manages the output to the user and at the same time ensures that * The handler manages the output to the user and at the same time ensures that
* the upload does not exceed the configued max file size. * the upload does not exceed the configured max file size.
*
*
*
*
*
* *
*/ */
public class UploadHandler implements StreamVariable, Receiver, SucceededListener, FailedListener, FinishedListener, public class UploadHandler implements StreamVariable, Receiver, SucceededListener, FailedListener, FinishedListener,
ProgressListener, StartedListener { ProgressListener, StartedListener {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(UploadHandler.class); private static final Logger LOG = LoggerFactory.getLogger(UploadHandler.class);
@@ -108,7 +100,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
public OutputStream receiveUpload(final String fileName, final String mimeType) { public OutputStream receiveUpload(final String fileName, final String mimeType) {
this.fileName = fileName; this.fileName = fileName;
this.mimeType = mimeType; this.mimeType = mimeType;
//reset has directory flag before upload // reset has directory flag before upload
view.setHasDirectory(false); view.setHasDirectory(false);
try { try {
if (view.checkIfSoftwareModuleIsSelected()) { if (view.checkIfSoftwareModuleIsSelected()) {
@@ -343,11 +335,6 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
} }
} }
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@@ -356,11 +343,6 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
return result; return result;
} }
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (this == obj) { if (this == obj) {

View File

@@ -170,6 +170,8 @@ public final class UserDetailsFormatter {
return trimmedDetail; return trimmedDetail;
} }
// Exception squid:S1166 - exception has to be hidden
@SuppressWarnings({ "squid:S1166" })
private static UserDetails loadUserByUsername(final String username) { private static UserDetails loadUserByUsername(final String username) {
final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class); final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class);
try { try {

View File

@@ -31,10 +31,7 @@ import cz.jirutka.rsql.parser.RSQLParserException;
* *
* Validates the target filter query. * Validates the target filter query.
* *
*
*
*/ */
public final class FilterQueryValidation { public final class FilterQueryValidation {
private static final Logger LOGGER = LoggerFactory.getLogger(FilterQueryValidation.class); private static final Logger LOGGER = LoggerFactory.getLogger(FilterQueryValidation.class);
@@ -103,6 +100,9 @@ public final class FilterQueryValidation {
* @param expectedTokens * @param expectedTokens
* @return * @return
*/ */
// Exception squid:S2095 - see
// https://jira.sonarsource.com/browse/SONARJAVA-1478
@SuppressWarnings({ "squid:S2095" })
public static List<String> processExpectedTokens(final List<Integer> expectedTokens) { public static List<String> processExpectedTokens(final List<Integer> expectedTokens) {
final List<String> expectToken = new ArrayList<>(); final List<String> expectToken = new ArrayList<>();
if (expectedTokens.size() == 2 && expectedTokens.contains(9) && expectedTokens.contains(4)) { if (expectedTokens.size() == 2 && expectedTokens.contains(9) && expectedTokens.contains(4)) {

View File

@@ -43,10 +43,6 @@ import com.vaadin.ui.themes.ValoTheme;
@SpringComponent @SpringComponent
@VaadinSessionScope @VaadinSessionScope
public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayout { public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayout {
/**
*
*/
private static final long serialVersionUID = 444276149954167545L; private static final long serialVersionUID = 444276149954167545L;
@Autowired @Autowired
@@ -288,16 +284,22 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) { void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
populateTagNameCombo(); populateTagNameCombo();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) { void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) {
populateTagNameCombo(); populateTagNameCombo();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) { void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
populateTagNameCombo(); populateTagNameCombo();
} }

View File

@@ -61,16 +61,22 @@ public class DistributionTagButtons extends AbstractFilterButtons {
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) { void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) {
refreshTagTable(); refreshTagTable();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) { void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) {
refreshTagTable(); refreshTagTable();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) { void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) {
refreshTagTable(); refreshTagTable();
} }

View File

@@ -332,7 +332,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
if (!isMaximized()) { if (!isMaximized()) {
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F)); columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F));
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F)); columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
} }
return columnList; return columnList;
} }

View File

@@ -85,16 +85,22 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout {
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) { void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
populateTagNameCombo(); populateTagNameCombo();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) { void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) {
populateTagNameCombo(); populateTagNameCombo();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetTagUpdateEvent(final TargetTagUpdateEvent event) { void onEventTargetTagUpdateEvent(final TargetTagUpdateEvent event) {
populateTagNameCombo(); populateTagNameCombo();
} }

View File

@@ -267,16 +267,22 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEvent(final TargetTagUpdateEvent event) { void onEvent(final TargetTagUpdateEvent event) {
refreshContainer(); refreshContainer();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) { void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) {
refreshContainer(); refreshContainer();
} }
@EventBusListenerMethod(scope = EventScope.SESSION) @EventBusListenerMethod(scope = EventScope.SESSION)
// Exception squid:S1172 - event not needed
@SuppressWarnings({ "squid:S1172" })
void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) { void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) {
refreshContainer(); refreshContainer();
} }