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