Merge pull request #56 from bsinno/feature_MECS-86_tenant_specific_polling_configuration

Feature: tenant specific polling configuration

Note: @fabnon is member of @michahirsch and my organisation
This commit is contained in:
Kai Zimmermann
2016-03-14 16:37:46 +01:00
69 changed files with 2742 additions and 756 deletions

View File

@@ -8,16 +8,13 @@
*/
package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.AuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.GatewaySecurityTokenAuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.TargetSecurityTokenAuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.TenantConfigurationItem;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,7 +23,6 @@ import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
@@ -40,17 +36,11 @@ import com.vaadin.ui.VerticalLayout;
*/
@SpringComponent
@ViewScope
public class AuthenticationConfigurationView extends CustomComponent
implements ConfigurationGroup, TenantConfigurationItem.TenantConfigurationChangeListener {
public class AuthenticationConfigurationView extends BaseConfigurationView
implements ConfigurationGroup, ConfigurationItem.ConfigurationItemChangeListener, ValueChangeListener {
/**
*
*/
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
/**
*
*/
private static final long serialVersionUID = 1L;
@Autowired
@@ -65,8 +55,6 @@ public class AuthenticationConfigurationView extends CustomComponent
@Autowired
private GatewaySecurityTokenAuthenticationConfigurationItem gatewaySecurityTokenAuthenticationConfigurationItem;
private final List<ConfigurationGroupChangeListener> configurationChangeListeners = new ArrayList<>();
private CheckBox gatewaySecTokenCheckBox;
private CheckBox targetSecTokenCheckBox;
@@ -100,42 +88,31 @@ public class AuthenticationConfigurationView extends CustomComponent
certificateAuthCheckbox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
certificateAuthCheckbox.setValue(certificateAuthenticationConfigurationItem.isConfigEnabled());
certificateAuthCheckbox.addValueChangeListener(new AuthenticationTenantConfigurationItemChangeListener(
certificateAuthCheckbox, certificateAuthenticationConfigurationItem));
certificateAuthenticationConfigurationItem.addConfigurationChangeListener(this);
certificateAuthCheckbox.addValueChangeListener(this);
certificateAuthenticationConfigurationItem.addChangeListener(this);
gridLayout.addComponent(certificateAuthCheckbox, 0, 0);
gridLayout.addComponent(certificateAuthenticationConfigurationItem, 1, 0);
targetSecTokenCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
targetSecTokenCheckBox.setValue(targetSecurityTokenAuthenticationConfigurationItem.isConfigEnabled());
targetSecTokenCheckBox.addValueChangeListener(new AuthenticationTenantConfigurationItemChangeListener(
targetSecTokenCheckBox, targetSecurityTokenAuthenticationConfigurationItem));
targetSecurityTokenAuthenticationConfigurationItem.addConfigurationChangeListener(this);
targetSecTokenCheckBox.addValueChangeListener(this);
targetSecurityTokenAuthenticationConfigurationItem.addChangeListener(this);
gridLayout.addComponent(targetSecTokenCheckBox, 0, 1);
gridLayout.addComponent(targetSecurityTokenAuthenticationConfigurationItem, 1, 1);
gatewaySecTokenCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
gatewaySecTokenCheckBox.setId("gatewaysecuritycheckbox");
gatewaySecTokenCheckBox.setValue(gatewaySecurityTokenAuthenticationConfigurationItem.isConfigEnabled());
gatewaySecTokenCheckBox.addValueChangeListener(new AuthenticationTenantConfigurationItemChangeListener(
gatewaySecTokenCheckBox, gatewaySecurityTokenAuthenticationConfigurationItem));
gatewaySecurityTokenAuthenticationConfigurationItem.addConfigurationChangeListener(this);
gatewaySecTokenCheckBox.addValueChangeListener(this);
gatewaySecurityTokenAuthenticationConfigurationItem.addChangeListener(this);
gridLayout.addComponent(gatewaySecTokenCheckBox, 0, 2);
gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, 2);
vLayout.addComponent(gridLayout);
rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup#save
* ()
*/
@Override
public void save() {
certificateAuthenticationConfigurationItem.save();
@@ -143,13 +120,6 @@ public class AuthenticationConfigurationView extends CustomComponent
gatewaySecurityTokenAuthenticationConfigurationItem.save();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup#undo
* ()
*/
@Override
public void undo() {
certificateAuthenticationConfigurationItem.undo();
@@ -160,47 +130,37 @@ public class AuthenticationConfigurationView extends CustomComponent
gatewaySecTokenCheckBox.setValue(gatewaySecurityTokenAuthenticationConfigurationItem.isConfigEnabled());
}
private void notifyConfigurationChanged() {
configurationChangeListeners.forEach(listener -> listener.configurationChanged());
}
@Override
public void addChangeListener(final ConfigurationGroupChangeListener listener) {
configurationChangeListeners.add(listener);
}
@Override
public void configurationHasChanged() {
notifyConfigurationChanged();
}
private final class AuthenticationTenantConfigurationItemChangeListener implements ValueChangeListener {
@Override
public void valueChange(final ValueChangeEvent event) {
private static final long serialVersionUID = 1L;
private final CheckBox checkBox;
private final TenantConfigurationItem configurationItem;
private AuthenticationTenantConfigurationItemChangeListener(final CheckBox checkBox,
final TenantConfigurationItem configurationItem) {
this.checkBox = checkBox;
this.configurationItem = configurationItem;
if (!(event.getProperty() instanceof CheckBox)) {
return;
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.
* data.Property. ValueChangeEvent)
*/
@Override
public void valueChange(final ValueChangeEvent event) {
notifyConfigurationChanged();
if (checkBox.getValue()) {
configurationItem.configEnable();
} else {
configurationItem.configDisable();
}
notifyConfigurationChanged();
final CheckBox checkBox = (CheckBox) event.getProperty();
AuthenticationConfigurationItem configurationItem;
if (checkBox == gatewaySecTokenCheckBox) {
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
} else if (checkBox == targetSecTokenCheckBox) {
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
} else if (checkBox == certificateAuthCheckbox) {
configurationItem = certificateAuthenticationConfigurationItem;
} else {
return;
}
if (checkBox.getValue()) {
configurationItem.configEnable();
} else {
configurationItem.configDisable();
}
}
}

View File

@@ -0,0 +1,42 @@
/**
* 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.ui.tenantconfiguration;
import java.util.ArrayList;
import java.util.List;
import com.vaadin.ui.CustomComponent;
/**
* base class for all configuration views. This class implements the logic for
* the handling of the
*
*/
public abstract class BaseConfigurationView extends CustomComponent implements ConfigurationGroup {
private static final long serialVersionUID = 1L;
private final List<ConfigurationItemChangeListener> configurationChangeListeners = new ArrayList<>();
protected void notifyConfigurationChanged() {
configurationChangeListeners.forEach(listener -> listener.configurationHasChanged());
}
@Override
public void addChangeListener(final ConfigurationItemChangeListener listener) {
configurationChangeListeners.add(listener);
}
@Override
public boolean isUserInputValid() {
// default return value is true, because often user can only choose from
// different valid options.
return true;
}
}

View File

@@ -8,14 +8,14 @@
*/
package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.io.Serializable;
import com.vaadin.ui.Component;
/**
*
*
*
*/
public interface ConfigurationGroup {
public interface ConfigurationGroup extends Component, ConfigurationItem {
/**
* called to store any configuration changes.
@@ -26,29 +26,4 @@ public interface ConfigurationGroup {
* called to rollback any configuration changes.
*/
void undo();
/**
* Adds a configuration change listener to notify about configuration
* changes.
*
* @param listener
* the listener to be notified in case the item changes some
* configuration
*/
void addChangeListener(ConfigurationGroupChangeListener listener);
/**
* Configuration Change Listener to be notified about configuration changes
* in configuration group.
*
*
*
*/
interface ConfigurationGroupChangeListener extends Serializable {
/**
* called to notify about configuration has been changed.
*/
void configurationChanged();
}
}

View File

@@ -0,0 +1,47 @@
/**
* 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.ui.tenantconfiguration;
import java.io.Serializable;
/**
* represents an configurationItem, which can be modified by the user
*/
public interface ConfigurationItem {
/**
* called to verify that the Input done by the user is valid
*
* @return true when the data is valid, false otherwise
*/
boolean isUserInputValid();
/**
* Adds a configuration change listener to notify about configuration
* changes.
*
* @param listener
* the listener to be notified in case the item changes some
* configuration
*/
void addChangeListener(final ConfigurationItemChangeListener listener);
/**
* Configuration Change Listener to be notified about configuration changes
* in configuration group.
*
*/
@FunctionalInterface
interface ConfigurationItemChangeListener extends Serializable {
/**
* called to notify about configuration has been changed.
*/
void configurationHasChanged();
}
}

View File

@@ -8,9 +8,6 @@
*/
package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
@@ -29,7 +26,6 @@ import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
@@ -43,7 +39,7 @@ import com.vaadin.ui.VerticalLayout;
*/
@SpringComponent
@ViewScope
public class DefaultDistributionSetTypeLayout extends CustomComponent implements ConfigurationGroup {
public class DefaultDistributionSetTypeLayout extends BaseConfigurationView implements ConfigurationGroup {
private static final long serialVersionUID = 17896542758L;
@@ -66,8 +62,6 @@ public class DefaultDistributionSetTypeLayout extends CustomComponent implements
private Label changeIcon;
private final List<ConfigurationGroupChangeListener> configurationChangeListeners = new ArrayList<>();
/**
* Initialize Default Distribution Set layout.
*/
@@ -163,13 +157,4 @@ public class DefaultDistributionSetTypeLayout extends CustomComponent implements
changeIcon.setVisible(false);
}
}
private void notifyConfigurationChanged() {
configurationChangeListeners.forEach(listener -> listener.configurationChanged());
}
@Override
public void addChangeListener(final ConfigurationGroupChangeListener listener) {
configurationChangeListeners.add(listener);
}
}

View File

@@ -0,0 +1,168 @@
/**
* 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.ui.tenantconfiguration;
import java.time.Duration;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.tenantconfiguration.polling.DurationConfigField;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
/**
* View to configure the polling interval and the overdue time.
*
*
*/
@SpringComponent
@ViewScope
public class PollingConfigurationView extends BaseConfigurationView
implements ConfigurationGroup, ConfigurationItem.ConfigurationItemChangeListener {
private static final long serialVersionUID = 1L;
@Autowired
private I18N i18n;
@Autowired
private ControllerPollProperties controllerPollProperties;
@Autowired
private transient TenantConfigurationManagement tenantConfigurationManagement;
private DurationConfigField fieldPollTime = null;
private DurationConfigField fieldPollingOverdueTime = null;
private Duration minDuration;
private Duration maxDuration;
private Duration globalPollTime;
private Duration globalOverdueTime;
private Duration tenantPollTime = null;
private Duration tenantOverdueTime = null;
private final DurationHelper durationHelper = new DurationHelper();
/**
* Initialize Authentication Configuration layout.
*/
@PostConstruct
public void init() {
minDuration = durationHelper.formattedStringToDuration(controllerPollProperties.getMinPollingTime());
maxDuration = durationHelper.formattedStringToDuration(controllerPollProperties.getMaxPollingTime());
globalPollTime = durationHelper.formattedStringToDuration(tenantConfigurationManagement
.getGlobalConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class));
globalOverdueTime = durationHelper.formattedStringToDuration(tenantConfigurationManagement
.getGlobalConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class));
final TenantConfigurationValue<String> pollTimeConfValue = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class);
if (!pollTimeConfValue.isGlobal()) {
tenantPollTime = durationHelper.formattedStringToDuration(pollTimeConfValue.getValue());
}
final TenantConfigurationValue<String> overdueTimeConfValue = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class);
if (!overdueTimeConfValue.isGlobal()) {
tenantOverdueTime = durationHelper.formattedStringToDuration(overdueTimeConfValue.getValue());
}
final Panel rootPanel = new Panel();
rootPanel.setSizeFull();
rootPanel.addStyleName("config-panel");
final VerticalLayout vLayout = new VerticalLayout();
vLayout.setMargin(true);
final Label headerDisSetType = new Label(i18n.get("configuration.polling.title"));
headerDisSetType.addStyleName("config-panel-header");
vLayout.addComponent(headerDisSetType);
fieldPollTime = DurationConfigField.builder().caption(i18n.get("configuration.polling.time"))
.checkBoxTooltip(i18n.get("configuration.polling.custom.value")).range(minDuration, maxDuration)
.globalDuration(globalPollTime).tenantDuration(tenantPollTime).build();
fieldPollTime.addChangeListener(this);
vLayout.addComponent(fieldPollTime);
fieldPollingOverdueTime = DurationConfigField.builder().caption(i18n.get("configuration.polling.overduetime"))
.checkBoxTooltip(i18n.get("configuration.polling.custom.value")).range(minDuration, maxDuration)
.globalDuration(globalOverdueTime).tenantDuration(tenantOverdueTime).build();
fieldPollingOverdueTime.addChangeListener(this);
vLayout.addComponent(fieldPollingOverdueTime);
rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel);
}
@Override
public void save() {
// make sure values are only saved, when the value has been changed
if (!compareDurations(tenantPollTime, fieldPollTime.getValue())) {
tenantPollTime = fieldPollTime.getValue();
saveDurationConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, tenantPollTime);
}
if (!compareDurations(tenantOverdueTime, fieldPollingOverdueTime.getValue())) {
tenantOverdueTime = fieldPollingOverdueTime.getValue();
saveDurationConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, tenantOverdueTime);
}
}
private void saveDurationConfigurationValue(final TenantConfigurationKey key, final Duration duration) {
if (duration == null) {
tenantConfigurationManagement.deleteConfiguration(key);
} else {
tenantConfigurationManagement.addOrUpdateConfiguration(key,
durationHelper.durationToFormattedString(duration));
}
}
@Override
public void undo() {
fieldPollTime.setValue(tenantPollTime);
fieldPollingOverdueTime.setValue(tenantOverdueTime);
}
@Override
public boolean isUserInputValid() {
return fieldPollTime.isUserInputValid() && fieldPollingOverdueTime.isUserInputValid();
}
@Override
public void configurationHasChanged() {
notifyConfigurationChanged();
}
private boolean compareDurations(final Duration d1, final Duration d2) {
if (d1 == null && d2 == null) {
return true;
}
if (d1 != null) {
return d1.equals(d2);
}
// d1 == null, d2 != null
return false;
}
}

View File

@@ -8,11 +8,16 @@
*/
package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.HawkbitUI;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationGroup.ConfigurationGroupChangeListener;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem.ConfigurationItemChangeListener;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -33,14 +38,13 @@ import com.vaadin.ui.VerticalLayout;
/**
* Main UI for the system configuration view.
*
*
*
*
*/
@SpringView(name = TenantConfigurationDashboardView.VIEW_NAME, ui = HawkbitUI.class)
@ViewScope
public class TenantConfigurationDashboardView extends CustomComponent
implements View, ConfigurationGroupChangeListener {
public class TenantConfigurationDashboardView extends CustomComponent implements View, ConfigurationItemChangeListener {
public static final String VIEW_NAME = "spSystemConfig";
private static final long serialVersionUID = 1L;
@@ -51,6 +55,9 @@ public class TenantConfigurationDashboardView extends CustomComponent
@Autowired
private AuthenticationConfigurationView authenticationConfigurationView;
@Autowired
private PollingConfigurationView pollingConfigurationView;
@Autowired
private I18N i18n;
@@ -63,6 +70,18 @@ public class TenantConfigurationDashboardView extends CustomComponent
private Button saveConfigurationBtn;
private Button undoConfigurationBtn;
private final List<ConfigurationGroup> configurationViews = new ArrayList<>();
/**
* init method adds all Configuration Views to the list of Views.
*/
@PostConstruct
public void init() {
configurationViews.add(defaultDistributionSetTypeLayout);
configurationViews.add(authenticationConfigurationView);
configurationViews.add(pollingConfigurationView);
}
@Override
public void enter(final ViewChangeEvent event) {
@@ -73,17 +92,16 @@ public class TenantConfigurationDashboardView extends CustomComponent
rootLayout.setSizeFull();
rootLayout.setMargin(true);
rootLayout.setSpacing(true);
rootLayout.addComponent(defaultDistributionSetTypeLayout);
rootLayout.addComponent(authenticationConfigurationView);
configurationViews.forEach(view -> rootLayout.addComponent(view));
final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
rootLayout.addComponent(buttonContent);
rootLayout.setComponentAlignment(buttonContent, Alignment.BOTTOM_LEFT);
rootPanel.setContent(rootLayout);
setCompositionRoot(rootPanel);
authenticationConfigurationView.addChangeListener(this);
defaultDistributionSetTypeLayout.addChangeListener(this);
configurationViews.forEach(view -> view.addChangeListener(this));
}
private HorizontalLayout saveConfigurationButtonsLayout() {
@@ -112,19 +130,25 @@ public class TenantConfigurationDashboardView extends CustomComponent
}
private void saveConfiguration() {
defaultDistributionSetTypeLayout.save();
authenticationConfigurationView.save();
final boolean isUserInputValid = configurationViews.stream().allMatch(confView -> confView.isUserInputValid());
if (!isUserInputValid) {
uINotification.displayValidationError(i18n.get("notification.configuration.save.notpossible"));
return;
}
configurationViews.forEach(confView -> confView.save());
// More methods
saveConfigurationBtn.setEnabled(false);
undoConfigurationBtn.setEnabled(false);
uINotification.displaySuccess(i18n.get("notification.configuration.save"));
uINotification.displaySuccess(i18n.get("notification.configuration.save.successful"));
}
private void undoConfiguration() {
defaultDistributionSetTypeLayout.undo();
authenticationConfigurationView.undo();
configurationViews.forEach(confView -> {
confView.undo();
});
// More methods
saveConfigurationBtn.setEnabled(false);
undoConfigurationBtn.setEnabled(false);
@@ -132,13 +156,13 @@ public class TenantConfigurationDashboardView extends CustomComponent
/*
* (non-Javadoc)
*
*
* @see
* org.eclipse.hawkbit.server.ui.tenantconfiguration.ConfigurationGroup.
* ConfigurationGroupChangeListener #configurationChanged()
*/
@Override
public void configurationChanged() {
public void configurationHasChanged() {
saveConfigurationBtn.setEnabled(true);
undoConfigurationBtn.setEnabled(true);
}

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -19,34 +19,33 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import com.vaadin.ui.VerticalLayout;
/**
* Ab abstract authentication configuration item.
* abstract authentication configuration item.
*
*
*
*
*/
abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLayout implements TenantConfigurationItem {
abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLayout
implements AuthenticationConfigurationItem {
/**
*
*/
private static final long serialVersionUID = 1L;
private final TenantConfigurationKey configurationKey;
private final transient SystemManagement systemManagement;
private final transient TenantConfigurationManagement tenantConfigurationManagement;
private final List<TenantConfigurationChangeListener> configurationChangeListeners = new ArrayList<>();
private final List<ConfigurationItemChangeListener> configurationChangeListeners = new ArrayList<>();
/**
* @param configurationKey
* the key for this configuration
* @param systemManagement
* the system management to retrive the configuration value
* @param tenantConfigurationManagement
* the tenant configuration management to retrieve the
* configuration value
*/
public AbstractAuthenticationTenantConfigurationItem(final TenantConfigurationKey configurationKey,
final SystemManagement systemManagement) {
final TenantConfigurationManagement tenantConfigurationManagement) {
this.configurationKey = configurationKey;
this.systemManagement = systemManagement;
this.tenantConfigurationManagement = tenantConfigurationManagement;
}
/**
@@ -57,22 +56,16 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
addComponent(SPUIComponentProvider.getLabel(labelText, SPUILabelDefinitions.SP_LABEL_SIMPLE));
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# isConfigEnabled()
*/
@Override
public boolean isConfigEnabled() {
return systemManagement.getConfigurationValue(configurationKey, Boolean.class);
return tenantConfigurationManagement.getConfigurationValue(configurationKey, Boolean.class).getValue();
}
/**
* @return the systemManagement
*/
protected SystemManagement getSystemManagement() {
return systemManagement;
protected TenantConfigurationManagement getTenantConfigurationManagement() {
return tenantConfigurationManagement;
}
/**
@@ -86,16 +79,13 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
configurationChangeListeners.forEach(listener -> listener.configurationHasChanged());
}
/*
* (non-Javadoc)
*
* @see org.eclipse.hawkbit.server.ui.tenantconfiguration.
* TenantConfigurationItem# addConfigurationChangeListener
* (hawkbit.server.ui.tenantconfiguration.TenantConfigurationItem.
* TenantConfigurationChangeListener)
*/
@Override
public void addConfigurationChangeListener(final TenantConfigurationChangeListener listener) {
public void addChangeListener(final ConfigurationItemChangeListener listener) {
configurationChangeListeners.add(listener);
}
@Override
public boolean isUserInputValid() {
return true;
}
}

View File

@@ -8,7 +8,7 @@
*/
package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import java.io.Serializable;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem;
import com.vaadin.ui.Component;
@@ -20,7 +20,7 @@ import com.vaadin.ui.Component;
*
*
*/
public interface TenantConfigurationItem extends Component {
public interface AuthenticationConfigurationItem extends Component, ConfigurationItem {
/**
* @return {@code true} if configuration is enabled, otherwise {@code false}
@@ -47,28 +47,4 @@ public interface TenantConfigurationItem extends Component {
*/
void undo();
/**
* Adds a configuration change listener to notify about configuration
* changes.
*
* @param listener
* the listener to be notified in case the item changes some
* configuration
*/
void addConfigurationChangeListener(TenantConfigurationChangeListener listener);
/**
* Configuration Change Listener to be notified about configuration changes
* in configuration item.
*
*
*
*/
@FunctionalInterface
interface TenantConfigurationChangeListener extends Serializable {
/**
* called to notify about configuration has been changed.
*/
void configurationHasChanged();
}
}

View File

@@ -10,8 +10,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -54,8 +53,9 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
* the system management to retrie the configuration
*/
@Autowired
public CertificateAuthenticationConfigurationItem(final SystemManagement systemManagement) {
super(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, systemManagement);
public CertificateAuthenticationConfigurationItem(
final TenantConfigurationManagement tenantConfigurationManagement) {
super(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, tenantConfigurationManagement);
}
/**
@@ -133,13 +133,12 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
@Override
public void save() {
if (configurationEnabledChange) {
getSystemManagement().addOrUpdateConfiguration(
new TenantConfiguration(getConfigurationKey().getKeyName(), String.valueOf(configurationEnabled)));
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
}
if (configurationCaRootAuthorityChanged) {
final String value = caRootAuthorityTextField.getValue() != null ? caRootAuthorityTextField.getValue() : "";
getSystemManagement().addOrUpdateConfiguration(new TenantConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME.getKeyName(), value));
getTenantConfigurationManagement()
.addOrUpdateConfiguration(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, value);
}
}
@@ -153,13 +152,15 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
configurationEnabledChange = false;
configurationCaRootAuthorityChanged = false;
configurationEnabled = getSystemManagement().getConfigurationValue(getConfigurationKey(), Boolean.class);
configurationEnabled = getTenantConfigurationManagement()
.getConfigurationValue(getConfigurationKey(), Boolean.class).getValue();
caRootAuthorityTextField.setValue(getCaRootAuthorityValue());
}
private String getCaRootAuthorityValue() {
return getSystemManagement()
.getConfigurationValue(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class);
return getTenantConfigurationManagement()
.getConfigurationValue(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)
.getValue();
}
private void setDetailVisible(final boolean visible) {

View File

@@ -10,8 +10,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -62,12 +61,12 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
private VerticalLayout detailLayout;
/**
* @param configurationKey
* @param systemManagement
* @param tenantConfigurationManagement
*/
@Autowired
public GatewaySecurityTokenAuthenticationConfigurationItem(final SystemManagement systemManagement) {
super(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, systemManagement);
public GatewaySecurityTokenAuthenticationConfigurationItem(
final TenantConfigurationManagement tenantConfigurationManagement) {
super(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, tenantConfigurationManagement);
}
/**
@@ -163,13 +162,13 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
}
private String getSecurityTokenName() {
return getSystemManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME, String.class);
return getTenantConfigurationManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME, String.class).getValue();
}
private String getSecurityTokenKey() {
return getSystemManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class);
return getTenantConfigurationManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class).getValue();
}
@Override
@@ -184,20 +183,19 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
@Override
public void save() {
if (configurationEnabledChange) {
getSystemManagement().addOrUpdateConfiguration(new TenantConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED.getKeyName(),
String.valueOf(configurationEnabled)));
getTenantConfigurationManagement().addOrUpdateConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, configurationEnabled);
}
if (keyNameChanged) {
getSystemManagement().addOrUpdateConfiguration(new TenantConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME.getKeyName(),
gatewayTokenNameTextField.getValue()));
getTenantConfigurationManagement().addOrUpdateConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME,
gatewayTokenNameTextField.getValue());
}
if (keyChanged) {
getSystemManagement().addOrUpdateConfiguration(new TenantConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY.getKeyName(),
gatewayTokenkeyLabel.getValue()));
getTenantConfigurationManagement().addOrUpdateConfiguration(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY,
gatewayTokenkeyLabel.getValue());
}
}

View File

@@ -10,8 +10,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,8 +43,9 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
* the system management to retrie the configuration
*/
@Autowired
public TargetSecurityTokenAuthenticationConfigurationItem(final SystemManagement systemManagement) {
super(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, systemManagement);
public TargetSecurityTokenAuthenticationConfigurationItem(
final TenantConfigurationManagement tenantConfigurationManagement) {
super(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, tenantConfigurationManagement);
}
/**
@@ -87,15 +87,16 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
@Override
public void save() {
if (configurationEnabledChange) {
getSystemManagement().addOrUpdateConfiguration(
new TenantConfiguration(getConfigurationKey().getKeyName(), String.valueOf(configurationEnabled)));
if (!configurationEnabledChange) {
return;
}
getTenantConfigurationManagement().addOrUpdateConfiguration(getConfigurationKey(), configurationEnabled);
}
@Override
public void undo() {
configurationEnabledChange = false;
configurationEnabled = getSystemManagement().getConfigurationValue(getConfigurationKey(), Boolean.class);
configurationEnabled = getTenantConfigurationManagement()
.getConfigurationValue(getConfigurationKey(), Boolean.class).getValue();
}
}

View File

@@ -0,0 +1,184 @@
/**
* 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.ui.tenantconfiguration.polling;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.GridLayout;
/**
* The DurationConfigField consists of three vaadin fields. A {@link #Label}
* {@link #DurationField} and a {@link #CheckBox}. The user can then enter a
* duration in the DurationField or he can configure using the global duration
* by changing the CheckBox.
*/
public class DurationConfigField extends GridLayout implements ConfigurationItem {
private static final long serialVersionUID = 1L;
private final List<ConfigurationItemChangeListener> configurationChangeListeners = new ArrayList<>();
private final CheckBox checkBox = new CheckBox();
private final DurationField durationField = new DurationField();
private Duration globalDuration;
private DurationConfigField() {
super(2, 2);
this.addStyleName("duration-config-field");
this.setSpacing(true);
this.setImmediate(true);
this.setColumnExpandRatio(1, 1.0F);
this.addComponent(checkBox, 0, 0);
this.setComponentAlignment(checkBox, Alignment.MIDDLE_LEFT);
this.addComponent(durationField, 1, 0);
this.setComponentAlignment(durationField, Alignment.MIDDLE_LEFT);
checkBox.addValueChangeListener(event->checkBoxChange());
durationField.addValueChangeListener(event->notifyConfigurationChanged());
}
private void checkBoxChange() {
durationField.setEnabled(checkBox.getValue());
if (!checkBox.getValue()) {
durationField.setDuration(globalDuration);
}
notifyConfigurationChanged();
}
/**
* has to be called before using, see Builder Implementation.
*
* @param tenantDuration
* tenant specific duration value
* @param globalDuration
* duration value which is stored in the global configuration
*/
private void init(final Duration globalDuration, final Duration tenantDuration) {
this.globalDuration = globalDuration;
this.setValue(tenantDuration);
}
private void setCheckBoxTooltip(final String label) {
checkBox.setDescription(label);
}
private void setAllowedRange(final Duration minimumDuration, final Duration maximumDuration) {
durationField.setMinimumDuration(minimumDuration);
durationField.setMaximumDuration(maximumDuration);
}
/**
* Set the value of the duration field
*
* @param tenantDuration
* duration which will be set in to the duration field, when
* {@code null} the global configuration will be used.
*/
public void setValue(final Duration tenantDuration) {
if (tenantDuration == null) {
// no tenant specific configuration
checkBox.setValue(false);
durationField.setDuration(globalDuration);
durationField.setEnabled(false);
return;
}
checkBox.setValue(true);
durationField.setDuration(tenantDuration);
durationField.setEnabled(true);
}
/**
* @return the duration of the duration field or null, when the user has
* configured to use the global value.
*/
public Duration getValue() {
if (checkBox.getValue()) {
return durationField.getDuration();
}
return null;
}
@Override
public boolean isUserInputValid() {
return !checkBox.getValue() || (durationField.isValid() && durationField.getValue() != null);
}
private void notifyConfigurationChanged() {
configurationChangeListeners.forEach(listener -> listener.configurationHasChanged());
}
@Override
public void addChangeListener(final ConfigurationItemChangeListener listener) {
configurationChangeListeners.add(listener);
}
public static DurationConfigFieldBuilder builder() {
return new DurationConfigFieldBuilder();
}
public static class DurationConfigFieldBuilder {
private final DurationConfigField field;
private Duration globalDuration = null;
private Duration tenantDuration = null;
private DurationConfigFieldBuilder() {
field = new DurationConfigField();
};
public DurationConfigFieldBuilder checkBoxTooltip(final String label) {
field.setCheckBoxTooltip(label);
return this;
}
public DurationConfigFieldBuilder globalDuration(final Duration globalDuration) {
this.globalDuration = globalDuration;
return this;
}
public DurationConfigFieldBuilder caption(final String caption) {
field.setCaption(caption);
return this;
}
public DurationConfigFieldBuilder range(final Duration minDuration, final Duration maxDuration) {
field.setAllowedRange(minDuration, maxDuration);
return this;
}
public DurationConfigFieldBuilder tenantDuration(final Duration tenantDuration) {
this.tenantDuration = tenantDuration;
return this;
}
public DurationConfigField build() {
if (globalDuration == null) {
throw new IllegalStateException(
"Cannot build DurationConfigField without a value for global duration.");
}
field.init(globalDuration, tenantDuration);
return field;
}
};
}

View File

@@ -0,0 +1,230 @@
/**
* 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.ui.tenantconfiguration.polling;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.validation.constraints.NotNull;
import com.vaadin.data.Property;
import com.vaadin.data.Validator.InvalidValueException;
import com.vaadin.data.util.converter.Converter.ConversionException;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.DateField;
import com.vaadin.ui.themes.ValoTheme;
/**
* This class represents a Field which is optimized to enter a time duration in
* form HH:mm:ss (see {@link #DURATION_FORMAT_STIRNG}). It uses the vaadin
* DateField as a basic element, but the format is optimized for the duration
* input. For a correct view of the popup it is recommended not to display the
* css-class "v-datefield-calendarpanel-header" and
* "v-datefield-calendarpanel-body" (see systemconfig.scss}
*/
public class DurationField extends DateField {
private static final long serialVersionUID = 1L;
private static final String CSS_STYLE_NAME = "durationfield";
private static final String ADDITIONAL_DURATION_STRING = "HHmmss";
private static final String DURATION_FORMAT_STIRNG = "HH:mm:ss";
private static final ZoneId ZONEID_UTC = ZoneId.of("+0");
private static final Duration MAXIMUM_DURATION = Duration.ofHours(23).plusMinutes(59).plusSeconds(59);
private final SimpleDateFormat durationFormat = new SimpleDateFormat(DURATION_FORMAT_STIRNG);
private final SimpleDateFormat additionalFormat = new SimpleDateFormat(ADDITIONAL_DURATION_STRING);
private Date minimumDuration;
private Date maximumDuration;
/**
* Creates a DurationField
*/
protected DurationField() {
super();
this.setTimeZone(TimeZone.getTimeZone(ZONEID_UTC));
durationFormat.setTimeZone(TimeZone.getTimeZone(ZONEID_UTC));
additionalFormat.setTimeZone(TimeZone.getTimeZone(ZONEID_UTC));
durationFormat.setLenient(false);
additionalFormat.setLenient(false);
this.setResolution(Resolution.SECOND);
this.setDateFormat(DURATION_FORMAT_STIRNG);
this.addStyleName(CSS_STYLE_NAME);
this.addStyleName(ValoTheme.TEXTFIELD_TINY);
this.setWidth("100px");
// needed that popup shows a 24h clock
this.setLocale(Locale.GERMANY);
this.addValueChangeListener(this);
}
/**
* This method is called to handle a non-empty date string from the client
* if the client could not parse it as a Date. In the current case two
* different parsing schemas are tried. If parsing is not possible a
* ConversionException is thrown which marks the DurationField as invalid.
*/
@Override
protected Date handleUnparsableDateString(final String value) throws ConversionException {
try {
return durationFormat.parse(value);
} catch (final ParseException e1) {
try {
return additionalFormat.parse("000000".substring(value.length() <= 6 ? value.length() : 6) + value);
} catch (final ParseException e2) {
// if Parsing is not possible ConversionException is thrown
}
}
throw new ConversionException("input is not in HH:MM:SS format.");
}
@Override
public void valueChange(final Property.ValueChangeEvent event) {
// do not delete this method, even when removing the code inside this
// method. This method overwrites the super method, which is
// necessary, that parsing works correctly on pressing enter key
if (!(event.getProperty() instanceof DurationField)) {
return;
}
final Date value = (Date) event.getProperty().getValue();
// setValue() calls valueChanged again, when the minimum is greater
// than the maximum this can lead to an endless loop
if (value != null && minimumDuration != null && maximumDuration != null
&& minimumDuration.before(maximumDuration)) {
if (compareTimeOfDates(value, maximumDuration) > 0) {
((DateField) event.getProperty()).setValue(maximumDuration);
}
if (compareTimeOfDates(minimumDuration, value) > 0) {
((DateField) event.getProperty()).setValue(minimumDuration);
}
}
}
@Override
public void validate(final Date value) throws InvalidValueException {
super.validate(value);
if (value != null && maximumDuration != null && compareTimeOfDates(value, maximumDuration) > 0) {
throw new InvalidValueException("value is greater than the allowed maximum value");
}
if (value != null && minimumDuration != null && compareTimeOfDates(minimumDuration, value) > 0) {
throw new InvalidValueException("value is smaller than the allowed minimum value");
}
}
/**
* Sets the duration value
*
* @param duration
* duration, only values <= 23:59:59 are excepted
*/
public void setDuration(@NotNull final Duration duration) {
if (duration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The duaration has to be smaller than 23:59:59.");
}
super.setValue(durationToDate(duration));
}
/**
* Gets the duration value of the TextField
*
* @return duration which is written in the vaadin Field
*/
public Duration getDuration() {
if (this.getValue() == null) {
return null;
}
return dateToDuration(this.getValue());
}
/**
* Sets the minimal allowed duration value as a String
*
* @param minimumDuration
* minimum Duration, only values smaller 23:59:59 are excepted
*/
public void setMinimumDuration(@NotNull final Duration minimumDuration) {
if (minimumDuration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The minimum duaration has to be smaller than 23:59:59.");
}
this.minimumDuration = durationToDate(minimumDuration);
}
/**
* Sets the maximum allowed duration value as a String
*
* @param maximumDuration
* maximumDuration, only values smaller 23:59:59 are excepted
*/
public void setMaximumDuration(@NotNull final Duration maximumDuration) {
if (maximumDuration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The maximum duaration has to be smaller than 23:59:59.");
}
this.maximumDuration = durationToDate(maximumDuration);
}
private static Date durationToDate(final Duration duration) {
if (duration.compareTo(MAXIMUM_DURATION) > 0) {
throw new IllegalArgumentException("The duaration has to be smaller than 23:59:59.");
}
final LocalTime lt = LocalTime.ofNanoOfDay(duration.toNanos());
return Date.from(lt.atDate(LocalDate.now(ZONEID_UTC)).atZone(ZONEID_UTC).toInstant());
}
private static Duration dateToDuration(final Date date) {
final LocalTime endExclusive = LocalDateTime.ofInstant(date.toInstant(), ZONEID_UTC).toLocalTime();
return Duration.between(LocalTime.MIDNIGHT, LocalTime.from(endExclusive));
}
/**
* Because parsing done by base class returns a different date than parsing
* done by the user or converting duration to a date. But for the
* DurationField comparison only the time is important. This function helps
* comparing the time and ignores the values for day, month and year.
*
* @param d1
* date, which time will compared with the time of d2
* @param d2
* date, which time will compared with the time of d1
* @return the value 0 if the time represented d1 is equal to the time
* represented by d2; a value less than 0 if the time of d1 is
* before the time of d2; and a value greater than 0 if the time of
* d1 is after the time represented by d2.
*/
private int compareTimeOfDates(final Date d1, final Date d2) {
final LocalTime lt1 = LocalDateTime.ofInstant(d1.toInstant(), ZONEID_UTC).toLocalTime();
final LocalTime lt2 = LocalDateTime.ofInstant(d2.toInstant(), ZONEID_UTC).toLocalTime();
return lt1.compareTo(lt2);
}
}

View File

@@ -44,5 +44,11 @@
bottom: 13px;
color: $button-icon-color;
}
}
}
.durationfield .v-datefield-calendarpanel-header,
.durationfield .v-datefield-calendarpanel-body {
display: none;
}
}

View File

@@ -390,12 +390,17 @@ link.support.name=Support
link.usermanagement.name=User Management
# System Configuration View
notification.configuration.save=Saved changes
notification.configuration.save.successful=Saved changes
notification.configuration.save.notpossible = Saving was not possible, because of invalid user input.
configuration.defaultdistributionset.title=Distribution Set Type
configuration.defaultdistributionset.select.label=Select the default Distribution Set type:
configuration.savebutton.tooltip=Save Configurations
configuration.cancellbutton.tooltip=Cancel Configurations
configuration.authentication.title=Authentication Configuration
configuration.polling.title=Polling Configuration
configuration.polling.time=Polling Time
configuration.polling.overduetime=Polling Overdue Time
configuration.polling.custom.value=use a custom value
#Calendar
calendar.year=year

View File

@@ -380,6 +380,9 @@ configuration.defaultdistributionset.select.label=Select the default Distributio
configuration.savebutton.tooltip=Save Configurations
configuration.cancellbutton.tooltip=Cancel Configurations
configuration.authentication.title=Authentication Configuration
controller.polling.title=Polling Configuration
controller.polling.time=Polling Time
controller.polling.overduetime=Polling Overdue Time
#Calendar
calendar.year=year