@@ -12,6 +12,8 @@ import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* Look for a free port.
|
||||
@@ -48,6 +50,7 @@ public class FreePortFileWriter {
|
||||
}
|
||||
|
||||
boolean isFree(final int port) {
|
||||
ServerSocket sock = null;
|
||||
try {
|
||||
final File portFile = new File(filePortPath + File.separator + port + ".port");
|
||||
portFile.getParentFile().mkdirs();
|
||||
@@ -55,19 +58,20 @@ public class FreePortFileWriter {
|
||||
return false;
|
||||
}
|
||||
boolean isFree = false;
|
||||
final ServerSocket sock = new ServerSocket();
|
||||
sock = new ServerSocket();
|
||||
sock.setReuseAddress(true);
|
||||
sock.bind(new InetSocketAddress(port));
|
||||
if (portFile.createNewFile()) {
|
||||
portFile.deleteOnExit();
|
||||
isFree = true;
|
||||
}
|
||||
sock.close();
|
||||
return isFree;
|
||||
// We rely on an exception thrown to determine availability or
|
||||
// not availability and don't want to log the exception.
|
||||
} catch (@SuppressWarnings({ "squid:S2221", "squid:S1166" }) final Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(sock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||
* A mapper which maps repository model to RESTful model representation and
|
||||
* back.
|
||||
*/
|
||||
public class MgmtSystemMapper {
|
||||
public final class MgmtSystemMapper {
|
||||
|
||||
private MgmtSystemMapper() {
|
||||
// Utility class
|
||||
@@ -51,6 +51,8 @@ public class MgmtSystemMapper {
|
||||
* maps a TenantConfigurationValue from the repository model to a
|
||||
* MgmtSystemTenantConfigurationValue, the RESTful model.
|
||||
*
|
||||
* @param key
|
||||
* the key
|
||||
* @param repoConfValue
|
||||
* configuration value as repository model
|
||||
* @return configuration value as RESTful model
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.hamcrest.Matchers;
|
||||
/**
|
||||
* Matcher for {@link BaseEntity}.
|
||||
*/
|
||||
public class BaseEntityMatcher {
|
||||
public final class BaseEntityMatcher {
|
||||
|
||||
private BaseEntityMatcher() {
|
||||
}
|
||||
|
||||
@@ -28,11 +28,6 @@ import org.springframework.security.core.context.SecurityContextImpl;
|
||||
*/
|
||||
public class SecurityContextTenantAware implements TenantAware {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.tenancy.TenantAware#getCurrentTenantId()
|
||||
*/
|
||||
@Override
|
||||
public String getCurrentTenant() {
|
||||
final SecurityContext context = SecurityContextHolder.getContext();
|
||||
@@ -56,7 +51,7 @@ public class SecurityContextTenantAware implements TenantAware {
|
||||
}
|
||||
}
|
||||
|
||||
private SecurityContext buildSecurityContext(final String tenant) {
|
||||
private static SecurityContext buildSecurityContext(final String tenant) {
|
||||
final SecurityContextImpl securityContext = new SecurityContextImpl();
|
||||
securityContext.setAuthentication(
|
||||
new AuthenticationDelegate(SecurityContextHolder.getContext().getAuthentication(), tenant));
|
||||
@@ -68,7 +63,7 @@ public class SecurityContextTenantAware implements TenantAware {
|
||||
* {@link Authentication} object except setting the details specifically for
|
||||
* a specific tenant.
|
||||
*/
|
||||
private class AuthenticationDelegate implements Authentication {
|
||||
private static final class AuthenticationDelegate implements Authentication {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Authentication delegate;
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.google.common.base.Throwables;
|
||||
@Service
|
||||
public class SystemSecurityContext {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SystemSecurityContext.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SystemSecurityContext.class);
|
||||
|
||||
private final TenantAware tenantAware;
|
||||
|
||||
@@ -96,7 +96,7 @@ public class SystemSecurityContext {
|
||||
public <T> T runAsSystemAsTenant(final Callable<T> callable, final String tenant) {
|
||||
final SecurityContext oldContext = SecurityContextHolder.getContext();
|
||||
try {
|
||||
logger.debug("entering system code execution");
|
||||
LOG.debug("entering system code execution");
|
||||
return tenantAware.runAsTenant(tenant, () -> {
|
||||
try {
|
||||
setSystemContext(SecurityContextHolder.getContext());
|
||||
@@ -110,7 +110,7 @@ public class SystemSecurityContext {
|
||||
|
||||
} finally {
|
||||
SecurityContextHolder.setContext(oldContext);
|
||||
logger.debug("leaving system code execution");
|
||||
LOG.debug("leaving system code execution");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class SystemSecurityContext {
|
||||
* {@link SpringEvalExpressions#SYSTEM_ROLE} which is allowed to execute all
|
||||
* secured methods.
|
||||
*/
|
||||
public static class SystemCodeAuthentication implements Authentication {
|
||||
public static final class SystemCodeAuthentication implements Authentication {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final List<SimpleGrantedAuthority> AUTHORITIES = Collections
|
||||
|
||||
@@ -248,7 +248,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
||||
// selected software module at the time of file drop is
|
||||
// considered for upload
|
||||
SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
final SoftwareModule selectedSw = artifactUploadState.getSelectedBaseSoftwareModule().get();
|
||||
// reset the flag
|
||||
hasDirectory = Boolean.FALSE;
|
||||
for (final Html5File file : files) {
|
||||
@@ -265,7 +265,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void processFile(final Html5File file, SoftwareModule selectedSw) {
|
||||
private void processFile(final Html5File file, final SoftwareModule selectedSw) {
|
||||
if (!isDirectory(file)) {
|
||||
if (!checkForDuplicate(file.getFileName(), selectedSw)) {
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
|
||||
@@ -276,7 +276,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private StreamVariable createStreamVariable(final Html5File file, SoftwareModule selectedSw) {
|
||||
private StreamVariable createStreamVariable(final Html5File file, final SoftwareModule selectedSw) {
|
||||
return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this,
|
||||
spInfo.getMaxArtifactFileSize(), null, file.getType(), selectedSw);
|
||||
}
|
||||
@@ -366,11 +366,13 @@ public class UploadLayout extends VerticalLayout {
|
||||
* in case of upload errors
|
||||
*/
|
||||
OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType,
|
||||
SoftwareModule selectedSw) {
|
||||
final SoftwareModule selectedSw) {
|
||||
File tempFile = null;
|
||||
try {
|
||||
tempFile = File.createTempFile("spUiArtifactUpload", null);
|
||||
|
||||
// we return the outputstream so we cannot close it here
|
||||
@SuppressWarnings("squid:S2095")
|
||||
final OutputStream out = new FileOutputStream(tempFile);
|
||||
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(selectedSw.getName(),
|
||||
@@ -445,8 +447,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
*/
|
||||
public Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) {
|
||||
Boolean isDuplicate = false;
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
|
||||
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
|
||||
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
|
||||
final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
@@ -510,9 +512,9 @@ public class UploadLayout extends VerticalLayout {
|
||||
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
|
||||
}
|
||||
|
||||
void updateFileSize(final String name, final long size, SoftwareModule selectedSoftwareModule) {
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
void updateFileSize(final String name, final long size, final SoftwareModule selectedSoftwareModule) {
|
||||
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
|
||||
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
|
||||
|
||||
for (final CustomFile customFile : artifactUploadState.getFileSelected()) {
|
||||
final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion(
|
||||
@@ -594,12 +596,12 @@ public class UploadLayout extends VerticalLayout {
|
||||
|
||||
private void setConfirmationPopupHeightWidth(final float newWidth, final float newHeight) {
|
||||
if (currentUploadConfirmationwindow != null) {
|
||||
currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
|
||||
currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
|
||||
currentUploadConfirmationwindow.getUploadArtifactDetails().setWidth(HawkbitCommonUtil
|
||||
.getArtifactUploadPopupWidth(newWidth, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH),
|
||||
Unit.PIXELS);
|
||||
currentUploadConfirmationwindow.getUploadDetailsTable().setHeight(HawkbitCommonUtil
|
||||
.getArtifactUploadPopupHeight(newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT),
|
||||
Unit.PIXELS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,12 +618,10 @@ public class UploadLayout extends VerticalLayout {
|
||||
&& currentUploadConfirmationwindow.getCurrentUploadResultWindow() != null) {
|
||||
final UploadResultWindow uploadResultWindow = currentUploadConfirmationwindow
|
||||
.getCurrentUploadResultWindow();
|
||||
uploadResultWindow.getUploadResultsWindow().setWidth(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
|
||||
uploadResultWindow.getUploadResultTable().setHeight(
|
||||
HawkbitCommonUtil.getArtifactUploadPopupHeight(newHeight,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
|
||||
uploadResultWindow.getUploadResultsWindow().setWidth(HawkbitCommonUtil.getArtifactUploadPopupWidth(newWidth,
|
||||
SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH), Unit.PIXELS);
|
||||
uploadResultWindow.getUploadResultTable().setHeight(HawkbitCommonUtil.getArtifactUploadPopupHeight(
|
||||
newHeight, SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT), Unit.PIXELS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,8 +632,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
} else {
|
||||
currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState);
|
||||
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
|
||||
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent()
|
||||
.getBrowserWindowHeight());
|
||||
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
|
||||
Page.getCurrent().getBrowserWindowHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -682,7 +682,7 @@ public class UploadLayout extends VerticalLayout {
|
||||
displayDuplicateValidationMessage();
|
||||
}
|
||||
|
||||
private void onUploadStreamingFailure(UploadStatusEvent event) {
|
||||
private void onUploadStreamingFailure(final UploadStatusEvent event) {
|
||||
/**
|
||||
* If upload interrupted because of duplicate file,do not remove the
|
||||
* file already in upload list
|
||||
@@ -691,13 +691,13 @@ public class UploadLayout extends VerticalLayout {
|
||||
|| !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) {
|
||||
final SoftwareModule sw = event.getUploadStatus().getSoftwareModule();
|
||||
if (sw != null) {
|
||||
getFileSelected().remove(
|
||||
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||
getFileSelected()
|
||||
.remove(new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||
}
|
||||
// failed reason to be updated only if there is error other than
|
||||
// duplicate file error
|
||||
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getFailureReason(), event.getUploadStatus().getSoftwareModule());
|
||||
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(),
|
||||
event.getUploadStatus().getFailureReason(), event.getUploadStatus().getSoftwareModule());
|
||||
increaseNumberOfFileUploadsFailed();
|
||||
}
|
||||
decreaseNumberOfFileUploadsExpected();
|
||||
@@ -711,9 +711,9 @@ public class UploadLayout extends VerticalLayout {
|
||||
displayDuplicateValidationMessage();
|
||||
}
|
||||
|
||||
private void onUploadSuccess(UploadStatusEvent event) {
|
||||
updateFileSize(event.getUploadStatus().getFileName(), event.getUploadStatus().getContentLength(), event
|
||||
.getUploadStatus().getSoftwareModule());
|
||||
private void onUploadSuccess(final UploadStatusEvent event) {
|
||||
updateFileSize(event.getUploadStatus().getFileName(), event.getUploadStatus().getContentLength(),
|
||||
event.getUploadStatus().getSoftwareModule());
|
||||
// recorded that we now one more uploaded
|
||||
increaseNumberOfFilesActuallyUpload();
|
||||
}
|
||||
@@ -730,8 +730,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
private boolean isUploadComplete() {
|
||||
int uploadedCount = artifactUploadState.getNumberOfFilesActuallyUpload().intValue();
|
||||
int expectedUploadsCount = artifactUploadState.getNumberOfFileUploadsExpected().intValue();
|
||||
final int uploadedCount = artifactUploadState.getNumberOfFilesActuallyUpload().intValue();
|
||||
final int expectedUploadsCount = artifactUploadState.getNumberOfFileUploadsExpected().intValue();
|
||||
return uploadedCount == expectedUploadsCount;
|
||||
}
|
||||
|
||||
@@ -744,13 +744,13 @@ public class UploadLayout extends VerticalLayout {
|
||||
|| !getDuplicateFileNamesList().contains(event.getUploadStatus().getFileName())) {
|
||||
final SoftwareModule sw = event.getUploadStatus().getSoftwareModule();
|
||||
if (sw != null) {
|
||||
getFileSelected().remove(
|
||||
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||
getFileSelected()
|
||||
.remove(new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||
}
|
||||
// failed reason to be updated only if there is error other than
|
||||
// duplicate file error
|
||||
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(), event.getUploadStatus()
|
||||
.getFailureReason(), event.getUploadStatus().getSoftwareModule());
|
||||
uploadInfoWindow.uploadFailed(event.getUploadStatus().getFileName(),
|
||||
event.getUploadStatus().getFailureReason(), event.getUploadStatus().getSoftwareModule());
|
||||
increaseNumberOfFileUploadsFailed();
|
||||
decreaseNumberOfFileUploadsExpected();
|
||||
}
|
||||
@@ -773,8 +773,8 @@ public class UploadLayout extends VerticalLayout {
|
||||
* @param selectedBaseSoftwareModule
|
||||
*/
|
||||
public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) {
|
||||
eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED,
|
||||
selectedBaseSoftwareModule));
|
||||
eventBus.publish(this,
|
||||
new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -804,10 +804,10 @@ public class UploadLayout extends VerticalLayout {
|
||||
}
|
||||
|
||||
void updateStatusButtonCount() {
|
||||
int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get()
|
||||
final int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get()
|
||||
- artifactUploadState.getNumberOfFilesActuallyUpload().get();
|
||||
int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get();
|
||||
StringBuilder builder = new StringBuilder("");
|
||||
final int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get();
|
||||
final StringBuilder builder = new StringBuilder("");
|
||||
if (uploadsFailed != 0) {
|
||||
if (uploadsPending != 0) {
|
||||
builder.append("<div class='error-count error-count-color'>" + uploadsFailed + "</div>");
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.vaadin.shared.ui.colorpicker.Color;
|
||||
* Provides color constants for the ColorPickerLayout
|
||||
*
|
||||
*/
|
||||
public class ColorPickerConstants {
|
||||
public final class ColorPickerConstants {
|
||||
|
||||
public static final String DEFAULT_COLOR = "rgb(44,151,32)";
|
||||
public static final Color START_COLOR = new Color(0, 146, 58);
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.vaadin.ui.Slider.ValueOutOfBoundsException;
|
||||
* Contains helper methods for the ColorPickerLayout to handle the ColorPicker
|
||||
*
|
||||
*/
|
||||
public class ColorPickerHelper {
|
||||
public final class ColorPickerHelper {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ColorPickerHelper.class);
|
||||
|
||||
@@ -30,7 +30,9 @@ public class ColorPickerHelper {
|
||||
|
||||
/**
|
||||
* Get color picked value as string.
|
||||
*
|
||||
*
|
||||
* @param preview
|
||||
* the color picker preview
|
||||
* @return String of color picked value.
|
||||
*/
|
||||
public static String getColorPickedString(final SpColorPickerPreview preview) {
|
||||
@@ -59,7 +61,7 @@ public class ColorPickerHelper {
|
||||
final int green = Integer.parseInt(colors[1]);
|
||||
final int blue = Integer.parseInt(colors[2]);
|
||||
if (colors.length > 3) {
|
||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255d);
|
||||
final int alpha = (int) (Double.parseDouble(colors[3]) * 255D);
|
||||
return new Color(red, green, blue, alpha);
|
||||
}
|
||||
return new Color(red, green, blue);
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.vaadin.ui.GridLayout;
|
||||
* duration in the DurationField or he can configure using the global duration
|
||||
* by changing the CheckBox.
|
||||
*/
|
||||
public class DurationConfigField extends GridLayout implements ConfigurationItem {
|
||||
public final class DurationConfigField extends GridLayout implements ConfigurationItem {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -130,45 +130,96 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
|
||||
configurationChangeListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DurationConfigFieldBuilder.
|
||||
*
|
||||
* @return the builder
|
||||
*/
|
||||
public static DurationConfigFieldBuilder builder() {
|
||||
return new DurationConfigFieldBuilder();
|
||||
}
|
||||
|
||||
public static class DurationConfigFieldBuilder {
|
||||
/**
|
||||
* Builder for the calendar widget.
|
||||
*
|
||||
*/
|
||||
public static final class DurationConfigFieldBuilder {
|
||||
private final DurationConfigField field;
|
||||
|
||||
private Duration globalDuration = null;
|
||||
private Duration tenantDuration = null;
|
||||
private Duration globalDuration;
|
||||
private Duration tenantDuration;
|
||||
|
||||
private DurationConfigFieldBuilder() {
|
||||
field = new DurationConfigField();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* set the checkbox tooltip.
|
||||
*
|
||||
* @param label
|
||||
* the tooltip
|
||||
* @return the builder
|
||||
*/
|
||||
public DurationConfigFieldBuilder checkBoxTooltip(final String label) {
|
||||
field.setCheckBoxTooltip(label);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the global duration.
|
||||
*
|
||||
* @param globalDuration
|
||||
* the global duration
|
||||
* @return the builder
|
||||
*/
|
||||
public DurationConfigFieldBuilder globalDuration(final Duration globalDuration) {
|
||||
this.globalDuration = globalDuration;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the caption.
|
||||
*
|
||||
* @param caption
|
||||
* the caption
|
||||
* @return the builder
|
||||
*/
|
||||
public DurationConfigFieldBuilder caption(final String caption) {
|
||||
field.setCaption(caption);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the range.
|
||||
*
|
||||
* @param minDuration
|
||||
* min duration
|
||||
* @param maxDuration
|
||||
* max duration
|
||||
* @return the builder
|
||||
*/
|
||||
public DurationConfigFieldBuilder range(final Duration minDuration, final Duration maxDuration) {
|
||||
field.setAllowedRange(minDuration, maxDuration);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the tenant duration.
|
||||
*
|
||||
* @param tenantDuration
|
||||
* the duration
|
||||
* @return the builder
|
||||
*/
|
||||
public DurationConfigFieldBuilder tenantDuration(final Duration tenantDuration) {
|
||||
this.tenantDuration = tenantDuration;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the {@link DurationConfigField}.
|
||||
*
|
||||
* @return the {@link DurationConfigField}
|
||||
*/
|
||||
public DurationConfigField build() {
|
||||
if (globalDuration == null) {
|
||||
throw new IllegalStateException(
|
||||
@@ -178,5 +229,5 @@ public class DurationConfigField extends GridLayout implements ConfigurationItem
|
||||
field.init(globalDuration, tenantDuration);
|
||||
return field;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user