Feature action cleanup (#704)
* Initial commit * Tenant configuration enhancements * Update REST documentation * Enhance System Configuration view in UI * Add unit tests * Fix delete query for H2 * Improve test coverage * Fix Sonar findings * Fix Hawkbit bot findings * Fix PR review findings * Fix peer review findings Signed-off-by: Stefan Behl <stefan.behl@bosch-si.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
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;
|
||||
import com.vaadin.ui.Label;
|
||||
@@ -87,17 +88,14 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
vLayout.setMargin(true);
|
||||
vLayout.setSizeFull();
|
||||
|
||||
final Label headerDisSetType = new Label(i18n.getMessage("configuration.authentication.title"));
|
||||
headerDisSetType.addStyleName("config-panel-header");
|
||||
vLayout.addComponent(headerDisSetType);
|
||||
final Label header = new Label(i18n.getMessage("configuration.authentication.title"));
|
||||
header.addStyleName("config-panel-header");
|
||||
vLayout.addComponent(header);
|
||||
|
||||
final Link linkToSecurityHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getSecurity());
|
||||
vLayout.addComponent(linkToSecurityHelp);
|
||||
|
||||
final GridLayout gridLayout = new GridLayout(2, 4);
|
||||
final GridLayout gridLayout = new GridLayout(3, 4);
|
||||
gridLayout.setSpacing(true);
|
||||
gridLayout.setImmediate(true);
|
||||
gridLayout.setSizeFull();
|
||||
gridLayout.setColumnExpandRatio(1, 1.0F);
|
||||
|
||||
certificateAuthCheckbox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
|
||||
@@ -130,6 +128,11 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
|
||||
gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3);
|
||||
gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, 3);
|
||||
|
||||
final Link linkToSecurityHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getSecurity());
|
||||
gridLayout.addComponent(linkToSecurityHelp, 2, 3);
|
||||
gridLayout.setComponentAlignment(linkToSecurityHelp, Alignment.BOTTOM_RIGHT);
|
||||
|
||||
vLayout.addComponent(gridLayout);
|
||||
rootPanel.setContent(vLayout);
|
||||
setCompositionRoot(rootPanel);
|
||||
|
||||
@@ -13,13 +13,13 @@ import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
@@ -62,22 +62,21 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView {
|
||||
final VerticalLayout vlayout = new VerticalLayout();
|
||||
vlayout.setMargin(true);
|
||||
vlayout.setSizeFull();
|
||||
final String disSetTypeTitle = i18n.getMessage("configuration.defaultdistributionset.title");
|
||||
|
||||
final Label headerDisSetType = new Label(disSetTypeTitle);
|
||||
headerDisSetType.addStyleName("config-panel-header");
|
||||
vlayout.addComponent(headerDisSetType);
|
||||
final Label header = new Label(i18n.getMessage("configuration.defaultdistributionset.title"));
|
||||
header.addStyleName("config-panel-header");
|
||||
vlayout.addComponent(header);
|
||||
|
||||
final DistributionSetType currentDistributionSetType = getCurrentDistributionSetType();
|
||||
currentDefaultDisSetType = currentDistributionSetType.getId();
|
||||
|
||||
final HorizontalLayout hlayout = new HorizontalLayout();
|
||||
hlayout.setSpacing(true);
|
||||
hlayout.setStyleName("config-h-panel");
|
||||
hlayout.setImmediate(true);
|
||||
|
||||
final Label configurationLabel = new Label(
|
||||
i18n.getMessage("configuration.defaultdistributionset.select.label"));
|
||||
final Label configurationLabel = new LabelBuilder()
|
||||
.name(i18n.getMessage("configuration.defaultdistributionset.select.label")).buildLabel();
|
||||
hlayout.addComponent(configurationLabel);
|
||||
hlayout.setComponentAlignment(configurationLabel, Alignment.MIDDLE_LEFT);
|
||||
|
||||
final Iterable<DistributionSetType> distributionSetTypeCollection = distributionSetTypeManagement
|
||||
.findAll(new PageRequest(0, 100));
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.tenantconfiguration.generic.BooleanConfigurationItem;
|
||||
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutocleanupConfigurationItem;
|
||||
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutocloseConfigurationItem;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
@@ -37,13 +38,19 @@ public class RepositoryConfigurationView extends BaseConfigurationView
|
||||
|
||||
private final ActionAutocloseConfigurationItem actionAutocloseConfigurationItem;
|
||||
|
||||
private final ActionAutocleanupConfigurationItem actionAutocleanupConfigurationItem;
|
||||
|
||||
private CheckBox actionAutocloseCheckBox;
|
||||
|
||||
private CheckBox actionAutocleanupCheckBox;
|
||||
|
||||
RepositoryConfigurationView(final VaadinMessageSource i18n,
|
||||
final TenantConfigurationManagement tenantConfigurationManagement) {
|
||||
this.i18n = i18n;
|
||||
this.actionAutocloseConfigurationItem = new ActionAutocloseConfigurationItem(tenantConfigurationManagement,
|
||||
i18n);
|
||||
this.actionAutocleanupConfigurationItem = new ActionAutocleanupConfigurationItem(tenantConfigurationManagement,
|
||||
i18n);
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -59,11 +66,11 @@ public class RepositoryConfigurationView extends BaseConfigurationView
|
||||
vLayout.setMargin(true);
|
||||
vLayout.setSizeFull();
|
||||
|
||||
final Label headerDisSetType = new Label(i18n.getMessage("configuration.repository.title"));
|
||||
headerDisSetType.addStyleName("config-panel-header");
|
||||
vLayout.addComponent(headerDisSetType);
|
||||
final Label header = new Label(i18n.getMessage("configuration.repository.title"));
|
||||
header.addStyleName("config-panel-header");
|
||||
vLayout.addComponent(header);
|
||||
|
||||
final GridLayout gridLayout = new GridLayout(2, 1);
|
||||
final GridLayout gridLayout = new GridLayout(2, 2);
|
||||
gridLayout.setSpacing(true);
|
||||
gridLayout.setImmediate(true);
|
||||
gridLayout.setColumnExpandRatio(1, 1.0F);
|
||||
@@ -77,6 +84,14 @@ public class RepositoryConfigurationView extends BaseConfigurationView
|
||||
gridLayout.addComponent(actionAutocloseCheckBox, 0, 0);
|
||||
gridLayout.addComponent(actionAutocloseConfigurationItem, 1, 0);
|
||||
|
||||
actionAutocleanupCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
|
||||
actionAutocleanupCheckBox.setId(UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX);
|
||||
actionAutocleanupCheckBox.setValue(actionAutocleanupConfigurationItem.isConfigEnabled());
|
||||
actionAutocleanupCheckBox.addValueChangeListener(this);
|
||||
actionAutocleanupConfigurationItem.addChangeListener(this);
|
||||
gridLayout.addComponent(actionAutocleanupCheckBox, 0, 1);
|
||||
gridLayout.addComponent(actionAutocleanupConfigurationItem, 1, 1);
|
||||
|
||||
vLayout.addComponent(gridLayout);
|
||||
rootPanel.setContent(vLayout);
|
||||
setCompositionRoot(rootPanel);
|
||||
@@ -85,12 +100,21 @@ public class RepositoryConfigurationView extends BaseConfigurationView
|
||||
@Override
|
||||
public void save() {
|
||||
actionAutocloseConfigurationItem.save();
|
||||
actionAutocleanupConfigurationItem.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInputValid() {
|
||||
return actionAutocloseConfigurationItem.isUserInputValid()
|
||||
&& actionAutocleanupConfigurationItem.isUserInputValid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
actionAutocloseConfigurationItem.undo();
|
||||
actionAutocloseCheckBox.setValue(actionAutocloseConfigurationItem.isConfigEnabled());
|
||||
actionAutocleanupConfigurationItem.undo();
|
||||
actionAutocleanupCheckBox.setValue(actionAutocleanupConfigurationItem.isConfigEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,6 +136,8 @@ public class RepositoryConfigurationView extends BaseConfigurationView
|
||||
|
||||
if (actionAutocloseCheckBox.equals(checkBox)) {
|
||||
configurationItem = actionAutocloseConfigurationItem;
|
||||
} else if (actionAutocleanupCheckBox.equals(checkBox)) {
|
||||
configurationItem = actionAutocleanupConfigurationItem;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.tenantconfiguration;
|
||||
|
||||
import com.vaadin.data.Property;
|
||||
import com.vaadin.ui.CheckBox;
|
||||
import com.vaadin.ui.GridLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Link;
|
||||
import com.vaadin.ui.Panel;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.ui.UiProperties;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
@@ -22,6 +15,15 @@ import org.eclipse.hawkbit.ui.tenantconfiguration.rollout.ApprovalConfigurationI
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
|
||||
import com.vaadin.data.Property;
|
||||
import com.vaadin.ui.Alignment;
|
||||
import com.vaadin.ui.CheckBox;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Link;
|
||||
import com.vaadin.ui.Panel;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
/**
|
||||
* Provides configuration of the RolloutManagement including enabling/disabling
|
||||
* of the approval workflow.
|
||||
@@ -55,28 +57,28 @@ public class RolloutConfigurationView extends BaseConfigurationView
|
||||
vLayout.setMargin(true);
|
||||
vLayout.setSizeFull();
|
||||
|
||||
final Label headerDisSetType = new Label(i18n.getMessage("configuration.rollout.title"));
|
||||
headerDisSetType.addStyleName("config-panel-header");
|
||||
vLayout.addComponent(headerDisSetType);
|
||||
final Label header = new Label(i18n.getMessage("configuration.rollout.title"));
|
||||
header.addStyleName("config-panel-header");
|
||||
vLayout.addComponent(header);
|
||||
|
||||
final Link linkToApprovalHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getRollout());
|
||||
vLayout.addComponent(linkToApprovalHelp);
|
||||
|
||||
final GridLayout gridLayout = new GridLayout(2, 1);
|
||||
gridLayout.setSpacing(true);
|
||||
gridLayout.setImmediate(true);
|
||||
gridLayout.setColumnExpandRatio(1, 1.0F);
|
||||
final HorizontalLayout hLayout = new HorizontalLayout();
|
||||
hLayout.setSpacing(true);
|
||||
hLayout.setImmediate(true);
|
||||
|
||||
approvalCheckbox = SPUIComponentProvider.getCheckBox("", "", null, false, "");
|
||||
approvalCheckbox.setId(UIComponentIdProvider.ROLLOUT_APPROVAL_ENABLED_CHECKBOX);
|
||||
approvalCheckbox.setValue(approvalConfigurationItem.isConfigEnabled());
|
||||
approvalCheckbox.addValueChangeListener(this);
|
||||
approvalConfigurationItem.addChangeListener(this);
|
||||
gridLayout.addComponent(approvalCheckbox, 0, 0);
|
||||
gridLayout.addComponent(approvalConfigurationItem, 1, 0);
|
||||
hLayout.addComponent(approvalCheckbox);
|
||||
hLayout.addComponent(approvalConfigurationItem);
|
||||
|
||||
vLayout.addComponent(gridLayout);
|
||||
final Link linkToApprovalHelp = SPUIComponentProvider
|
||||
.getHelpLink(uiProperties.getLinks().getDocumentation().getRollout());
|
||||
hLayout.addComponent(linkToApprovalHelp);
|
||||
hLayout.setComponentAlignment(linkToApprovalHelp, Alignment.BOTTOM_RIGHT);
|
||||
|
||||
vLayout.addComponent(hLayout);
|
||||
rootPanel.setContent(vLayout);
|
||||
setCompositionRoot(rootPanel);
|
||||
}
|
||||
@@ -92,7 +94,7 @@ public class RolloutConfigurationView extends BaseConfigurationView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChange(Property.ValueChangeEvent event) {
|
||||
public void valueChange(final Property.ValueChangeEvent event) {
|
||||
if (approvalCheckbox.equals(event.getProperty())) {
|
||||
if (approvalCheckbox.getValue()) {
|
||||
approvalConfigurationItem.configEnable();
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
/**
|
||||
* Copyright (c) 2018 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.repository;
|
||||
|
||||
import static org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey.ACTION_CLEANUP_ACTION_EXPIRY;
|
||||
import static org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey.ACTION_CLEANUP_ACTION_STATUS;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
|
||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
|
||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||
import org.eclipse.hawkbit.ui.tenantconfiguration.generic.AbstractBooleanTenantConfigurationItem;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.vaadin.data.Validator;
|
||||
import com.vaadin.data.validator.IntegerRangeValidator;
|
||||
import com.vaadin.ui.ComboBox;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.TextField;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
/**
|
||||
* This class represents the UI item for configuring automatic action cleanup in
|
||||
* the Repository Configuration section of the System Configuration view.
|
||||
*/
|
||||
public class ActionAutocleanupConfigurationItem extends AbstractBooleanTenantConfigurationItem {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActionAutocleanupConfigurationItem.class);
|
||||
|
||||
private static final int MAX_EXPIRY_IN_DAYS = 1000;
|
||||
private static final EnumSet<Status> EMPTY_STATUS_SET = EnumSet.noneOf(Status.class);
|
||||
|
||||
private static final String MSG_KEY_PREFIX = "label.configuration.repository.autocleanup.action.prefix";
|
||||
private static final String MSG_KEY_BODY = "label.configuration.repository.autocleanup.action.body";
|
||||
private static final String MSG_KEY_SUFFIX = "label.configuration.repository.autocleanup.action.suffix";
|
||||
private static final String MSG_KEY_INVALID_EXPIRY = "label.configuration.repository.autocleanup.action.expiry.invalid";
|
||||
private static final String MSG_KEY_NOTICE = "label.configuration.repository.autocleanup.action.notice";
|
||||
|
||||
private static final Collection<ActionStatusOption> ACTION_STATUS_OPTIONS = Arrays.asList(
|
||||
new ActionStatusOption(Status.CANCELED), new ActionStatusOption(Status.ERROR),
|
||||
new ActionStatusOption(Status.CANCELED, Status.ERROR));
|
||||
|
||||
private final VerticalLayout container;
|
||||
private final ComboBox actionStatusCombobox;
|
||||
private final TextField actionExpiryInput;
|
||||
|
||||
private final VaadinMessageSource i18n;
|
||||
|
||||
private boolean cleanupEnabled;
|
||||
private boolean cleanupEnabledChanged;
|
||||
private boolean actionStatusChanged;
|
||||
private boolean actionExpiryChanged;
|
||||
|
||||
/**
|
||||
* Constructs the Action Cleanup configuration UI.
|
||||
*
|
||||
* @param tenantConfigurationManagement
|
||||
* Configuration service to read /write tenant-specific
|
||||
* configuration settings.
|
||||
* @param i18n
|
||||
* The resource bundle to get all localized strings from.
|
||||
*/
|
||||
public ActionAutocleanupConfigurationItem(final TenantConfigurationManagement tenantConfigurationManagement,
|
||||
final VaadinMessageSource i18n) {
|
||||
super(TenantConfigurationKey.ACTION_CLEANUP_ENABLED, tenantConfigurationManagement, i18n);
|
||||
super.init("label.configuration.repository.autocleanup.action");
|
||||
|
||||
this.i18n = i18n;
|
||||
cleanupEnabled = isConfigEnabled();
|
||||
|
||||
container = new VerticalLayout();
|
||||
container.setImmediate(true);
|
||||
|
||||
final HorizontalLayout row1 = newHorizontalLayout();
|
||||
|
||||
actionStatusCombobox = SPUIComponentProvider.getComboBox(null, "200", null, null, false, "",
|
||||
"label.combobox.action.status.options");
|
||||
actionStatusCombobox.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_TYPES);
|
||||
actionStatusCombobox.setNullSelectionAllowed(false);
|
||||
|
||||
for (final ActionStatusOption statusOption : ACTION_STATUS_OPTIONS) {
|
||||
actionStatusCombobox.addItem(statusOption);
|
||||
actionStatusCombobox.setItemCaption(statusOption, statusOption.getName());
|
||||
}
|
||||
actionStatusCombobox.setImmediate(true);
|
||||
actionStatusCombobox.addValueChangeListener(e -> onActionStatusChanged());
|
||||
actionStatusCombobox.select(getActionStatusOption());
|
||||
|
||||
actionExpiryInput = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();
|
||||
actionExpiryInput.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_EXPIRY);
|
||||
actionExpiryInput.setWidth(55, Unit.PIXELS);
|
||||
actionExpiryInput.setNullSettingAllowed(false);
|
||||
actionExpiryInput.addTextChangeListener(e -> onActionExpiryChanged());
|
||||
actionExpiryInput.addValidator(new ActionExpiryValidator(i18n.getMessage(MSG_KEY_INVALID_EXPIRY)));
|
||||
actionExpiryInput.setValue(String.valueOf(getActionExpiry()));
|
||||
|
||||
row1.addComponent(newLabel(MSG_KEY_PREFIX));
|
||||
row1.addComponent(actionStatusCombobox);
|
||||
row1.addComponent(newLabel(MSG_KEY_BODY));
|
||||
row1.addComponent(actionExpiryInput);
|
||||
row1.addComponent(newLabel(MSG_KEY_SUFFIX));
|
||||
container.addComponent(row1);
|
||||
|
||||
final HorizontalLayout row2 = newHorizontalLayout();
|
||||
row2.addComponent(newLabel(MSG_KEY_NOTICE));
|
||||
container.addComponent(row2);
|
||||
|
||||
if (isConfigEnabled()) {
|
||||
setSettingsVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configEnable() {
|
||||
if (!cleanupEnabled) {
|
||||
cleanupEnabledChanged = true;
|
||||
}
|
||||
cleanupEnabled = true;
|
||||
setSettingsVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configDisable() {
|
||||
if (cleanupEnabled) {
|
||||
cleanupEnabledChanged = true;
|
||||
}
|
||||
cleanupEnabled = false;
|
||||
setSettingsVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (cleanupEnabledChanged) {
|
||||
setActionCleanupEnabled(cleanupEnabled);
|
||||
cleanupEnabledChanged = false;
|
||||
}
|
||||
if (cleanupEnabled && actionStatusChanged) {
|
||||
setActionStatus((ActionStatusOption) actionStatusCombobox.getValue());
|
||||
actionStatusChanged = false;
|
||||
}
|
||||
if (cleanupEnabled && actionExpiryChanged) {
|
||||
setActionExpiry(Long.parseLong(actionExpiryInput.getValue()));
|
||||
actionExpiryChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInputValid() {
|
||||
return actionExpiryInput.getErrorMessage() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
cleanupEnabledChanged = false;
|
||||
cleanupEnabled = readConfigValue(getConfigurationKey(), Boolean.class).getValue();
|
||||
actionStatusChanged = false;
|
||||
actionStatusCombobox.select(getActionStatusOption());
|
||||
actionExpiryChanged = false;
|
||||
actionExpiryInput.setValue(String.valueOf(getActionExpiry()));
|
||||
}
|
||||
|
||||
private void onActionExpiryChanged() {
|
||||
actionExpiryChanged = true;
|
||||
notifyConfigurationChanged();
|
||||
}
|
||||
|
||||
private void onActionStatusChanged() {
|
||||
actionStatusChanged = true;
|
||||
notifyConfigurationChanged();
|
||||
}
|
||||
|
||||
private Label newLabel(final String msgKey) {
|
||||
final Label label = new LabelBuilder().name(i18n.getMessage(msgKey)).buildLabel();
|
||||
label.setWidthUndefined();
|
||||
return label;
|
||||
}
|
||||
|
||||
private static HorizontalLayout newHorizontalLayout() {
|
||||
final HorizontalLayout layout = new HorizontalLayout();
|
||||
layout.setSpacing(true);
|
||||
layout.setImmediate(true);
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void setSettingsVisible(final boolean visible) {
|
||||
if (visible) {
|
||||
addComponent(container);
|
||||
} else {
|
||||
removeComponent(container);
|
||||
}
|
||||
}
|
||||
|
||||
private void setActionCleanupEnabled(final boolean enabled) {
|
||||
writeConfigValue(getConfigurationKey(), enabled);
|
||||
}
|
||||
|
||||
private void setActionExpiry(final long days) {
|
||||
writeConfigValue(ACTION_CLEANUP_ACTION_EXPIRY, TimeUnit.DAYS.toMillis(days));
|
||||
}
|
||||
|
||||
private long getActionExpiry() {
|
||||
return TimeUnit.MILLISECONDS.toDays(readConfigValue(ACTION_CLEANUP_ACTION_EXPIRY, Long.class).getValue());
|
||||
}
|
||||
|
||||
private void setActionStatus(final ActionStatusOption statusOption) {
|
||||
setActionStatus(statusOption.getStatus());
|
||||
}
|
||||
|
||||
private void setActionStatus(final Set<Status> status) {
|
||||
writeConfigValue(ACTION_CLEANUP_ACTION_STATUS,
|
||||
status.stream().map(Status::name).collect(Collectors.joining(",")));
|
||||
}
|
||||
|
||||
private ActionStatusOption getActionStatusOption() {
|
||||
final Set<Status> actionStatus = getActionStatus();
|
||||
return ACTION_STATUS_OPTIONS.stream().filter(option -> actionStatus.equals(option.getStatus())).findFirst()
|
||||
.orElse(ACTION_STATUS_OPTIONS.iterator().next());
|
||||
}
|
||||
|
||||
private EnumSet<Status> getActionStatus() {
|
||||
final TenantConfigurationValue<String> statusStr = readConfigValue(ACTION_CLEANUP_ACTION_STATUS, String.class);
|
||||
if (statusStr != null) {
|
||||
return Arrays.stream(statusStr.getValue().split("[;,]")).map(Status::valueOf)
|
||||
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Status.class)));
|
||||
}
|
||||
return EMPTY_STATUS_SET;
|
||||
}
|
||||
|
||||
private <T extends Serializable> TenantConfigurationValue<T> readConfigValue(final String key,
|
||||
final Class<T> valueType) {
|
||||
return getTenantConfigurationManagement().getConfigurationValue(key, valueType);
|
||||
}
|
||||
|
||||
private <T extends Serializable> void writeConfigValue(final String key, final T value) {
|
||||
getTenantConfigurationManagement().addOrUpdateConfiguration(key, value);
|
||||
}
|
||||
|
||||
private static class ActionStatusOption {
|
||||
|
||||
private static final CharSequence SEPARATOR = " + ";
|
||||
private final Set<Status> statusSet;
|
||||
private String name;
|
||||
|
||||
public ActionStatusOption(final Status... status) {
|
||||
statusSet = Arrays.stream(status).collect(Collectors.toCollection(() -> EnumSet.noneOf(Status.class)));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
name = assembleName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public Set<Status> getStatus() {
|
||||
return statusSet;
|
||||
}
|
||||
|
||||
private String assembleName() {
|
||||
return statusSet.stream().map(Status::name).collect(Collectors.joining(SEPARATOR));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class ActionExpiryValidator implements Validator {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String message;
|
||||
|
||||
private final Validator rangeValidator;
|
||||
|
||||
ActionExpiryValidator(final String message) {
|
||||
this.message = message;
|
||||
this.rangeValidator = new IntegerRangeValidator(message, 1, MAX_EXPIRY_IN_DAYS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final Object value) {
|
||||
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
throw new InvalidValueException(message);
|
||||
}
|
||||
|
||||
try {
|
||||
rangeValidator.validate(Integer.parseInt(value.toString()));
|
||||
} catch (final RuntimeException e) {
|
||||
LOGGER.debug("Action expiry validation failed", e);
|
||||
throw new InvalidValueException(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -519,6 +519,16 @@ public final class UIComponentIdProvider {
|
||||
*/
|
||||
public static final String SYSTEM_CONFIGURATION_SAVE = "system.configuration.save";
|
||||
|
||||
/**
|
||||
* Combobox for action types
|
||||
*/
|
||||
public static final String SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_TYPES = "system.configuration.autocleanup.action.types";
|
||||
|
||||
/**
|
||||
* Combobox for action expiry in days
|
||||
*/
|
||||
public static final String SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_EXPIRY = "system.configuration.autocleanup.action.expiry";
|
||||
|
||||
/**
|
||||
* ID for save button in pop-up-windows instance of commonDialogWindow
|
||||
*/
|
||||
@@ -1200,6 +1210,12 @@ public final class UIComponentIdProvider {
|
||||
*/
|
||||
public static final String REPOSITORY_ACTIONS_AUTOCLOSE_CHECKBOX = "repositoryactionsautoclosecheckbox";
|
||||
|
||||
/**
|
||||
* Configuration checkbox for
|
||||
* {@link TenantConfigurationKey#REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED}.
|
||||
*/
|
||||
public static final String REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX = "repositoryactionsautocleanupcheckbox";
|
||||
|
||||
/**
|
||||
* Configuration checkbox for
|
||||
* {@link TenantConfigurationKey#ROLLOUT_APPROVAL_ENABLED}
|
||||
|
||||
@@ -230,12 +230,18 @@ label.tag.name = Tag name
|
||||
label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by an reverse proxy
|
||||
label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token
|
||||
label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token
|
||||
label.configuration.repository.autoclose.action = Autoclose running actions with new Distribution set assignment
|
||||
label.configuration.repository.autoclose.action = Autoclose running actions when a new distribution set is assigned
|
||||
label.configuration.repository.autocleanup.action = Automatically delete terminated actions
|
||||
label.configuration.repository.autocleanup.action.prefix = Delete actions with status
|
||||
label.configuration.repository.autocleanup.action.body = after
|
||||
label.configuration.repository.autocleanup.action.suffix = day(s)
|
||||
label.configuration.repository.autocleanup.action.expiry.invalid = The specified number of days is invalid. Please enter a positive integer value between 1 and 1000.
|
||||
label.configuration.anonymous.download = Allow targets to download artifacts without security credentials
|
||||
label.unsupported.browser.ie=Sorry! current browser is not supported. Please use Internet Explorer 11 and above
|
||||
label.auto.assign.description=When an auto assign distribution set is selected, it will be automatically assigned to all targets that match the target filter.
|
||||
label.auto.assign.enable=Enable auto assignment
|
||||
label.scheduled=Scheduled
|
||||
label.configuration.repository.autocleanup.action.notice = Warning: The actions are deleted from the repository and cannot be restored
|
||||
label.unsupported.browser.ie = Sorry! Your current browser is not supported. Please use Internet Explorer 11 and above
|
||||
label.auto.assign.description = When an auto assign distribution set is selected, it will be automatically assigned to all targets that match the target filter.
|
||||
label.auto.assign.enable = Enable auto assignment
|
||||
label.scheduled = Scheduled
|
||||
label.approval.decision = Approval decision
|
||||
label.approval.remark = Remark (optional)
|
||||
label.drop.area.upload = Drop Files to upload
|
||||
@@ -509,8 +515,8 @@ link.usermanagement.name=User Management
|
||||
# System Configuration View
|
||||
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.defaultdistributionset.title=Distribution Configuration
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user