Merge branch 'feature_MECS-86_tenant_specific_polling_configuration' of https://github.com/bsinno/hawkbit.git into feature_MECS-86_tenant_specific_polling_configuration
This commit is contained in:
@@ -75,8 +75,7 @@ public abstract class SpServerRtException extends RuntimeException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return the SpServerError which is wrapped by this exception
|
||||||
* @return the SpServerError
|
|
||||||
*/
|
*/
|
||||||
public SpServerError getError() {
|
public SpServerError getError() {
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.tenancy.configuration;
|
package org.eclipse.hawkbit.tenancy.configuration;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator;
|
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationBooleanValidator;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator;
|
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationPollingDurationValidator;
|
||||||
@@ -84,10 +84,18 @@ public enum TenantConfigurationKey {
|
|||||||
private final Class<? extends TenantConfigurationValidator> validator;
|
private final Class<? extends TenantConfigurationValidator> validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* the property key name
|
* the property key name
|
||||||
* @param allowedValues
|
* @param defaultKeyName
|
||||||
* the allowed values for this specific key
|
* the allowed values for this specific key
|
||||||
|
* @param dataType
|
||||||
|
* the class of the property
|
||||||
|
* @param defaultValue
|
||||||
|
* value which should be returned, in case there is no value in
|
||||||
|
* the database
|
||||||
|
* @param validator
|
||||||
|
* Validator which validates, that property is of correct format
|
||||||
*/
|
*/
|
||||||
private TenantConfigurationKey(final String key, final String defaultKeyName, final Class<?> dataType,
|
private TenantConfigurationKey(final String key, final String defaultKeyName, final Class<?> dataType,
|
||||||
final String defaultValue, final Class<? extends TenantConfigurationValidator> validator) {
|
final String defaultValue, final Class<? extends TenantConfigurationValidator> validator) {
|
||||||
@@ -96,7 +104,6 @@ public enum TenantConfigurationKey {
|
|||||||
this.defaultKeyName = defaultKeyName;
|
this.defaultKeyName = defaultKeyName;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
this.validator = validator;
|
this.validator = validator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,17 +145,14 @@ public enum TenantConfigurationKey {
|
|||||||
* @param value
|
* @param value
|
||||||
* which will be validated
|
* which will be validated
|
||||||
* @throws TenantConfigurationValidatorException
|
* @throws TenantConfigurationValidatorException
|
||||||
* is thrown when object is invalid.
|
* is thrown, when object is invalid
|
||||||
*/
|
*/
|
||||||
public void validate(final ApplicationContext context, final Object value)
|
public void validate(final ApplicationContext context, final Object value) {
|
||||||
throws TenantConfigurationValidatorException {
|
final TenantConfigurationValidator createdBean = context.getAutowireCapableBeanFactory().createBean(validator);
|
||||||
final TenantConfigurationValidator createBean = context.getAutowireCapableBeanFactory().createBean(validator);
|
|
||||||
try {
|
try {
|
||||||
createBean.validate(value);
|
createdBean.validate(value);
|
||||||
} catch (final TenantConfigurationValidatorException ex) {
|
|
||||||
throw ex;
|
|
||||||
} finally {
|
} finally {
|
||||||
context.getAutowireCapableBeanFactory().destroyBean(createBean);
|
context.getAutowireCapableBeanFactory().destroyBean(createdBean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,17 +160,15 @@ public enum TenantConfigurationKey {
|
|||||||
* @param keyName
|
* @param keyName
|
||||||
* name of the TenantConfigurationKey
|
* name of the TenantConfigurationKey
|
||||||
* @return the TenantConfigurationKey with the name keyName
|
* @return the TenantConfigurationKey with the name keyName
|
||||||
* @throws InvalidTenantConfigurationKeyException
|
|
||||||
* if there is no TenantConfigurationKey with the name keyName
|
|
||||||
*/
|
*/
|
||||||
public static TenantConfigurationKey fromKeyName(final String keyName)
|
public static TenantConfigurationKey fromKeyName(final String keyName) {
|
||||||
throws InvalidTenantConfigurationKeyException {
|
|
||||||
|
|
||||||
try {
|
final Optional<TenantConfigurationKey> optKey = Arrays.stream(TenantConfigurationKey.values())
|
||||||
return Arrays.stream(TenantConfigurationKey.values()).filter(conf -> conf.getKeyName().equals(keyName))
|
.filter(conf -> conf.getKeyName().equals(keyName)).findFirst();
|
||||||
.findFirst().get();
|
|
||||||
} catch (final NoSuchElementException e) {
|
if (optKey.isPresent()) {
|
||||||
|
return optKey.get();
|
||||||
|
}
|
||||||
throw new InvalidTenantConfigurationKeyException("The given configuration key name does not exist.");
|
throw new InvalidTenantConfigurationKeyException("The given configuration key name does not exist.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,12 @@ import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* specific tenant configuration validator, which validates that the given value
|
* This class is used to validate, that the property is a String and that it is
|
||||||
* is a String in the correct duration format..
|
* in the correct duration format.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class TenantConfigurationPollingDurationValidator implements TenantConfigurationValidator {
|
public class TenantConfigurationPollingDurationValidator implements TenantConfigurationValidator {
|
||||||
|
|
||||||
// private final ControllerPollProperties properties;
|
|
||||||
|
|
||||||
private final DurationHelper durationHelper = new DurationHelper();
|
private final DurationHelper durationHelper = new DurationHelper();
|
||||||
|
|
||||||
private final Duration minDuration;
|
private final Duration minDuration;
|
||||||
@@ -35,8 +34,6 @@ public class TenantConfigurationPollingDurationValidator implements TenantConfig
|
|||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
public TenantConfigurationPollingDurationValidator(final ControllerPollProperties properties) {
|
public TenantConfigurationPollingDurationValidator(final ControllerPollProperties properties) {
|
||||||
// this.properties = properties;
|
|
||||||
|
|
||||||
minDuration = durationHelper.formattedStringToDuration(properties.getMinPollingTime());
|
minDuration = durationHelper.formattedStringToDuration(properties.getMinPollingTime());
|
||||||
maxDuration = durationHelper.formattedStringToDuration(properties.getMaxPollingTime());
|
maxDuration = durationHelper.formattedStringToDuration(properties.getMaxPollingTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class HttpControllerPreAuthenticateSecurityTokenFilter extends AbstractHt
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param systemManagement
|
* @param tenantConfigurationManagement
|
||||||
* the system management service to retrieve configuration
|
* the system management service to retrieve configuration
|
||||||
* properties
|
* properties
|
||||||
* @param tenantAware
|
* @param tenantAware
|
||||||
@@ -44,6 +44,8 @@ public class HttpControllerPreAuthenticateSecurityTokenFilter extends AbstractHt
|
|||||||
* @param controllerManagement
|
* @param controllerManagement
|
||||||
* the controller management to retrieve the specific target
|
* the controller management to retrieve the specific target
|
||||||
* security token to verify
|
* security token to verify
|
||||||
|
* @param systemSecurityContext
|
||||||
|
* the system security context
|
||||||
*/
|
*/
|
||||||
public HttpControllerPreAuthenticateSecurityTokenFilter(
|
public HttpControllerPreAuthenticateSecurityTokenFilter(
|
||||||
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
|
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
|
||||||
|
|||||||
@@ -27,12 +27,17 @@ public class HttpControllerPreAuthenticatedGatewaySecurityTokenFilter
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
* @param tenantConfigurationManagement
|
||||||
|
* the system management service to retrieve configuration
|
||||||
|
* properties
|
||||||
* @param systemManagement
|
* @param systemManagement
|
||||||
* the system management service to retrieve configuration
|
* the system management service to retrieve configuration
|
||||||
* properties
|
* properties
|
||||||
* @param tenantAware
|
* @param tenantAware
|
||||||
* the tenant aware service to get configuration for the specific
|
* the tenant aware service to get configuration for the specific
|
||||||
* tenant
|
* tenant
|
||||||
|
* @param systemSecurityContext
|
||||||
|
* * @param systemSecurityContext the system security context
|
||||||
*/
|
*/
|
||||||
public HttpControllerPreAuthenticatedGatewaySecurityTokenFilter(
|
public HttpControllerPreAuthenticatedGatewaySecurityTokenFilter(
|
||||||
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
|
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
|
||||||
|
|||||||
@@ -35,13 +35,15 @@ public class HttpControllerPreAuthenticatedSecurityHeaderFilter extends Abstract
|
|||||||
* @param caAuthorityNameHeader
|
* @param caAuthorityNameHeader
|
||||||
* the http-header which holds the ca-authority name of the
|
* the http-header which holds the ca-authority name of the
|
||||||
* certificate
|
* certificate
|
||||||
* @param systemManagement
|
* @param tenantConfigurationManagement
|
||||||
* the system management service to retrieve configuration
|
* the tenant configuration management service to retrieve
|
||||||
* properties to check if the header authentication is enabled
|
* configuration properties to check if the header authentication
|
||||||
* for this tenant
|
* is enabled for this tenant
|
||||||
* @param tenantAware
|
* @param tenantAware
|
||||||
* the tenant aware service to get configuration for the specific
|
* the tenant aware service to get configuration for the specific
|
||||||
* tenant
|
* tenant
|
||||||
|
* @param systemSecurityContext
|
||||||
|
* the system security context
|
||||||
*/
|
*/
|
||||||
public HttpControllerPreAuthenticatedSecurityHeaderFilter(final String caCommonNameHeader,
|
public HttpControllerPreAuthenticatedSecurityHeaderFilter(final String caCommonNameHeader,
|
||||||
final String caAuthorityNameHeader, final TenantConfigurationManagement tenantConfigurationManagement,
|
final String caAuthorityNameHeader, final TenantConfigurationManagement tenantConfigurationManagement,
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||||
public <T> TenantConfigurationValue<T> getConfigurationValue(final TenantConfigurationKey configurationKey,
|
public <T> TenantConfigurationValue<T> getConfigurationValue(final TenantConfigurationKey configurationKey,
|
||||||
final Class<T> propertyType) throws TenantConfigurationValidatorException {
|
final Class<T> propertyType) {
|
||||||
|
|
||||||
if (!configurationKey.getDataType().isAssignableFrom(propertyType)) {
|
if (!configurationKey.getDataType().isAssignableFrom(propertyType)) {
|
||||||
throw new TenantConfigurationValidatorException(
|
throw new TenantConfigurationValidatorException(
|
||||||
@@ -130,8 +130,7 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
* {@code propertyType}
|
* {@code propertyType}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||||
public TenantConfigurationValue<?> getConfigurationValue(final TenantConfigurationKey configurationKey)
|
public TenantConfigurationValue<?> getConfigurationValue(final TenantConfigurationKey configurationKey) {
|
||||||
throws TenantConfigurationValidatorException {
|
|
||||||
return getConfigurationValue(configurationKey, configurationKey.getDataType());
|
return getConfigurationValue(configurationKey, configurationKey.getDataType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,8 +155,8 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
* {@code propertyType}
|
* {@code propertyType}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||||
public <T> T getGlobalConfigurationValue(final TenantConfigurationKey configurationKey, final Class<T> propertyType)
|
public <T> T getGlobalConfigurationValue(final TenantConfigurationKey configurationKey,
|
||||||
throws TenantConfigurationValidatorException {
|
final Class<T> propertyType) {
|
||||||
|
|
||||||
if (!configurationKey.getDataType().isAssignableFrom(propertyType)) {
|
if (!configurationKey.getDataType().isAssignableFrom(propertyType)) {
|
||||||
throw new TenantConfigurationValidatorException(
|
throw new TenantConfigurationValidatorException(
|
||||||
@@ -167,12 +166,13 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
|
|
||||||
final T valueInProperties = environment.getProperty(configurationKey.getDefaultKeyName(), propertyType);
|
final T valueInProperties = environment.getProperty(configurationKey.getDefaultKeyName(), propertyType);
|
||||||
|
|
||||||
if (valueInProperties != null) {
|
if (valueInProperties == null) {
|
||||||
return valueInProperties;
|
|
||||||
}
|
|
||||||
return conversionService.convert(configurationKey.getDefaultValue(), propertyType);
|
return conversionService.convert(configurationKey.getDefaultValue(), propertyType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return valueInProperties;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds or updates a specific configuration for a specific tenant.
|
* Adds or updates a specific configuration for a specific tenant.
|
||||||
*
|
*
|
||||||
@@ -206,14 +206,11 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
|
|
||||||
TenantConfiguration tenantConfiguration = tenantConfigurationRepository
|
TenantConfiguration tenantConfiguration = tenantConfigurationRepository
|
||||||
.findByKey(configurationKey.getKeyName());
|
.findByKey(configurationKey.getKeyName());
|
||||||
if (tenantConfiguration != null)
|
|
||||||
|
|
||||||
{
|
if (tenantConfiguration == null) {
|
||||||
tenantConfiguration.setValue(value.toString());
|
|
||||||
} else
|
|
||||||
|
|
||||||
{
|
|
||||||
tenantConfiguration = new TenantConfiguration(configurationKey.getKeyName(), value.toString());
|
tenantConfiguration = new TenantConfiguration(configurationKey.getKeyName(), value.toString());
|
||||||
|
} else {
|
||||||
|
tenantConfiguration.setValue(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
final TenantConfiguration updatedTenantConfiguration = tenantConfigurationRepository.save(tenantConfiguration);
|
final TenantConfiguration updatedTenantConfiguration = tenantConfigurationRepository.save(tenantConfiguration);
|
||||||
|
|||||||
@@ -320,13 +320,14 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
* before this method returns {@code null}
|
* before this method returns {@code null}
|
||||||
*/
|
*/
|
||||||
public PollStatus getPollStatus() {
|
public PollStatus getPollStatus() {
|
||||||
if (lastTargetQuery != null) {
|
if (lastTargetQuery == null) {
|
||||||
final Duration pollTime = durationHelper.formattedStringToDuration(TenantConfigurationManagement
|
return null;
|
||||||
.getInstance().getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class)
|
}
|
||||||
.getValue());
|
|
||||||
final Duration overdueTime = durationHelper
|
final Duration pollTime = durationHelper.formattedStringToDuration(TenantConfigurationManagement.getInstance()
|
||||||
.formattedStringToDuration(TenantConfigurationManagement.getInstance()
|
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue());
|
||||||
.getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class)
|
final Duration overdueTime = durationHelper.formattedStringToDuration(TenantConfigurationManagement
|
||||||
|
.getInstance().getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class)
|
||||||
.getValue());
|
.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),
|
||||||
@@ -335,8 +336,6 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
final LocalDateTime overdueDate = nextPollDate.plus(overdueTime);
|
final LocalDateTime overdueDate = nextPollDate.plus(overdueTime);
|
||||||
return new PollStatus(lastPollDate, nextPollDate, overdueDate, currentDate);
|
return new PollStatus(lastPollDate, nextPollDate, overdueDate, currentDate);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The poll time object which holds all the necessary information around the
|
* The poll time object which holds all the necessary information around the
|
||||||
@@ -378,23 +377,14 @@ public class TargetInfo implements Persistable<Long>, Serializable {
|
|||||||
return lastPollDate;
|
return lastPollDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the nextPollDate
|
|
||||||
*/
|
|
||||||
public LocalDateTime getNextPollDate() {
|
public LocalDateTime getNextPollDate() {
|
||||||
return nextPollDate;
|
return nextPollDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the overdueDate
|
|
||||||
*/
|
|
||||||
public LocalDateTime getOverdueDate() {
|
public LocalDateTime getOverdueDate() {
|
||||||
return overdueDate;
|
return overdueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the current date
|
|
||||||
*/
|
|
||||||
public LocalDateTime getCurrentDate() {
|
public LocalDateTime getCurrentDate() {
|
||||||
return currentDate;
|
return currentDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,16 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
*/
|
*/
|
||||||
public class TenantConfigurationValue<T> {
|
public class TenantConfigurationValue<T> {
|
||||||
|
|
||||||
|
private T value;
|
||||||
|
private Long lastModifiedAt;
|
||||||
|
private String lastModifiedBy;
|
||||||
|
private Long createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private boolean isGlobal = true;
|
||||||
|
|
||||||
private TenantConfigurationValue() {
|
private TenantConfigurationValue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private T value = null;
|
|
||||||
private boolean isGlobal = true;
|
|
||||||
private Long lastModifiedAt = null;
|
|
||||||
private String lastModifiedBy = null;
|
|
||||||
private Long createdAt = null;
|
|
||||||
private String createdBy = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value.
|
* Gets the value.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,20 +15,25 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A json annotated rest model for a tenant configuration value to RESTful API
|
||||||
|
* representation.
|
||||||
|
*
|
||||||
|
*/
|
||||||
@JsonInclude(Include.NON_NULL)
|
@JsonInclude(Include.NON_NULL)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public class TenantConfigurationValueRest extends ResourceSupport {
|
public class TenantConfigurationValueRest extends ResourceSupport {
|
||||||
|
|
||||||
@JsonInclude(Include.ALWAYS)
|
@JsonInclude(Include.ALWAYS)
|
||||||
private Object value = null;
|
private Object value;
|
||||||
|
|
||||||
@JsonInclude(Include.ALWAYS)
|
@JsonInclude(Include.ALWAYS)
|
||||||
private boolean isGlobal = true;
|
private boolean isGlobal = true;
|
||||||
|
|
||||||
private Long lastModifiedAt = null;
|
private Long lastModifiedAt;
|
||||||
private String lastModifiedBy = null;
|
private String lastModifiedBy;
|
||||||
private Long createdAt = null;
|
private Long createdAt;
|
||||||
private String createdBy = null;
|
private String createdBy;
|
||||||
|
|
||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -39,14 +39,8 @@ import com.vaadin.ui.VerticalLayout;
|
|||||||
public class AuthenticationConfigurationView extends BaseConfigurationView
|
public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||||
implements ConfigurationGroup, ConfigurationItem.ConfigurationItemChangeListener, ValueChangeListener {
|
implements ConfigurationGroup, ConfigurationItem.ConfigurationItemChangeListener, ValueChangeListener {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
|
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -119,13 +113,6 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
|||||||
setCompositionRoot(rootPanel);
|
setCompositionRoot(rootPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup#save
|
|
||||||
* ()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
certificateAuthenticationConfigurationItem.save();
|
certificateAuthenticationConfigurationItem.save();
|
||||||
@@ -133,13 +120,6 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
|||||||
gatewaySecurityTokenAuthenticationConfigurationItem.save();
|
gatewaySecurityTokenAuthenticationConfigurationItem.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup#undo
|
|
||||||
* ()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {
|
public void undo() {
|
||||||
certificateAuthenticationConfigurationItem.undo();
|
certificateAuthenticationConfigurationItem.undo();
|
||||||
@@ -155,20 +135,17 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
|||||||
notifyConfigurationChanged();
|
notifyConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.
|
|
||||||
* data.Property. ValueChangeEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
public void valueChange(final ValueChangeEvent event) {
|
||||||
|
|
||||||
if (event.getProperty() instanceof CheckBox) {
|
if (!(event.getProperty() instanceof CheckBox)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notifyConfigurationChanged();
|
notifyConfigurationChanged();
|
||||||
|
|
||||||
CheckBox checkBox = (CheckBox) event.getProperty();
|
final CheckBox checkBox = (CheckBox) event.getProperty();
|
||||||
AuthenticationConfigurationItem configurationItem = null;
|
AuthenticationConfigurationItem configurationItem;
|
||||||
|
|
||||||
if (checkBox == gatewaySecTokenCheckBox) {
|
if (checkBox == gatewaySecTokenCheckBox) {
|
||||||
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
|
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
|
||||||
@@ -185,7 +162,5 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
|||||||
} else {
|
} else {
|
||||||
configurationItem.configDisable();
|
configurationItem.configDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* represents an configurationItem, which can be modified by the user
|
||||||
|
*/
|
||||||
public interface ConfigurationItem {
|
public interface ConfigurationItem {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ import com.vaadin.ui.VerticalLayout;
|
|||||||
*/
|
*/
|
||||||
@SpringView(name = TenantConfigurationDashboardView.VIEW_NAME, ui = HawkbitUI.class)
|
@SpringView(name = TenantConfigurationDashboardView.VIEW_NAME, ui = HawkbitUI.class)
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class TenantConfigurationDashboardView extends CustomComponent
|
public class TenantConfigurationDashboardView extends CustomComponent implements View, ConfigurationItemChangeListener {
|
||||||
implements View, ConfigurationItemChangeListener {
|
|
||||||
|
|
||||||
public static final String VIEW_NAME = "spSystemConfig";
|
public static final String VIEW_NAME = "spSystemConfig";
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -68,7 +67,7 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
|||||||
private Button saveConfigurationBtn;
|
private Button saveConfigurationBtn;
|
||||||
private Button undoConfigurationBtn;
|
private Button undoConfigurationBtn;
|
||||||
|
|
||||||
private List<ConfigurationGroup> configurationViews = new ArrayList<ConfigurationGroup>();
|
private final List<ConfigurationGroup> configurationViews = new ArrayList<ConfigurationGroup>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init method adds all Configuration Views to the list of Views.
|
* init method adds all Configuration Views to the list of Views.
|
||||||
@@ -91,9 +90,7 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
|||||||
rootLayout.setMargin(true);
|
rootLayout.setMargin(true);
|
||||||
rootLayout.setSpacing(true);
|
rootLayout.setSpacing(true);
|
||||||
|
|
||||||
configurationViews.forEach(view -> {
|
configurationViews.forEach(view -> rootLayout.addComponent(view));
|
||||||
rootLayout.addComponent(view);
|
|
||||||
});
|
|
||||||
|
|
||||||
final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
|
final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
|
||||||
rootLayout.addComponent(buttonContent);
|
rootLayout.addComponent(buttonContent);
|
||||||
@@ -101,9 +98,7 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
|||||||
rootPanel.setContent(rootLayout);
|
rootPanel.setContent(rootLayout);
|
||||||
setCompositionRoot(rootPanel);
|
setCompositionRoot(rootPanel);
|
||||||
|
|
||||||
configurationViews.forEach(view -> {
|
configurationViews.forEach(view -> view.addChangeListener(this));
|
||||||
view.addChangeListener(this);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout saveConfigurationButtonsLayout() {
|
private HorizontalLayout saveConfigurationButtonsLayout() {
|
||||||
@@ -132,23 +127,18 @@ public class TenantConfigurationDashboardView extends CustomComponent
|
|||||||
|
|
||||||
private void saveConfiguration() {
|
private void saveConfiguration() {
|
||||||
|
|
||||||
boolean isUserInputValid = configurationViews.stream().allMatch(confView -> {
|
final boolean isUserInputValid = configurationViews.stream().allMatch(confView -> confView.isUserInputValid());
|
||||||
return confView.isUserInputValid();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isUserInputValid) {
|
if (!isUserInputValid) {
|
||||||
configurationViews.forEach(confView -> {
|
uINotification.displayValidationError(i18n.get("notification.configuration.save.notpossible"));
|
||||||
confView.save();
|
return;
|
||||||
});
|
}
|
||||||
|
configurationViews.forEach(confView -> confView.save());
|
||||||
|
|
||||||
// More methods
|
// More methods
|
||||||
saveConfigurationBtn.setEnabled(false);
|
saveConfigurationBtn.setEnabled(false);
|
||||||
undoConfigurationBtn.setEnabled(false);
|
undoConfigurationBtn.setEnabled(false);
|
||||||
uINotification.displaySuccess(i18n.get("notification.configuration.save.successful"));
|
uINotification.displaySuccess(i18n.get("notification.configuration.save.successful"));
|
||||||
|
|
||||||
} else {
|
|
||||||
uINotification.displayValidationError(i18n.get("notification.configuration.save.notpossible"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void undoConfiguration() {
|
private void undoConfiguration() {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ab abstract authentication configuration item.
|
* abstract authentication configuration item.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -28,9 +28,6 @@ import com.vaadin.ui.VerticalLayout;
|
|||||||
abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLayout
|
abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLayout
|
||||||
implements AuthenticationConfigurationItem {
|
implements AuthenticationConfigurationItem {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final TenantConfigurationKey configurationKey;
|
private final TenantConfigurationKey configurationKey;
|
||||||
@@ -59,17 +56,9 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
|
|||||||
addComponent(SPUIComponentProvider.getLabel(labelText, SPUILabelDefinitions.SP_LABEL_SIMPLE));
|
addComponent(SPUIComponentProvider.getLabel(labelText, SPUILabelDefinitions.SP_LABEL_SIMPLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
|
|
||||||
* TenantConfigurationItem# isConfigEnabled()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConfigEnabled() {
|
public boolean isConfigEnabled() {
|
||||||
final boolean b = tenantConfigurationManagement.getConfigurationValue(configurationKey, Boolean.class)
|
return tenantConfigurationManagement.getConfigurationValue(configurationKey, Boolean.class).getValue();
|
||||||
.getValue();
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,14 +79,6 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
|
|||||||
configurationChangeListeners.forEach(listener -> listener.configurationHasChanged());
|
configurationChangeListeners.forEach(listener -> listener.configurationHasChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
|
|
||||||
* TenantConfigurationItem# addConfigurationChangeListener
|
|
||||||
* (hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem.
|
|
||||||
* TenantConfigurationChangeListener)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addChangeListener(final ConfigurationItemChangeListener listener) {
|
public void addChangeListener(final ConfigurationItemChangeListener listener) {
|
||||||
configurationChangeListeners.add(listener);
|
configurationChangeListeners.add(listener);
|
||||||
|
|||||||
@@ -87,9 +87,10 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
if (configurationEnabledChange) {
|
if (!configurationEnabledChange) {
|
||||||
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
|
return;
|
||||||
}
|
}
|
||||||
|
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -56,14 +56,18 @@ public class DurationConfigField extends GridLayout implements ValueChangeListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
public void valueChange(final ValueChangeEvent event) {
|
||||||
if (event.getProperty() == checkBox) {
|
if (event.getProperty() != checkBox) {
|
||||||
if (checkBox.getValue()) {
|
return;
|
||||||
durationField.setEnabled(true);
|
}
|
||||||
} else {
|
|
||||||
|
durationField.setEnabled(checkBox.getValue());
|
||||||
|
|
||||||
|
if (!checkBox.getValue()) {
|
||||||
durationField.setDuration(globalDuration);
|
durationField.setDuration(globalDuration);
|
||||||
|
}
|
||||||
|
|
||||||
durationField.setEnabled(false);
|
durationField.setEnabled(false);
|
||||||
}
|
|
||||||
}
|
|
||||||
notifyConfigurationChanged();
|
notifyConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,12 +106,13 @@ public class DurationConfigField extends GridLayout implements ValueChangeListen
|
|||||||
checkBox.setValue(false);
|
checkBox.setValue(false);
|
||||||
durationField.setDuration(globalDuration);
|
durationField.setDuration(globalDuration);
|
||||||
durationField.setEnabled(false);
|
durationField.setEnabled(false);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
checkBox.setValue(true);
|
checkBox.setValue(true);
|
||||||
durationField.setDuration(tenantDuration);
|
durationField.setDuration(tenantDuration);
|
||||||
durationField.setEnabled(true);
|
durationField.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the duration of the duration field or null, when the user has
|
* @return the duration of the duration field or null, when the user has
|
||||||
|
|||||||
@@ -108,7 +108,9 @@ public class DurationField extends DateField {
|
|||||||
// method. This method overwrites the super method, which is
|
// method. This method overwrites the super method, which is
|
||||||
// necessary, that parsing works correctly on pressing enter key
|
// necessary, that parsing works correctly on pressing enter key
|
||||||
|
|
||||||
if (event.getProperty() instanceof DurationField) {
|
if (!(event.getProperty() instanceof DurationField)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final Date value = (Date) event.getProperty().getValue();
|
final Date value = (Date) event.getProperty().getValue();
|
||||||
|
|
||||||
// setValue() calls valueChanged again, when the minimum is greater
|
// setValue() calls valueChanged again, when the minimum is greater
|
||||||
@@ -125,7 +127,6 @@ public class DurationField extends DateField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(final Date value) throws InvalidValueException {
|
public void validate(final Date value) throws InvalidValueException {
|
||||||
|
|||||||
Reference in New Issue
Block a user