From 70959ec1408a12623e9f152899b7e0fc4a42d308 Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Mon, 8 Feb 2016 10:47:42 +0100 Subject: [PATCH 01/45] intial commit Signed-off-by: asharani-murugesh --- .../ui/artifacts/upload/UploadHandler.java | 6 +- .../ui/artifacts/upload/UploadLayout.java | 1053 +++++++++-------- 2 files changed, 548 insertions(+), 511 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java index 834246c63..ed4e22ba0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java @@ -89,6 +89,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene @Override public final OutputStream getOutputStream() { try { + view.getDuplicateFileNamesList().clear(); return view.saveUploadedFileDetails(fileName, fileSize, mimeType); } catch (final ArtifactUploadFailedException e) { LOG.error("Atifact upload failed {} ", e); @@ -108,6 +109,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene public OutputStream receiveUpload(final String fileName, final String mimeType) { this.fileName = fileName; this.mimeType = mimeType; + view.getDuplicateFileNamesList().clear(); try { if (view.validate()) { if (view.checkForDuplicate(fileName)) { @@ -167,7 +169,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene view.updateActionCount(); // display the duplicate message after streaming all files - view.displayDuplicateMessageAfterStreamingAll(); + view.displayValidationMessage(); } /** @@ -292,7 +294,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene if (view.enableProcessBtn()) { infoWindow.uploadSessionFinished(); } - view.displayDuplicateMessageAfterStreamingAll(); + view.displayValidationMessage(); LOG.info("Streaming failed due to :{}", event.getException()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index e570c84c4..b944006ff 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -46,6 +46,7 @@ import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; +import com.google.common.base.Strings; import com.vaadin.event.dd.DragAndDropEvent; import com.vaadin.event.dd.DropHandler; import com.vaadin.event.dd.acceptcriteria.AcceptAll; @@ -70,529 +71,563 @@ import com.vaadin.ui.VerticalLayout; /** * Upload files layout. * - * + * @author G Venkata Narayana (RBEI/BSO3) */ @ViewScope @SpringComponent public class UploadLayout extends VerticalLayout { - private static final long serialVersionUID = -566164756606779220L; + private static final long serialVersionUID = -566164756606779220L; - private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class); + private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class); - @Autowired - private UploadStatusInfoWindow uploadInfoWindow; + @Autowired + private UploadStatusInfoWindow uploadInfoWindow; - @Autowired - private I18N i18n; + @Autowired + private I18N i18n; - @Autowired - private transient UINotification uiNotification; + @Autowired + private transient UINotification uiNotification; - @Autowired - private transient EventBus.SessionEventBus eventBus; + @Autowired + private transient EventBus.SessionEventBus eventBus; - @Autowired - private ArtifactUploadState artifactUploadState; + @Autowired + private ArtifactUploadState artifactUploadState; - @Autowired - private transient SPInfo spInfo; + @Autowired + private transient SPInfo spInfo; - private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger(); + private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger(); - private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger(); + private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger(); - private final List duplicateFileNamesList = new ArrayList(); - - private Button processBtn; - - private Button discardBtn; - - private UploadConfirmationwindow currentUploadConfirmationwindow; - - private VerticalLayout dropAreaLayout; - - private UI ui; - - private HorizontalLayout fileUploadLayout; - - private DragAndDropWrapper dropAreaWrapper; - - /** - * Initialize the upload layout. - */ - @PostConstruct - void init() { - createComponents(); - buildLayout(); - updateActionCount(); - eventBus.subscribe(this); - ui = UI.getCurrent(); - } - - private void createComponents() { - - createProcessButton(); - createDiscardBtn(); - } - - private void buildLayout() { - - final Upload upload = new Upload(); - final UploadHandler uploadHandler = new UploadHandler(null, 0, this, uploadInfoWindow, - spInfo.getMaxArtifactFileSize(), upload, null); - upload.setButtonCaption(i18n.get("upload.file")); - upload.setImmediate(true); - upload.setReceiver(uploadHandler); - upload.addSucceededListener(uploadHandler); - upload.addFailedListener(uploadHandler); - upload.addFinishedListener(uploadHandler); - upload.addProgressListener(uploadHandler); - upload.addStartedListener(uploadHandler); - upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); - - fileUploadLayout = new HorizontalLayout(); - fileUploadLayout.setSpacing(true); - fileUploadLayout.addComponent(upload); - fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); - fileUploadLayout.addComponent(processBtn); - fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT); - fileUploadLayout.addComponent(discardBtn); - fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT); - setMargin(false); - - /* create drag-drop wrapper for drop area */ - dropAreaWrapper = new DragAndDropWrapper(createDropAreaLayout()); - dropAreaWrapper.setDropHandler(new DropAreahandler()); - setSizeFull(); - setSpacing(true); - - } - - public DragAndDropWrapper getDropAreaWrapper() { - return dropAreaWrapper; - } - - private class DropAreahandler implements DropHandler { - - private static final long serialVersionUID = 1L; - - @Override - public AcceptCriterion getAcceptCriterion() { - return AcceptAll.get(); - } - - @Override - public void drop(final DragAndDropEvent event) { - if (validate()) { - - final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); - if (files != null) { - for (final Html5File file : files) { - if (!checkForDuplicate(file.getFileName())) { - numberOfFileUploadsExpected.incrementAndGet(); - file.setStreamVariable(createStreamVariable(file)); - } - } - if (numberOfFileUploadsExpected.get() > 0) { - processBtn.setEnabled(false); - // reset before we start - uploadInfoWindow.uploadSessionStarted(); - } - // in case if all selected files are duplicate ,then display - // message - displayDuplicateMessageAfterStreamingAll(); - } - } - } - } - - private VerticalLayout createDropAreaLayout() { - dropAreaLayout = new VerticalLayout(); - final Label dropHereLabel = new Label("Drop files to upload"); - dropHereLabel.setWidth(null); - - final Label dropIcon = new Label(FontAwesome.ARROW_DOWN.getHtml(), ContentMode.HTML); - dropIcon.addStyleName("drop-icon"); - dropIcon.setWidth(null); - - dropAreaLayout.addComponent(dropIcon); - dropAreaLayout.setComponentAlignment(dropIcon, Alignment.BOTTOM_CENTER); - dropAreaLayout.addComponent(dropHereLabel); - dropAreaLayout.setComponentAlignment(dropHereLabel, Alignment.TOP_CENTER); - dropAreaLayout.setSizeFull(); - dropAreaLayout.setStyleName("upload-drop-area-layout-info"); - dropAreaLayout.setSpacing(false); - return dropAreaLayout; - } - - private void createProcessButton() { - processBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON, - SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null, - SPUIButtonStyleSmall.class); - processBtn.setIcon(FontAwesome.BELL); - processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); - processBtn.addClickListener(event -> displayConfirmWindow(event)); - processBtn.setHtmlContentAllowed(true); - if (artifactUploadState.getFileSelected().isEmpty()) { - processBtn.setEnabled(false); - } - } - - private void createDiscardBtn() { - discardBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_BUTTON, - SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null, - SPUIButtonStyleSmall.class); - discardBtn.setIcon(FontAwesome.TRASH_O); - discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); - discardBtn.addClickListener(event -> discardUploadData(event)); - } - - private StreamVariable createStreamVariable(final Html5File file) { - return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow, - spInfo.getMaxArtifactFileSize(), null, file.getType()); - } - - boolean checkForDuplicate(final String filename) { - final Boolean isDuplicate = checkIfFileIsDuplicate(filename); - if (isDuplicate) { - getDuplicateFileNamesList().add(filename); - } - return isDuplicate; - } - - @EventBusListenerMethod(scope = EventScope.SESSION) - void toggleProcessButton(final UploadArtifactUIEvent event) { - if (event == UploadArtifactUIEvent.ENABLE_PROCESS_BUTTON) { - processBtn.setEnabled(true); - } else if (event == UploadArtifactUIEvent.DISABLE_PROCESS_BUTTON) { - processBtn.setEnabled(false); - } - } - - /** - * Save uploaded file details. - * - * @param stream - * read from uploaded file - * @param name - * file name - * @param size - * file size - * @param mimeType - * the mimeType of the file - * @throws IOException - * in case of upload errors - */ - OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType) { - File tempFile = null; - try { - tempFile = File.createTempFile("spUiArtifactUpload", null); - - final OutputStream out = new FileOutputStream(tempFile); - - final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); - - final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(), - selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion(), mimeType); - - artifactUploadState.getFileSelected().add(customFile); - processBtn.setEnabled(false); - - if (!artifactUploadState.getBaseSwModuleList().keySet().contains(currentBaseSoftwareModuleKey)) { - artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSoftwareModule); - } - return out; - } catch (final FileNotFoundException e) { - LOG.error("Upload failed {}", e); - throw new ArtifactUploadFailedException(i18n.get("message.file.not.found")); - } catch (final IOException e) { - LOG.error("Upload failed {}", e); - throw new ArtifactUploadFailedException(i18n.get("message.upload.failed")); - } - } - - Boolean validate() { - if (!isSoftwareModuleSelected()) { - uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected")); - - return false; - } - return true; - } - - SoftwareModule getSoftwareModuleSelected() { - if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) { - return artifactUploadState.getSelectedBaseSoftwareModule().get(); - } - return null; - } - - Boolean isSoftwareModuleSelected() { - if (!artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { - return false; - } - return true; - } - - /** - * Check if file selected is duplicate.i,e already selected for upload for - * same software module. - * - * @param name - * file name - * @return Boolean - */ - public Boolean checkIfFileIsDuplicate(final String name) { - Boolean isDuplicate = false; - final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); - - for (final CustomFile customFile : artifactUploadState.getFileSelected()) { - final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( - customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); - if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { - isDuplicate = true; - break; - } - } - return isDuplicate; - } - - void decreaseNumberOfFileUploadsExpected() { - numberOfFileUploadsExpected.decrementAndGet(); - } - - List getDuplicateFileNamesList() { - return duplicateFileNamesList; - } - - /** - * Update pending action count. - */ - void updateActionCount() { - if (!artifactUploadState.getFileSelected().isEmpty()) { - processBtn.setCaption(SPUILabelDefinitions.PROCESS + "
" - + artifactUploadState.getFileSelected().size() + "
"); - } else { - processBtn.setCaption(SPUILabelDefinitions.PROCESS); - } - } - - void displayDuplicateMessageAfterStreamingAll() { - // check if streaming of all dropped files are completed - if (numberOfFilesActuallyUpload.intValue() == numberOfFileUploadsExpected.intValue()) { - showDuplicateMessage(); - } - } - - /** - * Show duplicate file selected message. - */ - public void showDuplicateMessage() { - if (!duplicateFileNamesList.isEmpty()) { - final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); - if (duplicateFileNamesList.size() == 1) { - uiNotification.displayValidationError(i18n.get("message.no.duplicateFile") + fileNames); - - } else if (duplicateFileNamesList.size() > 1) { - uiNotification.displayValidationError(i18n.get("message.no.duplicateFiles")); - } - duplicateFileNamesList.clear(); - } - } - - void increaseNumberOfFileUploadsExpected() { - numberOfFileUploadsExpected.incrementAndGet(); - } - - void updateFileSize(final String name, final long size) { - final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); - - for (final CustomFile customFile : artifactUploadState.getFileSelected()) { - final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( - customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); - if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { - customFile.setFileSize(size); - break; - } - } - } - - void increaseNumberOfFilesActuallyUpload() { - numberOfFilesActuallyUpload.incrementAndGet(); - } - - /** - * Enable process button once upload is completed. - */ - boolean enableProcessBtn() { - if (numberOfFilesActuallyUpload.intValue() >= numberOfFileUploadsExpected.intValue()) { - processBtn.setEnabled(true); - numberOfFileUploadsExpected.set(0); - numberOfFilesActuallyUpload.set(0); - return true; - } - return false; - } - - Set getFileSelected() { - return artifactUploadState.getFileSelected(); - } - - private void discardUploadData(final Button.ClickEvent event) { - if (event.getButton().equals(discardBtn)) { - if (artifactUploadState.getFileSelected().isEmpty()) { - uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); - - } else { - clearFileList(); - } - } - } - - /** - * Clear details. - */ - void clearFileList() { - // delete file system zombies - artifactUploadState.getFileSelected().forEach(customFile -> { - final File file = new File(customFile.getFilePath()); - file.delete(); - }); - - artifactUploadState.getFileSelected().clear(); - artifactUploadState.getBaseSwModuleList().clear(); - processBtn.setCaption(SPUILabelDefinitions.PROCESS); - /* disable when there is no files to upload. */ - processBtn.setEnabled(false); - numberOfFileUploadsExpected.set(0); - numberOfFilesActuallyUpload.set(0); - duplicateFileNamesList.clear(); - } - - 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); - } - } - - /** - * Set artifact upload result pop up size changes. - * - * @param newWidth - * new width of result pop up - * @param newHeight - * new height of result pop up - */ - void setResultPopupHeightWidth(final float newWidth, final float newHeight) { - if (currentUploadConfirmationwindow != null - && 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); - } - } - - private void displayConfirmWindow(final Button.ClickEvent event) { - if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON)) { - if (artifactUploadState.getFileSelected().isEmpty()) { - uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); - } else { - currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState); - UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow()); - setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), - Page.getCurrent().getBrowserWindowHeight()); - } - } - } - - /** - * @return - */ - I18N getI18n() { - return i18n; - } - - /** - * @return - */ - SPInfo getSPInfo() { - return spInfo; - } - - void setCurrentUploadConfirmationwindow(final UploadConfirmationwindow currentUploadConfirmationwindow) { - this.currentUploadConfirmationwindow = currentUploadConfirmationwindow; - } - - /** - * @return - */ - - VerticalLayout getDropAreaLayout() { - return dropAreaLayout; - } - - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final UploadArtifactUIEvent event) { - if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) { - ui.access(() -> updateActionCount()); - } - } - - @PreDestroy - void destroy() { - /* - * It's good manners to do this, even though vaadin-spring will - * automatically unsubscribe when this UI is garbage collected. - */ - eventBus.unsubscribe(this); - } - - /** - * set upload status and confirmation window. - * - * @param newWidth - * browser width - * @param newHeight - * browser height - */ - public void setUploadPopupSize(final float newWidth, final float newHeight) { - setConfirmationPopupHeightWidth(newWidth, newHeight); - setResultPopupHeightWidth(newWidth, newHeight); - } - - /** - * @param selectedBaseSoftwareModule - */ - public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) { - eventBus.publish(this, - new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule)); - } - - /** - * @return the fileUploadLayout - */ - public HorizontalLayout getFileUploadLayout() { - return fileUploadLayout; - } - - public UINotification getUINotification() { - return uiNotification; - } + private final List duplicateFileNamesList = new ArrayList(); + + private Button processBtn; + + private Button discardBtn; + + private UploadConfirmationwindow currentUploadConfirmationwindow; + + private VerticalLayout dropAreaLayout; + + private UI ui; + + private HorizontalLayout fileUploadLayout; + + private DragAndDropWrapper dropAreaWrapper; + + private Boolean hasDirectory = Boolean.FALSE; + + /** + * Initialize the upload layout. + */ + @PostConstruct + void init() { + createComponents(); + buildLayout(); + updateActionCount(); + eventBus.subscribe(this); + ui = UI.getCurrent(); + } + + private void createComponents() { + + createProcessButton(); + createDiscardBtn(); + } + + private void buildLayout() { + + final Upload upload = new Upload(); + final UploadHandler uploadHandler = new UploadHandler(null, 0, this, uploadInfoWindow, + spInfo.getMaxArtifactFileSize(), upload, null); + upload.setButtonCaption(i18n.get("upload.file")); + upload.setImmediate(true); + upload.setReceiver(uploadHandler); + upload.addSucceededListener(uploadHandler); + upload.addFailedListener(uploadHandler); + upload.addFinishedListener(uploadHandler); + upload.addProgressListener(uploadHandler); + upload.addStartedListener(uploadHandler); + upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + + fileUploadLayout = new HorizontalLayout(); + fileUploadLayout.setSpacing(true); + fileUploadLayout.addComponent(upload); + fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); + fileUploadLayout.addComponent(processBtn); + fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT); + fileUploadLayout.addComponent(discardBtn); + fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT); + setMargin(false); + + /* create drag-drop wrapper for drop area */ + dropAreaWrapper = new DragAndDropWrapper(createDropAreaLayout()); + dropAreaWrapper.setDropHandler(new DropAreahandler()); + setSizeFull(); + setSpacing(true); + + } + + public DragAndDropWrapper getDropAreaWrapper() { + return dropAreaWrapper; + } + + private class DropAreahandler implements DropHandler { + + private static final long serialVersionUID = 1L; + + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } + + @Override + public void drop(final DragAndDropEvent event) { + if (validate()) { + ((WrapperTransferable) event.getTransferable()).getDraggedComponent(); + final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); + if (files != null) { + for (final Html5File file : files) { + if (!isDirectory(file)) { + if (!checkForDuplicate(file.getFileName())) { + numberOfFileUploadsExpected.incrementAndGet(); + file.setStreamVariable(createStreamVariable(file)); + } + } else { + hasDirectory = Boolean.TRUE; + } + } + if (numberOfFileUploadsExpected.get() > 0) { + processBtn.setEnabled(false); + // reset before we start + uploadInfoWindow.uploadSessionStarted(); + } else { + //If the upload is not started, it signifies all dropped files as either duplicate or directory.So display message accordingly + displayCompositeMessage(hasDirectory); + } + } + } + } + } + + private static boolean isDirectory(final Html5File file) { + if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) { + return true; + } + return false; + } + + private void displayCompositeMessage(final Boolean hasDirectory) { + final String duplicateMessage = showDuplicateMessage(); + final StringBuilder compositeMessage = new StringBuilder(); + if (null != duplicateMessage) { + // in case if all selected files are duplicate ,then display + // messag + compositeMessage.append(duplicateMessage); + } + if (hasDirectory) { + if (compositeMessage.length() > 0) { + compositeMessage.append("
"); + } + compositeMessage.append(i18n.get("message.no.directory.upload")); + } + if (!compositeMessage.toString().isEmpty()) { + uiNotification.displayValidationError(compositeMessage.toString()); + } + } + + private VerticalLayout createDropAreaLayout() { + dropAreaLayout = new VerticalLayout(); + final Label dropHereLabel = new Label("Drop files to upload"); + dropHereLabel.setWidth(null); + + final Label dropIcon = new Label(FontAwesome.ARROW_DOWN.getHtml(), ContentMode.HTML); + dropIcon.addStyleName("drop-icon"); + dropIcon.setWidth(null); + + dropAreaLayout.addComponent(dropIcon); + dropAreaLayout.setComponentAlignment(dropIcon, Alignment.BOTTOM_CENTER); + dropAreaLayout.addComponent(dropHereLabel); + dropAreaLayout.setComponentAlignment(dropHereLabel, Alignment.TOP_CENTER); + dropAreaLayout.setSizeFull(); + dropAreaLayout.setStyleName("upload-drop-area-layout-info"); + dropAreaLayout.setSpacing(false); + return dropAreaLayout; + } + + private void createProcessButton() { + processBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON, + SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null, + SPUIButtonStyleSmall.class); + processBtn.setIcon(FontAwesome.BELL); + processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + processBtn.addClickListener(event -> displayConfirmWindow(event)); + processBtn.setHtmlContentAllowed(true); + if (artifactUploadState.getFileSelected().isEmpty()) { + processBtn.setEnabled(false); + } + } + + private void createDiscardBtn() { + discardBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_BUTTON, + SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null, + SPUIButtonStyleSmall.class); + discardBtn.setIcon(FontAwesome.TRASH_O); + discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + discardBtn.addClickListener(event -> discardUploadData(event)); + } + + private StreamVariable createStreamVariable(final Html5File file) { + return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow, + spInfo.getMaxArtifactFileSize(), null, file.getType()); + } + + boolean checkForDuplicate(final String filename) { + final Boolean isDuplicate = checkIfFileIsDuplicate(filename); + if (isDuplicate) { + getDuplicateFileNamesList().add(filename); + } + return isDuplicate; + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void toggleProcessButton(final UploadArtifactUIEvent event) { + if (event == UploadArtifactUIEvent.ENABLE_PROCESS_BUTTON) { + processBtn.setEnabled(true); + } else if (event == UploadArtifactUIEvent.DISABLE_PROCESS_BUTTON) { + processBtn.setEnabled(false); + } + } + + /** + * Save uploaded file details. + * + * @param stream + * read from uploaded file + * @param name + * file name + * @param size + * file size + * @param mimeType + * the mimeType of the file + * @throws IOException + * in case of upload errors + */ + OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType) { + File tempFile = null; + try { + tempFile = File.createTempFile("spUiArtifactUpload", null); + + final OutputStream out = new FileOutputStream(tempFile); + + final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); + + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + + final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(), + selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion(), mimeType); + + artifactUploadState.getFileSelected().add(customFile); + processBtn.setEnabled(false); + + if (!artifactUploadState.getBaseSwModuleList().keySet().contains(currentBaseSoftwareModuleKey)) { + artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSoftwareModule); + } + return out; + } catch (final FileNotFoundException e) { + LOG.error("Upload failed {}", e); + throw new ArtifactUploadFailedException(i18n.get("message.file.not.found")); + } catch (final IOException e) { + LOG.error("Upload failed {}", e); + throw new ArtifactUploadFailedException(i18n.get("message.upload.failed")); + } + } + + Boolean validate() { + if (!isSoftwareModuleSelected()) { + uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected")); + return false; + } + return true; + } + + SoftwareModule getSoftwareModuleSelected() { + if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) { + return artifactUploadState.getSelectedBaseSoftwareModule().get(); + } + return null; + } + + Boolean isSoftwareModuleSelected() { + if (!artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { + return false; + } + return true; + } + + /** + * Check if file selected is duplicate.i,e already selected for upload for + * same software module. + * + * @param name + * file name + * @return Boolean + */ + public Boolean checkIfFileIsDuplicate(final String name) { + Boolean isDuplicate = false; + final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + + for (final CustomFile customFile : artifactUploadState.getFileSelected()) { + final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( + customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); + if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { + isDuplicate = true; + break; + } + } + return isDuplicate; + } + + void decreaseNumberOfFileUploadsExpected() { + numberOfFileUploadsExpected.decrementAndGet(); + } + + List getDuplicateFileNamesList() { + return duplicateFileNamesList; + } + + /** + * Update pending action count. + */ + void updateActionCount() { + if (!artifactUploadState.getFileSelected().isEmpty()) { + processBtn.setCaption(SPUILabelDefinitions.PROCESS + "
" + + artifactUploadState.getFileSelected().size() + "
"); + } else { + processBtn.setCaption(SPUILabelDefinitions.PROCESS); + } + } + + void displayValidationMessage() { + // check if streaming of all dropped files are completed + if (numberOfFilesActuallyUpload.intValue() == numberOfFileUploadsExpected.intValue()) { + displayCompositeMessage(hasDirectory); + } + } + + /** + * Show duplicate file selected message. + * + * @return duplicate file names + */ + public String showDuplicateMessage() { + if (!duplicateFileNamesList.isEmpty()) { + final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); + if (duplicateFileNamesList.size() == 1) { + return i18n.get("message.no.duplicateFile") + fileNames; + + } else if (duplicateFileNamesList.size() > 1) { + return i18n.get("message.no.duplicateFiles"); + } + duplicateFileNamesList.clear(); + } + return null; + } + + void increaseNumberOfFileUploadsExpected() { + numberOfFileUploadsExpected.incrementAndGet(); + } + + void updateFileSize(final String name, final long size) { + final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + + for (final CustomFile customFile : artifactUploadState.getFileSelected()) { + final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( + customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); + if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { + customFile.setFileSize(size); + break; + } + } + } + + void increaseNumberOfFilesActuallyUpload() { + numberOfFilesActuallyUpload.incrementAndGet(); + } + + /** + * Enable process button once upload is completed. + */ + boolean enableProcessBtn() { + if (numberOfFilesActuallyUpload.intValue() >= numberOfFileUploadsExpected.intValue()) { + processBtn.setEnabled(true); + numberOfFileUploadsExpected.set(0); + numberOfFilesActuallyUpload.set(0); + return true; + } + return false; + } + + Set getFileSelected() { + return artifactUploadState.getFileSelected(); + } + + private void discardUploadData(final Button.ClickEvent event) { + if (event.getButton().equals(discardBtn)) { + if (artifactUploadState.getFileSelected().isEmpty()) { + uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); + + } else { + clearFileList(); + } + } + } + + /** + * Clear details. + */ + void clearFileList() { + // delete file system zombies + artifactUploadState.getFileSelected().forEach(customFile -> { + final File file = new File(customFile.getFilePath()); + file.delete(); + }); + + artifactUploadState.getFileSelected().clear(); + artifactUploadState.getBaseSwModuleList().clear(); + processBtn.setCaption(SPUILabelDefinitions.PROCESS); + /* disable when there is no files to upload. */ + processBtn.setEnabled(false); + numberOfFileUploadsExpected.set(0); + numberOfFilesActuallyUpload.set(0); + duplicateFileNamesList.clear(); + } + + 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); + } + } + + /** + * Set artifact upload result pop up size changes. + * + * @param newWidth + * new width of result pop up + * @param newHeight + * new height of result pop up + */ + void setResultPopupHeightWidth(final float newWidth, final float newHeight) { + if (currentUploadConfirmationwindow != null + && 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); + } + } + + private void displayConfirmWindow(final Button.ClickEvent event) { + if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON)) { + if (artifactUploadState.getFileSelected().isEmpty()) { + uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); + } else { + currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState); + UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow()); + setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), + Page.getCurrent().getBrowserWindowHeight()); + } + } + } + + /** + * @return + */ + I18N getI18n() { + return i18n; + } + + /** + * @return + */ + SPInfo getSPInfo() { + return spInfo; + } + + void setCurrentUploadConfirmationwindow(final UploadConfirmationwindow currentUploadConfirmationwindow) { + this.currentUploadConfirmationwindow = currentUploadConfirmationwindow; + } + + /** + * @return + */ + + VerticalLayout getDropAreaLayout() { + return dropAreaLayout; + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final UploadArtifactUIEvent event) { + if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) { + ui.access(() -> updateActionCount()); + } + } + + @PreDestroy + void destroy() { + /* + * It's good manners to do this, even though vaadin-spring will + * automatically unsubscribe when this UI is garbage collected. + */ + eventBus.unsubscribe(this); + } + + /** + * set upload status and confirmation window. + * + * @param newWidth + * browser width + * @param newHeight + * browser height + */ + public void setUploadPopupSize(final float newWidth, final float newHeight) { + setConfirmationPopupHeightWidth(newWidth, newHeight); + setResultPopupHeightWidth(newWidth, newHeight); + } + + /** + * @param selectedBaseSoftwareModule + */ + public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) { + eventBus.publish(this, + new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule)); + } + + /** + * @return the fileUploadLayout + */ + public HorizontalLayout getFileUploadLayout() { + return fileUploadLayout; + } + + public UINotification getUINotification() { + return uiNotification; + } } From 7237e352ff7800b2b7da8063fc1a2e7b5d686c52 Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Mon, 8 Feb 2016 11:55:57 +0100 Subject: [PATCH 02/45] Bug fixed Signed-off-by: asharani-murugesh --- .../ui/artifacts/upload/UploadHandler.java | 7 +- .../ui/artifacts/upload/UploadLayout.java | 838 +++++++++--------- 2 files changed, 421 insertions(+), 424 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java index ed4e22ba0..3d7ce0886 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java @@ -89,7 +89,6 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene @Override public final OutputStream getOutputStream() { try { - view.getDuplicateFileNamesList().clear(); return view.saveUploadedFileDetails(fileName, fileSize, mimeType); } catch (final ArtifactUploadFailedException e) { LOG.error("Atifact upload failed {} ", e); @@ -109,7 +108,6 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene public OutputStream receiveUpload(final String fileName, final String mimeType) { this.fileName = fileName; this.mimeType = mimeType; - view.getDuplicateFileNamesList().clear(); try { if (view.validate()) { if (view.checkForDuplicate(fileName)) { @@ -169,7 +167,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene view.updateActionCount(); // display the duplicate message after streaming all files - view.displayValidationMessage(); + view.displayDuplicateValidationMessage(); } /** @@ -294,7 +292,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene if (view.enableProcessBtn()) { infoWindow.uploadSessionFinished(); } - view.displayValidationMessage(); + view.displayDuplicateValidationMessage(); LOG.info("Streaming failed due to :{}", event.getException()); } @@ -318,7 +316,6 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene } view.updateActionCount(); infoWindow.uploadFailed(event.getFilename(), failureReason); - LOG.info("Upload failed for file :{}", event.getReason()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index b944006ff..0f9bcd5cc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -71,123 +71,123 @@ import com.vaadin.ui.VerticalLayout; /** * Upload files layout. * - * @author G Venkata Narayana (RBEI/BSO3) + * */ @ViewScope @SpringComponent public class UploadLayout extends VerticalLayout { - private static final long serialVersionUID = -566164756606779220L; + private static final long serialVersionUID = -566164756606779220L; - private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class); + private static final Logger LOG = LoggerFactory.getLogger(UploadLayout.class); - @Autowired - private UploadStatusInfoWindow uploadInfoWindow; + @Autowired + private UploadStatusInfoWindow uploadInfoWindow; - @Autowired - private I18N i18n; + @Autowired + private I18N i18n; - @Autowired - private transient UINotification uiNotification; + @Autowired + private transient UINotification uiNotification; - @Autowired - private transient EventBus.SessionEventBus eventBus; + @Autowired + private transient EventBus.SessionEventBus eventBus; - @Autowired - private ArtifactUploadState artifactUploadState; + @Autowired + private ArtifactUploadState artifactUploadState; - @Autowired - private transient SPInfo spInfo; + @Autowired + private transient SPInfo spInfo; - private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger(); + private final AtomicInteger numberOfFileUploadsExpected = new AtomicInteger(); - private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger(); + private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger(); - private final List duplicateFileNamesList = new ArrayList(); + private final List duplicateFileNamesList = new ArrayList(); - private Button processBtn; + private Button processBtn; - private Button discardBtn; + private Button discardBtn; - private UploadConfirmationwindow currentUploadConfirmationwindow; + private UploadConfirmationwindow currentUploadConfirmationwindow; - private VerticalLayout dropAreaLayout; + private VerticalLayout dropAreaLayout; - private UI ui; + private UI ui; - private HorizontalLayout fileUploadLayout; + private HorizontalLayout fileUploadLayout; - private DragAndDropWrapper dropAreaWrapper; + private DragAndDropWrapper dropAreaWrapper; private Boolean hasDirectory = Boolean.FALSE; - /** - * Initialize the upload layout. - */ - @PostConstruct - void init() { - createComponents(); - buildLayout(); - updateActionCount(); - eventBus.subscribe(this); - ui = UI.getCurrent(); - } + /** + * Initialize the upload layout. + */ + @PostConstruct + void init() { + createComponents(); + buildLayout(); + updateActionCount(); + eventBus.subscribe(this); + ui = UI.getCurrent(); + } - private void createComponents() { + private void createComponents() { - createProcessButton(); - createDiscardBtn(); - } + createProcessButton(); + createDiscardBtn(); + } - private void buildLayout() { + private void buildLayout() { - final Upload upload = new Upload(); - final UploadHandler uploadHandler = new UploadHandler(null, 0, this, uploadInfoWindow, - spInfo.getMaxArtifactFileSize(), upload, null); - upload.setButtonCaption(i18n.get("upload.file")); - upload.setImmediate(true); - upload.setReceiver(uploadHandler); - upload.addSucceededListener(uploadHandler); - upload.addFailedListener(uploadHandler); - upload.addFinishedListener(uploadHandler); - upload.addProgressListener(uploadHandler); - upload.addStartedListener(uploadHandler); - upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + final Upload upload = new Upload(); + final UploadHandler uploadHandler = new UploadHandler(null, 0, this, uploadInfoWindow, + spInfo.getMaxArtifactFileSize(), upload, null); + upload.setButtonCaption(i18n.get("upload.file")); + upload.setImmediate(true); + upload.setReceiver(uploadHandler); + upload.addSucceededListener(uploadHandler); + upload.addFailedListener(uploadHandler); + upload.addFinishedListener(uploadHandler); + upload.addProgressListener(uploadHandler); + upload.addStartedListener(uploadHandler); + upload.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); - fileUploadLayout = new HorizontalLayout(); - fileUploadLayout.setSpacing(true); - fileUploadLayout.addComponent(upload); - fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); - fileUploadLayout.addComponent(processBtn); - fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT); - fileUploadLayout.addComponent(discardBtn); - fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT); - setMargin(false); + fileUploadLayout = new HorizontalLayout(); + fileUploadLayout.setSpacing(true); + fileUploadLayout.addComponent(upload); + fileUploadLayout.setComponentAlignment(upload, Alignment.MIDDLE_LEFT); + fileUploadLayout.addComponent(processBtn); + fileUploadLayout.setComponentAlignment(processBtn, Alignment.MIDDLE_RIGHT); + fileUploadLayout.addComponent(discardBtn); + fileUploadLayout.setComponentAlignment(discardBtn, Alignment.MIDDLE_RIGHT); + setMargin(false); - /* create drag-drop wrapper for drop area */ - dropAreaWrapper = new DragAndDropWrapper(createDropAreaLayout()); - dropAreaWrapper.setDropHandler(new DropAreahandler()); - setSizeFull(); - setSpacing(true); + /* create drag-drop wrapper for drop area */ + dropAreaWrapper = new DragAndDropWrapper(createDropAreaLayout()); + dropAreaWrapper.setDropHandler(new DropAreahandler()); + setSizeFull(); + setSpacing(true); - } + } - public DragAndDropWrapper getDropAreaWrapper() { - return dropAreaWrapper; - } + public DragAndDropWrapper getDropAreaWrapper() { + return dropAreaWrapper; + } - private class DropAreahandler implements DropHandler { + private class DropAreahandler implements DropHandler { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override - public AcceptCriterion getAcceptCriterion() { - return AcceptAll.get(); - } + @Override + public AcceptCriterion getAcceptCriterion() { + return AcceptAll.get(); + } - @Override - public void drop(final DragAndDropEvent event) { - if (validate()) { + @Override + public void drop(final DragAndDropEvent event) { + if (validate()) { ((WrapperTransferable) event.getTransferable()).getDraggedComponent(); final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); if (files != null) { @@ -207,12 +207,12 @@ public class UploadLayout extends VerticalLayout { uploadInfoWindow.uploadSessionStarted(); } else { //If the upload is not started, it signifies all dropped files as either duplicate or directory.So display message accordingly - displayCompositeMessage(hasDirectory); + displayCompositeMessage(); } } } - } - } + } + } private static boolean isDirectory(final Html5File file) { if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) { @@ -221,12 +221,10 @@ public class UploadLayout extends VerticalLayout { return false; } - private void displayCompositeMessage(final Boolean hasDirectory) { - final String duplicateMessage = showDuplicateMessage(); + private void displayCompositeMessage() { + final String duplicateMessage = getDuplicateFileValidationMessage(); final StringBuilder compositeMessage = new StringBuilder(); - if (null != duplicateMessage) { - // in case if all selected files are duplicate ,then display - // messag + if (!Strings.isNullOrEmpty(duplicateMessage)) { compositeMessage.append(duplicateMessage); } if (hasDirectory) { @@ -239,395 +237,397 @@ public class UploadLayout extends VerticalLayout { uiNotification.displayValidationError(compositeMessage.toString()); } } + + private VerticalLayout createDropAreaLayout() { + dropAreaLayout = new VerticalLayout(); + final Label dropHereLabel = new Label("Drop files to upload"); + dropHereLabel.setWidth(null); - private VerticalLayout createDropAreaLayout() { - dropAreaLayout = new VerticalLayout(); - final Label dropHereLabel = new Label("Drop files to upload"); - dropHereLabel.setWidth(null); + final Label dropIcon = new Label(FontAwesome.ARROW_DOWN.getHtml(), ContentMode.HTML); + dropIcon.addStyleName("drop-icon"); + dropIcon.setWidth(null); - final Label dropIcon = new Label(FontAwesome.ARROW_DOWN.getHtml(), ContentMode.HTML); - dropIcon.addStyleName("drop-icon"); - dropIcon.setWidth(null); + dropAreaLayout.addComponent(dropIcon); + dropAreaLayout.setComponentAlignment(dropIcon, Alignment.BOTTOM_CENTER); + dropAreaLayout.addComponent(dropHereLabel); + dropAreaLayout.setComponentAlignment(dropHereLabel, Alignment.TOP_CENTER); + dropAreaLayout.setSizeFull(); + dropAreaLayout.setStyleName("upload-drop-area-layout-info"); + dropAreaLayout.setSpacing(false); + return dropAreaLayout; + } - dropAreaLayout.addComponent(dropIcon); - dropAreaLayout.setComponentAlignment(dropIcon, Alignment.BOTTOM_CENTER); - dropAreaLayout.addComponent(dropHereLabel); - dropAreaLayout.setComponentAlignment(dropHereLabel, Alignment.TOP_CENTER); - dropAreaLayout.setSizeFull(); - dropAreaLayout.setStyleName("upload-drop-area-layout-info"); - dropAreaLayout.setSpacing(false); - return dropAreaLayout; - } + private void createProcessButton() { + processBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON, + SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null, + SPUIButtonStyleSmall.class); + processBtn.setIcon(FontAwesome.BELL); + processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + processBtn.addClickListener(event -> displayConfirmWindow(event)); + processBtn.setHtmlContentAllowed(true); + if (artifactUploadState.getFileSelected().isEmpty()) { + processBtn.setEnabled(false); + } + } - private void createProcessButton() { - processBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON, - SPUILabelDefinitions.PROCESS, SPUILabelDefinitions.PROCESS, null, false, null, - SPUIButtonStyleSmall.class); - processBtn.setIcon(FontAwesome.BELL); - processBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); - processBtn.addClickListener(event -> displayConfirmWindow(event)); - processBtn.setHtmlContentAllowed(true); - if (artifactUploadState.getFileSelected().isEmpty()) { - processBtn.setEnabled(false); - } - } + private void createDiscardBtn() { + discardBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_BUTTON, + SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null, + SPUIButtonStyleSmall.class); + discardBtn.setIcon(FontAwesome.TRASH_O); + discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + discardBtn.addClickListener(event -> discardUploadData(event)); + } - private void createDiscardBtn() { - discardBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.UPLOAD_DISCARD_BUTTON, - SPUILabelDefinitions.DISCARD, SPUILabelDefinitions.DISCARD, null, false, null, - SPUIButtonStyleSmall.class); - discardBtn.setIcon(FontAwesome.TRASH_O); - discardBtn.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); - discardBtn.addClickListener(event -> discardUploadData(event)); - } + private StreamVariable createStreamVariable(final Html5File file) { + return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow, + spInfo.getMaxArtifactFileSize(), null, file.getType()); + } - private StreamVariable createStreamVariable(final Html5File file) { - return new UploadHandler(file.getFileName(), file.getFileSize(), this, uploadInfoWindow, - spInfo.getMaxArtifactFileSize(), null, file.getType()); - } + boolean checkForDuplicate(final String filename) { + final Boolean isDuplicate = checkIfFileIsDuplicate(filename); + if (isDuplicate) { + getDuplicateFileNamesList().add(filename); + } + return isDuplicate; + } - boolean checkForDuplicate(final String filename) { - final Boolean isDuplicate = checkIfFileIsDuplicate(filename); - if (isDuplicate) { - getDuplicateFileNamesList().add(filename); - } - return isDuplicate; - } + @EventBusListenerMethod(scope = EventScope.SESSION) + void toggleProcessButton(final UploadArtifactUIEvent event) { + if (event == UploadArtifactUIEvent.ENABLE_PROCESS_BUTTON) { + processBtn.setEnabled(true); + } else if (event == UploadArtifactUIEvent.DISABLE_PROCESS_BUTTON) { + processBtn.setEnabled(false); + } + } - @EventBusListenerMethod(scope = EventScope.SESSION) - void toggleProcessButton(final UploadArtifactUIEvent event) { - if (event == UploadArtifactUIEvent.ENABLE_PROCESS_BUTTON) { - processBtn.setEnabled(true); - } else if (event == UploadArtifactUIEvent.DISABLE_PROCESS_BUTTON) { - processBtn.setEnabled(false); - } - } + /** + * Save uploaded file details. + * + * @param stream + * read from uploaded file + * @param name + * file name + * @param size + * file size + * @param mimeType + * the mimeType of the file + * @throws IOException + * in case of upload errors + */ + OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType) { + File tempFile = null; + try { + tempFile = File.createTempFile("spUiArtifactUpload", null); - /** - * Save uploaded file details. - * - * @param stream - * read from uploaded file - * @param name - * file name - * @param size - * file size - * @param mimeType - * the mimeType of the file - * @throws IOException - * in case of upload errors - */ - OutputStream saveUploadedFileDetails(final String name, final long size, final String mimeType) { - File tempFile = null; - try { - tempFile = File.createTempFile("spUiArtifactUpload", null); + final OutputStream out = new FileOutputStream(tempFile); - final OutputStream out = new FileOutputStream(tempFile); + final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(), + selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion(), mimeType); - final CustomFile customFile = new CustomFile(name, size, tempFile.getAbsolutePath(), - selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion(), mimeType); + artifactUploadState.getFileSelected().add(customFile); + processBtn.setEnabled(false); - artifactUploadState.getFileSelected().add(customFile); - processBtn.setEnabled(false); + if (!artifactUploadState.getBaseSwModuleList().keySet().contains(currentBaseSoftwareModuleKey)) { + artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSoftwareModule); + } + return out; + } catch (final FileNotFoundException e) { + LOG.error("Upload failed {}", e); + throw new ArtifactUploadFailedException(i18n.get("message.file.not.found")); + } catch (final IOException e) { + LOG.error("Upload failed {}", e); + throw new ArtifactUploadFailedException(i18n.get("message.upload.failed")); + } + } - if (!artifactUploadState.getBaseSwModuleList().keySet().contains(currentBaseSoftwareModuleKey)) { - artifactUploadState.getBaseSwModuleList().put(currentBaseSoftwareModuleKey, selectedSoftwareModule); - } - return out; - } catch (final FileNotFoundException e) { - LOG.error("Upload failed {}", e); - throw new ArtifactUploadFailedException(i18n.get("message.file.not.found")); - } catch (final IOException e) { - LOG.error("Upload failed {}", e); - throw new ArtifactUploadFailedException(i18n.get("message.upload.failed")); - } - } + Boolean validate() { + if (!isSoftwareModuleSelected()) { + uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected")); - Boolean validate() { - if (!isSoftwareModuleSelected()) { - uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected")); - return false; - } - return true; - } + return false; + } + return true; + } - SoftwareModule getSoftwareModuleSelected() { - if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) { - return artifactUploadState.getSelectedBaseSoftwareModule().get(); - } - return null; - } + SoftwareModule getSoftwareModuleSelected() { + if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) { + return artifactUploadState.getSelectedBaseSoftwareModule().get(); + } + return null; + } - Boolean isSoftwareModuleSelected() { - if (!artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { - return false; - } - return true; - } + Boolean isSoftwareModuleSelected() { + if (!artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { + return false; + } + return true; + } - /** - * Check if file selected is duplicate.i,e already selected for upload for - * same software module. - * - * @param name - * file name - * @return Boolean - */ - public Boolean checkIfFileIsDuplicate(final String name) { - Boolean isDuplicate = false; - final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + /** + * Check if file selected is duplicate.i,e already selected for upload for + * same software module. + * + * @param name + * file name + * @return Boolean + */ + public Boolean checkIfFileIsDuplicate(final String name) { + Boolean isDuplicate = false; + final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); - for (final CustomFile customFile : artifactUploadState.getFileSelected()) { - final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( - customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); - if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { - isDuplicate = true; - break; - } - } - return isDuplicate; - } + for (final CustomFile customFile : artifactUploadState.getFileSelected()) { + final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( + customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); + if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { + isDuplicate = true; + break; + } + } + return isDuplicate; + } - void decreaseNumberOfFileUploadsExpected() { - numberOfFileUploadsExpected.decrementAndGet(); - } + void decreaseNumberOfFileUploadsExpected() { + numberOfFileUploadsExpected.decrementAndGet(); + } - List getDuplicateFileNamesList() { - return duplicateFileNamesList; - } + List getDuplicateFileNamesList() { + return duplicateFileNamesList; + } - /** - * Update pending action count. - */ - void updateActionCount() { - if (!artifactUploadState.getFileSelected().isEmpty()) { - processBtn.setCaption(SPUILabelDefinitions.PROCESS + "
" - + artifactUploadState.getFileSelected().size() + "
"); - } else { - processBtn.setCaption(SPUILabelDefinitions.PROCESS); - } - } + /** + * Update pending action count. + */ + void updateActionCount() { + if (!artifactUploadState.getFileSelected().isEmpty()) { + processBtn.setCaption(SPUILabelDefinitions.PROCESS + "
" + + artifactUploadState.getFileSelected().size() + "
"); + } else { + processBtn.setCaption(SPUILabelDefinitions.PROCESS); + } + } - void displayValidationMessage() { - // check if streaming of all dropped files are completed - if (numberOfFilesActuallyUpload.intValue() == numberOfFileUploadsExpected.intValue()) { - displayCompositeMessage(hasDirectory); - } - } + void displayDuplicateValidationMessage() { + // check if streaming of all dropped files are completed + if (numberOfFilesActuallyUpload.intValue() == numberOfFileUploadsExpected.intValue()) { + displayCompositeMessage(); + } + } + - /** - * Show duplicate file selected message. - * - * @return duplicate file names - */ - public String showDuplicateMessage() { + private String getDuplicateFileValidationMessage() { + StringBuilder message = new StringBuilder(); if (!duplicateFileNamesList.isEmpty()) { final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); if (duplicateFileNamesList.size() == 1) { - return i18n.get("message.no.duplicateFile") + fileNames; + message.append(i18n.get("message.no.duplicateFile") + fileNames); } else if (duplicateFileNamesList.size() > 1) { - return i18n.get("message.no.duplicateFiles"); + message.append(i18n.get("message.no.duplicateFiles")); } duplicateFileNamesList.clear(); } - return null; + return message.toString(); } - void increaseNumberOfFileUploadsExpected() { - numberOfFileUploadsExpected.incrementAndGet(); + public void showDuplicateMessage() { + uiNotification.displayValidationError(getDuplicateFileValidationMessage()); } + + void increaseNumberOfFileUploadsExpected() { + numberOfFileUploadsExpected.incrementAndGet(); + } - void updateFileSize(final String name, final long size) { - final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - final String currentBaseSoftwareModuleKey = HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); + void updateFileSize(final String name, final long size) { + final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); + final String currentBaseSoftwareModuleKey = HawkbitCommonUtil + .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion()); - for (final CustomFile customFile : artifactUploadState.getFileSelected()) { - final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( - customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); - if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { - customFile.setFileSize(size); - break; - } - } - } + for (final CustomFile customFile : artifactUploadState.getFileSelected()) { + final String fileSoftwareModuleKey = HawkbitCommonUtil.getFormattedNameVersion( + customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion()); + if (customFile.getFileName().equals(name) && currentBaseSoftwareModuleKey.equals(fileSoftwareModuleKey)) { + customFile.setFileSize(size); + break; + } + } + } - void increaseNumberOfFilesActuallyUpload() { - numberOfFilesActuallyUpload.incrementAndGet(); - } + void increaseNumberOfFilesActuallyUpload() { + numberOfFilesActuallyUpload.incrementAndGet(); + } - /** - * Enable process button once upload is completed. - */ - boolean enableProcessBtn() { - if (numberOfFilesActuallyUpload.intValue() >= numberOfFileUploadsExpected.intValue()) { - processBtn.setEnabled(true); - numberOfFileUploadsExpected.set(0); - numberOfFilesActuallyUpload.set(0); - return true; - } - return false; - } + /** + * Enable process button once upload is completed. + */ + boolean enableProcessBtn() { + if (numberOfFilesActuallyUpload.intValue() >= numberOfFileUploadsExpected.intValue()) { + processBtn.setEnabled(true); + numberOfFileUploadsExpected.set(0); + numberOfFilesActuallyUpload.set(0); + return true; + } + return false; + } - Set getFileSelected() { - return artifactUploadState.getFileSelected(); - } + Set getFileSelected() { + return artifactUploadState.getFileSelected(); + } - private void discardUploadData(final Button.ClickEvent event) { - if (event.getButton().equals(discardBtn)) { - if (artifactUploadState.getFileSelected().isEmpty()) { - uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); + private void discardUploadData(final Button.ClickEvent event) { + if (event.getButton().equals(discardBtn)) { + if (artifactUploadState.getFileSelected().isEmpty()) { + uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); - } else { - clearFileList(); - } - } - } + } else { + clearFileList(); + } + } + } - /** - * Clear details. - */ - void clearFileList() { - // delete file system zombies - artifactUploadState.getFileSelected().forEach(customFile -> { - final File file = new File(customFile.getFilePath()); - file.delete(); - }); + /** + * Clear details. + */ + void clearFileList() { + // delete file system zombies + artifactUploadState.getFileSelected().forEach(customFile -> { + final File file = new File(customFile.getFilePath()); + file.delete(); + }); - artifactUploadState.getFileSelected().clear(); - artifactUploadState.getBaseSwModuleList().clear(); - processBtn.setCaption(SPUILabelDefinitions.PROCESS); - /* disable when there is no files to upload. */ - processBtn.setEnabled(false); - numberOfFileUploadsExpected.set(0); - numberOfFilesActuallyUpload.set(0); - duplicateFileNamesList.clear(); - } + artifactUploadState.getFileSelected().clear(); + artifactUploadState.getBaseSwModuleList().clear(); + processBtn.setCaption(SPUILabelDefinitions.PROCESS); + /* disable when there is no files to upload. */ + processBtn.setEnabled(false); + numberOfFileUploadsExpected.set(0); + numberOfFilesActuallyUpload.set(0); + duplicateFileNamesList.clear(); + } - 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); - } - } + 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); + } + } - /** - * Set artifact upload result pop up size changes. - * - * @param newWidth - * new width of result pop up - * @param newHeight - * new height of result pop up - */ - void setResultPopupHeightWidth(final float newWidth, final float newHeight) { - if (currentUploadConfirmationwindow != null - && 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); - } - } + /** + * Set artifact upload result pop up size changes. + * + * @param newWidth + * new width of result pop up + * @param newHeight + * new height of result pop up + */ + void setResultPopupHeightWidth(final float newWidth, final float newHeight) { + if (currentUploadConfirmationwindow != null + && 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); + } + } - private void displayConfirmWindow(final Button.ClickEvent event) { - if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON)) { - if (artifactUploadState.getFileSelected().isEmpty()) { - uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); - } else { - currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState); - UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow()); - setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), - Page.getCurrent().getBrowserWindowHeight()); - } - } - } + private void displayConfirmWindow(final Button.ClickEvent event) { + if (event.getComponent().getId().equals(SPUIComponetIdProvider.UPLOAD_PROCESS_BUTTON)) { + if (artifactUploadState.getFileSelected().isEmpty()) { + uiNotification.displayValidationError(i18n.get("message.error.noFileSelected")); + } else { + currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState); + UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow()); + setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(), + Page.getCurrent().getBrowserWindowHeight()); + } + } + } - /** - * @return - */ - I18N getI18n() { - return i18n; - } + /** + * @return + */ + I18N getI18n() { + return i18n; + } - /** - * @return - */ - SPInfo getSPInfo() { - return spInfo; - } + /** + * @return + */ + SPInfo getSPInfo() { + return spInfo; + } - void setCurrentUploadConfirmationwindow(final UploadConfirmationwindow currentUploadConfirmationwindow) { - this.currentUploadConfirmationwindow = currentUploadConfirmationwindow; - } + void setCurrentUploadConfirmationwindow(final UploadConfirmationwindow currentUploadConfirmationwindow) { + this.currentUploadConfirmationwindow = currentUploadConfirmationwindow; + } - /** - * @return - */ + /** + * @return + */ - VerticalLayout getDropAreaLayout() { - return dropAreaLayout; - } + VerticalLayout getDropAreaLayout() { + return dropAreaLayout; + } - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final UploadArtifactUIEvent event) { - if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) { - ui.access(() -> updateActionCount()); - } - } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final UploadArtifactUIEvent event) { + if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) { + ui.access(() -> updateActionCount()); + } + } - @PreDestroy - void destroy() { - /* - * It's good manners to do this, even though vaadin-spring will - * automatically unsubscribe when this UI is garbage collected. - */ - eventBus.unsubscribe(this); - } + @PreDestroy + void destroy() { + /* + * It's good manners to do this, even though vaadin-spring will + * automatically unsubscribe when this UI is garbage collected. + */ + eventBus.unsubscribe(this); + } - /** - * set upload status and confirmation window. - * - * @param newWidth - * browser width - * @param newHeight - * browser height - */ - public void setUploadPopupSize(final float newWidth, final float newHeight) { - setConfirmationPopupHeightWidth(newWidth, newHeight); - setResultPopupHeightWidth(newWidth, newHeight); - } + /** + * set upload status and confirmation window. + * + * @param newWidth + * browser width + * @param newHeight + * browser height + */ + public void setUploadPopupSize(final float newWidth, final float newHeight) { + setConfirmationPopupHeightWidth(newWidth, newHeight); + setResultPopupHeightWidth(newWidth, newHeight); + } - /** - * @param selectedBaseSoftwareModule - */ - public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) { - eventBus.publish(this, - new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule)); - } + /** + * @param selectedBaseSoftwareModule + */ + public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) { + eventBus.publish(this, + new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule)); + } - /** - * @return the fileUploadLayout - */ - public HorizontalLayout getFileUploadLayout() { - return fileUploadLayout; - } + /** + * @return the fileUploadLayout + */ + public HorizontalLayout getFileUploadLayout() { + return fileUploadLayout; + } - public UINotification getUINotification() { - return uiNotification; - } + public UINotification getUINotification() { + return uiNotification; + } } From d3035ccebe7969b34a1552f516078ee1d6e9afb3 Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Mon, 8 Feb 2016 13:20:50 +0100 Subject: [PATCH 03/45] modified error message Signed-off-by: asharani-murugesh --- .../org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java | 1 + hawkbit-ui/src/main/resources/messages.properties | 2 +- hawkbit-ui/src/main/resources/messages_de.properties | 2 +- hawkbit-ui/src/main/resources/messages_en.properties | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index 0f9bcd5cc..1737d0495 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -196,6 +196,7 @@ public class UploadLayout extends VerticalLayout { if (!checkForDuplicate(file.getFileName())) { numberOfFileUploadsExpected.incrementAndGet(); file.setStreamVariable(createStreamVariable(file)); + hasDirectory = Boolean.FALSE; } } else { hasDirectory = Boolean.TRUE; diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties index 8e785c3db..168920f52 100644 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -308,7 +308,7 @@ soft.module.os =OS message.error.noFileSelected = No file selected for upload message.error.noProvidedName = Please provide custom file name message.error.noSwModuleSelected = Please select a software module -message.no.duplicateFiles = duplicate files selected +message.no.duplicateFiles = Duplicate files selected message.no.duplicateFile = Duplicate file selected : message.delete.artifact = Are you sure that you want to delete artifact {0} ? message.duplicate.filename = Duplicate file name diff --git a/hawkbit-ui/src/main/resources/messages_de.properties b/hawkbit-ui/src/main/resources/messages_de.properties index 94a0df4cf..62088946a 100644 --- a/hawkbit-ui/src/main/resources/messages_de.properties +++ b/hawkbit-ui/src/main/resources/messages_de.properties @@ -305,7 +305,7 @@ soft.module.os =OS message.error.noFileSelected = No file selected for upload message.error.noProvidedName = Please provide custom file name message.error.noSwModuleSelected = Please select a software module -message.no.duplicateFiles = duplicate files selected +message.no.duplicateFiles = Duplicate files selected message.no.duplicateFile = Duplicate file selected : message.delete.artifact = Are you sure that you want to delete artifact {0} ? message.duplicate.filename = Duplicate file name diff --git a/hawkbit-ui/src/main/resources/messages_en.properties b/hawkbit-ui/src/main/resources/messages_en.properties index d31ca2af3..075347f12 100644 --- a/hawkbit-ui/src/main/resources/messages_en.properties +++ b/hawkbit-ui/src/main/resources/messages_en.properties @@ -299,7 +299,7 @@ soft.module.os =OS message.error.noFileSelected = No file selected for upload message.error.noProvidedName = Please provide custom file name message.error.noSwModuleSelected = Please select a software module -message.no.duplicateFiles = duplicate files selected +message.no.duplicateFiles = Duplicate files selected message.no.duplicateFile = Duplicate file selected : message.delete.artifact = Are you sure that you want to delete artifact {0} ? message.duplicate.filename = Duplicate file name From 3479a8d692ade5964503fdfafc96da426162dac9 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Wed, 10 Feb 2016 14:35:30 +0530 Subject: [PATCH 04/45] Drag and drop handles wrong item. Signed-off-by: venu1278 --- .../footer/SMDeleteActionsLayout.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java index 841256da4..eb8ed75e1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.ui.artifacts.footer; +import java.util.HashSet; import java.util.Set; import javax.annotation.PostConstruct; @@ -21,6 +22,7 @@ import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; +import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; @@ -36,6 +38,7 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.UI; +import com.vaadin.ui.Table.TableTransferable; /** * Upload view footer layout implementation. @@ -196,7 +199,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { final Component sourceComponent = event.getTransferable().getSourceComponent(); if (sourceComponent instanceof Table) { final Table sourceTable = (Table) event.getTransferable().getSourceComponent(); - addToDeleteList(sourceTable); + addToDeleteList(sourceTable,(TableTransferable) event.getTransferable()); updateSWActionCount(); } if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { @@ -220,16 +223,23 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { private void deleteSWModuleType(final String swModuleTypeName) { artifactUploadState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName); } - - private void addToDeleteList(final Table sourceTable) { - final Set swModuleIds = (Set) sourceTable.getValue(); - swModuleIds.forEach(id -> { + + private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) { + @SuppressWarnings("unchecked") + final Set swModuleSelected = (Set) sourceTable.getValue(); + final Set swModuleIdNameSet = new HashSet(); + if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) { + swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID)); + } else { + swModuleIdNameSet.addAll(swModuleSelected); + } + swModuleIdNameSet.forEach(id -> { final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id) .getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue(); artifactUploadState.getDeleteSofwareModules().put(id, swModuleName); }); } - + /** * Update the software module delete count. */ From f78bd68c032d63dcd0ee0697fd5a52a519c26935 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 10 Feb 2016 16:22:20 +0100 Subject: [PATCH 05/45] Verify that the target controller id cannot be empty Signed-off-by: SirWayne --- .../repository/ControllerManagement.java | 16 +++++--------- .../hawkbit/repository/TargetManagement.java | 7 +++++++ .../repository/ControllerManagementTest.java | 21 +++++++++++++++++++ .../repository/TargetManagementTest.java | 12 +++++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 844bbd097..e4a1e5e6b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -15,7 +15,6 @@ import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import javax.validation.constraints.NotNull; @@ -212,14 +211,9 @@ public class ControllerManagement implements EnvironmentAware { @Modifying @Transactional @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - public Target findOrRegisterTargetIfItDoesNotexist(@NotNull final String targetid, final URI address) { - final Specification spec = new Specification() { - @Override - public Predicate toPredicate(final Root targetRoot, final CriteriaQuery query, - final CriteriaBuilder cb) { - return cb.equal(targetRoot.get(Target_.controllerId), targetid); - } - }; + public Target findOrRegisterTargetIfItDoesNotexist(@NotEmpty final String targetid, final URI address) { + final Specification spec = (targetRoot, query, cb) -> cb.equal(targetRoot.get(Target_.controllerId), + targetid); Target target = targetRepository.findOne(spec); @@ -229,9 +223,9 @@ public class ControllerManagement implements EnvironmentAware { target.setName(targetid); return targetManagement.createTarget(target, TargetUpdateStatus.REGISTERED, System.currentTimeMillis(), address); - } else { - return updateLastTargetQuery(target.getTargetInfo(), address).getTarget(); } + + return updateLastTargetQuery(target.getTargetInfo(), address).getTarget(); } /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index e790d0a5e..fb824dfae 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -27,8 +27,10 @@ import javax.persistence.criteria.JoinType; import javax.persistence.criteria.Order; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; +import javax.validation.ConstraintViolationException; import javax.validation.constraints.NotNull; +import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.Constants; import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; @@ -931,6 +933,11 @@ public class TargetManagement { public Target createTarget(@NotNull final Target target, @NotNull final TargetUpdateStatus status, final Long lastTargetQuery, final URI address) { + if (StringUtils.isEmpty(target.getControllerId())) { + throw new ConstraintViolationException("Empty string for controller id not allowed", + Collections.emptySet()); + } + if (targetRepository.findByControllerId(target.getControllerId()) != null) { throw new EntityAlreadyExistsException(target.getControllerId()); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java index 8289b8173..41a7c7848 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java @@ -9,10 +9,13 @@ package org.eclipse.hawkbit.repository; import static org.fest.assertions.api.Assertions.assertThat; +import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; +import javax.validation.ConstraintViolationException; + import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.TestDataUtil; @@ -71,6 +74,24 @@ public class ControllerManagementTest extends AbstractIntegrationTest { .getNumberOfElements()).isEqualTo(3); } + @Test + @Description("Register a controller which not exist") + public void testfindOrRegisterTargetIfItDoesNotexist() { + final Target target = controllerManagament.findOrRegisterTargetIfItDoesNotexist("AA", null); + assertThat(target).as("target should not be null").isNotNull(); + + final Target sameTarget = controllerManagament.findOrRegisterTargetIfItDoesNotexist("AA", null); + assertThat(target).as("Target should be the equals").isEqualTo(sameTarget); + assertThat(targetRepository.count()).as("Only 1 target should be registred").isEqualTo(1L); + + try { + controllerManagament.findOrRegisterTargetIfItDoesNotexist("", null); + fail("target with empty controller id should not be registred"); + } catch (final ConstraintViolationException e) { + // ok + } + } + @Test @Description("Controller trys to finish an update process after it has been finished by an error action status.") public void tryToFinishUpdateProcessMoreThenOnce() { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index a7b8e673f..72f1951c6 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -26,6 +26,7 @@ import java.util.Set; import java.util.stream.Collectors; import javax.persistence.Query; +import javax.validation.ConstraintViolationException; import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.TestDataUtil; @@ -65,6 +66,17 @@ public class TargetManagementTest extends AbstractIntegrationTest { } } + @Test + @Description("Verify that a target with empty controller id cannot be created") + public void createTarget() { + try { + targetManagement.createTarget(new Target("")); + fail("target with empty controller id should not be created"); + } catch (final ConstraintViolationException e) { + // ok + } + } + @Test @Description("Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.") public void assignAndUnassignTargetsToTag() { From 46a71c1b3a2f8c28b4a8b069bc61a07fe8cabd90 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 10 Feb 2016 16:51:45 +0100 Subject: [PATCH 06/45] Use javax annotation for validation Signed-off-by: SirWayne --- .../org/eclipse/hawkbit/repository/TargetManagement.java | 7 ------- .../org/eclipse/hawkbit/repository/model/Target.java | 4 ++++ .../eclipse/hawkbit/repository/TargetManagementTest.java | 9 ++++++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index fb824dfae..e790d0a5e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -27,10 +27,8 @@ import javax.persistence.criteria.JoinType; import javax.persistence.criteria.Order; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.validation.ConstraintViolationException; import javax.validation.constraints.NotNull; -import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.Constants; import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent; import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; @@ -933,11 +931,6 @@ public class TargetManagement { public Target createTarget(@NotNull final Target target, @NotNull final TargetUpdateStatus status, final Long lastTargetQuery, final URI address) { - if (StringUtils.isEmpty(target.getControllerId())) { - throw new ConstraintViolationException("Empty string for controller id not allowed", - Collections.emptySet()); - } - if (targetRepository.findByControllerId(target.getControllerId()) != null) { throw new EntityAlreadyExistsException(target.getControllerId()); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java index 6de84ccaa..08e4fcecb 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java @@ -32,6 +32,8 @@ import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; import javax.persistence.Transient; import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.model.helper.SecurityChecker; @@ -74,6 +76,8 @@ public class Target extends NamedEntity implements Persistable { private static final long serialVersionUID = 1L; @Column(name = "controller_id", length = 64) + @Size(min = 1) + @NotNull private String controllerId; @Transient diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index 72f1951c6..3fe6a8738 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -68,13 +68,20 @@ public class TargetManagementTest extends AbstractIntegrationTest { @Test @Description("Verify that a target with empty controller id cannot be created") - public void createTarget() { + public void createTargetWithNoControllerId() { try { targetManagement.createTarget(new Target("")); fail("target with empty controller id should not be created"); } catch (final ConstraintViolationException e) { // ok } + + try { + targetManagement.createTarget(new Target(null)); + fail("target with empty controller id should not be created"); + } catch (final ConstraintViolationException e) { + // ok + } } @Test From fbc16a42746a60bcad9cacb997429b23ac9ca6aa Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Thu, 11 Feb 2016 12:06:44 +0100 Subject: [PATCH 07/45] Signed-off-by: asharani-murugesh --- .../footer/TargetFilterCountMessageLabel.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java index 1c8382223..c3e55f8a0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java @@ -71,12 +71,14 @@ public class TargetFilterCountMessageLabel extends Label { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final CustomFilterUIEvent custFUIEvent) { - if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY - || custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW + if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK || custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) { displayTargetFilterMessage(); } + else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY){ + this.getUI().access(() -> displayTargetFilterMessage()); + } } private void applyStyle() { From e84b5938533be765e9bd2a85a524ce2e79ba3c18 Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Thu, 11 Feb 2016 13:26:57 +0100 Subject: [PATCH 08/45] Safely getting access to the UI thread to modify the target count label Signed-off-by: asharani-murugesh --- .../filtermanagement/footer/TargetFilterCountMessageLabel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java index c3e55f8a0..c6bcc879e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java @@ -29,6 +29,7 @@ import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Label; +import com.vaadin.ui.UI; /** * @author Venugopal Boodidadinne(RBEI/BSJ) @@ -74,7 +75,7 @@ public class TargetFilterCountMessageLabel extends Label { if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK || custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW) { - displayTargetFilterMessage(); + UI.getCurrent().access(()->displayTargetFilterMessage()); } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY){ this.getUI().access(() -> displayTargetFilterMessage()); From 7fe23aa8a002603712b388adb71fa615937c3f3a Mon Sep 17 00:00:00 2001 From: venu1278 Date: Fri, 12 Feb 2016 14:34:17 +0530 Subject: [PATCH 09/45] clearing the search field should keep the focus. Signed-off-by: venu1278 --- .../smtable/SoftwareModuleTable.java | 36 ++++++++++--- .../dstable/DistributionSetTable.java | 41 +++++++++++---- .../distributions/smtable/SwModuleTable.java | 46 ++++++++++++----- .../management/dstable/DistributionTable.java | 51 ++++++++++++++----- .../management/targettable/TargetTable.java | 19 ++++++- 5 files changed, 150 insertions(+), 43 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index a4f8a8f70..bd9291473 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -78,6 +78,8 @@ public class SoftwareModuleTable extends AbstractTable { @Autowired private UploadViewAcceptCriteria uploadViewAcceptCriteria; + + private Boolean isFilterEvent = false; /** * Initialize the filter layout. @@ -105,7 +107,19 @@ public class SoftwareModuleTable extends AbstractTable { if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - refreshFilter(); + + if(prepareQueryConfigFilters().size()<1 && isFilterEvent==false){ + UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); + + }else { + refreshFilter(); + if(prepareQueryConfigFilters().size()<1){ + isFilterEvent = false; + }else{ + isFilterEvent = true; + } + } + //refreshFilter(); } }); } @@ -127,12 +141,7 @@ public class SoftwareModuleTable extends AbstractTable { */ @Override protected Container createContainer() { - final Map queryConfiguration = new HashMap(); - artifactUploadState.getSoftwareModuleFilters().getSearchText() - .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value)); - - artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType() - .ifPresent(type -> queryConfiguration.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type)); + final Map queryConfiguration = prepareQueryConfigFilters(); final BeanQueryFactory swQF = new BeanQueryFactory( BaseSwModuleBeanQuery.class); @@ -142,6 +151,19 @@ public class SoftwareModuleTable extends AbstractTable { new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); return container; } + + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap(); + artifactUploadState.getSoftwareModuleFilters().getSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + + artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType() + .ifPresent(type -> queryConfig.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type)); + + return queryConfig; + } + + @Override protected void addContainerProperties(final Container container) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index 107ed0299..a6f55cbc2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -114,6 +114,8 @@ public class DistributionSetTable extends AbstractTable { @Autowired private transient TargetManagement targetManagement; + + private Boolean isFilterEvent = false; /** * Initialize the component. @@ -157,15 +159,8 @@ public class DistributionSetTable extends AbstractTable { @Override protected Container createContainer() { - final Map queryConfiguration = new HashMap(); - manageDistUIState.getManageDistFilters().getSearchText() - .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value)); - - if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) { - queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, - manageDistUIState.getManageDistFilters().getClickedDistSetType()); - } - + final Map queryConfiguration = prepareQueryConfigFilters(); + final BeanQueryFactory distributionQF = new BeanQueryFactory( ManageDistBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); @@ -175,6 +170,20 @@ public class DistributionSetTable extends AbstractTable { return distContainer; } + + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap(); + manageDistUIState.getManageDistFilters().getSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + + if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) { + queryConfig.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, + manageDistUIState.getManageDistFilters().getClickedDistSetType()); + } + + return queryConfig; + } + /* * (non-Javadoc) @@ -612,7 +621,19 @@ public class DistributionSetTable extends AbstractTable { if (event == DistributionTableFilterEvent.FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { - UI.getCurrent().access(() -> refreshFilter()); + if(prepareQueryConfigFilters().size()<1 && isFilterEvent==false){ + UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); + + }else { + UI.getCurrent().access(() -> refreshFilter()); + if(prepareQueryConfigFilters().size()<1){ + isFilterEvent = false; + }else{ + isFilterEvent = true; + } + } + + // UI.getCurrent().access(() -> refreshFilter()); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index 17ee9b8af..6d5b7dcd5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -94,6 +94,8 @@ public class SwModuleTable extends AbstractTable { @Autowired private ArtifactDetailsLayout artifactDetailsLayout; + + private Boolean isFilterEvent = false; /** * Initialize the filter layout. @@ -124,9 +126,23 @@ public class SwModuleTable extends AbstractTable { if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - refreshFilter(); - styleTableOnDistSelection(); - } + if(prepareQueryConfigFilters().size()<2 && isFilterEvent==false){ + UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); + + }else { + UI.getCurrent().access(() ->{ refreshFilter(); + styleTableOnDistSelection(); + }); + if(prepareQueryConfigFilters().size()<2){ + isFilterEvent = false; + }else{ + isFilterEvent = true; + } + } + + /* refreshFilter(); + styleTableOnDistSelection();*/ + } }); } @@ -177,15 +193,7 @@ public class SwModuleTable extends AbstractTable { */ @Override protected Container createContainer() { - final Map queryConfiguration = new HashMap(); - manageDistUIState.getSoftwareModuleFilters().getSearchText() - .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value)); - - manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType() - .ifPresent(type -> queryConfiguration.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type)); - - manageDistUIState.getLastSelectedDistribution().ifPresent( - distIdName -> queryConfiguration.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, distIdName.getId())); + final Map queryConfiguration = prepareQueryConfigFilters(); final BeanQueryFactory swQF = new BeanQueryFactory( SwModuleBeanQuery.class); @@ -195,6 +203,20 @@ public class SwModuleTable extends AbstractTable { new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); return container; } + + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap(); + manageDistUIState.getSoftwareModuleFilters().getSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + + manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType() + .ifPresent(type -> queryConfig.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type)); + + manageDistUIState.getLastSelectedDistribution().ifPresent( + distIdName -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, distIdName.getId())); + + return queryConfig; + } /* * (non-Javadoc) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index 225407b84..e8f9e57ac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -112,6 +112,8 @@ public class DistributionTable extends AbstractTable { private Boolean isDistPinned = false; private Button distributinPinnedBtn; + + private Boolean isFilterEvent = false; /** * Initialize the distribution table. @@ -140,7 +142,24 @@ public class DistributionTable extends AbstractTable { if (event == DistributionTableFilterEvent.FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { - UI.getCurrent().access(() -> refreshFilter()); + if(((boolean)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) + && ((List)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() + && prepareQueryConfigFilters().size()<3 + && isFilterEvent==false){ + UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); + + }else { + UI.getCurrent().access(() -> refreshFilter()); + if(((boolean)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) + && ((List)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() + && prepareQueryConfigFilters().size()<3){ + isFilterEvent = false; + }else{ + isFilterEvent = true; + } + } + + // UI.getCurrent().access(() -> refreshFilter()); } } @@ -219,18 +238,8 @@ public class DistributionTable extends AbstractTable { */ @Override protected Container createContainer() { - final Map queryConfiguration = new HashMap(); - managementUIState.getDistributionTableFilters().getSearchText() - .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value)); - managementUIState.getDistributionTableFilters().getPinnedTargetId() - .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value)); - final List list = new ArrayList(); - queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, - managementUIState.getDistributionTableFilters().isNoTagSelected()); - if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) { - list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags()); - } - queryConfiguration.put(SPUIDefinitions.FILTER_BY_TAG, list); + final Map queryConfiguration = prepareQueryConfigFilters(); + final BeanQueryFactory distributionQF = new BeanQueryFactory( DistributionBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); @@ -239,6 +248,22 @@ public class DistributionTable extends AbstractTable { distributionQF); return distributionContainer; } + + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap(); + managementUIState.getDistributionTableFilters().getSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + managementUIState.getDistributionTableFilters().getPinnedTargetId() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value)); + final List list = new ArrayList(); + queryConfig.put(SPUIDefinitions.FILTER_BY_NO_TAG, + managementUIState.getDistributionTableFilters().isNoTagSelected()); + if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) { + list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags()); + } + queryConfig.put(SPUIDefinitions.FILTER_BY_TAG, list); + return queryConfig; + } /* * (non-Javadoc) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 62276346e..186207c50 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -15,6 +15,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -138,6 +139,9 @@ public class TargetTable extends AbstractTable implements Handler { private Boolean isTargetPinned = Boolean.FALSE; private ShortcutAction actionSelectAll; private ShortcutAction actionUnSelectAll; + + private Boolean isFilterEvent = Boolean.FALSE;; + @Override @PostConstruct @@ -207,7 +211,20 @@ public class TargetTable extends AbstractTable implements Handler { void onEvent(final TargetFilterEvent filterEvent) { UI.getCurrent().access(() -> { if (checkFilterEvent(filterEvent)) { - refreshFilter(); + if(((boolean)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) + && prepareQueryConfigFilters().size()<2 + && isFilterEvent==Boolean.FALSE){ + ((LazyQueryContainer) getContainerDataSource()).refresh(); + + }else { + refreshFilter(); + if(prepareQueryConfigFilters().size()<2){ + isFilterEvent = Boolean.FALSE; + }else{ + isFilterEvent = Boolean.TRUE; + } + } + eventBus.publish(this, ManagementUIEvent.TARGET_TABLE_FILTER); } }); From b30375e9e6d046e2e4f38bd9620d3ce14e24397b Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 12 Feb 2016 12:36:12 +0100 Subject: [PATCH 10/45] fix count select statement join is wrong Signed-off-by: Michael Hirsch --- .../eclipse/hawkbit/repository/RolloutGroupManagement.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java index e98439b57..54ff37e87 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java @@ -245,8 +245,9 @@ public class RolloutGroupManagement { JoinType.LEFT); final Root countQueryFrom = countQuery.distinct(true).from(RolloutTargetGroup.class); - countQuery - .select(cb.count(countQueryFrom.join(RolloutTargetGroup_.target).join(Target_.actions, JoinType.LEFT))) + countQueryFrom.join(RolloutTargetGroup_.target); + countQueryFrom.join(RolloutTargetGroup_.actions, JoinType.LEFT); + countQuery.select(cb.count(countQueryFrom)) .where(cb.equal(countQueryFrom.get(RolloutTargetGroup_.rolloutGroup), rolloutGroup)); final Long totalCount = entityManager.createQuery(countQuery).getSingleResult(); From e2927acfca50775afaf67a6f41b7b858892a795f Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Fri, 12 Feb 2016 13:18:55 +0100 Subject: [PATCH 11/45] reduce logging from info to debug when checking rollout Signed-off-by: Michael Hirsch --- .../java/org/eclipse/hawkbit/repository/RolloutManagement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 0d3bc62c6..1573048ec 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -552,7 +552,7 @@ public class RolloutManagement { if (updated == 0) { // nothing to check, maybe another instance already checked in // between - LOGGER.info("No rolloutcheck necessary for current scheduled check {}, next check at {}", lastCheck, + LOGGER.debug("No rolloutcheck necessary for current scheduled check {}, next check at {}", lastCheck, lastCheck + delayBetweenChecks); return; } From 88c854f2beab7ad39581faf8a82383d2027bbd08 Mon Sep 17 00:00:00 2001 From: Jonathan Philip Knoblauch Date: Fri, 12 Feb 2016 13:47:53 +0100 Subject: [PATCH 12/45] =?UTF-8?q?Clean=20code=20for=20junit=20tests=20?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added messages to JUnit assertions - Added Description when missing - Changed to assertThat when assertEquals Signed-off-by: Jonathan Philip Knoblauch --- .../AmqpControllerAuthentficationTest.java | 26 +++-- .../repository/ReportManagementTest.java | 95 ++++++++++-------- .../repository/TargetManagementTest.java | 96 +++++++++++-------- .../repository/rsql/RSQLTargetFieldTest.java | 3 +- .../controller/ArtifactDownloadTest.java | 9 +- .../rest/resource/SortUtilityTest.java | 52 +++++++--- .../ui/utils/NamingThreadFactoryTest.java | 17 +++- 7 files changed, 190 insertions(+), 108 deletions(-) diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java index 5a77c5fce..1d962907b 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java @@ -45,7 +45,7 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * - * + * Test Amqp controller authentfication. */ @Features("AMQP Authenfication Test") @Stories("Tests the authenfication") @@ -86,24 +86,34 @@ public class AmqpControllerAuthentficationTest { amqpMessageHandlerService.setAuthenticationManager(authenticationManager); } - @Test(expected = BadCredentialsException.class) + @Test @Description("Tests authentication manager without principal") public void testAuthenticationeBadCredantialsWithoutPricipal() { final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345"); - authenticationManager.doAuthenticate(securityToken); - fail(); + try { + authenticationManager.doAuthenticate(securityToken); + fail("BadCredentialsException was excepeted since principal was missing"); + } catch (final BadCredentialsException exception) { + // test ok - exception was excepted + } + } - @Test(expected = BadCredentialsException.class) - @Description("Tests authentication manager without wrong credential") + @Test + @Description("Tests authentication manager without wrong credential") public void testAuthenticationBadCredantialsWithWrongCredential() { final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345"); when(systemManagement.getConfigurationValue( eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), any())) .thenReturn(Boolean.TRUE); securityToken.getHeaders().put(TenantSecruityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLLER_ID); - authenticationManager.doAuthenticate(securityToken); - fail(); + try { + authenticationManager.doAuthenticate(securityToken); + fail("BadCredentialsException was excepeted due to wrong credential"); + } catch (final BadCredentialsException exception) { + // test ok - exception was excepted + } + } @Test diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java index 5c9c86aa7..bb5450083 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java @@ -99,7 +99,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { assertThat(targetsCreatedOverPeriod.getData()).hasSize(maxMonthBackAmountReportTargets + 1); for (final DataReportSeriesItem reportItem : targetsCreatedOverPeriod.getData()) { // only one target is created for each month - assertThat(reportItem.getData().intValue()).isEqualTo(1); + assertThat(reportItem.getData().intValue()).as("Target for each month").isEqualTo(1); } // check cache evict @@ -109,7 +109,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { } targetsCreatedOverPeriod = reportManagement.targetsCreatedOverPeriod(DateTypes.perMonth(), from, to); for (final DataReportSeriesItem reportItem : targetsCreatedOverPeriod.getData()) { - assertThat(reportItem.getData().intValue()).isEqualTo(2); + assertThat(reportItem.getData().intValue()).as("Target for each month").isEqualTo(2); } } @@ -221,21 +221,26 @@ public class ReportManagementTest extends AbstractIntegrationTest { .getData()[0]; if (dataReportSeriesItem.getType().equals("ds1")) { // total count of three because ds1 has two different versions - assertThat(dataReportSeriesItem.getData()).isEqualTo(3L); + assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 1 in statistics") + .isEqualTo(3L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(Arrays.stream(outerData).map(DataReportSeriesItem::getType).collect(Collectors.toList())) .contains("0.0.0", "0.0.1"); } else if (dataReportSeriesItem.getType().equals("ds2")) { - assertThat(dataReportSeriesItem.getData()).isEqualTo(1L); + assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 2 in statistics") + .isEqualTo(1L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(outerData).hasSize(1); - assertThat(outerData[0].getType()).isEqualTo("0.0.2"); - + assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 2 in statistics") + .isEqualTo("0.0.2"); } else if (dataReportSeriesItem.getType().equals("ds3")) { - assertThat(dataReportSeriesItem.getData()).isEqualTo(0L); + + assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 3 in statistics") + .isEqualTo(0L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(outerData).hasSize(1); - assertThat(outerData[0].getType()).isEqualTo("0.0.3"); + assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 3 in statistics") + .isEqualTo("0.0.3"); } else { fail("no assertion count for distribution set " + dataReportSeriesItem.getType()); } @@ -251,8 +256,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { final DataReportSeriesItem dataReportSeriesItem = innerOuterDataReportSeries.getInnerSeries() .getData()[0]; if (dataReportSeriesItem.getType().equals("ds1")) { - assertThat(dataReportSeriesItem.getData()).isEqualTo(4L); - + assertThat(dataReportSeriesItem.getData()).as("Data report item number").isEqualTo(4L); } } } @@ -278,19 +282,23 @@ public class ReportManagementTest extends AbstractIntegrationTest { switch (reportItem.getType()) { case ERROR: - assertThat(reportItem.getData()).isEqualTo(knownErrorCount); + assertThat(reportItem.getData()).as("ERROR count for targets in statistics").isEqualTo(knownErrorCount); break; case IN_SYNC: - assertThat(reportItem.getData()).isEqualTo(knownSyncCount); + assertThat(reportItem.getData()).as("IN_SYNC count for targets in statistics") + .isEqualTo(knownSyncCount); break; case PENDING: - assertThat(reportItem.getData()).isEqualTo(knownPendingCount); + assertThat(reportItem.getData()).as("PENDING count for targets in statistics") + .isEqualTo(knownPendingCount); break; case REGISTERED: - assertThat(reportItem.getData()).isEqualTo(knownRegCount); + assertThat(reportItem.getData()).as("REGISTERED count for targets in statistics") + .isEqualTo(knownRegCount); break; case UNKNOWN: - assertThat(reportItem.getData()).isEqualTo(knownUnknownCount); + assertThat(reportItem.getData()).as("UNKNOWN count for targets in statistics") + .isEqualTo(knownUnknownCount); break; default: fail("missing case for unknown target update status " + reportItem.getType()); @@ -309,19 +317,24 @@ public class ReportManagementTest extends AbstractIntegrationTest { switch (reportItem.getType()) { case ERROR: - assertThat(reportItem.getData()).isEqualTo(knownErrorCount * 2); + assertThat(reportItem.getData()).as("ERROR count for targets in statistics") + .isEqualTo(knownErrorCount * 2); break; case IN_SYNC: - assertThat(reportItem.getData()).isEqualTo(knownSyncCount * 2); + assertThat(reportItem.getData()).as("IN_SYNC count for targets in statistics") + .isEqualTo(knownSyncCount * 2); break; case PENDING: - assertThat(reportItem.getData()).isEqualTo(knownPendingCount * 2); + assertThat(reportItem.getData()).as("PENDING count for targets in statistics") + .isEqualTo(knownPendingCount * 2); break; case REGISTERED: - assertThat(reportItem.getData()).isEqualTo(knownRegCount * 2); + assertThat(reportItem.getData()).as("REGISTERED count for targets in statistics") + .isEqualTo(knownRegCount * 2); break; case UNKNOWN: - assertThat(reportItem.getData()).isEqualTo(knownUnknownCount * 2); + assertThat(reportItem.getData()).as("UNKNOWN count for targets in statistics") + .isEqualTo(knownUnknownCount * 2); break; default: fail("missing case for unknown target update status " + reportItem.getType()); @@ -373,22 +386,30 @@ public class ReportManagementTest extends AbstractIntegrationTest { final DataReportSeriesItem dataReportSeriesItem = innerOuterDataReportSeries.getInnerSeries() .getData()[0]; if (dataReportSeriesItem.getType().equals("ds1")) { + // total count of three because ds1 has two different versions - assertThat(dataReportSeriesItem.getData()).isEqualTo(3L); + assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 1 in statistics") + .isEqualTo(3L); + final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(Arrays.stream(outerData).map(DataReportSeriesItem::getType).collect(Collectors.toList())) .contains("0.0.0", "0.0.1"); + } else if (dataReportSeriesItem.getType().equals("ds2")) { - assertThat(dataReportSeriesItem.getData()).isEqualTo(1L); + assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 2 in statistics") + .isEqualTo(1L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(outerData).hasSize(1); - assertThat(outerData[0].getType()).isEqualTo("0.0.2"); + assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 2 in statistics") + .isEqualTo("0.0.2"); } else if (dataReportSeriesItem.getType().equals("ds3")) { - assertThat(dataReportSeriesItem.getData()).isEqualTo(0L); + assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 3 in statistics") + .isEqualTo(0L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(outerData).hasSize(1); - assertThat(outerData[0].getType()).isEqualTo("0.0.3"); + assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 3 in statistics") + .isEqualTo("0.0.3"); } else { fail("no assertion count for distribution set " + dataReportSeriesItem.getType()); } @@ -402,7 +423,8 @@ public class ReportManagementTest extends AbstractIntegrationTest { final DataReportSeriesItem dataReportSeriesItem = innerOuterDataReportSeries.getInnerSeries() .getData()[0]; if (dataReportSeriesItem.getType().equals("ds1")) { - assertThat(dataReportSeriesItem.getData()).isEqualTo(4L); + assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 1 in statistics") + .isEqualTo(4L); } } } @@ -435,29 +457,24 @@ public class ReportManagementTest extends AbstractIntegrationTest { DataReportSeries targetsNotLastPoll = reportManagement.targetsLastPoll(); DataReportSeriesItem[] data = targetsNotLastPoll.getData(); - // for( final DataReportSeriesItem dataReportSeriesItem : - // data ) { - // System.out.println( dataReportSeriesItem.getData() ); - // } - // --- Verfiy --- // verify hour - assertThat(data[0].getType()).isEqualTo(SeriesTime.HOUR); - assertThat(data[0].getData()).isEqualTo((long) knownTargetsPollLastHour); + assertThat(data[0].getType()).as("Series time").isEqualTo(SeriesTime.HOUR); + assertThat(data[0].getData()).as("Targets poll last hour").isEqualTo((long) knownTargetsPollLastHour); // verify day - assertThat(data[1].getType()).isEqualTo(SeriesTime.DAY); - assertThat(data[1].getData()).isEqualTo((long) knownTargetsPollLastDay); + assertThat(data[1].getType()).as("Series time").isEqualTo(SeriesTime.DAY); + assertThat(data[1].getData()).as("Targets poll last day").isEqualTo((long) knownTargetsPollLastDay); // verify week - assertThat(data[2].getType()).isEqualTo(SeriesTime.WEEK); - assertThat(data[2].getData()).isEqualTo((long) knownTargetsPollLastWeek); + assertThat(data[2].getType()).as("Series time").isEqualTo(SeriesTime.WEEK); + assertThat(data[2].getData()).as("Targets poll last week").isEqualTo((long) knownTargetsPollLastWeek); // test cache evict createTargets("hourPoll2", knownTargetsPollLastHour, now.minusMinutes(59)); targetsNotLastPoll = reportManagement.targetsLastPoll(); data = targetsNotLastPoll.getData(); - assertThat(data[0].getType()).isEqualTo(SeriesTime.HOUR); - assertThat(data[0].getData()).isEqualTo((long) knownTargetsPollLastHour * 2); + assertThat(data[0].getType()).as("Series time").isEqualTo(SeriesTime.HOUR); + assertThat(data[0].getData()).as("Targets poll last hour").isEqualTo((long) knownTargetsPollLastHour * 2); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index a7b8e673f..555d654c5 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository; import static org.fest.assertions.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -226,10 +225,10 @@ public class TargetManagementTest extends AbstractIntegrationTest { } } if (strict) { - fail(); + fail("Target does not contain all tags"); } } - fail(); + fail("Target does not contain any tags or the expected tag was not found"); } } @@ -240,7 +239,7 @@ public class TargetManagementTest extends AbstractIntegrationTest { for (final Tag tag : tags) { for (final Tag tt : t.getTags()) { if (tag.getName().equals(tt.getName())) { - fail(); + fail("Target should have no tags"); } } } @@ -256,30 +255,33 @@ public class TargetManagementTest extends AbstractIntegrationTest { final Target target = TestDataUtil.buildTargetFixture(myCtrlID, "the description!"); Target savedTarget = targetManagement.createTarget(target); - assertNotNull(savedTarget); + assertNotNull("The target should not be null", savedTarget); final Long createdAt = savedTarget.getCreatedAt(); Long modifiedAt = savedTarget.getLastModifiedAt(); - assertEquals(createdAt, modifiedAt); - assertNotNull(savedTarget.getCreatedAt()); - assertNotNull(savedTarget.getLastModifiedAt()); - assertEquals(target, savedTarget); + + assertThat(createdAt).as("CreatedAt compared with modifiedAt").isEqualTo(modifiedAt); + assertNotNull("The createdAt attribut of the target should no be null", savedTarget.getCreatedAt()); + assertNotNull("The lastModifiedAt attribut of the target should no be null", savedTarget.getLastModifiedAt()); + assertThat(target).as("Target compared with saved target").isEqualTo(savedTarget); savedTarget.setDescription("changed description"); Thread.sleep(1); savedTarget = targetManagement.updateTarget(savedTarget); - - assertNotNull(savedTarget.getLastModifiedAt()); - assertNotEquals(createdAt, savedTarget.getLastModifiedAt()); - assertNotEquals(modifiedAt, savedTarget.getLastModifiedAt()); + assertNotNull("The lastModifiedAt attribute of the target should not be null", savedTarget.getLastModifiedAt()); + assertThat(createdAt).as("CreatedAt compared with saved modifiedAt") + .isNotEqualTo(savedTarget.getLastModifiedAt()); + assertThat(modifiedAt).as("ModifiedAt compared with saved modifiedAt") + .isNotEqualTo(savedTarget.getLastModifiedAt()); modifiedAt = savedTarget.getLastModifiedAt(); final Target foundTarget = targetManagement.findTargetByControllerID(savedTarget.getControllerId()); - - assertNotNull(foundTarget); - assertEquals(myCtrlID, foundTarget.getControllerId()); - assertEquals(savedTarget, foundTarget); - assertEquals(createdAt, foundTarget.getCreatedAt()); - assertEquals(modifiedAt, foundTarget.getLastModifiedAt()); + assertNotNull("The target should not be null", foundTarget); + assertThat(myCtrlID).as("ControllerId compared with saved controllerId") + .isEqualTo(foundTarget.getControllerId()); + assertThat(savedTarget).as("Target compared with saved target").isEqualTo(foundTarget); + assertThat(createdAt).as("CreatedAt compared with saved createdAt").isEqualTo(foundTarget.getCreatedAt()); + assertThat(modifiedAt).as("LastModifiedAt compared with saved lastModifiedAt") + .isEqualTo(foundTarget.getLastModifiedAt()); } @Test @@ -296,8 +298,11 @@ public class TargetManagementTest extends AbstractIntegrationTest { final Target savedExtra = targetManagement.createTarget(extra); Iterable allFound = targetRepository.findAll(); - assertEquals(firstList.size(), firstSaved.spliterator().getExactSizeIfKnown()); - assertEquals(firstList.size() + 1, allFound.spliterator().getExactSizeIfKnown()); + + assertThat(Long.valueOf(firstList.size())).as("List size of targets") + .isEqualTo(firstSaved.spliterator().getExactSizeIfKnown()); + assertThat(Long.valueOf(firstList.size() + 1)).as("LastModifiedAt compared with saved lastModifiedAt") + .isEqualTo(allFound.spliterator().getExactSizeIfKnown()); // change the objects and save to again to trigger a change on // lastModifiedAt @@ -308,18 +313,23 @@ public class TargetManagementTest extends AbstractIntegrationTest { _founds: for (final Target foundTarget : allFound) { for (final Target changedTarget : firstSaved) { if (changedTarget.getControllerId().equals(foundTarget.getControllerId())) { - assertEquals(changedTarget.getDescription(), foundTarget.getDescription()); - assertTrue(changedTarget.getName().startsWith(foundTarget.getName())); - assertTrue(changedTarget.getName().endsWith("changed")); - assertEquals(changedTarget.getCreatedAt(), foundTarget.getCreatedAt()); - assertThat(changedTarget.getLastModifiedAt()).isNotEqualTo(changedTarget.getCreatedAt()); - + assertThat(changedTarget.getDescription()) + .as("Description of changed target compared with description saved target") + .isEqualTo(foundTarget.getDescription()); + assertThat(changedTarget.getName()).as("Name of changed target starts with name of saved target") + .startsWith(foundTarget.getName()); + assertThat(changedTarget.getName()).as("Name of changed target ends with 'changed'") + .endsWith("changed"); + assertThat(changedTarget.getCreatedAt()).as("CreatedAt compared with saved createdAt") + .isEqualTo(foundTarget.getCreatedAt()); + assertThat(changedTarget.getLastModifiedAt()).as("LastModifiedAt compared with saved createdAt") + .isNotEqualTo(changedTarget.getCreatedAt()); continue _founds; } } if (!foundTarget.getControllerId().equals(savedExtra.getControllerId())) { - fail(); + fail("The controllerId of the found target is not equal to the controllerId of the saved target"); } } @@ -341,8 +351,8 @@ public class TargetManagementTest extends AbstractIntegrationTest { targetManagement.deleteTargets(deletedTargetIDs); allFound = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent(); - assertEquals(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del, - allFound.spliterator().getExactSizeIfKnown()); + assertThat(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del).as("Size of splited list") + .isEqualTo(allFound.spliterator().getExactSizeIfKnown()); // verify that all undeleted are still found assertThat(allFound).doesNotContain(deletedTargets); @@ -376,15 +386,26 @@ public class TargetManagementTest extends AbstractIntegrationTest { } final Query qry = entityManager.createNativeQuery("select * from sp_target_attributes ta"); final List result = qry.getResultList(); - assertEquals(attribs.size() * ts.spliterator().getExactSizeIfKnown(), result.size()); + + assertThat(attribs.size() * ts.spliterator().getExactSizeIfKnown()).as("Amount of all target attributes") + .isEqualTo(result.size()); for (final Target myT : ts) { final Target t = targetManagement.findTargetByControllerIDWithDetails(myT.getControllerId()); - assertEquals(attribs.size(), t.getTargetInfo().getControllerAttributes().size()); + assertThat(attribs.size()).as("Amount of target attributes per target") + .isEqualTo(t.getTargetInfo().getControllerAttributes().size()); + for (final Entry ca : t.getTargetInfo().getControllerAttributes().entrySet()) { - assertTrue(attribs.containsKey(ca.getKey())); + assertTrue("Attributes list does not contain target attribute key", attribs.containsKey(ca.getKey())); // has the same value: see string concatenation above - assertEquals(String.format("%s-%s", attribs.get(ca.getKey()), t.getControllerId()), ca.getValue()); + // assertThat(String.format("%s-%s", + // attribs.get(ca.getKey()))).as("Value of string + // concatenation") + // .isEqualTo(ca.getValue()); + + assertEquals("The value of the string concatenation is not equal to the value of the target attributes", + String.format("%s-%s", attribs.get(ca.getKey()), t.getControllerId()), ca.getValue()); + } } @@ -656,9 +677,8 @@ public class TargetManagementTest extends AbstractIntegrationTest { final List targetsListWithNoTag = targetManagement .findTargetByFilters(new PageRequest(0, 500), null, null, null, Boolean.TRUE, tagNames).getContent(); - // Total targets - assertEquals(50, targetManagement.findAllTargetIds().size()); - // Targets with no tag - assertEquals(25, targetsListWithNoTag.size()); + assertThat(50).as("Total targets").isEqualTo(targetManagement.findAllTargetIds().size()); + assertThat(25).as("Targets with no tag").isEqualTo(targetsListWithNoTag.size()); + } } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java index 50b6600e9..2f77346f2 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLTargetFieldTest.java @@ -114,8 +114,9 @@ public class RSQLTargetFieldTest extends AbstractIntegrationTest { assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "!=pending", 3); try { assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==noExist*", 0); - fail(); + fail("RSQLParameterUnsupportedFieldException was expected since update status unknown"); } catch (final RSQLParameterUnsupportedFieldException e) { + // test ok - exception was excepted } assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "=in=(pending,error)", 1); assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "=out=(pending,error)", 3); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java index a87ce748a..2db088e64 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java @@ -57,9 +57,6 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Test artifact downloads from the controller. * - * - * - * */ @ActiveProfiles({ "im", "test" }) @@ -285,7 +282,8 @@ public class ArtifactDownloadTest extends AbstractIntegrationTestWithMongoDB { .andExpect(header().string("Content-Disposition", "attachment;filename=" + artifact.getFilename())) .andReturn(); - assertTrue(Arrays.equals(result.getResponse().getContentAsByteArray(), random)); + assertTrue("The same file that was uploaded is expected when downloaded", + Arrays.equals(result.getResponse().getContentAsByteArray(), random)); // download complete assertThat(downLoadProgress).isEqualTo(10); @@ -393,7 +391,8 @@ public class ArtifactDownloadTest extends AbstractIntegrationTestWithMongoDB { .andExpect(header().longValue("Last-Modified", artifact.getCreatedAt())) .andExpect(header().string("Content-Disposition", "attachment;filename=file1")).andReturn(); - assertTrue(Arrays.equals(result.getResponse().getContentAsByteArray(), random)); + assertTrue("The same file that was uploaded is expected when downloaded", + Arrays.equals(result.getResponse().getContentAsByteArray(), random)); // one (update) action assertThat(actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent()).hasSize(1); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java index 7ca7814b2..d915c4e9e 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java @@ -8,7 +8,8 @@ */ package org.eclipse.hawkbit.rest.resource; -import static org.junit.Assert.assertEquals; +import static org.fest.assertions.api.Assertions.assertThat; +import static org.junit.Assert.fail; import java.util.List; @@ -16,9 +17,15 @@ import org.eclipse.hawkbit.repository.TargetFields; import org.junit.Test; import org.springframework.data.domain.Sort.Order; +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + /** * */ +@Features("Component Tests - Management RESTful API") +@Stories("Sorting parameter") public class SortUtilityTest { private static final String SORT_PARAM_1 = "NAME:ASC"; private static final String SORT_PARAM_2 = "NAME:ASC, DESCRIPTION:DESC"; @@ -29,36 +36,55 @@ public class SortUtilityTest { private static final String WRONG_FIELD_PARAM = "ASDF:ASC"; @Test + @Description("Ascending sorting based on name.") public void parseSortParam1() { - final List parse = SortUtility.parse(TargetFields.class, SORT_PARAM_1); - assertEquals(1, parse.size()); + assertThat(1).as("Count of parsing parameter").isEqualTo(parse.size()); } @Test + @Description("Ascending sorting based on name and descending sorting based on description.") public void parseSortParam2() { final List parse = SortUtility.parse(TargetFields.class, SORT_PARAM_2); - assertEquals(2, parse.size()); - } - - @Test(expected = SortParameterSyntaxErrorException.class) - public void parseWrongSyntaxParam() { - SortUtility.parse(TargetFields.class, SYNTAX_FAILURE_SORT_PARAM); + assertThat(2).as("Count of parsing parameter").isEqualTo(parse.size()); } @Test + @Description("Sorting with wrong syntax leads to SortParameterSyntaxErrorException.") + public void parseWrongSyntaxParam() { + try { + SortUtility.parse(TargetFields.class, SYNTAX_FAILURE_SORT_PARAM); + fail("SortParameterSyntaxErrorException expected because of wrong syntax"); + } catch (final SortParameterSyntaxErrorException e) { + } + } + + @Test + @Description("Sorting based on name with case sensitive is possible.") public void parsingIsNotCaseSensitive() { SortUtility.parse(TargetFields.class, CASE_INSENSITIVE_DIRECTION_PARAM); SortUtility.parse(TargetFields.class, CASE_INSENSITIVE_DIRECTION_PARAM_1); } - @Test(expected = SortParameterUnsupportedDirectionException.class) + @Test + @Description("Sorting with unknown direction order leads to SortParameterUnsupportedDirectionException.") public void parseWrongDirectionParam() { - SortUtility.parse(TargetFields.class, WRONG_DIRECTION_PARAM); + try { + SortUtility.parse(TargetFields.class, WRONG_DIRECTION_PARAM); + fail("SortParameterUnsupportedDirectionException expected because of unknown direction order"); + } catch (final SortParameterUnsupportedDirectionException e) { + } + } - @Test(expected = SortParameterUnsupportedFieldException.class) + @Test + @Description("Sorting with unknown field leads to SortParameterUnsupportedFieldException.") public void parseWrongFieldParam() { - SortUtility.parse(TargetFields.class, WRONG_FIELD_PARAM); + try { + SortUtility.parse(TargetFields.class, WRONG_FIELD_PARAM); + fail("SortParameterUnsupportedFieldException expected because of unknown field"); + } catch (final SortParameterUnsupportedFieldException e) { + } + } } diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java index d351f976d..1ff1b3d33 100644 --- a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java +++ b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java @@ -19,24 +19,32 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.context.annotation.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Component Tests - UI") +@Stories("Threads with NamingThreadFactory") @RunWith(MockitoJUnitRunner.class) public class NamingThreadFactoryTest { @Mock private final Runnable runnableMock = mock(Runnable.class); @Test + @Description("Correct name of threads when created through NamingThreadFactory.") public void setsNameForThreads() { final String knownName = "knownName"; final ThreadFactory threadFactory = new NamingThreadFactory(knownName); final Thread newThread1 = threadFactory.newThread(runnableMock); final Thread newThread2 = threadFactory.newThread(runnableMock); - assertThat(newThread1.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName); - assertThat(newThread2.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName); + assertThat(newThread1.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName); + assertThat(newThread2.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName); } @Test + @Description("Correct name of threads when created through NamingThreadFactory with formated name.") public void setsFormatedNameForThreads() { final String nameFormat = "knownName-%d"; final String knownName1 = "knownName-0"; @@ -45,11 +53,12 @@ public class NamingThreadFactoryTest { final Thread newThread1 = threadFactory.newThread(runnableMock); final Thread newThread2 = threadFactory.newThread(runnableMock); - assertThat(newThread1.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName1); - assertThat(newThread2.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName2); + assertThat(newThread1.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName1); + assertThat(newThread2.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName2); } @Test + @Description("Created threads run are running.") public void setsRunnableForThreads() { final String knownName = "knownName"; final ThreadFactory threadFactory = new NamingThreadFactory(knownName); From 629ac6c4de7b78eb0a64edfd49e2dc10bdfc63ce Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Sat, 13 Feb 2016 12:26:46 +0100 Subject: [PATCH 13/45] Sonar issues fixed Signed-off-by: asharani-murugesh --- .../ui/filtermanagement/CreateOrUpdateFilterTable.java | 1 - .../footer/TargetFilterCountMessageLabel.java | 4 ---- 2 files changed, 5 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index 35eb7238f..64599928c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -37,7 +37,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.google.common.base.Strings; import com.vaadin.data.Item; import com.vaadin.server.FontAwesome; -import com.vaadin.server.Sizeable.Unit; import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java index 126bb3322..ab0161b37 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.filtermanagement.footer; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -46,9 +45,6 @@ public class TargetFilterCountMessageLabel extends Label { @Autowired private FilterManagementUIState filterManagementUIState; - @Autowired - private transient TargetManagement targetManagement; - @Autowired private I18N i18n; From 59fb97fea2cccb3b4e25c9211830c5a6941b1f5a Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Sat, 13 Feb 2016 21:33:27 +0100 Subject: [PATCH 14/45] In and Out parameter changes Signed-off-by: asharani-murugesh --- .../hawkbit/repository/rsql/RSQLUtility.java | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java index db6d11ba3..d0931cf4a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java @@ -470,27 +470,35 @@ public final class RSQLUtility { } } - private Predicate getInPredicate(final List transformedValues, final Path fieldPath) { - List inParams =new ArrayList<>(); - for(Object param :transformedValues){ - if(param instanceof String){ - inParams.add(((String) param).toUpperCase()); - } - } - return cb.upper(pathOfString(fieldPath)).in(inParams); - } + private Predicate getInPredicate(final List transformedValues, final Path fieldPath) { + List inParams = new ArrayList<>(); + for (Object param : transformedValues) { + if (param instanceof String) { + inParams.add(((String) param).toUpperCase()); + } + } + if (!inParams.isEmpty()) { + return cb.upper(pathOfString(fieldPath)).in(inParams); + } else { + return fieldPath.in(transformedValues); + } + } - private Predicate getOutPredicate(final List transformedValues, final Path fieldPath) { - List outParams =new ArrayList<>(); - for(Object param :transformedValues){ - if(param instanceof String){ - outParams.add(((String) param).toUpperCase()); - } - } - return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams)); - } + private Predicate getOutPredicate(final List transformedValues, final Path fieldPath) { + List outParams = new ArrayList<>(); + for (Object param : transformedValues) { + if (param instanceof String) { + outParams.add(((String) param).toUpperCase()); + } + } + if (!outParams.isEmpty()) { + return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams)); + } else { + return cb.not(fieldPath.in(transformedValues)); + } + } private Path getMapValueFieldPath(final A enumField, final Path fieldPath) { if (!enumField.isMap() || enumField.getValueFieldName() == null) { From 158a9cfa204a6a5e8b175f2b3b9803138d6be931 Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Mon, 15 Feb 2016 10:38:30 +0100 Subject: [PATCH 15/45] RSQLUtility : convert query to lower case before parsing Signed-off-by: asharani-murugesh --- .../hawkbit/repository/TargetManagement.java | 10 +++++----- .../hawkbit/repository/rsql/RSQLUtility.java | 13 ++++++++----- .../CreateOrUpdateFilterHeader.java | 7 +++---- .../filtermanagement/CreateOrUpdateFilterTable.java | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index 150bbf53c..e790d0a5e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -205,7 +205,7 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) public Slice findTargetsAll(@NotNull final TargetFilterQuery targetFilterQuery, @NotNull final Pageable pageable) { - return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery().toLowerCase(), TargetFields.class), pageable); + return findTargetsAll(RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class), pageable); } /** @@ -219,7 +219,7 @@ public class TargetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) public Slice findTargetsAll(@NotNull final String targetFilterQuery, @NotNull final Pageable pageable) { - return findTargetsAll(RSQLUtility.parse(targetFilterQuery.toLowerCase(), TargetFields.class), pageable); + return findTargetsAll(RSQLUtility.parse(targetFilterQuery, TargetFields.class), pageable); } /** @@ -883,7 +883,7 @@ public class TargetManagement { targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(pageRequest.getSort().iterator().next().getProperty())); - final Specification spec = RSQLUtility.parse(targetFilterQuery.getQuery().toLowerCase(), TargetFields.class); + final Specification spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class); final List> specList = new ArrayList<>(); specList.add(spec); @@ -1057,7 +1057,7 @@ public class TargetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) public Long countTargetByTargetFilterQuery(@NotNull final TargetFilterQuery targetFilterQuery) { - final Specification specs = RSQLUtility.parse(targetFilterQuery.getQuery().toLowerCase(), TargetFields.class); + final Specification specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class); return targetRepository.count(specs); } @@ -1070,7 +1070,7 @@ public class TargetManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) public Long countTargetByTargetFilterQuery(@NotNull final String targetFilterQuery) { - final Specification specs = RSQLUtility.parse(targetFilterQuery.toLowerCase(), TargetFields.class); + final Specification specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class); return targetRepository.count(specs); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java index d0931cf4a..23b6c52c8 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java @@ -18,6 +18,7 @@ import java.util.stream.Collectors; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Expression; import javax.persistence.criteria.MapJoin; import javax.persistence.criteria.Path; import javax.persistence.criteria.Predicate; @@ -101,7 +102,7 @@ public final class RSQLUtility { */ public static & FieldNameProvider, T> Specification parse(final String rsql, final Class fieldNameProvider) { - return new RSQLSpecification<>(rsql, fieldNameProvider); + return new RSQLSpecification<>(rsql.toLowerCase(), fieldNameProvider); } /** @@ -507,7 +508,8 @@ public final class RSQLUtility { return fieldPath.get(enumField.getValueFieldName()); } - private Predicate mapToMapPredicate(final ComparisonNode node, final Path fieldPath, + @SuppressWarnings("unchecked") + private Predicate mapToMapPredicate(final ComparisonNode node, final Path fieldPath, final A enumField) { if (!enumField.isMap()) { return null; @@ -515,10 +517,11 @@ public final class RSQLUtility { final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR); final String keyValue = graph[graph.length - 1]; if (fieldPath instanceof MapJoin) { - return cb.equal(((MapJoin) fieldPath).key(), keyValue); + //Currently we support only string key .So below cast is safe. + return cb.equal(cb.upper((Expression) (((MapJoin) fieldPath).key())), keyValue.toUpperCase()); } - - return cb.equal(fieldPath.get(enumField.getKeyFieldName()), keyValue); + + return cb.equal(cb.upper(fieldPath.get(enumField.getKeyFieldName())), keyValue.toUpperCase()); } private Predicate getEqualToPredicate(final Object transformedValue, final Path fieldPath) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java index 67371d30c..22b00d372 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java @@ -348,9 +348,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } } - private void onQueryChange(final String text) { - if (!Strings.isNullOrEmpty(text)) { - final String input = text.toLowerCase(); + private void onQueryChange(final String input) { + if (!Strings.isNullOrEmpty(input)) { final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input); if (!validationResult.getIsValidationFailed()) { filterManagementUIState.setFilterQueryValue(input); @@ -369,7 +368,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE); } - queryTextField.setValue(text); + queryTextField.setValue(input); } private void enableDisableSaveButton(final boolean validationFailed, final String query) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index 64599928c..98ecfa304 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -111,7 +111,7 @@ public class CreateOrUpdateFilterTable extends Table { filterManagementUIState.setFilterQueryValue(null); } else { filterManagementUIState.getTfQuery().ifPresent( - value -> filterManagementUIState.setFilterQueryValue(value.getQuery().toLowerCase())); + value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); } } From b498f60392caf8a79437884169f6cb72c87c2212 Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Mon, 15 Feb 2016 10:40:30 +0100 Subject: [PATCH 16/45] Reverting the changes as per master copy Signed-off-by: asharani-murugesh --- .../DistributionAddUpdateWindowLayout.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 256a04926..cf581652c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -342,25 +342,26 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { distributionSet.setRequiredMigrationStep(isMigStepReq); } + private boolean duplicateCheck(final String name, final String version) { final DistributionSet existingDs = distributionSetManagement.findDistributionSetByNameAndVersion(name, version); + /* + * Distribution should not exists with the same name & version. Display + * error message, when the "existingDs" is not null and it is add window + * (or) when the "existingDs" is not null and it is edit window and the + * distribution Id of the edit window is different then the "existingDs" + */ + if (existingDs != null && !existingDs.getId().equals(editDistId)) { + distNameTextField.addStyleName("v-textfield-error"); + distVersionTextField.addStyleName("v-textfield-error"); + notificationMessage.displayValidationError( + i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() })); - if (existingDs == null) { + return false; + } else { return true; } - - if (editDistribution && !existingDs.getId().equals(editDistId)) { - return true; - } - - distNameTextField.addStyleName("v-textfield-error"); - distVersionTextField.addStyleName("v-textfield-error"); - notificationMessage.displayValidationError( - i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() })); - - return false; } - /** * Mandatory Check. * From 7b79010fbf9f5a9aaea51bc49d7a19c97a3647db Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Mon, 15 Feb 2016 12:32:12 +0100 Subject: [PATCH 17/45] format sources with correct formatter. Signed-off-by: Michael Hirsch --- .../hawkbit/repository/rsql/RSQLUtility.java | 72 +++++++++--------- .../CreateOrUpdateFilterHeader.java | 74 +++++++++---------- .../CreateOrUpdateFilterTable.java | 39 +++++----- .../CustomTargetBeanQuery.java | 6 +- .../footer/TargetFilterCountMessageLabel.java | 2 +- 5 files changed, 93 insertions(+), 100 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java index 23b6c52c8..03f213fef 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java @@ -461,46 +461,46 @@ public final class RSQLUtility { singleList.add(cb.lessThanOrEqualTo(pathOfString(fieldPath), value)); break; case "=in=": - singleList.add(getInPredicate(transformedValues,fieldPath)); + singleList.add(getInPredicate(transformedValues, fieldPath)); break; case "=out=": - singleList.add(getOutPredicate(transformedValues,fieldPath)); + singleList.add(getOutPredicate(transformedValues, fieldPath)); break; default: LOGGER.info("operator symbol {} is either not supported or not implemented"); } } - - private Predicate getInPredicate(final List transformedValues, final Path fieldPath) { - List inParams = new ArrayList<>(); - for (Object param : transformedValues) { - if (param instanceof String) { - inParams.add(((String) param).toUpperCase()); - } - } - if (!inParams.isEmpty()) { - return cb.upper(pathOfString(fieldPath)).in(inParams); - } else { - return fieldPath.in(transformedValues); - } - } + private Predicate getInPredicate(final List transformedValues, final Path fieldPath) { + final List inParams = new ArrayList<>(); + for (final Object param : transformedValues) { + if (param instanceof String) { + inParams.add(((String) param).toUpperCase()); + } + } + if (!inParams.isEmpty()) { + return cb.upper(pathOfString(fieldPath)).in(inParams); + } else { + return fieldPath.in(transformedValues); - private Predicate getOutPredicate(final List transformedValues, final Path fieldPath) { - List outParams = new ArrayList<>(); - for (Object param : transformedValues) { - if (param instanceof String) { - outParams.add(((String) param).toUpperCase()); - } - } - if (!outParams.isEmpty()) { - return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams)); - } else { - return cb.not(fieldPath.in(transformedValues)); + } + } + + private Predicate getOutPredicate(final List transformedValues, final Path fieldPath) { + final List outParams = new ArrayList<>(); + for (final Object param : transformedValues) { + if (param instanceof String) { + outParams.add(((String) param).toUpperCase()); + } + } + if (!outParams.isEmpty()) { + return cb.not(cb.upper(pathOfString(fieldPath)).in(outParams)); + } else { + return cb.not(fieldPath.in(transformedValues)); + + } + } - } - } - private Path getMapValueFieldPath(final A enumField, final Path fieldPath) { if (!enumField.isMap() || enumField.getValueFieldName() == null) { return fieldPath; @@ -509,7 +509,7 @@ public final class RSQLUtility { } @SuppressWarnings("unchecked") - private Predicate mapToMapPredicate(final ComparisonNode node, final Path fieldPath, + private Predicate mapToMapPredicate(final ComparisonNode node, final Path fieldPath, final A enumField) { if (!enumField.isMap()) { return null; @@ -517,10 +517,11 @@ public final class RSQLUtility { final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR); final String keyValue = graph[graph.length - 1]; if (fieldPath instanceof MapJoin) { - //Currently we support only string key .So below cast is safe. - return cb.equal(cb.upper((Expression) (((MapJoin) fieldPath).key())), keyValue.toUpperCase()); + // Currently we support only string key .So below cast is safe. + return cb.equal(cb.upper((Expression) (((MapJoin) fieldPath).key())), + keyValue.toUpperCase()); } - + return cb.equal(cb.upper(fieldPath.get(enumField.getKeyFieldName())), keyValue.toUpperCase()); } @@ -532,9 +533,6 @@ public final class RSQLUtility { return cb.equal(fieldPath, transformedValue); } - - - private Predicate getNotEqualToPredicate(final Object transformedValue, final Path fieldPath) { if (transformedValue instanceof String) { final String preFormattedValue = escapeValueToSQL((String) transformedValue); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java index 22b00d372..43f5919ef 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java @@ -8,7 +8,6 @@ */ package org.eclipse.hawkbit.ui.filtermanagement; - import java.util.concurrent.Executor; import javax.annotation.PostConstruct; @@ -122,7 +121,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button private LayoutClickListener nameLayoutClickListner; private boolean validationFailed = false; - + /** * Initialize the Campaign Status History Header. */ @@ -148,20 +147,18 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final CustomFilterUIEvent custFUIEvent) { - if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) { - populateComponents(); - eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW); - } else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { - setUpCaptionLayout(true); - resetComponents(); - } else if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) { - UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated()); - } - } + void onEvent(final CustomFilterUIEvent custFUIEvent) { + if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) { + populateComponents(); + eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW); + } else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { + setUpCaptionLayout(true); + resetComponents(); + } else if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) { + UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated()); + } + } - - private void populateComponents() { if (filterManagementUIState.getTfQuery().isPresent()) { queryTextField.setValue(filterManagementUIState.getTfQuery().get().getQuery()); @@ -219,8 +216,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button closeIcon = createSearchResetIcon(); } - - + private TextField createNameTextField() { final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH); @@ -337,13 +333,15 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } class StatusCircledAsync implements Runnable { - private UI current; - public StatusCircledAsync(UI current) { - this.current = current; - } - @Override + private final UI current; + + public StatusCircledAsync(final UI current) { + this.current = current; + } + + @Override public void run() { - UI.setCurrent(current); + UI.setCurrent(current); eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY); } } @@ -364,7 +362,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } enableDisableSaveButton(validationFailed, input); } else { - setInitialStatusIconStyle(validationIcon); + setInitialStatusIconStyle(validationIcon); filterManagementUIState.setFilterQueryValue(null); filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE); } @@ -372,9 +370,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } private void enableDisableSaveButton(final boolean validationFailed, final String query) { - if (validationFailed - || (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField - .getValue().equals(oldFilterName)))) { + if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query) + || (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) { saveButton.setEnabled(false); } else { if (hasSavePermission()) { @@ -390,10 +387,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button return false; } - private void showValidationSuccesIcon() { - validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); - validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON); + validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); + validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON); } private void showValidationFailureIcon() { @@ -474,8 +470,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button targetFilterQuery.setName(nameTextField.getValue()); targetFilterQuery.setQuery(queryTextField.getValue()); targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery); - notification.displaySuccess(i18n.get("message.create.filter.success", - new Object[] { targetFilterQuery.getName() })); + notification.displaySuccess( + i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() })); eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY); } @@ -516,12 +512,12 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button } return true; } - - private void updateStatusIconAfterTablePopulated() { - queryTextField.focus(); - if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) { - showValidationSuccesIcon(); - } - } + + private void updateStatusIconAfterTablePopulated() { + queryTextField.focus(); + if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) { + showValidationSuccesIcon(); + } + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java index 98ecfa304..ebeb95957 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java @@ -100,18 +100,16 @@ public class CreateOrUpdateFilterTable extends Table { || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) { UI.getCurrent().access(() -> populateTableData()); } else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) { - UI.getCurrent().access(() -> onQuery()); + UI.getCurrent().access(() -> onQuery()); } } - - - private void restoreOnLoad() { + private void restoreOnLoad() { if (filterManagementUIState.isCreateFilterViewDisplayed()) { filterManagementUIState.setFilterQueryValue(null); } else { - filterManagementUIState.getTfQuery().ifPresent( - value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); + filterManagementUIState.getTfQuery() + .ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery())); } } @@ -127,8 +125,9 @@ public class CreateOrUpdateFilterTable extends Table { targetQF.setQueryConfiguration(queryConfig); // create lazy query container with lazy defination and query - final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF); + final LazyQueryContainer targetTableContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), + targetQF); targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); return targetTableContainer; @@ -181,16 +180,16 @@ public class CreateOrUpdateFilterTable extends Table { private List getVisbleColumns() { final List columnList = new ArrayList<>(); - columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"),0.15f)); + columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), - 0.1F)); - columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n - .get("header.assigned.ds"), 0.125F)); - columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n - .get("header.installed.ds"), 0.125F)); + columnList.add( + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, + i18n.get("header.assigned.ds"), 0.125F)); + columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, + i18n.get("header.installed.ds"), 0.125F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F)); return columnList; @@ -198,8 +197,8 @@ public class CreateOrUpdateFilterTable extends Table { private Component getStatusIcon(final Object itemId) { final Item row1 = getItem(itemId); - final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty( - SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); + final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1 + .getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE); label.setContentMode(ContentMode.HTML); if (targetStatus == TargetUpdateStatus.PENDING) { @@ -240,9 +239,9 @@ public class CreateOrUpdateFilterTable extends Table { protected void addCustomGeneratedColumns() { addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId)); } - + private void onQuery() { - populateTableData(); + populateTableData(); eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); - } + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java index 400124b6f..bf5fdbe54 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java @@ -32,8 +32,8 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition; import com.google.common.base.Strings; /** - * Simple implementation of generics bean query which dynamically loads {@link ProxyTarget} batch - * of beans. + * Simple implementation of generics bean query which dynamically loads + * {@link ProxyTarget} batch of beans. * */ public class CustomTargetBeanQuery extends AbstractBeanQuery { @@ -163,7 +163,7 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery { */ @Override public int size() { - long size=0; + long size = 0; if (!Strings.isNullOrEmpty(filterQuery)) { size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java index ab0161b37..322d32a45 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/footer/TargetFilterCountMessageLabel.java @@ -71,7 +71,7 @@ public class TargetFilterCountMessageLabel extends Label { if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW || custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK || custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW - ||custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) { + || custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) { UI.getCurrent().access(() -> displayTargetFilterMessage()); } } From 1252bfe53dcdec535d917128ed1fe5582d5bc82f Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Tue, 16 Feb 2016 09:29:17 +0100 Subject: [PATCH 18/45] Formatted Signed-off-by: asharani-murugesh --- .../ui/artifacts/upload/UploadLayout.java | 135 +++++++++--------- 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index 1737d0495..2e8c6a51e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -119,7 +119,7 @@ public class UploadLayout extends VerticalLayout { private DragAndDropWrapper dropAreaWrapper; - private Boolean hasDirectory = Boolean.FALSE; + private Boolean hasDirectory = Boolean.FALSE; /** * Initialize the upload layout. @@ -187,58 +187,60 @@ public class UploadLayout extends VerticalLayout { @Override public void drop(final DragAndDropEvent event) { - if (validate()) { - ((WrapperTransferable) event.getTransferable()).getDraggedComponent(); - final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); - if (files != null) { - for (final Html5File file : files) { - if (!isDirectory(file)) { - if (!checkForDuplicate(file.getFileName())) { - numberOfFileUploadsExpected.incrementAndGet(); - file.setStreamVariable(createStreamVariable(file)); - hasDirectory = Boolean.FALSE; - } - } else { - hasDirectory = Boolean.TRUE; - } - } - if (numberOfFileUploadsExpected.get() > 0) { - processBtn.setEnabled(false); - // reset before we start - uploadInfoWindow.uploadSessionStarted(); - } else { - //If the upload is not started, it signifies all dropped files as either duplicate or directory.So display message accordingly - displayCompositeMessage(); - } - } - } + if (validate()) { + ((WrapperTransferable) event.getTransferable()).getDraggedComponent(); + final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); + if (files != null) { + for (final Html5File file : files) { + if (!isDirectory(file)) { + if (!checkForDuplicate(file.getFileName())) { + numberOfFileUploadsExpected.incrementAndGet(); + file.setStreamVariable(createStreamVariable(file)); + hasDirectory = Boolean.FALSE; + } + } else { + hasDirectory = Boolean.TRUE; + } + } + if (numberOfFileUploadsExpected.get() > 0) { + processBtn.setEnabled(false); + // reset before we start + uploadInfoWindow.uploadSessionStarted(); + } else { + // If the upload is not started, it signifies all + // dropped files as either duplicate or directory.So + // display message accordingly + displayCompositeMessage(); + } + } + } } } - private static boolean isDirectory(final Html5File file) { - if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) { - return true; - } - return false; - } + private static boolean isDirectory(final Html5File file) { + if (Strings.isNullOrEmpty(file.getType()) && file.getFileSize() % 4096 == 0) { + return true; + } + return false; + } + + private void displayCompositeMessage() { + final String duplicateMessage = getDuplicateFileValidationMessage(); + final StringBuilder compositeMessage = new StringBuilder(); + if (!Strings.isNullOrEmpty(duplicateMessage)) { + compositeMessage.append(duplicateMessage); + } + if (hasDirectory) { + if (compositeMessage.length() > 0) { + compositeMessage.append("
"); + } + compositeMessage.append(i18n.get("message.no.directory.upload")); + } + if (!compositeMessage.toString().isEmpty()) { + uiNotification.displayValidationError(compositeMessage.toString()); + } + } - private void displayCompositeMessage() { - final String duplicateMessage = getDuplicateFileValidationMessage(); - final StringBuilder compositeMessage = new StringBuilder(); - if (!Strings.isNullOrEmpty(duplicateMessage)) { - compositeMessage.append(duplicateMessage); - } - if (hasDirectory) { - if (compositeMessage.length() > 0) { - compositeMessage.append("
"); - } - compositeMessage.append(i18n.get("message.no.directory.upload")); - } - if (!compositeMessage.toString().isEmpty()) { - uiNotification.displayValidationError(compositeMessage.toString()); - } - } - private VerticalLayout createDropAreaLayout() { dropAreaLayout = new VerticalLayout(); final Label dropHereLabel = new Label("Drop files to upload"); @@ -421,27 +423,26 @@ public class UploadLayout extends VerticalLayout { displayCompositeMessage(); } } - - private String getDuplicateFileValidationMessage() { - StringBuilder message = new StringBuilder(); - if (!duplicateFileNamesList.isEmpty()) { - final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); - if (duplicateFileNamesList.size() == 1) { - message.append(i18n.get("message.no.duplicateFile") + fileNames); + private String getDuplicateFileValidationMessage() { + StringBuilder message = new StringBuilder(); + if (!duplicateFileNamesList.isEmpty()) { + final String fileNames = StringUtils.collectionToCommaDelimitedString(duplicateFileNamesList); + if (duplicateFileNamesList.size() == 1) { + message.append(i18n.get("message.no.duplicateFile") + fileNames); - } else if (duplicateFileNamesList.size() > 1) { - message.append(i18n.get("message.no.duplicateFiles")); - } - duplicateFileNamesList.clear(); - } - return message.toString(); - } + } else if (duplicateFileNamesList.size() > 1) { + message.append(i18n.get("message.no.duplicateFiles")); + } + duplicateFileNamesList.clear(); + } + return message.toString(); + } + + public void showDuplicateMessage() { + uiNotification.displayValidationError(getDuplicateFileValidationMessage()); + } - public void showDuplicateMessage() { - uiNotification.displayValidationError(getDuplicateFileValidationMessage()); - } - void increaseNumberOfFileUploadsExpected() { numberOfFileUploadsExpected.incrementAndGet(); } From 600a16def8d1dde564a40c8da81c4691a4ffd742 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Tue, 16 Feb 2016 15:52:04 +0530 Subject: [PATCH 19/45] Clearing the search field should keep the focus Signed-off-by: venu1278 --- .../smtable/SoftwareModuleTable.java | 13 +++++------ .../dstable/DistributionSetTable.java | 13 +++++------ .../distributions/smtable/SwModuleTable.java | 18 +++++++-------- .../management/dstable/DistributionTable.java | 23 +++++++++---------- .../management/targettable/TargetTable.java | 17 +++++++------- 5 files changed, 40 insertions(+), 44 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index bd9291473..940e3b27a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -79,7 +79,7 @@ public class SoftwareModuleTable extends AbstractTable { @Autowired private UploadViewAcceptCriteria uploadViewAcceptCriteria; - private Boolean isFilterEvent = false; + private Boolean isFilterApplied = false; /** * Initialize the filter layout. @@ -107,19 +107,18 @@ public class SoftwareModuleTable extends AbstractTable { if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - - if(prepareQueryConfigFilters().size()<1 && isFilterEvent==false){ + final Map queryConfig = prepareQueryConfigFilters(); + if(queryConfig.size()<1 && isFilterApplied==false){ UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); }else { refreshFilter(); - if(prepareQueryConfigFilters().size()<1){ - isFilterEvent = false; + if(queryConfig.size()<1){ + isFilterApplied = false; }else{ - isFilterEvent = true; + isFilterApplied = true; } } - //refreshFilter(); } }); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index 575f0a367..f62504911 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -115,7 +115,7 @@ public class DistributionSetTable extends AbstractTable { @Autowired private transient TargetManagement targetManagement; - private Boolean isFilterEvent = false; + private Boolean isFilterApplied = false; /** * Initialize the component. @@ -616,19 +616,18 @@ public class DistributionSetTable extends AbstractTable { if (event == DistributionTableFilterEvent.FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { - if(prepareQueryConfigFilters().size()<1 && isFilterEvent==false){ + final Map queryConfig = prepareQueryConfigFilters(); + if(queryConfig.size()<1 && isFilterApplied==false){ UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); }else { UI.getCurrent().access(() -> refreshFilter()); - if(prepareQueryConfigFilters().size()<1){ - isFilterEvent = false; + if(queryConfig.size()<1){ + isFilterApplied = false; }else{ - isFilterEvent = true; + isFilterApplied = true; } } - - // UI.getCurrent().access(() -> refreshFilter()); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index 6d5b7dcd5..dd8216dfd 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -95,7 +95,7 @@ public class SwModuleTable extends AbstractTable { @Autowired private ArtifactDetailsLayout artifactDetailsLayout; - private Boolean isFilterEvent = false; + private Boolean isFilterApplied = false; /** * Initialize the filter layout. @@ -126,23 +126,21 @@ public class SwModuleTable extends AbstractTable { if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - if(prepareQueryConfigFilters().size()<2 && isFilterEvent==false){ + final Map queryConfig = prepareQueryConfigFilters(); + if(queryConfig.size()<2 && isFilterApplied==false){ UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); }else { UI.getCurrent().access(() ->{ refreshFilter(); - styleTableOnDistSelection(); + styleTableOnDistSelection(); }); - if(prepareQueryConfigFilters().size()<2){ - isFilterEvent = false; + if(queryConfig.size()<2){ + isFilterApplied = false; }else{ - isFilterEvent = true; + isFilterApplied = true; } } - - /* refreshFilter(); - styleTableOnDistSelection();*/ - } + } }); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index e8f9e57ac..ab1ccdeac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -113,7 +113,7 @@ public class DistributionTable extends AbstractTable { private Button distributinPinnedBtn; - private Boolean isFilterEvent = false; + private Boolean isFilterApplied = false; /** * Initialize the distribution table. @@ -142,24 +142,23 @@ public class DistributionTable extends AbstractTable { if (event == DistributionTableFilterEvent.FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { - if(((boolean)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) - && ((List)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() - && prepareQueryConfigFilters().size()<3 - && isFilterEvent==false){ + final Map queryConfig = prepareQueryConfigFilters(); + if(((boolean)queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) + && ((List)queryConfig.get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() + && queryConfig.size()<3 + && isFilterApplied==false){ UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); }else { UI.getCurrent().access(() -> refreshFilter()); - if(((boolean)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) - && ((List)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() - && prepareQueryConfigFilters().size()<3){ - isFilterEvent = false; + if(((boolean)queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) + && ((List)queryConfig.get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() + && queryConfig.size()<3){ + isFilterApplied = false; }else{ - isFilterEvent = true; + isFilterApplied = true; } } - - // UI.getCurrent().access(() -> refreshFilter()); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 186207c50..17256cca8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -140,7 +140,7 @@ public class TargetTable extends AbstractTable implements Handler { private ShortcutAction actionSelectAll; private ShortcutAction actionUnSelectAll; - private Boolean isFilterEvent = Boolean.FALSE;; + private Boolean isFilterApplied = Boolean.FALSE;; @Override @@ -211,17 +211,18 @@ public class TargetTable extends AbstractTable implements Handler { void onEvent(final TargetFilterEvent filterEvent) { UI.getCurrent().access(() -> { if (checkFilterEvent(filterEvent)) { - if(((boolean)prepareQueryConfigFilters().get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) - && prepareQueryConfigFilters().size()<2 - && isFilterEvent==Boolean.FALSE){ + final Map queryConfiguration = prepareQueryConfigFilters(); + if(((boolean)queryConfiguration.get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) + && queryConfiguration.size()<2 + && isFilterApplied==Boolean.FALSE){ ((LazyQueryContainer) getContainerDataSource()).refresh(); - + }else { refreshFilter(); - if(prepareQueryConfigFilters().size()<2){ - isFilterEvent = Boolean.FALSE; + if(queryConfiguration.size()<2){ + isFilterApplied = Boolean.FALSE; }else{ - isFilterEvent = Boolean.TRUE; + isFilterApplied = Boolean.TRUE; } } From e3801e9e56a1e322d0edd615c9d6cd502db5d1df Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 16 Feb 2016 13:48:52 +0100 Subject: [PATCH 20/45] DistributionSetAssignmentResult contains actions that do not reflect the status on the DB. Needs to be avoided by returning actions IDs only and force the user to query an updated action entity. Signed-off-by: Kai Zimmermann --- .../hawkbit/repository/ActionRepository.java | 58 ++++++++----------- .../repository/DeploymentManagement.java | 7 ++- .../DistributionSetAssignmentResult.java | 12 ++-- .../repository/DeploymentManagementTest.java | 11 ++-- .../repository/ReportManagementTest.java | 8 ++- .../repository/TargetManagementTest.java | 4 +- .../utils/RepositoryDataGenerator.java | 14 +++-- 7 files changed, 52 insertions(+), 62 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java index 331fdad5b..a93fbdca7 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java @@ -40,7 +40,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /* * (non-Javadoc) - * + * * @see org.springframework.data.repository.CrudRepository#findAll() */ @Override @@ -49,7 +49,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves an Action with all lazy attributes. - * + * * @param actionId * the ID of the action * @return the found {@link Action} @@ -73,7 +73,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s which are referring the given * {@link Target}. - * + * * @param pageable * page parameters * @param target @@ -85,7 +85,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s which are active and referring the given * {@link Target} in a specified order. - * + * * @param pageable * page parameters * @param target @@ -132,7 +132,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target, without pagination * ordered by action ID. - * + * * @param target * to search for * @return a list of actions according to the searched target @@ -143,7 +143,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target and given active flag * ordered by action ID. - * + * * @param pageable * the pagination parameter * @param target @@ -160,7 +160,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target and given active flag * ordered by action ID. - * + * * @param target * to search for * @param active @@ -174,7 +174,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Updates all {@link Action} to inactive for all targets with given ID. - * + * * @param keySet * the list of actions to set inactive * @param targetsIds @@ -190,7 +190,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp * Switches the status of actions from one specific status into another, * only if the actions are in a specific status. This should be a atomar * operation. - * + * * @param statusToSet * the new status the actions should get * @param targetIds @@ -210,7 +210,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp * Switches the status of actions from one specific status into another, * only if the actions are in a specific status. This should be a atomar * operation. - * + * * @param statusToSet * the new status the actions should get * @param rollout @@ -227,7 +227,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp @Param("active") boolean active, @Param("currentStatus") Action.Status currentStatus); /** - * + * * Retrieves all {@link Action}s which are active and referring to the given * target Ids and distribution set required migration step. * @@ -243,36 +243,24 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all {@link Action}s referring to the given target. - * + * * @param target * the target to count the {@link Action}s * @return the count of actions referring to the given target */ Long countByTarget(Target target); - /* - * (non-Javadoc) - * - * @see org.springframework.data.repository.CrudRepository#save(java.lang. - * Iterable) - */ @Override @CacheEvict(value = "feedbackReceivedOverTime", allEntries = true) List save(Iterable entities); - /* - * (non-Javadoc) - * - * @see - * org.springframework.data.repository.CrudRepository#save(java.lang.Object) - */ @Override @CacheEvict(value = "feedbackReceivedOverTime", allEntries = true) S save(S entity); /** * Counts all {@link Action}s referring to the given DistributionSet. - * + * * @param distributionSet * DistributionSet to count the {@link Action}s from * @return the count of actions referring to the given distributionSet @@ -281,7 +269,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all {@link Action}s referring to the given rollout. - * + * * @param rollout * the rollout to count the {@link Action}s from * @return the count of actions referring to the given rollout @@ -293,7 +281,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp * are currently not in the given status. An in-clause statement does not * work with the spring-data, so this is specific usecase regarding to the * rollout-management to find out actions which are not in specific states. - * + * * @param rollout * the rollout the actions are belong to * @param rolloutGroup @@ -312,7 +300,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all actions referring to a given rollout and rolloutgroup. - * + * * @param rollout * the rollout the actions belong to * @param rolloutGroup @@ -323,7 +311,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all actions referring to a given rollout, rolloutgroup and status. - * + * * @param rolloutId * the ID of rollout the actions belong to * @param rolloutGroupId @@ -338,7 +326,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieving all actions referring to a given rollout with a specific * action as parent reference and a specific status. - * + * * Finding all actions of a specific rolloutgroup parent relation. * * @param rollout @@ -355,7 +343,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all actions for a specific rollout and in a specific status. - * + * * @param rollout * the rollout the actions beglong to * @param actionStatus @@ -367,7 +355,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout. - * + * * @param rolloutId * id of {@link Rollout} * @return list of objects with status and target count @@ -378,7 +366,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout. - * + * * @param rolloutId * id of {@link Rollout} * @return list of objects with status and target count @@ -389,7 +377,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout group. - * + * * @param rolloutGroupId * id of {@link RolloutGroup} * @return list of objects with status and target count @@ -400,7 +388,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout group. - * + * * @param rolloutGroupId * list of id of {@link RolloutGroup} * @return list of objects with status and target count diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 172f1c3e1..b0a61395b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -378,11 +378,13 @@ public class DeploymentManagement { actionStatusRepository.save(actionStatus); }); + // flush to get action IDs + entityManager.flush(); // select updated targets in order to return them final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult( targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), - controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()), - targetManagement); + controllerIDs.size() - targets.size(), + targetIdsToActions.values().stream().map(Action::getId).collect(Collectors.toList()), targetManagement); LOG.debug("assignDistribution({}) finished {}", set, result); @@ -392,7 +394,6 @@ public class DeploymentManagement { entityManager.detach(set); // send distribution set assignment event - targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId())) .forEach(t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(), softwareModules)); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java index ac562131d..3e61e4499 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository; import java.util.List; -import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.Target; @@ -19,14 +18,11 @@ import org.eclipse.hawkbit.repository.model.Target; * information of an assignment and how much of the assignment has been done and * how much of the assignments had already been existed. * - * - * - * */ public class DistributionSetAssignmentResult extends AssignmentResult { private final List assignedTargets; - private final List actions; + private final List actions; private final TargetManagement targetManagement; @@ -48,7 +44,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult { * */ public DistributionSetAssignmentResult(final List assignedTargets, final int assigned, - final int alreadyAssigned, final List actions, final TargetManagement targetManagement) { + final int alreadyAssigned, final List actions, final TargetManagement targetManagement) { super(assigned, alreadyAssigned); this.assignedTargets = assignedTargets; this.actions = actions; @@ -63,9 +59,9 @@ public class DistributionSetAssignmentResult extends AssignmentResult { } /** - * @return the actionId + * @return the actionIds */ - public List getActions() { + public List getActions() { return actions; } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 46747cd9c..5ad98069a 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -73,7 +73,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { distributionSetManagement, new ArrayList()); final List testTarget = targetManagement.createTargets(TestDataUtil.generateTargets(1)); // one action with one action status is generated - final Action action = deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0)); // save 2 action status actionStatusRepository.save(new ActionStatus(action, Status.RETRIEVED, System.currentTimeMillis())); actionStatusRepository.save(new ActionStatus(action, Status.RUNNING, System.currentTimeMillis())); @@ -349,7 +350,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { * test a simple deployment by calling the * {@link TargetRepository#assignDistributionSet(DistributionSet, Iterable)} * and checking the active action and the action history of the targets. - * + * * @throws InterruptedException */ @Test @@ -805,7 +806,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // assign ds to create an action final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement .assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId()); - final Action action = assignDistributionSet.getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0)); // verify preparation Action findAction = deploymentManagement.findAction(action.getId()); assertThat(findAction.getActionType()).isEqualTo(ActionType.SOFT); @@ -828,7 +829,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // assign ds to create an action final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement .assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId()); - final Action action = assignDistributionSet.getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0)); // verify perparation Action findAction = deploymentManagement.findAction(action.getId()); assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED); @@ -848,7 +849,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { *

* All created distribution sets are assigned to all targets of the * target list deployedTargets. - * + * * @param undeployedTargetPrefix * prefix to be used as target controller prefix * @param noOfUndeployedTargets diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java index bb5450083..0f91fb521 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java @@ -138,7 +138,8 @@ public class ReportManagementTest extends AbstractIntegrationTest { final Target createTarget = targetManagement.createTarget(new Target("t" + month)); final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(distributionSet, Lists.newArrayList(createTarget)); - controllerManagament.registerRetrieved(result.getActions().get(0), + controllerManagament.registerRetrieved( + deploymentManagement.findActionWithDetails(result.getActions().get(0)), "Controller retrieved update action and should start now the download."); } DataReportSeries feedbackReceivedOverTime = reportManagement @@ -158,7 +159,8 @@ public class ReportManagementTest extends AbstractIntegrationTest { final Target createTarget = targetManagement.createTarget(new Target("t2" + month)); final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(distributionSet, Lists.newArrayList(createTarget)); - controllerManagament.registerRetrieved(result.getActions().get(0), + controllerManagament.registerRetrieved( + deploymentManagement.findActionWithDetails(result.getActions().get(0)), "Controller retrieved update action and should start now the download."); } feedbackReceivedOverTime = reportManagement.feedbackReceivedOverTime(DateTypes.perMonth(), from, to); @@ -572,7 +574,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { /* * (non-Javadoc) - * + * * @see org.springframework.data.auditing.DateTimeProvider#getNow() */ @Override diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index 3a70441ca..cdcaff25e 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -174,7 +174,7 @@ public class TargetManagementTest extends AbstractIntegrationTest { final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(set.getId(), "4711"); - final Action action = result.getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(result.getActions().get(0)); action.setStatus(Status.FINISHED); controllerManagament.addUpdateActionStatus( new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action); @@ -221,7 +221,7 @@ public class TargetManagementTest extends AbstractIntegrationTest { * verifies, that all {@link TargetTag} of parameter. NOTE: it's accepted * that the target have additional tags assigned to them which are not * contained within parameter tags. - * + * * @param strict * if true, the given targets MUST contain EXACTLY ALL given * tags, AND NO OTHERS. If false, the given targets MUST contain diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java index dffec4df1..d7efa50d5 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java @@ -199,13 +199,14 @@ public final class RepositoryDataGenerator { } - private void createActionStatusHistory(final List actions, final int sizeMultiplikator) { + private void createActionStatusHistory(final List actions, final int sizeMultiplikator) { final AtomicInteger counter = new AtomicInteger(); int index = 0; - for (final Action actionGiven : actions) { + for (final Long actionGiven : actions) { // retrieved - Action action = controllerManagement.registerRetrieved(actionGiven, + Action action = controllerManagement.registerRetrieved( + deploymentManagement.findActionWithDetails(actionGiven), "Controller retrieved update action and should start now the download."); // download @@ -260,10 +261,11 @@ public final class RepositoryDataGenerator { } } - private void createSimpleActionStatusHistory(final List actions) { - for (final Action actionGiven : actions) { + private void createSimpleActionStatusHistory(final List actions) { + for (final Long actionGiven : actions) { // retrieved - Action action = controllerManagement.registerRetrieved(actionGiven, + Action action = controllerManagement.registerRetrieved( + deploymentManagement.findActionWithDetails(actionGiven), "Controller retrieved update action and should start now the download."); // close From 38b750f674465d5ae4fabc706547cfe8e506feed Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 16 Feb 2016 13:48:52 +0100 Subject: [PATCH 21/45] DistributionSetAssignmentResult contains actions that do not reflect the status on the DB. Needs to be avoided by returning actions IDs only and force the user to query an updated action entity. Signed-off-by: Kai Zimmermann --- .../hawkbit/repository/ActionRepository.java | 58 ++++++++----------- .../repository/DeploymentManagement.java | 7 ++- .../DistributionSetAssignmentResult.java | 12 ++-- .../repository/DeploymentManagementTest.java | 11 ++-- .../repository/ReportManagementTest.java | 8 ++- .../repository/TargetManagementTest.java | 4 +- .../utils/RepositoryDataGenerator.java | 14 +++-- .../hawkbit/controller/CancelActionTest.java | 29 +++++----- .../controller/DeploymentBaseTest.java | 15 ++--- 9 files changed, 76 insertions(+), 82 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java index 331fdad5b..a93fbdca7 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java @@ -40,7 +40,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /* * (non-Javadoc) - * + * * @see org.springframework.data.repository.CrudRepository#findAll() */ @Override @@ -49,7 +49,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves an Action with all lazy attributes. - * + * * @param actionId * the ID of the action * @return the found {@link Action} @@ -73,7 +73,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s which are referring the given * {@link Target}. - * + * * @param pageable * page parameters * @param target @@ -85,7 +85,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s which are active and referring the given * {@link Target} in a specified order. - * + * * @param pageable * page parameters * @param target @@ -132,7 +132,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target, without pagination * ordered by action ID. - * + * * @param target * to search for * @return a list of actions according to the searched target @@ -143,7 +143,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target and given active flag * ordered by action ID. - * + * * @param pageable * the pagination parameter * @param target @@ -160,7 +160,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target and given active flag * ordered by action ID. - * + * * @param target * to search for * @param active @@ -174,7 +174,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Updates all {@link Action} to inactive for all targets with given ID. - * + * * @param keySet * the list of actions to set inactive * @param targetsIds @@ -190,7 +190,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp * Switches the status of actions from one specific status into another, * only if the actions are in a specific status. This should be a atomar * operation. - * + * * @param statusToSet * the new status the actions should get * @param targetIds @@ -210,7 +210,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp * Switches the status of actions from one specific status into another, * only if the actions are in a specific status. This should be a atomar * operation. - * + * * @param statusToSet * the new status the actions should get * @param rollout @@ -227,7 +227,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp @Param("active") boolean active, @Param("currentStatus") Action.Status currentStatus); /** - * + * * Retrieves all {@link Action}s which are active and referring to the given * target Ids and distribution set required migration step. * @@ -243,36 +243,24 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all {@link Action}s referring to the given target. - * + * * @param target * the target to count the {@link Action}s * @return the count of actions referring to the given target */ Long countByTarget(Target target); - /* - * (non-Javadoc) - * - * @see org.springframework.data.repository.CrudRepository#save(java.lang. - * Iterable) - */ @Override @CacheEvict(value = "feedbackReceivedOverTime", allEntries = true) List save(Iterable entities); - /* - * (non-Javadoc) - * - * @see - * org.springframework.data.repository.CrudRepository#save(java.lang.Object) - */ @Override @CacheEvict(value = "feedbackReceivedOverTime", allEntries = true) S save(S entity); /** * Counts all {@link Action}s referring to the given DistributionSet. - * + * * @param distributionSet * DistributionSet to count the {@link Action}s from * @return the count of actions referring to the given distributionSet @@ -281,7 +269,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all {@link Action}s referring to the given rollout. - * + * * @param rollout * the rollout to count the {@link Action}s from * @return the count of actions referring to the given rollout @@ -293,7 +281,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp * are currently not in the given status. An in-clause statement does not * work with the spring-data, so this is specific usecase regarding to the * rollout-management to find out actions which are not in specific states. - * + * * @param rollout * the rollout the actions are belong to * @param rolloutGroup @@ -312,7 +300,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all actions referring to a given rollout and rolloutgroup. - * + * * @param rollout * the rollout the actions belong to * @param rolloutGroup @@ -323,7 +311,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Counts all actions referring to a given rollout, rolloutgroup and status. - * + * * @param rolloutId * the ID of rollout the actions belong to * @param rolloutGroupId @@ -338,7 +326,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieving all actions referring to a given rollout with a specific * action as parent reference and a specific status. - * + * * Finding all actions of a specific rolloutgroup parent relation. * * @param rollout @@ -355,7 +343,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all actions for a specific rollout and in a specific status. - * + * * @param rollout * the rollout the actions beglong to * @param actionStatus @@ -367,7 +355,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout. - * + * * @param rolloutId * id of {@link Rollout} * @return list of objects with status and target count @@ -378,7 +366,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout. - * + * * @param rolloutId * id of {@link Rollout} * @return list of objects with status and target count @@ -389,7 +377,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout group. - * + * * @param rolloutGroupId * id of {@link RolloutGroup} * @return list of objects with status and target count @@ -400,7 +388,7 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Get list of objects which has details of status and count of targets in * each status in specified rollout group. - * + * * @param rolloutGroupId * list of id of {@link RolloutGroup} * @return list of objects with status and target count diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 172f1c3e1..b0a61395b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -378,11 +378,13 @@ public class DeploymentManagement { actionStatusRepository.save(actionStatus); }); + // flush to get action IDs + entityManager.flush(); // select updated targets in order to return them final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult( targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), - controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()), - targetManagement); + controllerIDs.size() - targets.size(), + targetIdsToActions.values().stream().map(Action::getId).collect(Collectors.toList()), targetManagement); LOG.debug("assignDistribution({}) finished {}", set, result); @@ -392,7 +394,6 @@ public class DeploymentManagement { entityManager.detach(set); // send distribution set assignment event - targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId())) .forEach(t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(), softwareModules)); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java index ac562131d..3e61e4499 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository; import java.util.List; -import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.Target; @@ -19,14 +18,11 @@ import org.eclipse.hawkbit.repository.model.Target; * information of an assignment and how much of the assignment has been done and * how much of the assignments had already been existed. * - * - * - * */ public class DistributionSetAssignmentResult extends AssignmentResult { private final List assignedTargets; - private final List actions; + private final List actions; private final TargetManagement targetManagement; @@ -48,7 +44,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult { * */ public DistributionSetAssignmentResult(final List assignedTargets, final int assigned, - final int alreadyAssigned, final List actions, final TargetManagement targetManagement) { + final int alreadyAssigned, final List actions, final TargetManagement targetManagement) { super(assigned, alreadyAssigned); this.assignedTargets = assignedTargets; this.actions = actions; @@ -63,9 +59,9 @@ public class DistributionSetAssignmentResult extends AssignmentResult { } /** - * @return the actionId + * @return the actionIds */ - public List getActions() { + public List getActions() { return actions; } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 46747cd9c..5ad98069a 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -73,7 +73,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { distributionSetManagement, new ArrayList()); final List testTarget = targetManagement.createTargets(TestDataUtil.generateTargets(1)); // one action with one action status is generated - final Action action = deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0)); // save 2 action status actionStatusRepository.save(new ActionStatus(action, Status.RETRIEVED, System.currentTimeMillis())); actionStatusRepository.save(new ActionStatus(action, Status.RUNNING, System.currentTimeMillis())); @@ -349,7 +350,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { * test a simple deployment by calling the * {@link TargetRepository#assignDistributionSet(DistributionSet, Iterable)} * and checking the active action and the action history of the targets. - * + * * @throws InterruptedException */ @Test @@ -805,7 +806,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // assign ds to create an action final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement .assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId()); - final Action action = assignDistributionSet.getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0)); // verify preparation Action findAction = deploymentManagement.findAction(action.getId()); assertThat(findAction.getActionType()).isEqualTo(ActionType.SOFT); @@ -828,7 +829,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // assign ds to create an action final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement .assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId()); - final Action action = assignDistributionSet.getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0)); // verify perparation Action findAction = deploymentManagement.findAction(action.getId()); assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED); @@ -848,7 +849,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { *

* All created distribution sets are assigned to all targets of the * target list deployedTargets. - * + * * @param undeployedTargetPrefix * prefix to be used as target controller prefix * @param noOfUndeployedTargets diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java index bb5450083..0f91fb521 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java @@ -138,7 +138,8 @@ public class ReportManagementTest extends AbstractIntegrationTest { final Target createTarget = targetManagement.createTarget(new Target("t" + month)); final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(distributionSet, Lists.newArrayList(createTarget)); - controllerManagament.registerRetrieved(result.getActions().get(0), + controllerManagament.registerRetrieved( + deploymentManagement.findActionWithDetails(result.getActions().get(0)), "Controller retrieved update action and should start now the download."); } DataReportSeries feedbackReceivedOverTime = reportManagement @@ -158,7 +159,8 @@ public class ReportManagementTest extends AbstractIntegrationTest { final Target createTarget = targetManagement.createTarget(new Target("t2" + month)); final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(distributionSet, Lists.newArrayList(createTarget)); - controllerManagament.registerRetrieved(result.getActions().get(0), + controllerManagament.registerRetrieved( + deploymentManagement.findActionWithDetails(result.getActions().get(0)), "Controller retrieved update action and should start now the download."); } feedbackReceivedOverTime = reportManagement.feedbackReceivedOverTime(DateTypes.perMonth(), from, to); @@ -572,7 +574,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { /* * (non-Javadoc) - * + * * @see org.springframework.data.auditing.DateTimeProvider#getNow() */ @Override diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java index 3a70441ca..cdcaff25e 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -174,7 +174,7 @@ public class TargetManagementTest extends AbstractIntegrationTest { final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(set.getId(), "4711"); - final Action action = result.getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(result.getActions().get(0)); action.setStatus(Status.FINISHED); controllerManagament.addUpdateActionStatus( new ActionStatus(action, Status.FINISHED, System.currentTimeMillis(), "message"), action); @@ -221,7 +221,7 @@ public class TargetManagementTest extends AbstractIntegrationTest { * verifies, that all {@link TargetTag} of parameter. NOTE: it's accepted * that the target have additional tags assigned to them which are not * contained within parameter tags. - * + * * @param strict * if true, the given targets MUST contain EXACTLY ALL given * tags, AND NO OTHERS. If false, the given targets MUST contain diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java index dffec4df1..d7efa50d5 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java @@ -199,13 +199,14 @@ public final class RepositoryDataGenerator { } - private void createActionStatusHistory(final List actions, final int sizeMultiplikator) { + private void createActionStatusHistory(final List actions, final int sizeMultiplikator) { final AtomicInteger counter = new AtomicInteger(); int index = 0; - for (final Action actionGiven : actions) { + for (final Long actionGiven : actions) { // retrieved - Action action = controllerManagement.registerRetrieved(actionGiven, + Action action = controllerManagement.registerRetrieved( + deploymentManagement.findActionWithDetails(actionGiven), "Controller retrieved update action and should start now the download."); // download @@ -260,10 +261,11 @@ public final class RepositoryDataGenerator { } } - private void createSimpleActionStatusHistory(final List actions) { - for (final Action actionGiven : actions) { + private void createSimpleActionStatusHistory(final List actions) { + for (final Long actionGiven : actions) { // retrieved - Action action = controllerManagement.registerRetrieved(actionGiven, + Action action = controllerManagement.registerRetrieved( + deploymentManagement.findActionWithDetails(actionGiven), "Controller retrieved update action and should start now the download."); // close diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java index 267b95408..e7b94cb30 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java @@ -56,7 +56,8 @@ public class CancelActionTest extends AbstractIntegrationTest { final List toAssign = new ArrayList(); toAssign.add(savedTarget); - final Action updateAction = deploymentManagement.assignDistributionSet(ds, toAssign).getActions().get(0); + final Action updateAction = deploymentManagement + .findActionWithDetails(deploymentManagement.assignDistributionSet(ds, toAssign).getActions().get(0)); final Action cancelAction = deploymentManagement.cancelAction(updateAction, targetManagement.findTargetByControllerID(savedTarget.getControllerId())); @@ -112,7 +113,8 @@ public class CancelActionTest extends AbstractIntegrationTest { final List toAssign = new ArrayList(); toAssign.add(savedTarget); - final Action updateAction = deploymentManagement.assignDistributionSet(ds, toAssign).getActions().get(0); + final Action updateAction = deploymentManagement + .findActionWithDetails(deploymentManagement.assignDistributionSet(ds, toAssign).getActions().get(0)); long current = System.currentTimeMillis(); mvc.perform(get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant())) @@ -227,7 +229,8 @@ public class CancelActionTest extends AbstractIntegrationTest { final Target savedTarget = targetManagement.createTarget(target); final List toAssign = new ArrayList(); toAssign.add(savedTarget); - final Action updateAction = deploymentManagement.assignDistributionSet(ds, toAssign).getActions().get(0); + final Action updateAction = deploymentManagement + .findActionWithDetails(deploymentManagement.assignDistributionSet(ds, toAssign).getActions().get(0)); return deploymentManagement.cancelAction(updateAction, targetManagement.findTargetByControllerID(savedTarget.getControllerId())); @@ -243,8 +246,8 @@ public class CancelActionTest extends AbstractIntegrationTest { final Target savedTarget = targetManagement.createTarget(target); - final Action updateAction = deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" }) - .getActions().get(0); + final Action updateAction = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" }).getActions().get(0)); // cancel action manually final Action cancelAction = deploymentManagement.cancelAction(updateAction, @@ -340,12 +343,12 @@ public class CancelActionTest extends AbstractIntegrationTest { final Target savedTarget = targetManagement.createTarget(target); - final Action updateAction = deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" }) - .getActions().get(0); - final Action updateAction2 = deploymentManagement.assignDistributionSet(ds2.getId(), new String[] { "4712" }) - .getActions().get(0); - final Action updateAction3 = deploymentManagement.assignDistributionSet(ds3.getId(), new String[] { "4712" }) - .getActions().get(0); + final Action updateAction = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" }).getActions().get(0)); + final Action updateAction2 = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds2.getId(), new String[] { "4712" }).getActions().get(0)); + final Action updateAction3 = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds3.getId(), new String[] { "4712" }).getActions().get(0)); assertThat(actionStatusRepository.findAll()).hasSize(3); @@ -456,8 +459,8 @@ public class CancelActionTest extends AbstractIntegrationTest { final List toAssign = new ArrayList(); toAssign.add(target); - final Action action = deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" }) - .getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" }).getActions().get(0)); final Action cancelAction = deploymentManagement.cancelAction(action, targetManagement.findTargetByControllerID(target.getControllerId())); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java index e0a4b8e5c..2aabb0cba 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java @@ -484,7 +484,8 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { final DistributionSet savedSet = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); - final Action action1 = deploymentManagement.assignDistributionSet(savedSet, toAssign).getActions().get(0); + final Action action1 = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(savedSet, toAssign).getActions().get(0)); mvc.perform( get("/{tenant}/controller/v1/4712/deploymentBase/" + action1.getId(), tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); @@ -544,12 +545,12 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { final List toAssign = new ArrayList(); toAssign.add(savedTarget1); - final Action action1 = deploymentManagement.assignDistributionSet(ds1.getId(), new String[] { "4712" }) - .getActions().get(0); - final Action action2 = deploymentManagement.assignDistributionSet(ds2.getId(), new String[] { "4712" }) - .getActions().get(0); - final Action action3 = deploymentManagement.assignDistributionSet(ds3.getId(), new String[] { "4712" }) - .getActions().get(0); + final Action action1 = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds1.getId(), new String[] { "4712" }).getActions().get(0)); + final Action action2 = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds2.getId(), new String[] { "4712" }).getActions().get(0)); + final Action action3 = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(ds3.getId(), new String[] { "4712" }).getActions().get(0)); Target myT = targetManagement.findTargetByControllerID("4712"); assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING); From 6a2b74e5651e8f1e15eaf74f31d529cfa7578000 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 16 Feb 2016 17:37:34 +0100 Subject: [PATCH 22/45] Enabled target.assignedDs load through action enitygraph. Signed-off-by: Kai Zimmermann --- .../hawkbit/repository/DeploymentManagement.java | 4 ++-- .../eclipse/hawkbit/repository/model/Action.java | 3 ++- .../repository/DeploymentManagementTest.java | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index b0a61395b..c9b08a554 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -710,8 +710,8 @@ public class DeploymentManagement { } /** - * Get the {@link Action} entity for given actionId with all lazy - * attributes. + * Get the {@link Action} entity for given actionId with all lazy attributes + * (i.e. distributionSet, target, target.assignedDs). * * @param actionId * to be id of the action diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java index 0554e6c58..1f8a71d76 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java @@ -24,6 +24,7 @@ import javax.persistence.ManyToOne; import javax.persistence.NamedAttributeNode; import javax.persistence.NamedEntityGraph; import javax.persistence.NamedEntityGraphs; +import javax.persistence.NamedSubgraph; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; @@ -55,7 +56,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; @Index(name = "sp_idx_action_prim", columnList = "tenant,id") }) @NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }), @NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"), - @NamedAttributeNode("target") }) }) + @NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet") ) ) }) @Entity public class Action extends BaseEntity implements Comparable { private static final long serialVersionUID = 1L; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 5ad98069a..248f630db 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -66,6 +66,22 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { @Autowired private EventBus eventBus; + @Test + @Description("Test verifies that the repistory retrieves the action including all defined (lazy) details.") + public void findActionWithLazyDetails() { + final DistributionSet testDs = TestDataUtil.generateDistributionSet("TestDs", "1.0", softwareManagement, + distributionSetManagement, new ArrayList()); + final List testTarget = targetManagement.createTargets(TestDataUtil.generateTargets(1)); + // one action with one action status is generated + final Action action = deploymentManagement.findActionWithDetails( + deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0)); + + assertThat(action.getDistributionSet()).as("DistributionSet in action").isNotNull(); + assertThat(action.getTarget()).as("Target in action").isNotNull(); + assertThat(action.getTarget().getAssignedDistributionSet()).as("AssignedDistributionSet of target in action") + .isNotNull(); + } + @Test @Description("Test verifies that the custom query to find all actions include the count of action status is working correctly") public void findActionsWithStatusCountByTarget() { From 52fee2b2dfe7b969b5a44f7010838343aad298e0 Mon Sep 17 00:00:00 2001 From: venu1278 Date: Wed, 17 Feb 2016 13:01:05 +0530 Subject: [PATCH 23/45] Drag and drop handles wrong item Signed-off-by: venu1278 --- .../smtable/SoftwareModuleTable.java | 16 ++----------- .../smtable/SoftwareModuleTableHeader.java | 6 +++-- .../dstable/DistributionSetTable.java | 15 +----------- .../dstable/DistributionSetTableHeader.java | 7 +++--- .../distributions/smtable/SwModuleTable.java | 22 ++++-------------- .../smtable/SwModuleTableHeader.java | 6 +++-- .../management/dstable/DistributionTable.java | 23 +++---------------- .../dstable/DistributionTableHeader.java | 6 +++-- .../management/targettable/TargetTable.java | 19 ++------------- .../targettable/TargetTableHeader.java | 6 +++-- 10 files changed, 32 insertions(+), 94 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index 940e3b27a..f1e302fdc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -79,8 +79,7 @@ public class SoftwareModuleTable extends AbstractTable { @Autowired private UploadViewAcceptCriteria uploadViewAcceptCriteria; - private Boolean isFilterApplied = false; - + /** * Initialize the filter layout. */ @@ -107,18 +106,7 @@ public class SoftwareModuleTable extends AbstractTable { if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - final Map queryConfig = prepareQueryConfigFilters(); - if(queryConfig.size()<1 && isFilterApplied==false){ - UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); - - }else { - refreshFilter(); - if(queryConfig.size()<1){ - isFilterApplied = false; - }else{ - isFilterApplied = true; - } - } + refreshFilter(); } }); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java index b08c4defb..b7db0096a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java @@ -219,8 +219,10 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { */ @Override protected void resetSearchText() { - artifactUploadState.getSoftwareModuleFilters().setSearchText(null); - eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); + if(artifactUploadState.getSoftwareModuleFilters().getSearchText().isPresent()){ + artifactUploadState.getSoftwareModuleFilters().setSearchText(null); + eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); + } } /* diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index f62504911..32223e995 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -115,8 +115,6 @@ public class DistributionSetTable extends AbstractTable { @Autowired private transient TargetManagement targetManagement; - private Boolean isFilterApplied = false; - /** * Initialize the component. */ @@ -616,18 +614,7 @@ public class DistributionSetTable extends AbstractTable { if (event == DistributionTableFilterEvent.FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { - final Map queryConfig = prepareQueryConfigFilters(); - if(queryConfig.size()<1 && isFilterApplied==false){ - UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); - - }else { - UI.getCurrent().access(() -> refreshFilter()); - if(queryConfig.size()<1){ - isFilterApplied = false; - }else{ - isFilterApplied = true; - } - } + UI.getCurrent().access(() -> refreshFilter()); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java index d64f07ca0..a39f32f6e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java @@ -170,9 +170,10 @@ public class DistributionSetTableHeader extends AbstractTableHeader { @Override protected void resetSearchText() { - manageDistUIstate.getManageDistFilters().setSearchText(null); - eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT); - + if(manageDistUIstate.getManageDistFilters().getSearchText().isPresent()){ + manageDistUIstate.getManageDistFilters().setSearchText(null); + eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT); + } } @Override diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index dd8216dfd..90d6a74df 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -95,9 +95,7 @@ public class SwModuleTable extends AbstractTable { @Autowired private ArtifactDetailsLayout artifactDetailsLayout; - private Boolean isFilterApplied = false; - - /** + /** * Initialize the filter layout. */ @PostConstruct @@ -126,21 +124,9 @@ public class SwModuleTable extends AbstractTable { if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - final Map queryConfig = prepareQueryConfigFilters(); - if(queryConfig.size()<2 && isFilterApplied==false){ - UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); - - }else { - UI.getCurrent().access(() ->{ refreshFilter(); - styleTableOnDistSelection(); - }); - if(queryConfig.size()<2){ - isFilterApplied = false; - }else{ - isFilterApplied = true; - } - } - } + refreshFilter(); + styleTableOnDistSelection(); + } }); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java index 1eae1297b..d8d018e27 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java @@ -203,8 +203,10 @@ public class SwModuleTableHeader extends AbstractTableHeader { */ @Override protected void resetSearchText() { - manageDistUIState.getSoftwareModuleFilters().setSearchText(null); - eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); + if(manageDistUIState.getSoftwareModuleFilters().getSearchText().isPresent()){ + manageDistUIState.getSoftwareModuleFilters().setSearchText(null); + eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); + } } /* diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index ab1ccdeac..53e723c7d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -113,8 +113,7 @@ public class DistributionTable extends AbstractTable { private Button distributinPinnedBtn; - private Boolean isFilterApplied = false; - + /** * Initialize the distribution table. */ @@ -142,24 +141,8 @@ public class DistributionTable extends AbstractTable { if (event == DistributionTableFilterEvent.FILTER_BY_TEXT || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { - final Map queryConfig = prepareQueryConfigFilters(); - if(((boolean)queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) - && ((List)queryConfig.get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() - && queryConfig.size()<3 - && isFilterApplied==false){ - UI.getCurrent().access(() -> ((LazyQueryContainer) getContainerDataSource()).refresh()); - - }else { - UI.getCurrent().access(() -> refreshFilter()); - if(((boolean)queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) - && ((List)queryConfig.get(SPUIDefinitions.FILTER_BY_TAG)).isEmpty() - && queryConfig.size()<3){ - isFilterApplied = false; - }else{ - isFilterApplied = true; - } - } - } + UI.getCurrent().access(() -> refreshFilter()); + } } @EventBusListenerMethod(scope = EventScope.SESSION) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java index 1f28293d2..32a3e914d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java @@ -210,8 +210,10 @@ public class DistributionTableHeader extends AbstractTableHeader { */ @Override protected void resetSearchText() { - managementUIState.getDistributionTableFilters().setSearchText(null); - eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT); + if( managementUIState.getDistributionTableFilters().getSearchText().isPresent()){ + managementUIState.getDistributionTableFilters().setSearchText(null); + eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT); + } } /* diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 17256cca8..6fc7f103b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -140,8 +140,7 @@ public class TargetTable extends AbstractTable implements Handler { private ShortcutAction actionSelectAll; private ShortcutAction actionUnSelectAll; - private Boolean isFilterApplied = Boolean.FALSE;; - + @Override @PostConstruct @@ -211,21 +210,7 @@ public class TargetTable extends AbstractTable implements Handler { void onEvent(final TargetFilterEvent filterEvent) { UI.getCurrent().access(() -> { if (checkFilterEvent(filterEvent)) { - final Map queryConfiguration = prepareQueryConfigFilters(); - if(((boolean)queryConfiguration.get(SPUIDefinitions.FILTER_BY_NO_TAG)==false) - && queryConfiguration.size()<2 - && isFilterApplied==Boolean.FALSE){ - ((LazyQueryContainer) getContainerDataSource()).refresh(); - - }else { - refreshFilter(); - if(queryConfiguration.size()<2){ - isFilterApplied = Boolean.FALSE; - }else{ - isFilterApplied = Boolean.TRUE; - } - } - + refreshFilter(); eventBus.publish(this, ManagementUIEvent.TARGET_TABLE_FILTER); } }); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java index a1b094f99..159c169d7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -258,8 +258,10 @@ public class TargetTableHeader extends AbstractTableHeader { @Override protected void resetSearchText() { - managementUIState.getTargetTableFilters().setSearchText(null); - eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TEXT); + if(managementUIState.getTargetTableFilters().getSearchText().isPresent()){ + managementUIState.getTargetTableFilters().setSearchText(null); + eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TEXT); + } } private String getSearchText() { From 3334cf4a649f723e17b9ccdae6f8a4f7f0df835d Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 17 Feb 2016 08:36:36 +0100 Subject: [PATCH 24/45] Updated test Signed-off-by: Kai Zimmermann --- .../eclipse/hawkbit/repository/DeploymentManagementTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 248f630db..693a67082 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -73,8 +73,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { distributionSetManagement, new ArrayList()); final List testTarget = targetManagement.createTargets(TestDataUtil.generateTargets(1)); // one action with one action status is generated - final Action action = deploymentManagement.findActionWithDetails( - deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0)); + final Long actionId = deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0); + final Action action = deploymentManagement.findActionWithDetails(actionId); assertThat(action.getDistributionSet()).as("DistributionSet in action").isNotNull(); assertThat(action.getTarget()).as("Target in action").isNotNull(); From 01b75fc93207623d96edc8876f26efbc7f7fa722 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 17 Feb 2016 09:57:07 +0100 Subject: [PATCH 25/45] Removed unnecessary entitygraph usage. Signed-off-by: Kai Zimmermann --- .../hawkbit/repository/ActionRepository.java | 18 ++++-------------- .../hawkbit/repository/model/Action.java | 16 +++++----------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java index a93fbdca7..8221fa0ca 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java @@ -37,16 +37,6 @@ import org.springframework.transaction.annotation.Transactional; */ @Transactional(readOnly = true) public interface ActionRepository extends BaseEntityRepository, JpaSpecificationExecutor { - - /* - * (non-Javadoc) - * - * @see org.springframework.data.repository.CrudRepository#findAll() - */ - @Override - @EntityGraph(value = "Action.all", type = EntityGraphType.LOAD) - Iterable findAll(); - /** * Retrieves an Action with all lazy attributes. * @@ -67,7 +57,6 @@ public interface ActionRepository extends BaseEntityRepository, Jp * the {@link DistributionSet} on which will be filtered * @return the found {@link Action}s */ - @EntityGraph(value = "Action.all", type = EntityGraphType.LOAD) Page findByDistributionSet(final Pageable pageable, final DistributionSet ds); /** @@ -84,7 +73,8 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s which are active and referring the given - * {@link Target} in a specified order. + * {@link Target} in a specified order. Loads also the lazy + * {@link Action#getDistributionSet()} field. * * @param pageable * page parameters @@ -125,7 +115,6 @@ public interface ActionRepository extends BaseEntityRepository, Jp * @return the found {@link UpdateAction}s */ @Query("Select a from Action a where a.target = :target and a.distributionSet = :ds order by a.id") - @EntityGraph(value = "Action.all", type = EntityGraphType.LOAD) Page findByTargetAndDistributionSet(final Pageable pageable, @Param("target") final Target target, @Param("ds") DistributionSet ds); @@ -159,7 +148,8 @@ public interface ActionRepository extends BaseEntityRepository, Jp /** * Retrieves all {@link Action}s of a specific target and given active flag - * ordered by action ID. + * ordered by action ID. Loads also the lazy + * {@link Action#getDistributionSet()} field. * * @param target * to search for diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java index 1f8a71d76..c19b947de 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java @@ -35,21 +35,15 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; /** *

- * Applicable transition changes of the software {@link SoftwareModule} state of - * a {@link Target}, e.g. install, uninstall, update, start, stop, and - * preparations for the transition change, i.e. download. + * Applicable transition changes of the {@link SoftwareModule}s state of a + * {@link Target}, e.g. install, uninstall, update and preparations for the + * transition change, i.e. download. *

* *

- * Actions are managed by the SP server (SPS) and applied to the edge controller - * by the SP controller (SPC). Actions may also be value added commands that are - * nor directly related to SP, e.g. factory reset. + * Actions are managed by the SP server and applied to the targets by the + * client. *

- * - * - * - * - * */ @Table(name = "sp_action", indexes = { @Index(name = "sp_idx_action_01", columnList = "tenant,distribution_set"), @Index(name = "sp_idx_action_02", columnList = "tenant,target,active"), From 8b9f0d57dc7c7a16c64071f679de57cb662aab23 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 17 Feb 2016 14:00:33 +0100 Subject: [PATCH 26/45] Create README.md --- 3rd-dependencies/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 3rd-dependencies/README.md diff --git a/3rd-dependencies/README.md b/3rd-dependencies/README.md new file mode 100644 index 000000000..357ca54c2 --- /dev/null +++ b/3rd-dependencies/README.md @@ -0,0 +1,3 @@ +# 3rd Party Dependencies + +Contains listing of all maven (transient) licenses of the project. Is primary used to identify all changes between eclipse releases. From 1c6223ba5d2ab994c405763698fc5b97dd5f7daa Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 18 Feb 2016 10:12:36 +0100 Subject: [PATCH 27/45] Improved readibility Signed-off-by: Kai Zimmermann --- .../repository/DeploymentManagement.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index c9b08a554..f266ffac4 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -380,7 +380,7 @@ public class DeploymentManagement { // flush to get action IDs entityManager.flush(); - // select updated targets in order to return them + // collect updated target and actions IDs in order to return them final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult( targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), controllerIDs.size() - targets.size(), @@ -393,12 +393,22 @@ public class DeploymentManagement { // detaching as it is not necessary to persist the set itself entityManager.detach(set); - // send distribution set assignment event + sendDistributionSetAssignmentEvent(targets, targetIdsCancellList, targetIdsToActions, softwareModules); + + return result; + } + + /** + * @param targets + * @param targetIdsCancellList + * @param targetIdsToActions + * @param softwareModules + */ + private void sendDistributionSetAssignmentEvent(final List targets, final Set targetIdsCancellList, + final Map targetIdsToActions, final List softwareModules) { targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId())) .forEach(t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(), softwareModules)); - - return result; } /** From b6509750bc7e623237de5c4b1260f7d30ef2a579 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 18 Feb 2016 10:22:21 +0100 Subject: [PATCH 28/45] Removed broken javadoc. Signed-off-by: Kai Zimmermann --- .../eclipse/hawkbit/repository/DeploymentManagement.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index f266ffac4..560549e7e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -398,12 +398,6 @@ public class DeploymentManagement { return result; } - /** - * @param targets - * @param targetIdsCancellList - * @param targetIdsToActions - * @param softwareModules - */ private void sendDistributionSetAssignmentEvent(final List targets, final Set targetIdsCancellList, final Map targetIdsToActions, final List softwareModules) { targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId())) From 878af52bc21a801a35a554fd23d4b484242a4d82 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 18 Feb 2016 12:13:48 +0100 Subject: [PATCH 29/45] Add sonar_lock to git ignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index dad7bec10..ba9cf4617 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,11 @@ *.jar *.war +###################### +# Sonar +###################### +.sonar_lock + # Eclipse IDE *.pydevproject From 6b143d6016862829283bbbed48dd7fded178a358 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 19 Feb 2016 16:30:38 +0100 Subject: [PATCH 30/45] Fixed production mode path --- .../src/main/resources/application.properties | 4 ++-- .../src/main/resources/hawkbitdefaults.properties | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/hawkbit-example-app/src/main/resources/application.properties b/examples/hawkbit-example-app/src/main/resources/application.properties index 7149dbb9c..13ceca40a 100644 --- a/examples/hawkbit-example-app/src/main/resources/application.properties +++ b/examples/hawkbit-example-app/src/main/resources/application.properties @@ -15,8 +15,8 @@ hawkbit.server.controller.security.authentication.gatewaytoken.enabled=false spring.profiles.active=amqp -vaadin.servlet.params.productionMode=false -vaadin.static.servlet.params.productionMode=false +vaadin.servlet.productionMode=false +vaadin.static.servlet.productionMode=false ## Configuration for RabbitMQ integration hawkbit.server.amqp.username=guest diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties index 4020d0cdd..09ae37f90 100644 --- a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties +++ b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties @@ -29,10 +29,10 @@ flyway.initOnMigrate=true flyway.sqlMigrationSuffix=${spring.jpa.database}.sql # Vaadin Servlet -vaadin.static.servlet.params.resourceCacheTime=${spring.resources.cache-period} -vaadin.static.servlet.params.productionMode=true -vaadin.servlet.params.productionMode=true -vaadin.servlet.params.resourceCacheTime=${spring.resources.cache-period} +vaadin.static.servlet.resourceCacheTime=${spring.resources.cache-period} +vaadin.static.servlet.productionMode=true +vaadin.servlet.productionMode=true +vaadin.servlet.resourceCacheTime=${spring.resources.cache-period} vaadin.servlet.urlMapping=/UI/* vaadin.servlet.params.heartbeatInterval=60 vaadin.servlet.params.closeIdleSessions=false From b9a2e155fdabe5ffd8fc17b67c2554bd879c36ff Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Sun, 21 Feb 2016 20:50:21 +0100 Subject: [PATCH 31/45] Removed runtime dependencies to sass compiler package --- .../ui/components/SPUIComponentProvider.java | 6 +-- .../management/targettable/TargetTable.java | 49 +++++++++---------- .../ui/rollout/AbstractSimpleTableHeader.java | 2 +- pom.xml | 24 --------- 4 files changed, 27 insertions(+), 54 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java index 265b1db83..62e16da94 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.components; import java.util.Arrays; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator; @@ -23,7 +24,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.vaadin.sass.internal.util.StringUtil; import com.vaadin.server.ExternalResource; import com.vaadin.server.FontAwesome; import com.vaadin.server.Resource; @@ -109,7 +109,7 @@ public final class SPUIComponentProvider { // Do we really need this??? HorizontalLayout hLayout = getHorizontalLayout(new SPUIHorizontalLayout().getUiHorizontalLayout().getClass()); try { - SPUIHeaderLayoutDecorator layoutDecorator = null; + SPUIHeaderLayoutDecorator layoutDecorator; if (tableHeaderLayoutDecorator != null) { layoutDecorator = tableHeaderLayoutDecorator.newInstance(); hLayout = layoutDecorator.decorate(hLayout); @@ -324,7 +324,7 @@ public final class SPUIComponentProvider { * @return Label */ public static Label createNameValueLabel(final String label, final String... values) { - final String valueStr = StringUtil.collectionToDelimitedString(Arrays.asList(values), " "); + final String valueStr = StringUtils.join(Arrays.asList(values), " "); final Label nameValueLabel = new Label(getBoldHTMLText(label) + valueStr, ContentMode.HTML); nameValueLabel.setSizeFull(); nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java index 62276346e..9ed202343 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -73,8 +73,8 @@ import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; +import com.google.common.base.Strings; import com.google.common.collect.Iterables; -import com.google.gwt.thirdparty.guava.common.base.Strings; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.event.Action; @@ -104,6 +104,8 @@ import com.vaadin.ui.themes.ValoTheme; @ViewScope public class TargetTable extends AbstractTable implements Handler { + private static final String TARGET_PINNED = "targetPinned"; + private static final long serialVersionUID = -2300392868806614568L; private static final Logger LOG = LoggerFactory.getLogger(TargetTable.class); @@ -271,7 +273,7 @@ public class TargetTable extends AbstractTable implements Handler { final Map queryConfig = prepareQueryConfigFilters(); // Create TargetBeanQuery factory with the query config. - final BeanQueryFactory targetQF = new BeanQueryFactory(TargetBeanQuery.class); + final BeanQueryFactory targetQF = new BeanQueryFactory<>(TargetBeanQuery.class); targetQF.setQueryConfiguration(queryConfig); // create lazy query container with lazy defination and query @@ -394,7 +396,7 @@ public class TargetTable extends AbstractTable implements Handler { */ @Override protected List getTableVisibleColumns() { - final List columnList = new ArrayList(); + final List columnList = new ArrayList<>(); if (isMaximized()) { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); @@ -469,7 +471,7 @@ public class TargetTable extends AbstractTable implements Handler { } private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); + final Map queryConfig = new HashMap<>(); managementUIState.getTargetTableFilters().getSearchText() .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); managementUIState.getTargetTableFilters().getDistributionSet() @@ -481,7 +483,7 @@ public class TargetTable extends AbstractTable implements Handler { queryConfig.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getTargetTableFilters().isNoTagSelected()); if (isFilteredByTags()) { - final List list = new ArrayList(); + final List list = new ArrayList<>(); list.addAll(managementUIState.getTargetTableFilters().getClickedTargetTags()); queryConfig.put(SPUIDefinitions.FILTER_BY_TAG, list.toArray(new String[list.size()])); } @@ -522,7 +524,7 @@ public class TargetTable extends AbstractTable implements Handler { pinBtn.setId(SPUIComponetIdProvider.TARGET_PIN_ICON + "." + itemId); pinBtn.addClickListener(event -> addPinClickListener(event)); if (isPinned(((TargetIdName) itemId).getControllerId())) { - pinBtn.addStyleName("targetPinned"); + pinBtn.addStyleName(TARGET_PINNED); isTargetPinned = Boolean.TRUE; targetPinnedBtn = pinBtn; eventBus.publish(this, PinUnpinEvent.PIN_TARGET); @@ -533,7 +535,7 @@ public class TargetTable extends AbstractTable implements Handler { } private boolean isPinned(final String targetId) { - boolean result = false; + boolean result; if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent() && targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) { result = true; @@ -594,7 +596,7 @@ public class TargetTable extends AbstractTable implements Handler { eventBus.publish(this, PinUnpinEvent.PIN_TARGET); /* change target table styling */ styleTargetTable(); - eventBtn.addStyleName("targetPinned"); + eventBtn.addStyleName(TARGET_PINNED); isTargetPinned = Boolean.FALSE; } @@ -605,7 +607,7 @@ public class TargetTable extends AbstractTable implements Handler { } private void resetPinStyle(final Button pinBtn) { - pinBtn.removeStyleName("targetPinned"); + pinBtn.removeStyleName(TARGET_PINNED); pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE); HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, pinBtn.getData()); } @@ -644,7 +646,7 @@ public class TargetTable extends AbstractTable implements Handler { final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails(); final Table targetTable = (Table) taregtDet.getTarget(); final Set targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(targetTable); - final Set targetList = new HashSet(); + final Set targetList = new HashSet<>(); final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object targetItemId = dropData.getItemIdOver(); if (!targetSelected.contains(targetItemId)) { @@ -701,9 +703,8 @@ public class TargetTable extends AbstractTable implements Handler { private static Set getDraggedDistributionSet(final TableTransferable transferable, final Table source) { - @SuppressWarnings("unchecked") final Set distSelected = HawkbitCommonUtil.getSelectedDSDetails(source); - final Set distributionIdSet = new HashSet(); + final Set distributionIdSet = new HashSet<>(); if (!distSelected.contains(transferable.getData(ITEMID))) { distributionIdSet.add((DistributionSetIdName) transferable.getData(ITEMID)); } else { @@ -828,15 +829,11 @@ public class TargetTable extends AbstractTable implements Handler { } } - /** - * @param filterEvent - * @return - */ - private boolean checkFilterEvent(final TargetFilterEvent filterEvent) { - boolean isFilterEvent = false; - boolean isFilter = false; - boolean isRemoveFilters = false; - boolean isStatusFilter = false; + private static boolean checkFilterEvent(final TargetFilterEvent filterEvent) { + boolean isFilterEvent; + boolean isFilter; + boolean isRemoveFilters; + boolean isStatusFilter; isFilter = filterEvent == TargetFilterEvent.FILTER_BY_TEXT || filterEvent == TargetFilterEvent.FILTER_BY_TAG || filterEvent == TargetFilterEvent.FILTER_BY_DISTRIBUTION || filterEvent == TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY; @@ -1020,11 +1017,11 @@ public class TargetTable extends AbstractTable implements Handler { private List getTargetIdsBySimpleFilters(final PageRequest pageRequest) { final Long filterByDistId = managementUIState.getTargetTableFilters().getDistributionSet().isPresent() ? managementUIState.getTargetTableFilters().getDistributionSet().get().getId() : null; - final List statusList = new ArrayList(); + final List statusList = new ArrayList<>(); if (isFilteredByStatus()) { statusList.addAll(managementUIState.getTargetTableFilters().getClickedStatusTargetTags()); } - final List tagList = new ArrayList(); + final List tagList = new ArrayList<>(); if (isFilteredByTags()) { tagList.addAll(managementUIState.getTargetTableFilters().getClickedTargetTags()); } @@ -1081,7 +1078,7 @@ public class TargetTable extends AbstractTable implements Handler { String[] targetTags = null; Long distributionId = null; String searchText = null; - Boolean noTagClicked = Boolean.FALSE; + Boolean noTagClicked; Long pinnedDistId = null; if (isFilteredByTags()) { @@ -1129,13 +1126,13 @@ public class TargetTable extends AbstractTable implements Handler { && !Strings.isNullOrEmpty(managementUIState.getTargetTableFilters().getSearchText().get()); } - private Boolean anyFilterSelected(final Collection status, final Long distributionId, + private static Boolean anyFilterSelected(final Collection status, final Long distributionId, final Boolean noTagClicked, final String[] targetTags, final String searchText) { return status == null && distributionId == null && Strings.isNullOrEmpty(searchText) && !isTagSelected(targetTags, noTagClicked); } - private Boolean isTagSelected(final String[] targetTags, final Boolean noTagClicked) { + private static Boolean isTagSelected(final String[] targetTags, final Boolean noTagClicked) { return targetTags == null && !noTagClicked; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AbstractSimpleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AbstractSimpleTableHeader.java index c51c02fe4..38f59b270 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AbstractSimpleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AbstractSimpleTableHeader.java @@ -15,7 +15,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; -import com.google.gwt.thirdparty.guava.common.base.Strings; +import com.google.common.base.Strings; import com.vaadin.server.FontAwesome; import com.vaadin.ui.AbstractTextField.TextChangeEventMode; import com.vaadin.ui.Alignment; diff --git a/pom.xml b/pom.xml index aa188e76a..82163f1d3 100644 --- a/pom.xml +++ b/pom.xml @@ -363,30 +363,6 @@ vaadin-push ${vaadin.version} - - - com.vaadin - vaadin-client-compiler - ${vaadin.version} - provided - - - org.eclipse.jetty - jetty-servlets - - - org.eclipse.jetty - jetty-annotations - - - org.eclipse.jetty - jetty-util - - - com.vaadin vaadin-themes From 13345406ee2e9d7355b89802c210d549606cf7a4 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 22 Feb 2016 11:01:47 +0100 Subject: [PATCH 32/45] Upgraded 3rd party libs --- .../hawkbit/artifact/MongoDBTestRule.java | 2 +- .../AbstractIntegrationTestWithMongoDB.java | 2 +- pom.xml | 41 +++++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java index d8485787e..f5d88ceaa 100644 --- a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java +++ b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java @@ -88,7 +88,7 @@ public class MongoDBTestRule implements TestRule { System.setProperty("spring.data.mongodb.port", String.valueOf(port)); } - Version version = Version.V3_1_0; + Version version = Version.V3_0_8; if (System.getProperty("inf.mongodb.version") != null) { version = Version.valueOf("V" + System.getProperty("inf.mongodb.version").trim().replaceAll("\\.", "_")); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java index eb2174a57..6d116c5f0 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java @@ -55,7 +55,7 @@ public abstract class AbstractIntegrationTestWithMongoDB extends AbstractIntegra System.setProperty("spring.data.mongodb.port", String.valueOf(port)); } - Version version = Version.V3_0_5; + Version version = Version.V3_0_8; if (System.getProperty("inf.mongodb.version") != null) { version = Version .valueOf("V" + System.getProperty("inf.mongodb.version").trim().replaceAll("\\.", "_")); diff --git a/pom.xml b/pom.xml index aa188e76a..99471bb93 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ org.springframework.boot spring-boot-starter-parent - 1.2.7.RELEASE + 1.2.8.RELEASE org.eclipse.hawkbit @@ -57,42 +57,49 @@ - 1.2.7.RELEASE + 1.2.8.RELEASE - - 1.4.186 + + 2.5.0 5.2.2.Final - Fowler-SR1 1.2.0.RELEASE - 3.0.2 - + + Fowler-SR1 + 3.2.2 + 1.0.0 0.0.6.RELEASE - 7.5.7 + 7.5.10 ${vaadin.version} - + 1.4 2.0M10 - 1.8 1.4.15 - 2.6.0 + 2.6.2 1.5.4 1.0.2 0.9.1 3.4 1.8.5 + 19.0 + 1.3.5 + 1.50.2 + + + 1.8 - + scm:git:https://github.com/eclipse/hawkbit.git scm:git:https://github.com/eclipse/hawkbit.git https://github.com/eclipse/hawkbit.git + - + https://sonar.eu-gb.mybluemix.net eclipse/hawkbit jacoco @@ -123,7 +130,7 @@ ${jacoco.outputDir}/${jacoco.out.it.file} - 19.0 + @@ -335,7 +342,7 @@ org.slf4j slf4j-api - 1.7.7 + ${slf4j.version} @@ -582,7 +589,7 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - 1.50.0 + ${embedded-mongo.version} test @@ -624,7 +631,7 @@ org.mariadb.jdbc mariadb-java-client - 1.2.3 + ${mariadb-java-client.version} test From cf3adaac63c62886b4e5fc24c72c0e87e05ee511 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 22 Feb 2016 12:20:56 +0100 Subject: [PATCH 33/45] Cleaned up POM --- pom.xml | 65 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index 99471bb93..67dbdadd9 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,11 @@ 0.0.6.RELEASE 7.5.10 ${vaadin.version} + 7.4.0.1 + 2.2.0 + 7.0.1 + 1.2.0 + 4.5 @@ -84,11 +89,18 @@ 1.5.4 1.0.2 0.9.1 - 3.4 1.8.5 19.0 1.3.5 1.50.2 + 1.18.1 + 2.2.4 + 1.1.7 + 1.1 + 1.1.1 + 3.4 + 20141113 + 2.0.0 1.8 @@ -402,44 +414,44 @@ org.vaadin.addons.lazyquerycontainer vaadin-lazyquerycontainer - 7.4.0.1 + ${vaadin.addon.vaadin-lazyquerycontainer.version} org.vaadin.addons flexibleoptiongroup - 2.2.0 + ${vaadin.addon.flexibleoptiongroup.version} org.vaadin.addons tokenfield - 7.0.1 + ${vaadin.addon.tokenfield.version} org.vaadin.alump.distributionbar dbar-addon - 1.2.0 + ${vaadin.addon.dbar-addon.version} org.vaadin.addons contextmenu - 4.5 + ${vaadin.addon.contextmenu.version} javax.el javax.el-api - 2.2.4 + ${javax.el-api.version} net.sf.corn corn-cps - 1.1.7 + ${corn-cps.version} net._01001111 jlorem - 1.1 + ${jlorem.version} @@ -521,13 +533,6 @@ - - - com.fasterxml - classmate - 1.3.0 - org.eclipse.persistence org.eclipse.persistence.jpa @@ -537,7 +542,7 @@ cz.jirutka.rsql rsql-parser - 2.0.0 + ${rsql-parser.version} @@ -548,7 +553,7 @@ com.googlecode.json-simple json-simple - 1.1.1 + ${json-simple.version} junit @@ -556,13 +561,13 @@ - - - xml-apis - xml-apis - 1.4.01 + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} - + org.springframework.boot spring-boot-starter-test @@ -574,16 +579,10 @@ - - com.vaadin - vaadin-testbench - 4.0.3 - test - org.json json - 20141113 + ${json.version} test @@ -613,7 +612,7 @@ com.sun.jersey jersey-client - 1.18.1 + ${jersey-client.version} test @@ -625,7 +624,7 @@ com.jayway.jsonpath json-path-assert - 0.9.1 + ${json-path.version} test From 713922d7624077a2e33b62f8651c32c413e1c7c1 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Mon, 22 Feb 2016 12:21:14 +0100 Subject: [PATCH 34/45] Remove broken spring property usage for vaadin caching --- .../src/main/resources/hawkbitdefaults.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties index 09ae37f90..98749a384 100644 --- a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties +++ b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties @@ -29,10 +29,8 @@ flyway.initOnMigrate=true flyway.sqlMigrationSuffix=${spring.jpa.database}.sql # Vaadin Servlet -vaadin.static.servlet.resourceCacheTime=${spring.resources.cache-period} vaadin.static.servlet.productionMode=true vaadin.servlet.productionMode=true -vaadin.servlet.resourceCacheTime=${spring.resources.cache-period} vaadin.servlet.urlMapping=/UI/* vaadin.servlet.params.heartbeatInterval=60 vaadin.servlet.params.closeIdleSessions=false From 8507ae2bd3cf0baece719f8865215d7ba5559512 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 11:14:48 +0100 Subject: [PATCH 35/45] Moved java version on top --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 67dbdadd9..e5ac3ca26 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,8 @@ + 1.8 + 1.2.8.RELEASE @@ -102,8 +104,6 @@ 20141113 2.0.0 - - 1.8 scm:git:https://github.com/eclipse/hawkbit.git From 6a5a3f2188b18f1168766987578eab4a62b36f7b Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 11:34:36 +0100 Subject: [PATCH 36/45] Cleaned up code --- .../ui/components/SPUIComponentProvider.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java index 62e16da94..5b2e4ed9a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java @@ -108,16 +108,16 @@ public final class SPUIComponentProvider { final Class tableHeaderLayoutDecorator) { // Do we really need this??? HorizontalLayout hLayout = getHorizontalLayout(new SPUIHorizontalLayout().getUiHorizontalLayout().getClass()); + + if (tableHeaderLayoutDecorator == null) { + return hLayout; + } + try { - SPUIHeaderLayoutDecorator layoutDecorator; - if (tableHeaderLayoutDecorator != null) { - layoutDecorator = tableHeaderLayoutDecorator.newInstance(); - hLayout = layoutDecorator.decorate(hLayout); - } - } catch (final InstantiationException exception) { - LOG.error("Error occured while creating horizontal decorator " + SPUIHeaderLayoutDecorator.class, - exception); - } catch (final IllegalAccessException exception) { + final SPUIHeaderLayoutDecorator layoutDecorator = tableHeaderLayoutDecorator.newInstance(); + hLayout = layoutDecorator.decorate(hLayout); + + } catch (final InstantiationException | IllegalAccessException exception) { LOG.error("Error occured while creating horizontal decorator " + SPUIHeaderLayoutDecorator.class, exception); } From 1db0d6a5e98c3191e67ba305f4fde0d87741c743 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Tue, 23 Feb 2016 13:10:33 +0100 Subject: [PATCH 37/45] Upgraded to newer jackson and hibernate validator version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e5ac3ca26..f5ec54435 100644 --- a/pom.xml +++ b/pom.xml @@ -63,8 +63,8 @@ - 2.5.0 - 5.2.2.Final + 2.5.5 + 5.2.4.Final 1.2.0.RELEASE Fowler-SR1 From fcd6555e3e76193bfd5c962455dc17c76f0bda88 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 24 Feb 2016 18:24:53 +0100 Subject: [PATCH 38/45] Fix diamond operator Remove unused override comments Remove unused javadoc on private methode Signed-off-by: SirWayne --- .../hawkbit/cache/RedisConfiguration.java | 2 +- .../cache/eventbus/EventDistributor.java | 2 +- .../report/model/ListReportSeries.java | 2 +- .../repository/DeploymentManagement.java | 7 +- .../repository/NoCountPagingRepository.java | 6 +- .../hawkbit/repository/TagManagement.java | 4 +- .../repository/model/ActionStatus.java | 2 +- .../hawkbit/repository/model/Target.java | 2 +- .../resource/DistributionSetTypeMapper.java | 2 +- .../resource/SoftwareModuleTypeMapper.java | 2 +- .../details/ArtifactDetailsLayout.java | 7 +- .../event/UploadViewAcceptCriteria.java | 41 +---- .../smtable/BaseSwModuleBeanQuery.java | 6 +- .../smtable/SoftwareModuleTable.java | 38 +--- .../CreateUpdateSoftwareTypeLayout.java | 35 +--- .../upload/UploadConfirmationwindow.java | 8 +- .../ui/artifacts/upload/UploadLayout.java | 4 +- .../artifacts/upload/UploadResultWindow.java | 2 +- .../common/DistributionSetTypeBeanQuery.java | 2 +- .../tagdetails/DistributionTagToken.java | 31 +--- .../CreateUpdateDistSetTypeLayout.java | 16 +- .../dstable/DistributionSetTable.java | 68 +------- .../dstable/ManageDistBeanQuery.java | 29 +--- .../DistributionsViewAcceptCriteria.java | 43 +---- .../smtable/SwModuleBeanQuery.java | 12 +- .../distributions/smtable/SwModuleTable.java | 91 ++-------- .../smtype/DistSMTypeFilterButtons.java | 53 +----- .../state/ManageDistFilters.java | 13 +- .../TargetFilterBeanQuery.java | 5 +- .../filtermanagement/TargetFilterTable.java | 65 +++---- .../actionhistory/ActionHistoryTable.java | 10 +- .../dstable/DistributionBeanQuery.java | 2 +- .../management/dstable/DistributionTable.java | 163 ++---------------- .../dstag/DistributionTagBeanQuery.java | 2 +- .../dstag/DistributionTagButtons.java | 51 +----- .../event/DistributionTagDropEvent.java | 35 +--- .../event/ManagementViewAcceptCriteria.java | 52 +----- .../footer/DeleteActionsLayout.java | 156 +---------------- .../state/DistributionTableFilters.java | 4 +- .../state/TargetFilterParameters.java | 4 +- .../management/state/TargetTableFilters.java | 7 +- .../targettable/TargetBeanQuery.java | 6 +- .../targettable/TargetTableHeader.java | 32 +--- .../targettag/TargetTagBeanQuery.java | 2 +- .../targettag/TargetTagFilterButtons.java | 64 +------ 45 files changed, 142 insertions(+), 1048 deletions(-) diff --git a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java index 2d1b99c98..acf50ad3f 100644 --- a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java +++ b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java @@ -75,7 +75,7 @@ public class RedisConfiguration { */ @Bean public RedisTemplate redisTemplate() { - final RedisTemplate redisTemplate = new RedisTemplate(); + final RedisTemplate redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); redisTemplate.setKeySerializer(new JdkSerializationRedisSerializer()); redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer()); diff --git a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java index e52128cbc..8749340f0 100644 --- a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java +++ b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java @@ -95,7 +95,7 @@ public class EventDistributor { * wants to subscribe */ public Collection getTopics() { - final List topics = new ArrayList(); + final List topics = new ArrayList<>(); topics.add(new PatternTopic(SUB_DISTRIBUTION_CHANNEL)); return topics; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java index 55125e046..79c496480 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java @@ -21,7 +21,7 @@ import java.util.List; */ public class ListReportSeries extends AbstractReportSeries { - private final List data = new ArrayList(); + private final List data = new ArrayList<>(); /** * @param name diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 560549e7e..236816192 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -330,7 +330,7 @@ public class DeploymentManagement { // one we have been switched to canceling state because for targets // which we have changed to // canceling we don't want to publish the new action update event. - final Set targetIdsCancellList = new HashSet(); + final Set targetIdsCancellList = new HashSet<>(); targetIds.forEach(ids -> targetIdsCancellList.addAll(overrideObsoleteUpdateActions(ids))); // cancel all scheduled actions which are in-active, these actions were @@ -435,7 +435,7 @@ public class DeploymentManagement { */ private Set overrideObsoleteUpdateActions(final List targetsIds) { - final Set cancelledTargetIds = new HashSet(); + final Set cancelledTargetIds = new HashSet<>(); // Figure out if there are potential target/action combinations that // need to be considered @@ -779,8 +779,7 @@ public class DeploymentManagement { multiselect.where(cb.equal(actionRoot.get(Action_.target), target)); multiselect.orderBy(cb.desc(actionRoot.get(Action_.id))); multiselect.groupBy(actionRoot.get(Action_.id)); - final List resultList = entityManager.createQuery(multiselect).getResultList(); - return resultList; + return entityManager.createQuery(multiselect).getResultList(); } /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java index 4290607fd..79f54a3f0 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java @@ -57,7 +57,7 @@ public class NoCountPagingRepository { */ public Slice findAll(final Specification spec, final Pageable pageable, final Class domainClass) { - final SimpleJpaNoCountRepository noCountDao = new SimpleJpaNoCountRepository(domainClass, em); + final SimpleJpaNoCountRepository noCountDao = new SimpleJpaNoCountRepository<>(domainClass, em); return noCountDao.findAll(spec, pageable); } @@ -76,7 +76,7 @@ public class NoCountPagingRepository { * org.springframework.data.domain.Pageable) */ public Slice findAll(final Pageable pageable, final Class domainClass) { - final SimpleJpaNoCountRepository noCountDao = new SimpleJpaNoCountRepository(domainClass, em); + final SimpleJpaNoCountRepository noCountDao = new SimpleJpaNoCountRepository<>(domainClass, em); return noCountDao.findAll(pageable); } @@ -120,7 +120,7 @@ public class NoCountPagingRepository { final List content = query.getResultList(); - return new PageImpl(content, pageable, content.size()); + return new PageImpl<>(content, pageable, content.size()); } } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java index 4d8b4ff5c..e0ab951ac 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java @@ -160,7 +160,7 @@ public class TagManagement { public void deleteTargetTag(@NotEmpty final String targetTagName) { final TargetTag tag = targetTagRepository.findByNameEquals(targetTagName); - final List changed = new LinkedList(); + final List changed = new LinkedList<>(); for (final Target target : targetRepository.findByTag(tag)) { target.getTags().remove(tag); changed.add(target); @@ -311,7 +311,7 @@ public class TagManagement { public void deleteDistributionSetTag(@NotEmpty final String tagName) { final DistributionSetTag tag = distributionSetTagRepository.findByNameEquals(tagName); - final List changed = new LinkedList(); + final List changed = new LinkedList<>(); for (final DistributionSet set : distributionSetRepository.findByTag(tag)) { set.getTags().remove(tag); changed.add(set); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java index 28389ab01..2b0effae9 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java @@ -63,7 +63,7 @@ public class ActionStatus extends BaseEntity { @CollectionTable(name = "sp_action_status_messages", joinColumns = @JoinColumn(name = "action_status_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_stat_msg_act_stat") ) , indexes = { @Index(name = "sp_idx_action_status_msgs_01", columnList = "action_status_id") }) @Column(name = "detail_message", length = 512) - private final List messages = new ArrayList(); + private final List messages = new ArrayList<>(); /** * Creates a new {@link ActionStatus} object. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java index 08e4fcecb..bb7781733 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java @@ -87,7 +87,7 @@ public class Target extends NamedEntity implements Persistable { @JoinTable(name = "sp_target_target_tag", joinColumns = { @JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target") ) }, inverseJoinColumns = { @JoinColumn(name = "tag", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag") ) }) - private Set tags = new HashSet(); + private Set tags = new HashSet<>(); @CascadeOnDelete @OneToMany(fetch = FetchType.LAZY, orphanRemoval = true, cascade = { CascadeType.REMOVE }) diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java index 92923cb56..b32302705 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java @@ -88,7 +88,7 @@ final class DistributionSetTypeMapper { } static List toListResponse(final List types) { - final List response = new ArrayList(); + final List response = new ArrayList<>(); for (final DistributionSetType dsType : types) { response.add(toResponse(dsType)); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java index 5a05133b2..bd2c5f1c1 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java @@ -59,7 +59,7 @@ final class SoftwareModuleTypeMapper { } static List toListResponse(final Collection types) { - final List response = new ArrayList(); + final List response = new ArrayList<>(); for (final SoftwareModuleType softwareModule : types) { response.add(toResponse(softwareModule)); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java index d0ba20db6..1bc9da65c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java @@ -208,14 +208,13 @@ public class ArtifactDetailsLayout extends VerticalLayout { } private Container createArtifactLazyQueryContainer() { - final Map queryConfiguration = new HashMap(); + final Map queryConfiguration = new HashMap<>(); return getArtifactLazyQueryContainer(queryConfiguration); } private LazyQueryContainer getArtifactLazyQueryContainer(final Map queryConfig) { - final BeanQueryFactory artifactQF = new BeanQueryFactory( - ArtifactBeanQuery.class); + final BeanQueryFactory artifactQF = new BeanQueryFactory<>(ArtifactBeanQuery.class); artifactQF.setQueryConfiguration(queryConfig); final LazyQueryContainer artifactCont = new LazyQueryContainer(new LazyQueryDefinition(true, 10, "id"), artifactQF); @@ -431,7 +430,7 @@ public class ArtifactDetailsLayout extends VerticalLayout { titleOfArtifactDetails.setContentMode(ContentMode.HTML); } } - final Map queryConfiguration = new HashMap(); + final Map queryConfiguration = new HashMap<>(); if (baseSwModuleId != null) { queryConfiguration.put(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE, baseSwModuleId); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java index a4ae322fa..a3f045a08 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java @@ -47,12 +47,6 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria { @Autowired private transient EventBus.SessionEventBus eventBus; - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.AbstractAcceptCriteria#analyseDragComponent - * (com.vaadin.event .dd.DragAndDropEvent, com.vaadin.ui.Component) - */ @Override protected void analyseDragComponent(final Component compsource) { final String sourceID = getComponentId(compsource); @@ -60,24 +54,11 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria { eventBus.publish(this, event); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria#hideDropHints - * () - */ @Override protected void hideDropHints() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria#invalidDrop() - */ @Override protected void invalidDrop() { uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED); @@ -92,41 +73,23 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria { return id; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * getDropHintConfigurations() - */ @Override protected Map getDropHintConfigurations() { return DROP_HINTS_CONFIGS; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * publishDragStartEvent(java.lang.Object) - */ @Override protected void publishDragStartEvent(final Object event) { eventBus.publish(this, event); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * getDropConfigurations() - */ @Override protected Map> getDropConfigurations() { return DROP_CONFIGS; } private static Map> createDropConfigurations() { - final Map> config = new HashMap>(); + final Map> config = new HashMap<>(); // Delete drop area droppable components config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID, Arrays.asList( SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)); @@ -135,7 +98,7 @@ public class UploadViewAcceptCriteria extends AbstractAcceptCriteria { } private static Map createDropHintConfigurations() { - final Map config = new HashMap(); + final Map config = new HashMap<>(); config.put(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, UploadArtifactUIEvent.SOFTWARE_TYPE_DRAG_START); config.put(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, UploadArtifactUIEvent.SOFTWARE_DRAG_START); return config; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java index 04339c1a6..bb48c515a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java @@ -32,10 +32,6 @@ import com.google.common.base.Strings; * Simple implementation of generics bean query which dynamically loads a batch * of beans. * - * - * - * - * */ public class BaseSwModuleBeanQuery extends AbstractBeanQuery { private static final long serialVersionUID = 4362142538539335466L; @@ -76,7 +72,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery loadBeans(final int startIndex, final int count) { final Slice swModuleBeans; - final List proxyBeans = new ArrayList(); + final List proxyBeans = new ArrayList<>(); if (type == null && Strings.isNullOrEmpty(searchText)) { swModuleBeans = getSoftwareManagementService() diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java index f1e302fdc..aea80476a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -55,8 +55,6 @@ import com.vaadin.ui.UI; /** * Header of Software module table. * - * - * */ @SpringComponent @ViewScope @@ -78,11 +76,11 @@ public class SoftwareModuleTable extends AbstractTable { @Autowired private UploadViewAcceptCriteria uploadViewAcceptCriteria; - - + /** * Initialize the filter layout. */ + @Override @PostConstruct protected void init() { super.init(); @@ -111,36 +109,23 @@ public class SoftwareModuleTable extends AbstractTable { }); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableId() - */ @Override protected String getTableId() { return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#createContainer() - */ @Override protected Container createContainer() { final Map queryConfiguration = prepareQueryConfigFilters(); - final BeanQueryFactory swQF = new BeanQueryFactory( - BaseSwModuleBeanQuery.class); + final BeanQueryFactory swQF = new BeanQueryFactory<>(BaseSwModuleBeanQuery.class); swQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer container = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); - return container; + return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); } - + private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); + final Map queryConfig = new HashMap<>(); artifactUploadState.getSoftwareModuleFilters().getSearchText() .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); @@ -149,8 +134,6 @@ public class SoftwareModuleTable extends AbstractTable { return queryConfig; } - - @Override protected void addContainerProperties(final Container container) { @@ -274,16 +257,9 @@ public class SoftwareModuleTable extends AbstractTable { select(swModule.getId()); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableVisibleColumns - * () - */ @Override protected List getTableVisibleColumns() { - final List columnList = new ArrayList(); + final List columnList = new ArrayList<>(); if (isMaximized()) { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1F)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index 824faa83b..b79b53ae0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -193,7 +193,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C getPreviewButtonColor(DEFAULT_COLOR); tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE); - selectors = new HashSet(); + selectors = new HashSet<>(); selectedColor = new Color(44, 151, 32); selPreview = new SpColorPickerPreview(selectedColor); @@ -741,38 +741,17 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C return null; } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.components.colorpicker.HasColorChangeListener# - * addColorChangeListener(com.vaadin - * .ui.components.colorpicker.ColorChangeListener) - */ @Override public void addColorChangeListener(final ColorChangeListener listener) { LOG.debug("inside addColorChangeListener"); } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.components.colorpicker.HasColorChangeListener# - * removeColorChangeListener(com. - * vaadin.ui.components.colorpicker.ColorChangeListener) - */ @Override public void removeColorChangeListener(final ColorChangeListener listener) { LOG.debug("inside removeColorChangeListener"); } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.ui.components.colorpicker.ColorSelector#setColor(com.vaadin. - * shared.ui.colorpicker .Color) - */ @Override public void setColor(final Color color) { if (color == null) { @@ -788,23 +767,11 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.components.colorpicker.ColorSelector#getColor() - */ @Override public Color getColor() { return null; } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.ui.components.colorpicker.ColorChangeListener#colorChanged(com - * .vaadin.ui.components .colorpicker.ColorChangeEvent) - */ @Override public void colorChanged(final ColorChangeEvent event) { setColor(event.getColor()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java index 51ac43ba5..f009985f9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java @@ -56,11 +56,7 @@ import com.vaadin.ui.themes.ValoTheme; /** * Artifact upload confirmation popup. - * - * - * - * - * + * */ public class UploadConfirmationwindow implements Button.ClickListener { @@ -106,7 +102,7 @@ public class UploadConfirmationwindow implements Button.ClickListener { private IndexedContainer tabelContainer; - private final List uploadResultList = new ArrayList(); + private final List uploadResultList = new ArrayList<>(); private VerticalLayout uploadArtifactDetails; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index e570c84c4..c12c72dd8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -69,8 +69,6 @@ import com.vaadin.ui.VerticalLayout; /** * Upload files layout. - * - * */ @ViewScope @SpringComponent @@ -102,7 +100,7 @@ public class UploadLayout extends VerticalLayout { private final AtomicInteger numberOfFilesActuallyUpload = new AtomicInteger(); - private final List duplicateFileNamesList = new ArrayList(); + private final List duplicateFileNamesList = new ArrayList<>(); private Button processBtn; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java index a4470b8e1..c5319a221 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java @@ -44,7 +44,7 @@ public class UploadResultWindow implements Button.ClickListener { private static final long serialVersionUID = 5205927189362269027L; - private List uploadResultList = new ArrayList(); + private List uploadResultList = new ArrayList<>(); private Button closeBtn; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java index 787e51d83..b09255bc7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java @@ -83,7 +83,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery loadBeans(final int startIndex, final int count) { Page typeBeans; - final List distSetTypeList = new ArrayList(); + final List distSetTypeList = new ArrayList<>(); if (startIndex == 0 && firstPageDistSetType != null) { typeBeans = firstPageDistSetType; } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java index ebcd097c3..af02169f0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java @@ -45,8 +45,6 @@ import com.vaadin.ui.UI; /** * Implementation of target/ds tag token layout. - * - * * */ @SpringComponent @@ -80,6 +78,7 @@ public class DistributionTagToken extends AbstractTagToken { // To Be Done : have to set this value based on view??? private static final Boolean NOTAGS_SELECTED = Boolean.FALSE; + @Override @PostConstruct protected void init() { super.init(); @@ -129,7 +128,7 @@ public class DistributionTagToken extends AbstractTagToken { } private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) { - final Set distributionList = new HashSet(); + final Set distributionList = new HashSet<>(); distributionList.add(selectedDS.getId()); final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList, tagNameSelected); @@ -137,12 +136,6 @@ public class DistributionTagToken extends AbstractTagToken { return result; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.tagDetails.AbstractTagToken#unassignTag( - * java.lang.String) - */ @Override protected void unassignTag(final String tagName) { final DistributionSetTagAssigmentResult result = toggleAssignment(tagName); @@ -160,26 +153,14 @@ public class DistributionTagToken extends AbstractTagToken { /* To Be Done : this implementation will vary in views */ private List getClickedTagList() { - return new ArrayList(); + return new ArrayList<>(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.tagDetails.AbstractTagToken# - * hasUpdatePermission() - */ @Override protected Boolean isToggleTagAssignmentAllowed() { return spChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.tagDetails.AbstractTagToken# - * displayAlreadyAssignedTags() - */ @Override public void displayAlreadyAssignedTags() { removePreviouslyAddedTokens(); @@ -190,12 +171,6 @@ public class DistributionTagToken extends AbstractTagToken { } } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.tagDetails.AbstractTagToken# - * populateContainer() - */ @Override protected void populateContainer() { container.removeAllItems(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index 3cd1764e3..ff52208c6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -79,8 +79,6 @@ import com.vaadin.ui.themes.ValoTheme; /** * Window for create update Distribution Set Type. - * - * */ @SpringComponent @ViewScope @@ -221,7 +219,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co getPreviewButtonColor(DEFAULT_COLOR); - selectors = new HashSet(); + selectors = new HashSet<>(); selectedColor = new Color(44, 151, 32); selPreview = new SpColorPickerPreview(selectedColor); @@ -457,6 +455,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co sourceTable.setItemDescriptionGenerator(new ItemDescriptionGenerator() { private static final long serialVersionUID = 1L; + @Override public String generateDescription(final Component source, final Object itemId, final Object propertyId) { final Item item = sourceTable.getItem(itemId); final String description = (String) item.getItemProperty(DIST_TYPE_DESCRIPTION).getValue(); @@ -657,10 +656,10 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co DistributionSetType newDistType = new DistributionSetType(typeKeyValue, typeNameValue, typeDescValue); for (final Long id : itemIds) { final Item item = selectedTable.getItem(id); - final String dist_type_name = (String) item.getItemProperty(DIST_TYPE_NAME).getValue(); + final String distTypeName = (String) item.getItemProperty(DIST_TYPE_NAME).getValue(); final CheckBox mandatoryCheckBox = (CheckBox) item.getItemProperty(DIST_TYPE_MANDATORY).getValue(); final Boolean isMandatory = mandatoryCheckBox.getValue(); - final SoftwareModuleType swModuleType = softwareManagement.findSoftwareModuleTypeByName(dist_type_name); + final SoftwareModuleType swModuleType = softwareManagement.findSoftwareModuleTypeByName(distTypeName); if (isMandatory) { newDistType.addMandatoryModuleType(swModuleType); @@ -1032,7 +1031,6 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co * as the selected tag from combo */ private void setTypeTagCombo(final String distSetTypeSelected) { - boolean mandatory = false; typeName.setValue(distSetTypeSelected); getSourceTableData(); selectedTable.getContainerDataSource().removeAllItems(); @@ -1053,13 +1051,11 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co saveDistSetType.setEnabled(false); } for (final SoftwareModuleType swModuleType : selectedTypeTag.getOptionalModuleTypes()) { - mandatory = false; - addTargetTableforUpdate(swModuleType, mandatory); + addTargetTableforUpdate(swModuleType, false); } for (final SoftwareModuleType swModuleType : selectedTypeTag.getMandatoryModuleTypes()) { - mandatory = true; - addTargetTableforUpdate(swModuleType, mandatory); + addTargetTableforUpdate(swModuleType, true); } if (null == selectedTypeTag.getColour()) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java index 32223e995..8d22f6782 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -74,8 +74,6 @@ import com.vaadin.ui.UI; /** * Distribution set table. * - * - * */ @SpringComponent @ViewScope @@ -114,7 +112,7 @@ public class DistributionSetTable extends AbstractTable { @Autowired private transient TargetManagement targetManagement; - + /** * Initialize the component. */ @@ -136,24 +134,11 @@ public class DistributionSetTable extends AbstractTable { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.AbstractTable#getTableId() - */ @Override protected String getTableId() { return SPUIComponetIdProvider.DIST_TABLE_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.AbstractTable#createContainer( - * ) - */ @Override protected Container createContainer() { @@ -165,9 +150,9 @@ public class DistributionSetTable extends AbstractTable { new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); } - + private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); + final Map queryConfig = new HashMap<>(); manageDistUIState.getManageDistFilters().getSearchText() .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); @@ -178,14 +163,7 @@ public class DistributionSetTable extends AbstractTable { return queryConfig; } - - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#addContainerProperties - * (com.vaadin.data.Container ) - */ @Override protected void addContainerProperties(final Container container) { HawkbitCommonUtil.getDsTableColumnProperties(container); @@ -193,12 +171,6 @@ public class DistributionSetTable extends AbstractTable { Boolean.class, null, false, true); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable# - * addCustomGeneratedColumns () - */ @Override protected void addCustomGeneratedColumns() { /** @@ -206,23 +178,12 @@ public class DistributionSetTable extends AbstractTable { */ } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable# - * isFirstRowSelectedOnLoad () - */ @Override protected boolean isFirstRowSelectedOnLoad() { return !manageDistUIState.getSelectedDistributions().isPresent() || manageDistUIState.getSelectedDistributions().get().isEmpty(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#getItemIdToSelect() - */ @Override protected Object getItemIdToSelect() { if (manageDistUIState.getSelectedDistributions().isPresent()) { @@ -231,12 +192,6 @@ public class DistributionSetTable extends AbstractTable { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.AbstractTable#onValueChange() - */ @Override protected void onValueChange() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); @@ -271,33 +226,16 @@ public class DistributionSetTable extends AbstractTable { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.AbstractTable#isMaximized() - */ @Override protected boolean isMaximized() { return manageDistUIState.isDsTableMaximized(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#getTableVisibleColumns - * () - */ @Override protected List getTableVisibleColumns() { return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), false, i18n); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#getTableDropHandler() - */ @Override protected DropHandler getTableDropHandler() { return new DropHandler() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java index 7c0d367f8..60b547285 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java @@ -37,8 +37,6 @@ import com.google.common.base.Strings; /** * Manage Distributions table bean query. * - * - * */ public class ManageDistBeanQuery extends AbstractBeanQuery { @@ -83,28 +81,15 @@ public class ManageDistBeanQuery extends AbstractBeanQuery { } } - /* - * (non-Javadoc) - * - * @see - * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#constructBean() - */ @Override protected ProxyDistribution constructBean() { return new ProxyDistribution(); } - /* - * (non-Javadoc) - * - * @see - * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int, - * int) - */ @Override protected List loadBeans(final int startIndex, final int count) { Page distBeans; - final List proxyDistributions = new ArrayList(); + final List proxyDistributions = new ArrayList<>(); if (startIndex == 0 && firstPageDistributionSets != null) { distBeans = firstPageDistributionSets; } else if (Strings.isNullOrEmpty(searchText)) { @@ -136,24 +121,12 @@ public class ManageDistBeanQuery extends AbstractBeanQuery { return proxyDistributions; } - /* - * (non-Javadoc) - * - * @see - * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java. - * util.List, java.util.List, java.util.List) - */ @Override protected void saveBeans(final List arg0, final List arg1, final List arg2) { // Add,Delete and Update are performed through repository methods } - /* - * (non-Javadoc) - * - * @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size() - */ @Override public int size() { if (Strings.isNullOrEmpty(searchText) && null == distributionSetType) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java index 6a8296c0f..5b79b96f4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java @@ -28,8 +28,6 @@ import com.vaadin.ui.Component; /** * Distributions View for Accept criteria. * - * - * */ @SpringComponent @ViewScope @@ -47,12 +45,6 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria { @Autowired private transient EventBus.SessionEventBus eventBus; - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.AbstractAcceptCriteria#analyseDragComponent - * (com.vaadin.event .dd.DragAndDropEvent, com.vaadin.ui.Component) - */ @Override protected void analyseDragComponent(final Component compsource) { final String sourceID = getComponentId(compsource); @@ -60,24 +52,11 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria { eventBus.publish(this, event); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria#hideDropHints - * () - */ @Override protected void hideDropHints() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria#invalidDrop() - */ @Override protected void invalidDrop() { uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED); @@ -94,34 +73,16 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria { return id; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * getDropHintConfigurations() - */ @Override protected Map getDropHintConfigurations() { return DROP_HINTS_CONFIGS; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * publishDragStartEvent(java.lang.Object) - */ @Override protected void publishDragStartEvent(final Object event) { eventBus.publish(this, event); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * getDropConfigurations() - */ @Override protected Map> getDropConfigurations() { return DROP_CONFIGS; @@ -137,7 +98,7 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria { } private static Map> createDropConfigurations() { - final Map> config = new HashMap>(); + final Map> config = new HashMap<>(); // Delete drop area droppable components config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID, @@ -153,7 +114,7 @@ public class DistributionsViewAcceptCriteria extends AbstractAcceptCriteria { } private static Map createDropHintConfigurations() { - final Map config = new HashMap(); + final Map config = new HashMap<>(); config.put(SPUIDefinitions.DISTRIBUTION_TYPE_ID_PREFIXS, DragEvent.DISTRIBUTION_TYPE_DRAG); config.put(SPUIComponetIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG); config.put(SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE, DragEvent.SOFTWAREMODULE_DRAG); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java index 1581bfadd..859febbce 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java @@ -32,9 +32,6 @@ import com.google.common.base.Strings; /** * Simple implementation of generics bean query which dynamically loads a batch * of beans. - * - * - * * */ public class SwModuleBeanQuery extends AbstractBeanQuery { @@ -77,17 +74,10 @@ public class SwModuleBeanQuery extends AbstractBeanQuery return new ProxyBaseSwModuleItem(); } - /* - * (non-Javadoc) - * - * @see - * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int, - * int) - */ @Override protected List loadBeans(final int startIndex, final int count) { final Slice swModuleBeans; - final List proxyBeans = new ArrayList(); + final List proxyBeans = new ArrayList<>(); swModuleBeans = getSoftwareManagement().findSoftwareModuleOrderByDistribution( new OffsetBasedPageRequest(startIndex, count, new Sort(Direction.ASC, "name", "version")), diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java index 90d6a74df..9218198b9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -67,8 +67,6 @@ import com.vaadin.ui.Window; /** * Implementation of software module table using generic abstract table styles . - * - * * */ @SpringComponent @@ -94,10 +92,11 @@ public class SwModuleTable extends AbstractTable { @Autowired private ArtifactDetailsLayout artifactDetailsLayout; - - /** + + /** * Initialize the filter layout. */ + @Override @PostConstruct protected void init() { super.init(); @@ -158,56 +157,35 @@ public class SwModuleTable extends AbstractTable { } } - /* All Override methods */ - - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableId() - */ @Override protected String getTableId() { return SPUIComponetIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#createContainer() - */ @Override protected Container createContainer() { final Map queryConfiguration = prepareQueryConfigFilters(); - final BeanQueryFactory swQF = new BeanQueryFactory( - SwModuleBeanQuery.class); + final BeanQueryFactory swQF = new BeanQueryFactory<>(SwModuleBeanQuery.class); swQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer container = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); - return container; + return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); } - + private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); + final Map queryConfig = new HashMap<>(); manageDistUIState.getSoftwareModuleFilters().getSearchText() .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType() .ifPresent(type -> queryConfig.put(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE, type)); - manageDistUIState.getLastSelectedDistribution().ifPresent( - distIdName -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, distIdName.getId())); + manageDistUIState.getLastSelectedDistribution() + .ifPresent(distIdName -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, distIdName.getId())); return queryConfig; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTable#addContainerProperties(com. - * vaadin.data.Container) - */ @Override protected void addContainerProperties(final Container container) { final LazyQueryContainer lazyContainer = (LazyQueryContainer) container; @@ -226,11 +204,6 @@ public class SwModuleTable extends AbstractTable { lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_SOFT_TYPE_ID, Long.class, null, false, true); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTable#addCustomGeneratedColumns() - */ @Override protected void addCustomGeneratedColumns() { @@ -249,32 +222,16 @@ public class SwModuleTable extends AbstractTable { }); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTable#isFirstRowSelectedOnLoad() - */ @Override protected boolean isFirstRowSelectedOnLoad() { return manageDistUIState.getSelectedSoftwareModules().isEmpty(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTable#getItemIdToSelect() - */ @Override protected Object getItemIdToSelect() { return manageDistUIState.getSelectedSoftwareModules(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#isMaximized() - */ @Override protected boolean isMaximized() { return manageDistUIState.isSwModuleTableMaximized(); @@ -306,16 +263,9 @@ public class SwModuleTable extends AbstractTable { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableVisibleColumns - * () - */ @Override protected List getTableVisibleColumns() { - final List columnList = new ArrayList(); + final List columnList = new ArrayList<>(); if (isMaximized()) { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1F)); @@ -370,11 +320,6 @@ public class SwModuleTable extends AbstractTable { } - /** - * @param color - * @param isAssigned - * @return - */ private String getTableStyle(final Long typeId, final boolean isAssigned, final String color) { if (isAssigned) { addTypeStyle(typeId, color); @@ -391,11 +336,6 @@ public class SwModuleTable extends AbstractTable { + "{background-color:" + color + " !important;background-image:none !important }"))); } - /** - * @param itemId - * @param propertyId - * @return - */ private String createTableStyle(final Object itemId, final Object propertyId) { if (null == propertyId) { final Item item = getItem(itemId); @@ -429,12 +369,6 @@ public class SwModuleTable extends AbstractTable { return name + "." + version; } - /** - * Add new software module to table. - * - * @param swModule - * new software module - */ @SuppressWarnings("unchecked") private void addSoftwareModule(final SoftwareModule swModule) { final Object addItem = addItem(); @@ -461,11 +395,6 @@ public class SwModuleTable extends AbstractTable { select(swModule.getId()); } - /** - * @param itemId - * @param nameVersionStr - * @return - */ private void showArtifactDetailsWindow(final Long itemId, final String nameVersionStr) { final Window atrifactDtlsWindow = new Window(); atrifactDtlsWindow.setCaption(HawkbitCommonUtil.getArtifactoryDetailsLabelId(nameVersionStr)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java index 18fafad2d..53d6555da 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java @@ -40,8 +40,6 @@ import com.vaadin.spring.annotation.ViewScope; /** * Software Module Type filter buttons. * - * - * */ @SpringComponent @ViewScope @@ -64,40 +62,25 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { * @param filterButtonClickBehaviour * the clickable behaviour. */ + @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); eventBus.subscribe(this); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButtonsTableId() - */ @Override protected String getButtonsTableId() { return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonsLazyQueryContainer () - */ @Override protected LazyQueryContainer createButtonsLazyQueryContainer() { - final Map queryConfig = new HashMap(); - final BeanQueryFactory typeQF = new BeanQueryFactory( + final Map queryConfig = new HashMap<>(); + final BeanQueryFactory typeQF = new BeanQueryFactory<>( SoftwareModuleTypeBeanQuery.class); typeQF.setQueryConfiguration(queryConfig); - final LazyQueryContainer lazyQueryContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), typeQF); - return lazyQueryContainer; + return new LazyQueryContainer(new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), typeQF); } @Override @@ -105,13 +88,6 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * isClickedByDefault(java.lang .Long) - */ @Override protected boolean isClickedByDefault(final Long buttonId) { @@ -119,25 +95,11 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { && manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getId().equals(buttonId); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonId(java.lang. String) - */ @Override protected String createButtonId(final String name) { return SPUIComponetIdProvider.SM_TYPE_FILTER_BTN_ID + name; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getFilterButtonDropHandler() - */ @Override protected DropHandler getFilterButtonDropHandler() { @@ -156,13 +118,6 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { }; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButttonWrapperId() - */ @Override protected String getButttonWrapperIdPrefix() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java index 7dbfafa7d..c63393fac 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java @@ -20,8 +20,6 @@ import com.vaadin.spring.annotation.VaadinSessionScope; /** * Distribution table filter state. - * - * */ @SpringComponent @VaadinSessionScope @@ -31,9 +29,9 @@ public class ManageDistFilters implements Serializable { private String searchText; - private List distSetTags = new ArrayList(); + private List distSetTags = new ArrayList<>(); - private List clickedDistSetTags = new ArrayList(); + private List clickedDistSetTags = new ArrayList<>(); private DistributionSetType clickedDistSetType; @@ -61,17 +59,10 @@ public class ManageDistFilters implements Serializable { this.clickedDistSetTags = clickedDistSetTags; } - /** - * @return the searchText - */ public Optional getSearchText() { return searchText == null ? Optional.empty() : Optional.of(searchText); } - /** - * @param searchText - * the searchText to set - */ public void setSearchText(final String searchText) { this.searchText = searchText; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java index 7dbe3467e..9c50640cd 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java @@ -34,7 +34,6 @@ import com.google.common.base.Strings; * * */ - public class TargetFilterBeanQuery extends AbstractBeanQuery { private static final long serialVersionUID = 1845964596238990987L; @@ -76,8 +75,8 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery @Override protected List loadBeans(final int startIndex, final int count) { - Slice targetFilterQuery = null; - final List proxyTargetFilter = new ArrayList(); + Slice targetFilterQuery; + final List proxyTargetFilter = new ArrayList<>(); if (startIndex == 0 && firstPageTargetFilter != null) { targetFilterQuery = firstPageTargetFilter; } else if (Strings.isNullOrEmpty(searchText)) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java index a251521f5..17bfefe56 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java @@ -41,7 +41,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.server.FontAwesome; -import com.vaadin.server.Sizeable.Unit; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Button; @@ -84,20 +83,20 @@ public class TargetFilterTable extends Table { * Initialize the Action History Table. */ @PostConstruct - public void init() { - setStyleName("sp-table"); - setSizeFull(); - setImmediate(true); - setHeight(100.0f, Unit.PERCENTAGE); - addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); - addStyleName(ValoTheme.TABLE_SMALL); - addCustomGeneratedColumns(); - populateTableData(); - setColumnCollapsingAllowed(true); - setColumnProperties(); - setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID); - eventBus.subscribe(this); - } + public void init() { + setStyleName("sp-table"); + setSizeFull(); + setImmediate(true); + setHeight(100.0f, Unit.PERCENTAGE); + addStyleName(ValoTheme.TABLE_NO_VERTICAL_LINES); + addStyleName(ValoTheme.TABLE_SMALL); + addCustomGeneratedColumns(); + populateTableData(); + setColumnCollapsingAllowed(true); + setColumnProperties(); + setId(SPUIComponetIdProvider.TAEGET_FILTER_TABLE_ID); + eventBus.subscribe(this); + } @PreDestroy void destroy() { @@ -114,20 +113,14 @@ public class TargetFilterTable extends Table { } } - /** - * Create a empty HierarchicalContainer. - * - * - */ private Container createContainer() { final Map queryConfig = prepareQueryConfigFilters(); - final BeanQueryFactory targetQF = new BeanQueryFactory( - TargetFilterBeanQuery.class); + final BeanQueryFactory targetQF = new BeanQueryFactory<>(TargetFilterBeanQuery.class); targetQF.setQueryConfiguration(queryConfig); // create lazy query container with lazy defination and query - final LazyQueryContainer targetFilterContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF); + final LazyQueryContainer targetFilterContainer = new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), targetQF); targetFilterContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT); return targetFilterContainer; @@ -135,15 +128,12 @@ public class TargetFilterTable extends Table { } private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); - filterManagementUIState.getCustomFilterSearchText().ifPresent( - value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + final Map queryConfig = new HashMap<>(); + filterManagementUIState.getCustomFilterSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); return queryConfig; } - /** - * Create a empty HierarchicalContainer. - */ private void addContainerproperties() { /* Create HierarchicalContainer container */ container.addContainerProperty(SPUILabelDefinitions.NAME, Link.class, null); @@ -154,7 +144,7 @@ public class TargetFilterTable extends Table { } private List getVisbleColumns() { - final List columnList = new ArrayList(); + final List columnList = new ArrayList<>(); columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.2F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_USER, i18n.get("header.createdBy"), 0.15F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.2F)); @@ -165,7 +155,6 @@ public class TargetFilterTable extends Table { } - /* re -create the container and get the data and set it to the table */ private void refreshContainer() { populateTableData(); @@ -187,10 +176,6 @@ public class TargetFilterTable extends Table { .toString(); } - /** - * @param event - * @return - */ private void onDelete(final ClickEvent event) { /* Display the confirmation */ final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.filter.delete.confirmbox"), @@ -206,8 +191,8 @@ public class TargetFilterTable extends Table { * of the deleted custom filter. */ - notification.displaySuccess(i18n.get("message.delete.filter.success", - new Object[] { deletedFilterName })); + notification.displaySuccess( + i18n.get("message.delete.filter.success", new Object[] { deletedFilterName })); refreshContainer(); } }); @@ -236,10 +221,6 @@ public class TargetFilterTable extends Table { return updateIcon; } - /** - * @param event - * @return - */ private void onClickOfDetailButton(final ClickEvent event) { final String targetFilterName = (String) ((Button) event.getComponent()).getData(); final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java index e3b84aac6..df9d8a60d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -202,16 +202,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { hierarchicalContainer.addContainerProperty(SPUIDefinitions.ACTION_HIS_TBL_ROLLOUT_NAME, String.class, null); } - /** - * Get Action based on status. - * - * @param type - * as Action.Type - * - * @return List of Actions - */ private List getVisbleColumns() { - final List visibleColumnIds = new ArrayList(); + final List visibleColumnIds = new ArrayList<>(); visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE); visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_DIST); visibleColumnIds.add(SPUIDefinitions.ACTION_HIS_TBL_DATETIME); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java index f3b68bce6..7b49ddcb2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java @@ -96,7 +96,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery @Override protected List loadBeans(final int startIndex, final int count) { Page distBeans; - final List proxyDistributions = new ArrayList(); + final List proxyDistributions = new ArrayList<>(); if (startIndex == 0 && firstPageDistributionSets != null) { distBeans = firstPageDistributionSets; } else if (pinnedControllerId != null) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index 53e723c7d..00be91ca4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -73,8 +73,6 @@ import com.vaadin.ui.UI; /** * Distribution set table. - * - * * */ @SpringComponent @@ -112,11 +110,11 @@ public class DistributionTable extends AbstractTable { private Boolean isDistPinned = false; private Button distributinPinnedBtn; - - + /** * Initialize the distribution table. */ + @Override @PostConstruct protected void init() { super.init(); @@ -142,7 +140,7 @@ public class DistributionTable extends AbstractTable { || event == DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT || event == DistributionTableFilterEvent.FILTER_BY_TAG) { UI.getCurrent().access(() -> refreshFilter()); - } + } } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -221,23 +219,22 @@ public class DistributionTable extends AbstractTable { @Override protected Container createContainer() { final Map queryConfiguration = prepareQueryConfigFilters(); - - final BeanQueryFactory distributionQF = new BeanQueryFactory( + + final BeanQueryFactory distributionQF = new BeanQueryFactory<>( DistributionBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer distributionContainer = new LazyQueryContainer( + return new LazyQueryContainer( new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); - return distributionContainer; } - + private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); - managementUIState.getDistributionTableFilters().getSearchText() + final Map queryConfig = new HashMap<>(); + managementUIState.getDistributionTableFilters().getSearchText() .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); - managementUIState.getDistributionTableFilters().getPinnedTargetId() + managementUIState.getDistributionTableFilters().getPinnedTargetId() .ifPresent(value -> queryConfig.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value)); - final List list = new ArrayList(); + final List list = new ArrayList<>(); queryConfig.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getDistributionTableFilters().isNoTagSelected()); if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) { @@ -247,23 +244,11 @@ public class DistributionTable extends AbstractTable { return queryConfig; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#addContainerProperties( - * com.vaadin.data.Container ) - */ @Override protected void addContainerProperties(final Container container) { HawkbitCommonUtil.getDsTableColumnProperties(container); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable# - * addCustomGeneratedColumns() - */ @Override protected void addCustomGeneratedColumns() { addGeneratedColumn(SPUILabelDefinitions.PIN_COLUMN, new Table.ColumnGenerator() { @@ -276,23 +261,12 @@ public class DistributionTable extends AbstractTable { }); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTable# - * isFirstRowSelectedOnLoad() - */ @Override protected boolean isFirstRowSelectedOnLoad() { return !managementUIState.getSelectedDsIdName().isPresent() || managementUIState.getSelectedDsIdName().get().isEmpty(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#getItemIdToSelect() - */ @Override protected Object getItemIdToSelect() { if (managementUIState.getSelectedDsIdName().isPresent()) { @@ -301,16 +275,9 @@ public class DistributionTable extends AbstractTable { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.AbstractTable#onValueChange() - */ @Override protected void onValueChange() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); - @SuppressWarnings("unchecked") final Set values = HawkbitCommonUtil.getSelectedDSDetails(this); DistributionSetIdName value = null; if (values != null && !values.isEmpty()) { @@ -319,10 +286,7 @@ public class DistributionTable extends AbstractTable { while (iterator.hasNext()) { value = iterator.next(); } - /** - * Adding null check to make to avoid NPE.Its weird that at times - * getValue returns null. - */ + if (null != value) { managementUIState.setSelectedDsIdName(values); managementUIState.setLastSelectedDsIdName(value); @@ -339,33 +303,16 @@ public class DistributionTable extends AbstractTable { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.AbstractTable#isMaximized() - */ @Override protected boolean isMaximized() { return managementUIState.isDsTableMaximized(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#getTableVisibleColumns( - * ) - */ @Override protected List getTableVisibleColumns() { return HawkbitCommonUtil.getTableVisibleColumns(isMaximized(), true, i18n); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTable#getTableDropHandler() - */ @Override protected DropHandler getTableDropHandler() { return new DropHandler() { @@ -403,7 +350,7 @@ public class DistributionTable extends AbstractTable { final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails(); final Table distTable = (Table) taregtDet.getTarget(); final Set distsSelected = HawkbitCommonUtil.getSelectedDSDetails(distTable); - final Set distList = new HashSet(); + final Set distList = new HashSet<>(); final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object distItemId = dropData.getItemIdOver(); @@ -435,7 +382,7 @@ public class DistributionTable extends AbstractTable { // assign dist to those targets final List assignedTargets = targetService.findTargetsByTag(targetTagName); if (!assignedTargets.isEmpty()) { - final Set targetDetailsList = new HashSet(); + final Set targetDetailsList = new HashSet<>(); assignedTargets.forEach(target -> targetDetailsList .add(new TargetIdName(target.getId(), target.getControllerId(), target.getName()))); assignTargetToDs(getItem(distItemId), targetDetailsList); @@ -448,7 +395,7 @@ public class DistributionTable extends AbstractTable { final TableTransferable transferable = (TableTransferable) event.getTransferable(); final Table source = transferable.getSourceComponent(); final Set targetsSelected = HawkbitCommonUtil.getSelectedTargetDetails(source); - final Set targetDetailsList = new HashSet(); + final Set targetDetailsList = new HashSet<>(); if (!targetsSelected.contains(transferable.getData("itemId"))) { targetDetailsList.add((TargetIdName) transferable.getData("itemId")); @@ -474,13 +421,6 @@ public class DistributionTable extends AbstractTable { } } - /** - * Validate event. - * - * @param dragEvent - * as event - * @return boolean as flag - */ private Boolean doValidation(final DragAndDropEvent dragEvent) { final Component compsource = dragEvent.getTransferable().getSourceComponent(); if (compsource instanceof Table) { @@ -528,15 +468,6 @@ public class DistributionTable extends AbstractTable { return false; } - /** - * Validate the assignment. - * - * @param targetDetailsList - * @param source - * @param distId - * @param distName - * @return String as indicator - */ private String validate(final Set targetDetailsList, final DistributionSetIdName distributionSetIdName) { String pendingActionMessage = null; @@ -555,17 +486,6 @@ public class DistributionTable extends AbstractTable { return pendingActionMessage; } - /** - * Message for Pending Action. - * - * @param message - * as msg - * @param targId - * as ID - * @param distName - * as Dist Set Name - * @return String as message - */ private String getPendingActionMessage(final String message, final String targId, final String distNameVersion) { String pendActionMsg = i18n.get("message.target.assigned.pending"); if (null == message) { @@ -574,12 +494,6 @@ public class DistributionTable extends AbstractTable { return pendActionMsg; } - /** - * Show or Hide Popup Notification Message. - * - * @param message - * as msg - */ private void showOrHidePopupAndNotification(final String message) { if (null != managementUIState.getAssignedList() && !managementUIState.getAssignedList().isEmpty()) { eventBus.publish(this, ManagementUIEvent.UPDATE_COUNT); @@ -636,19 +550,6 @@ public class DistributionTable extends AbstractTable { } } - /** - * Added by Saumya Get Pin style. - * - * @param itemId - * as item clicked - * @param propertyId - * as property - * @param installedDistItemIds - * as set - * @param assignedDistTableItemIds - * as set - * @return String as Style - */ private String getPinnedDistributionStyle(final Long installedDistItemIds, final Long assignedDistTableItemIds, final Object itemId) { final Long distId = ((DistributionSetIdName) itemId).getId(); @@ -662,10 +563,6 @@ public class DistributionTable extends AbstractTable { } } - /** - * @param itemId - * @return - */ private Object getPinButton(final Object itemId) { final DistributionSetIdName dist = (DistributionSetIdName) getContainerDataSource().getItem(itemId) .getItemProperty(SPUILabelDefinitions.VAR_DIST_ID_NAME).getValue(); @@ -684,12 +581,6 @@ public class DistributionTable extends AbstractTable { } } - /** - * Add listener to pin. - * - * @param pinBtn - * as event - */ private void addPinClickListener(final ClickEvent event) { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); checkifAlreadyPinned(event.getButton()); @@ -701,12 +592,6 @@ public class DistributionTable extends AbstractTable { } - /** - * Check already pinned. - * - * @param eventBtn - * as button - */ private void checkifAlreadyPinned(final Button eventBtn) { final Long newPinnedDistItemId = ((DistributionSetIdName) eventBtn.getData()).getId(); Long pinnedDistId = null; @@ -758,9 +643,6 @@ public class DistributionTable extends AbstractTable { } } - /** - * set style to distribution set table. - */ private void styleDistributionSetTable() { setCellStyleGenerator(new Table.CellStyleGenerator() { private static final long serialVersionUID = 1L; @@ -772,12 +654,6 @@ public class DistributionTable extends AbstractTable { }); } - /** - * Apply pin style to pin. - * - * @param eventBtn - * as button - */ private void applyPinStyle(final Button eventBtn) { final StringBuilder style = new StringBuilder(SPUIComponentProvider.getPinButtonStyle()); style.append(' ').append(SPUIStyleDefinitions.DIST_PIN).append(' ').append("tablePin").append(' ') @@ -822,14 +698,9 @@ public class DistributionTable extends AbstractTable { * @param assignedDistTableItemIds * Item ids of assigned distribution set */ - @SuppressWarnings("serial") public void styleDistributionSetTable(final Long installedDistItemId, final Long assignedDistTableItemId) { - setCellStyleGenerator(new Table.CellStyleGenerator() { - @Override - public String getStyle(final Table source, final Object itemId, final Object propertyId) { - return getPinnedDistributionStyle(installedDistItemId, assignedDistTableItemId, itemId); - } - }); + setCellStyleGenerator((source, itemId, propertyId) -> getPinnedDistributionStyle(installedDistItemId, + assignedDistTableItemId, itemId)); } public void setDistributinPinnedBtn(final Button distributinPinnedBtn) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java index 1df06e603..8be9548f7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java @@ -75,7 +75,7 @@ public class DistributionTagBeanQuery extends AbstractBeanQuery { @Override protected List loadBeans(final int startIndex, final int count) { Page dsTagBeans; - final List tagList = new ArrayList(); + final List tagList = new ArrayList<>(); if (startIndex == 0 && firstPageDsTag != null) { dsTagBeans = firstPageDsTag; } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java index 9866ba577..3c1bfcd0a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java @@ -70,6 +70,7 @@ public class DistributionTagButtons extends AbstractFilterButtons { * @param filterButtonClickBehaviour * the clickable behaviour. */ + @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); addNewTag(new DistributionSetTag("NO TAG")); @@ -106,34 +107,18 @@ public class DistributionTagButtons extends AbstractFilterButtons { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButtonsTableId() - */ @Override protected String getButtonsTableId() { return SPUIComponetIdProvider.DISTRIBUTION_TAG_TABLE_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonsLazyQueryContainer () - */ @Override protected LazyQueryContainer createButtonsLazyQueryContainer() { - final Map queryConfig = new HashMap(); - final BeanQueryFactory tagQF = new BeanQueryFactory( - DistributionTagBeanQuery.class); + final Map queryConfig = new HashMap<>(); + final BeanQueryFactory tagQF = new BeanQueryFactory<>(DistributionTagBeanQuery.class); tagQF.setQueryConfiguration(queryConfig); - final LazyQueryContainer tagContainer = HawkbitCommonUtil.createDSLazyQueryContainer( + return HawkbitCommonUtil.createDSLazyQueryContainer( new BeanQueryFactory(DistributionTagBeanQuery.class)); - return tagContainer; } @@ -142,13 +127,6 @@ public class DistributionTagButtons extends AbstractFilterButtons { return SPUIDefinitions.DISTRIBUTION_TAG_BUTTON; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * isClickedByDefault(java.lang .Long) - */ @Override protected boolean isClickedByDefault(final Long buttonId) { final DistributionSetTag dsTagObject = tagMgmtService.findDistributionSetTagById(buttonId); @@ -161,37 +139,16 @@ public class DistributionTagButtons extends AbstractFilterButtons { return managementUIState.getDistributionTableFilters().isNoTagSelected(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonId(java.lang. String) - */ @Override protected String createButtonId(final String name) { return name; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getFilterButtonDropHandler() - */ @Override protected DropHandler getFilterButtonDropHandler() { return spDistTagDropEvent; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButttonWrapperId() - */ @Override protected String getButttonWrapperIdPrefix() { return SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java index c87a5eec9..21013a55e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java @@ -86,20 +86,13 @@ public class DistributionTagDropEvent implements DropHandler { private Boolean isNoTagAssigned(final DragAndDropEvent event) { final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString(); if (tagName.equals(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON)) { - notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", - new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError( + i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); return false; } return true; } - /** - * Validate the drop. - * - * @param event - * DragAndDropEvent reference - * @return Boolean - */ private Boolean validate(final DragAndDropEvent event) { final Component compsource = event.getTransferable().getSourceComponent(); if (!(compsource instanceof Table)) { @@ -116,11 +109,6 @@ public class DistributionTagDropEvent implements DropHandler { return true; } - /** - * validate the update permission. - * - * @return boolean - */ private boolean checkForDSUpdatePermission() { if (!permChecker.hasUpdateDistributionPermission()) { @@ -131,13 +119,6 @@ public class DistributionTagDropEvent implements DropHandler { return true; } - /** - * validate the source tables. - * - * @param source - * table - * @return boolean - */ private boolean validateIfSourceIsDs(final Table source) { if (!source.getId().equals(SPUIComponetIdProvider.DIST_TABLE_ID)) { notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); @@ -146,12 +127,6 @@ public class DistributionTagDropEvent implements DropHandler { return true; } - /** - * Process target Drop event. - * - * @param event - * DragAndDropEvent - */ private void processDistributionDrop(final DragAndDropEvent event) { final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails(); @@ -161,7 +136,7 @@ public class DistributionTagDropEvent implements DropHandler { @SuppressWarnings("unchecked") final Set distSelected = (Set) source.getValue(); - final Set distributionList = new HashSet(); + final Set distributionList = new HashSet<>(); if (!distSelected.contains(transferable.getData(ITEMID))) { distributionList.add(((DistributionSetIdName) transferable.getData(ITEMID)).getId()); } else { @@ -172,8 +147,8 @@ public class DistributionTagDropEvent implements DropHandler { SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); final List tagsClickedList = distFilterParameters.getDistSetTags(); - final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment( - distributionList, distTagName); + final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList, + distTagName); notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n)); if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java index f5f890253..1c44014e8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java @@ -47,12 +47,6 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria { @Autowired private transient EventBus.SessionEventBus eventBus; - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.AbstractAcceptCriteria#analyseDragComponent - * (com.vaadin.event .dd.DragAndDropEvent, com.vaadin.ui.Component) - */ @Override protected void analyseDragComponent(final Component compsource) { final String sourceID = getComponentId(compsource); @@ -60,24 +54,11 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria { eventBus.publish(this, event); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria#hideDropHints - * () - */ @Override protected void hideDropHints() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria#invalidDrop() - */ @Override protected void invalidDrop() { uiNotification.displayValidationError(SPUILabelDefinitions.ACTION_NOT_ALLOWED); @@ -94,60 +75,31 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria { return id; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * getDropHintConfigurations() - */ @Override protected Map getDropHintConfigurations() { return DROP_HINTS_CONFIGS; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * publishDragStartEvent(java.lang.Object) - */ @Override protected void publishDragStartEvent(final Object event) { eventBus.publish(this, event); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.AbstractAcceptCriteria# - * getDropConfigurations() - */ @Override protected Map> getDropConfigurations() { return DROP_CONFIGS; } - /** - * @param id - * @return - */ private boolean isDistributionTagId(final String id) { return id != null && id.startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); } - /** - * @param id - * @return - */ private boolean isTargetTagId(final String id) { return id != null && id.startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS); } - /** - * @return - */ private static Map> createDropConfigurations() { - final Map> config = new HashMap>(); + final Map> config = new HashMap<>(); // Delete drop area acceptable components config.put(SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID, @@ -174,7 +126,7 @@ public class ManagementViewAcceptCriteria extends AbstractAcceptCriteria { } private static Map createDropHintConfigurations() { - final Map config = new HashMap(); + final Map config = new HashMap<>(); config.put(SPUIDefinitions.TARGET_TAG_ID_PREFIXS, DragEvent.TARGET_TAG_DRAG); config.put(SPUIComponetIdProvider.TARGET_TABLE_ID, DragEvent.TARGET_DRAG); config.put(SPUIComponetIdProvider.DIST_TABLE_ID, DragEvent.DISTRIBUTION_DRAG); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java index ec35463d7..1786429a1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java @@ -19,7 +19,6 @@ import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; -import org.eclipse.hawkbit.ui.management.dstable.DistributionTable; import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; @@ -28,7 +27,6 @@ import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; -import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; @@ -85,12 +83,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { @Autowired private CountMessageLabel countMessageLabel; - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init() - */ + @Override @PostConstruct protected void init() { super.init(); @@ -172,73 +165,31 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * hasDeletePermission() - */ @Override protected boolean hasDeletePermission() { return permChecker.hasDeleteDistributionPermission() || permChecker.hasDeleteTargetPermission(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * hasUpdatePermission() - */ @Override protected boolean hasUpdatePermission() { return permChecker.hasUpdateTargetPermission() && permChecker.hasReadDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getDeleteAreaLabel() - */ @Override protected String getDeleteAreaLabel() { return i18n.get("label.components.drop.area"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getDeleteAreaId() - */ @Override protected String getDeleteAreaId() { return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getDeleteLayoutAcceptCriteria () - */ @Override protected AcceptCriterion getDeleteLayoutAcceptCriteria() { return managementViewAcceptCriteria; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * processDroppedComponent(com .vaadin.event.dd.DragAndDropEvent) - */ @Override protected void processDroppedComponent(final DragAndDropEvent event) { final Component source = event.getTransferable().getSourceComponent(); @@ -275,61 +226,26 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { return true; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getNoActionsButtonLabel() - */ @Override protected String getNoActionsButtonLabel() { return i18n.get("button.no.actions"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getActionsButtonLabel() - */ @Override protected String getActionsButtonLabel() { return i18n.get("button.actions"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * reloadActionCount() - */ @Override protected void restoreActionCount() { updateActionCount(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getUnsavedActionsWindowCaption () - */ @Override protected String getUnsavedActionsWindowCaption() { return i18n.get("caption.save.window"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * unsavedActionsWindowClosed() - */ @Override protected void unsavedActionsWindowClosed() { final String message = manangementConfirmationWindowLayout.getConsolidatedMessage(); @@ -338,26 +254,12 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getUnsavedActionsWindowContent () - */ @Override protected Component getUnsavedActionsWindowContent() { manangementConfirmationWindowLayout.init(); return manangementConfirmationWindowLayout; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * hasUnsavedActions() - */ @Override protected boolean hasUnsavedActions() { if (!managementUIState.getDeletedDistributionList().isEmpty() @@ -368,25 +270,11 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { return false; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * hasCountMessage() - */ @Override protected boolean hasCountMessage() { return permChecker.hasTargetReadPermission(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getCountMessageLabel() - */ @Override protected Label getCountMessageLabel() { return countMessageLabel; @@ -413,19 +301,9 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } } - /** - * - * Prepare deleted distribution set . - * - * @param sourceTable - * {@link DistributionTable} - * @param transferable - * {@link TableTransferable} - * - */ private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) { final Set distSelected = HawkbitCommonUtil.getSelectedDSDetails(sourceTable); - final Set distributionIdNameSet = new HashSet(); + final Set distributionIdNameSet = new HashSet<>(); if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) { distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID)); @@ -477,15 +355,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { return false; } - /** - * Prepare deleted target list. - * - * @param sourceTable - * {@link TargetTable} - * @param transferable - * {@link TableTransferable} - * - */ private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) { final Set targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(sourceTable); @@ -521,9 +390,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } } - /** - * Update the software module delete count. - */ private void updateActionCount() { final int count = managementUIState.getDeletedTargetList().size() + managementUIState.getDeletedDistributionList().size() + managementUIState.getAssignedList().size(); @@ -546,34 +412,16 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { return true; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# - * hasBulkUploadPermission() - */ @Override protected boolean hasBulkUploadPermission() { return permChecker.hasCreateTargetPermission(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# - * showBulkUploadWindow() - */ @Override protected void showBulkUploadWindow() { eventBus.publish(this, BulkUploadPopupEvent.MAXIMIMIZED); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# - * restoreBulkUploadStatusCount() - */ @Override protected void restoreBulkUploadStatusCount() { final Long failedCount = managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java index f4c825283..b4ca40da9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java @@ -33,9 +33,9 @@ public class DistributionTableFilters implements Serializable { private String pinnedTargetId; - private final List distSetTags = new ArrayList(); + private final List distSetTags = new ArrayList<>(); - private List clickedDistSetTags = new ArrayList(); + private List clickedDistSetTags = new ArrayList<>(); private Boolean noTagSelected = Boolean.FALSE; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java index 4adeb52ed..4f23b410c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java @@ -30,9 +30,9 @@ public class TargetFilterParameters implements Serializable { private String searchText; - private final List status = new ArrayList(); + private final List status = new ArrayList<>(); - private List targetTags = new ArrayList(); + private List targetTags = new ArrayList<>(); private Long distributionSetId; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java index 1e65caba9..6d8297345 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java @@ -22,9 +22,6 @@ import com.vaadin.spring.annotation.VaadinSessionScope; /** * Target Table Filters. - * - * - * */ @VaadinSessionScope @SpringComponent @@ -32,8 +29,8 @@ public class TargetTableFilters implements Serializable { private static final long serialVersionUID = -5251492630546463593L; - private final List clickedTargetTags = new ArrayList(); - private final List clickedStatusTargetTags = new ArrayList(); + private final List clickedTargetTags = new ArrayList<>(); + private final List clickedStatusTargetTags = new ArrayList<>(); private String searchText; private DistributionSetIdName distributionSet; private Long pinnedDistId; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java index be98ef3bc..dac50ab0d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -39,10 +39,6 @@ import com.google.common.base.Strings; * Simple implementation of generics bean query which dynamically loads a batch * of beans. * - * - * - * - * */ public class TargetBeanQuery extends AbstractBeanQuery { private static final long serialVersionUID = -5645680058303167558L; @@ -105,7 +101,7 @@ public class TargetBeanQuery extends AbstractBeanQuery { @Override protected List loadBeans(final int startIndex, final int count) { Slice targetBeans; - final List proxyTargetBeans = new ArrayList(); + final List proxyTargetBeans = new ArrayList<>(); if (pinnedDistId != null) { targetBeans = getTargetManagement().findTargetsAllOrderByLinkedDistributionSet( new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId, diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java index 159c169d7..f0cdbdd23 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -56,9 +56,6 @@ import com.vaadin.ui.themes.ValoTheme; /** * Target table header layout. - * - * - * */ @SpringComponent @ViewScope @@ -95,6 +92,7 @@ public class TargetTableHeader extends AbstractTableHeader { /** * Initialization of Target Header Component. */ + @Override @PostConstruct protected void init() { super.init(); @@ -258,7 +256,7 @@ public class TargetTableHeader extends AbstractTableHeader { @Override protected void resetSearchText() { - if(managementUIState.getTargetTableFilters().getSearchText().isPresent()){ + if (managementUIState.getTargetTableFilters().getSearchText().isPresent()) { managementUIState.getTargetTableFilters().setSearchText(null); eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_TEXT); } @@ -337,6 +335,11 @@ public class TargetTableHeader extends AbstractTableHeader { @Override protected DropHandler getDropFilterHandler() { return new DropHandler() { + /** + * + */ + private static final long serialVersionUID = 1L; + @Override public void drop(final DragAndDropEvent event) { filterByDroppedDist(event); @@ -395,10 +398,9 @@ public class TargetTableHeader extends AbstractTableHeader { } private Set getDropppedDistributionDetails(final TableTransferable transferable) { - @SuppressWarnings("unchecked") final Set distSelected = HawkbitCommonUtil .getSelectedDSDetails(transferable.getSourceComponent()); - final Set distributionIdSet = new HashSet(); + final Set distributionIdSet = new HashSet<>(); if (!distSelected.contains(transferable.getData("itemId"))) { distributionIdSet.add((DistributionSetIdName) transferable.getData("itemId")); } else { @@ -443,12 +445,6 @@ public class TargetTableHeader extends AbstractTableHeader { eventBus.publish(this, TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * displayFilterDropedInfoOnLoad() - */ @Override protected void displayFilterDropedInfoOnLoad() { if (managementUIState.getTargetTableFilters().getDistributionSet().isPresent()) { @@ -456,23 +452,11 @@ public class TargetTableHeader extends AbstractTableHeader { } } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getFilterIconStyle() - */ @Override protected String getFilterIconStyle() { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# - * isBulkUploadInProgress() - */ @Override protected boolean isBulkUploadInProgress() { return managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount() != 0 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java index ec2cff7fa..5164a409a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java @@ -75,7 +75,7 @@ public class TargetTagBeanQuery extends AbstractBeanQuery { @Override protected List loadBeans(final int startIndex, final int count) { Page targetTagBeans; - final List targetTagList = new ArrayList(); + final List targetTagList = new ArrayList<>(); if (startIndex == 0 && firstPageTargetTag != null) { targetTagBeans = firstPageTargetTag; } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java index c9a2c945c..9d93962da 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -57,9 +57,6 @@ import com.vaadin.ui.UI; /** * Target Tag filter buttons table. - * - * - * */ @SpringComponent @ViewScope @@ -129,40 +126,18 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButtonsTableId() - */ @Override protected String getButtonsTableId() { return SPUIComponetIdProvider.TARGET_TAG_TABLE_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonsLazyQueryContainer () - */ @Override protected LazyQueryContainer createButtonsLazyQueryContainer() { - final LazyQueryContainer tagContainer = HawkbitCommonUtil + return HawkbitCommonUtil .createDSLazyQueryContainer(new BeanQueryFactory(TargetTagBeanQuery.class)); - return tagContainer; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * isClickedByDefault(java.lang .Long) - */ @Override protected boolean isClickedByDefault(final Long buttonId) { final TargetTag newTagClickedObj = tagMgmtService.findTargetTagById(buttonId); @@ -175,26 +150,12 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { return managementUIState.getTargetTableFilters().isNoTagSelected(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonId(java.lang. String) - */ @Override protected String createButtonId(final String name) { return name; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getFilterButtonDropHandler() - */ @Override protected DropHandler getFilterButtonDropHandler() { @@ -267,21 +228,14 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { return true; } - /** - * Process target Drop event. - * - * @param event - * DragAndDropEvent - */ private void processTargetDrop(final DragAndDropEvent event) { final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails(); final TableTransferable transferable = (TableTransferable) event.getTransferable(); final Table source = transferable.getSourceComponent(); - @SuppressWarnings("unchecked") final Set targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(source); - final Set targetList = new HashSet(); + final Set targetList = new HashSet<>(); if (transferable.getData(ITEMID) != null) { if (!targetSelected.contains(transferable.getData(ITEMID))) { targetList.add(((TargetIdName) transferable.getData(ITEMID)).getControllerId()); @@ -306,13 +260,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { } } - /** - * validate the source tables. - * - * @param source - * table - * @return boolean - */ private boolean validateIfSourceisTargetTable(final Table source) { if (!source.getId().equals(SPUIComponetIdProvider.TARGET_TABLE_ID)) { notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED)); @@ -321,13 +268,6 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { return true; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButttonWrapperId() - */ @Override protected String getButttonWrapperIdPrefix() { From dbf03dca122dd62e2b87438bd8cffcfe147ee5e0 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 25 Feb 2016 11:37:56 +0100 Subject: [PATCH 39/45] Add the "@Override" annotation Add some description to JUnit Tests Remove unused override comments Remove unused javadoc on private methode Signed-off-by: SirWayne --- .../amqp/AmqpMessageHandlerServiceTest.java | 32 +- .../eclipse/hawkbit/MethodSecurityUtil.java | 2 +- .../repository/DeploymentManagementTest.java | 314 ++++++++---------- .../repository/ReportManagementTest.java | 48 ++- .../footer/SMDeleteActionsLayout.java | 108 +----- .../smtable/SoftwareModuleDetails.java | 1 + .../smtable/SoftwareModuleTableHeader.java | 149 +-------- .../artifacts/smtype/SMTypeFilterButtons.java | 40 +-- .../artifacts/smtype/SMTypeFilterHeader.java | 51 +-- .../hawkbit/ui/common/ConfirmationDialog.java | 5 +- .../tagdetails/DistributionTagToken.java | 18 - .../SPUIButtonStylePrimarySmall.java | 22 +- .../ui/decorators/SPUIButtonStyleSmall.java | 21 +- .../SPUIButtonStyleSmallNoBorderUH.java | 21 +- .../SPUIButtonStyleSmallNoBorderUHS.java | 21 +- .../ui/decorators/SPUIButtonStyleTiny.java | 21 +- .../ui/decorators/SPUITagButtonStyle.java | 21 +- .../CreateUpdateDistSetTypeLayout.java | 2 +- .../disttype/DSTypeFilterButtons.java | 43 +-- .../disttype/DSTypeFilterHeader.java | 63 +--- .../dstable/DistributionSetTableHeader.java | 74 +---- .../smtable/SwModuleDetails.java | 41 +-- .../smtable/SwModuleTableHeader.java | 154 +-------- .../smtype/DistSMTypeFilterButtons.java | 8 - .../smtype/DistSMTypeFilterHeader.java | 65 +--- .../dstable/DistributionDetails.java | 67 +--- .../management/dstable/DistributionTable.java | 4 - .../dstable/DistributionTableHeader.java | 147 +------- .../dstag/DistributionTagButtons.java | 7 - .../dstag/DistributionTagHeader.java | 59 +--- .../targettable/TargetTableHeader.java | 3 - .../targettag/TargetTagFilterHeader.java | 65 +--- .../hawkbit/ui/rollout/ProxyRollout.java | 34 -- .../hawkbit/ui/rollout/ProxyRolloutGroup.java | 34 -- .../RolloutGroupTargetsListHeader.java | 21 +- .../rollout/RolloutGroupTargetsListTable.java | 105 +++--- .../ui/rollout/RolloutGroupsListHeader.java | 43 +-- .../hawkbit/ui/rollout/RolloutListHeader.java | 25 +- 38 files changed, 284 insertions(+), 1675 deletions(-) diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index bea75e9d6..18f7b853f 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -133,18 +133,15 @@ public class AmqpMessageHandlerServiceTest { messageProperties.setHeader(MessageHeaderKey.THING_ID, "1"); final Message message = messageConverter.toMessage(new byte[0], messageProperties); - // mock final ArgumentCaptor targetIdCaptor = ArgumentCaptor.forClass(String.class); final ArgumentCaptor uriCaptor = ArgumentCaptor.forClass(URI.class); when(controllerManagementMock.findOrRegisterTargetIfItDoesNotexist(targetIdCaptor.capture(), uriCaptor.capture())).thenReturn(null); - // test amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT); - // verify - assertThat(targetIdCaptor.getValue()).isEqualTo(knownThingId); - assertThat(uriCaptor.getValue().toString()).isEqualTo("amqp://MyTest"); + assertThat(targetIdCaptor.getValue()).as("Extraxted Thing should be the same").isEqualTo(knownThingId); + assertThat(uriCaptor.getValue().toString()).as("Extraxted Uri should be the same").isEqualTo("amqp://MyTest"); } @@ -271,8 +268,9 @@ public class AmqpMessageHandlerServiceTest { // verify final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); - assertThat(downloadResponse).isNotNull(); - assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.NOT_FOUND.value()); + assertThat(downloadResponse).as("Message body should not null").isNotNull(); + assertThat(downloadResponse.getResponseCode()).as("Message body response code is wrong") + .isEqualTo(HttpStatus.NOT_FOUND.value()); } @Test @@ -294,8 +292,9 @@ public class AmqpMessageHandlerServiceTest { // verify final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); - assertThat(downloadResponse).isNotNull(); - assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.NOT_FOUND.value()); + assertThat(downloadResponse).as("Message body should not null").isNotNull(); + assertThat(downloadResponse.getResponseCode()).as("Message body response code is wrong") + .isEqualTo(HttpStatus.NOT_FOUND.value()); } @Test @@ -325,9 +324,10 @@ public class AmqpMessageHandlerServiceTest { // verify final DownloadResponse downloadResponse = (DownloadResponse) messageConverter.fromMessage(onMessage); - assertThat(downloadResponse).isNotNull(); - assertThat(downloadResponse.getResponseCode()).isEqualTo(HttpStatus.OK.value()); - assertThat(downloadResponse.getArtifact().getSize()).isEqualTo(1L); + assertThat(downloadResponse).as("Message body should not null").isNotNull(); + assertThat(downloadResponse.getResponseCode()).as("Message body response code is wrong") + .isEqualTo(HttpStatus.OK.value()); + assertThat(downloadResponse.getArtifact().getSize()).as("Wrong artifact size in message body").isEqualTo(1L); assertThat(downloadResponse.getDownloadUrl()).startsWith("http://localhost/api/v1/downloadserver/downloadId/"); } @@ -364,9 +364,11 @@ public class AmqpMessageHandlerServiceTest { final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = captorTargetAssignDistributionSetEvent .getValue(); - assertThat(targetAssignDistributionSetEvent.getControllerId()).isEqualTo("target1"); - assertThat(targetAssignDistributionSetEvent.getActionId()).isEqualTo(22L); - assertThat(targetAssignDistributionSetEvent.getSoftwareModules()).isEqualTo(softwareModuleList); + assertThat(targetAssignDistributionSetEvent.getControllerId()).as("event has wrong controller id") + .isEqualTo("target1"); + assertThat(targetAssignDistributionSetEvent.getActionId()).as("event has wrong action id").isEqualTo(22L); + assertThat(targetAssignDistributionSetEvent.getSoftwareModules()).as("event has wrong sofware modules") + .isEqualTo(softwareModuleList); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java index 2fb68ec31..6633a27e5 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java @@ -54,7 +54,7 @@ public class MethodSecurityUtil { if (!METHOD_SECURITY_EXCLUSION.contains(method.getName()) && !method.isSynthetic() && Modifier.isPublic(method.getModifiers())) { final PreAuthorize annotation = method.getAnnotation(PreAuthorize.class); - assertThat(annotation).describedAs( + assertThat(annotation).as( "The public method " + method.getName() + " is not annoated with @PreAuthorize, security leak?") .isNotNull(); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 693a67082..985bc6bd9 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -19,7 +19,6 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.Constants; @@ -98,8 +97,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final List findActionsWithStatusCountByTarget = deploymentManagement .findActionsWithStatusCountByTargetOrderByIdDesc(testTarget.get(0)); - assertThat(findActionsWithStatusCountByTarget).hasSize(1); - assertThat(findActionsWithStatusCountByTarget.get(0).getActionStatusCount()).isEqualTo(3L); + assertThat(findActionsWithStatusCountByTarget).as("wrong action size").hasSize(1); + assertThat(findActionsWithStatusCountByTarget.get(0).getActionStatusCount()).as("wrong action status size") + .isEqualTo(3L); } @Test @@ -115,27 +115,32 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("Tag1")); final List assignedDS = distributionSetManagement.assignTag(assignDS, tag); - assertThat(assignedDS.size()).isEqualTo(4); - assignedDS.forEach(ds -> assertThat(ds.getTags().size()).isEqualTo(1)); + assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4); + assignedDS.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1)); DistributionSetTag findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1"); - assertThat(assignedDS.size()).isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size()); + assertThat(assignedDS.size()).as("assigned ds has wrong size") + .isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size()); - assertThat(distributionSetManagement.unAssignTag(Long.valueOf(100), findDistributionSetTag)).isNull(); + assertThat(distributionSetManagement.unAssignTag(Long.valueOf(100), findDistributionSetTag)) + .as("unassign tag result should be null").isNull(); final DistributionSet unAssignDS = distributionSetManagement.unAssignTag(assignDS.get(0), findDistributionSetTag); - assertThat(unAssignDS.getId()).isEqualTo(assignDS.get(0)); - assertThat(unAssignDS.getTags().size()).isEqualTo(0); + assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0)); + assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isEqualTo(0); findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1"); - assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).isEqualTo(3); + assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).as("ds tag ds has wrong ds size") + .isEqualTo(3); final List unAssignTargets = distributionSetManagement .unAssignAllDistributionSetsByTag(findDistributionSetTag); findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1"); - assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).isEqualTo(0); - assertThat(unAssignTargets.size()).isEqualTo(3); - unAssignTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(0)); + assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).as("ds tag has wrong ds size") + .isEqualTo(0); + assertThat(unAssignTargets.size()).as("unassigned target has wrong size").isEqualTo(3); + unAssignTargets + .forEach(target -> assertThat(target.getTags().size()).as("target has wrong tag size").isEqualTo(0)); } @Test @@ -157,7 +162,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { targetManagement.findAllTargetIds().forEach(targetIdName -> { assertThat(deploymentManagement.findActiveActionsByTarget( - targetManagement.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2); + targetManagement.findTargetByControllerID(targetIdName.getControllerId()))) + .as("active action has wrong size").hasSize(2); }); } @@ -180,14 +186,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // check initial status assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.UNKNOWN); + .as("target has update status").isEqualTo(TargetUpdateStatus.UNKNOWN); // assign the two sets in a row Action firstAction = assignSet(target, dsFirst); Action secondAction = assignSet(target, dsSecond); - assertThat(actionRepository.findAll()).hasSize(2); - assertThat(actionStatusRepository.findAll()).hasSize(2); + assertThat(actionRepository.findAll()).as("wrong size of actions").hasSize(2); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(2); // we cancel second -> back to first deploymentManagement.cancelAction(secondAction, @@ -197,10 +203,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { secondAction.setStatus(Status.CANCELED); controllerManagement.addCancelActionStatus( new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction); - assertThat(actionStatusRepository.findAll()).hasSize(4); - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst); + assertThat(actionStatusRepository.findAll()).as("wrong size of actions status").hasSize(4); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).as("wrong ds") + .isEqualTo(dsFirst); assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING); // we cancel first -> back to installed deploymentManagement.cancelAction(firstAction, @@ -210,11 +217,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { firstAction.setStatus(Status.CANCELED); controllerManagement.addCancelActionStatus( new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction); - assertThat(actionStatusRepository.findAll()).hasSize(6); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(6); assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) - .isEqualTo(dsInstalled); + .as("wrong assigned ds").isEqualTo(dsInstalled); assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.IN_SYNC); + .as("wrong update status").isEqualTo(TargetUpdateStatus.IN_SYNC); } @Test @@ -236,14 +243,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // check initial status assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.UNKNOWN); + .as("wrong update status").isEqualTo(TargetUpdateStatus.UNKNOWN); // assign the two sets in a row Action firstAction = assignSet(target, dsFirst); Action secondAction = assignSet(target, dsSecond); - assertThat(actionRepository.findAll()).hasSize(2); - assertThat(actionStatusRepository.findAll()).hasSize(2); + assertThat(actionRepository.findAll()).as("wrong size of actions").hasSize(2); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(2); // we cancel first -> second is left deploymentManagement.cancelAction(firstAction, @@ -253,26 +260,28 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { firstAction.setStatus(Status.CANCELED); controllerManagement.addCancelActionStatus( new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction); - assertThat(actionStatusRepository.findAll()).hasSize(4); - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(4); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) + .as("wrong assigned ds").isEqualTo(dsSecond); assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING); // we cancel second -> remain assigned until finished cancellation deploymentManagement.cancelAction(secondAction, targetManagement.findTargetByControllerID(target.getControllerId())); secondAction = deploymentManagement.findActionWithDetails(secondAction.getId()); - assertThat(actionStatusRepository.findAll()).hasSize(5); - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(5); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) + .as("wrong assigned ds").isEqualTo(dsSecond); // confirm cancellation secondAction.setStatus(Status.CANCELED); controllerManagement.addCancelActionStatus( new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction); // cancelled success -> back to dsInstalled assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) - .isEqualTo(dsInstalled); + .as("wrong installed ds").isEqualTo(dsInstalled); assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.IN_SYNC); + .as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC); } @Test @@ -291,13 +300,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // verify initial status assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.UNKNOWN); + .as("wrong target info update status").isEqualTo(TargetUpdateStatus.UNKNOWN); Action assigningAction = assignSet(target, ds); // verify assignment - assertThat(actionRepository.findAll()).hasSize(1); - assertThat(actionStatusRepository.findAll()).hasSize(1); + assertThat(actionRepository.findAll()).as("wrong size of action").hasSize(1); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(1); target = targetManagement.findTargetByControllerID(target.getControllerId()); @@ -310,11 +319,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId()); // verify - assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED); + assertThat(assigningAction.getStatus()).as("wrong size of status").isEqualTo(Status.CANCELED); assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) - .isEqualTo(dsInstalled); + .as("wrong assigned ds").isEqualTo(dsInstalled); assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.IN_SYNC); + .as("wrong target update status").isEqualTo(TargetUpdateStatus.IN_SYNC); } @Test @@ -333,13 +342,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // verify initial status assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.UNKNOWN); + .as("wrong update status").isEqualTo(TargetUpdateStatus.UNKNOWN); final Action assigningAction = assignSet(target, ds); // verify assignment - assertThat(actionRepository.findAll()).hasSize(1); - assertThat(actionStatusRepository.findAll()).hasSize(1); + assertThat(actionRepository.findAll()).as("wrong size of action").hasSize(1); + assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(1); // force quit assignment try { @@ -354,11 +363,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() }); assertThat( targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING); assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet()) - .isEqualTo(ds); + .as("wrong assigned ds").isEqualTo(ds); final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0); - assertThat(action).isNotNull(); + assertThat(action).as("action should not be null").isNotNull(); return action; } @@ -390,26 +399,30 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { deploymentManagement.assignDistributionSet(ds, savedDeployedTargets); // verify that one Action for each assignDistributionSet - assertThat(actionRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(20); + assertThat(actionRepository.findAll(pageReq).getNumberOfElements()).as("wrong size of actions").isEqualTo(20); final Iterable allFoundTargets = targetManagement.findTargetsAll(pageReq).getContent(); - assertThat(allFoundTargets).containsAll(savedDeployedTargets).containsAll(savedNakedTargets); - assertThat(savedDeployedTargets).doesNotContain(Iterables.toArray(savedNakedTargets, Target.class)); - assertThat(savedNakedTargets).doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class)); + assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets) + .containsAll(savedNakedTargets); + assertThat(savedDeployedTargets).as("saved target are wrong") + .doesNotContain(Iterables.toArray(savedNakedTargets, Target.class)); + assertThat(savedNakedTargets).as("saved target are wrong") + .doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class)); for (final Target myt : savedNakedTargets) { final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()); - assertThat(deploymentManagement.findActionsByTarget(t)).isEmpty(); + assertThat(deploymentManagement.findActionsByTarget(t)).as("action should be empty").isEmpty(); } for (final Target myt : savedDeployedTargets) { final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()); final List activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(t); - assertThat(activeActionsByTarget).isNotEmpty(); - assertThat(t.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING); + assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty(); + assertThat(t.getTargetInfo().getUpdateStatus()).as("wrong target update status") + .isEqualTo(TargetUpdateStatus.PENDING); for (final Action ua : activeActionsByTarget) { - assertThat(ua.getDistributionSet()).isEqualTo(ds); + assertThat(ua.getDistributionSet()).as("action has wrong ds").isEqualTo(ds); } } @@ -448,12 +461,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // give some chance to receive events asynchronously Thread.sleep(300); final List events = eventHandlerMock.getEvents(1, TimeUnit.MILLISECONDS); - assertThat(events).isEmpty(); + assertThat(events).as("events should be empty").isEmpty(); final EventHandlerMock eventHandlerMockAfterCompletionOfDs = new EventHandlerMock(10); eventBus.register(eventHandlerMockAfterCompletionOfDs); - assertThat(deploymentManagement.assignDistributionSet(nowComplete, targets).getAssigned()).isEqualTo(10); + assertThat(deploymentManagement.assignDistributionSet(nowComplete, targets).getAssigned()) + .as("assign ds doesn't work").isEqualTo(10); assertTargetAssignDistributionSetEvents(targets, nowComplete, eventHandlerMockAfterCompletionOfDs.getEvents(10, TimeUnit.SECONDS)); } @@ -493,7 +507,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // retrieving all Actions created by the assignDistributionSet call final Page page = actionRepository.findAll(pageReq); // and verify the number - assertThat(page.getTotalElements()).isEqualTo(noOfDeployedTargets * noOfDistributionSets); + assertThat(page.getTotalElements()).as("wrong size of actions") + .isEqualTo(noOfDeployedTargets * noOfDistributionSets); // only records retrieved from the DB can be evaluated to be sure that // all fields are @@ -504,17 +519,20 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Iterable undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs); // test that number of Targets - assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()) + assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).as("number of target is wrong") .isEqualTo(deployedTargetsFromDB.spliterator().getExactSizeIfKnown() + undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()); - assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets); - assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets); + assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).as("number of target is wrong") + .isEqualTo(noOfDeployedTargets); + assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).as("number of target is wrong") + .isEqualTo(noOfUndeployedTargets); // test the content of different lists - assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB); - assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets) + assertThat(allFoundTargets).as("content of founded target is wrong").containsAll(deployedTargetsFromDB) + .containsAll(undeployedTargetsFromDB); + assertThat(deployedTargetsFromDB).as("content of deployed target is wrong").containsAll(savedDeployedTargets) .doesNotContain(Iterables.toArray(undeployedTargetsFromDB, Target.class)); - assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets) + assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets) .doesNotContain(Iterables.toArray(deployedTargetsFromDB, Target.class)); // For each of the 4 targets 1 distribution sets gets assigned @@ -542,42 +560,42 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSet dsC = deployResWithDsC.getDistributionSets().get(0); // retrieving the UpdateActions created by the assignments - final Action updActA = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(0); - final Action updActB = actionRepository.findByDistributionSet(pageRequest, dsB).getContent().get(0); - final Action updActC = actionRepository.findByDistributionSet(pageRequest, dsC).getContent().get(0); + actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(0); + actionRepository.findByDistributionSet(pageRequest, dsB).getContent().get(0); + actionRepository.findByDistributionSet(pageRequest, dsC).getContent().get(0); // verifying the correctness of the assignments for (final Target t : deployResWithDsA.getDeployedTargets()) { - assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId()); + assertThat(t.getAssignedDistributionSet().getId()).as("assignment is not correct").isEqualTo(dsA.getId()); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + .getInstalledDistributionSet()).as("installed ds should be null").isNull(); } for (final Target t : deployResWithDsB.getDeployedTargets()) { - assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId()); + assertThat(t.getAssignedDistributionSet().getId()).as("assigned ds is wrong").isEqualTo(dsB.getId()); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + .getInstalledDistributionSet()).as("installed ds should be null").isNull(); } for (final Target t : deployResWithDsC.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId()); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + .getInstalledDistributionSet()).as("installed ds should not be null").isNull(); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING); } final List updatedTsDsA = sendUpdateActionStatusToTargets(dsA, deployResWithDsA.getDeployedTargets(), Status.FINISHED, new String[] { "alles gut" }); // verify, that dsA is deployed correctly - assertThat(updatedTsDsA).isEqualTo(deployResWithDsA.getDeployedTargets()); + assertThat(updatedTsDsA).as("ds is not deployed correctly").isEqualTo(deployResWithDsA.getDeployedTargets()); for (final Target t_ : updatedTsDsA) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); - assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA); + assertThat(t.getAssignedDistributionSet()).as("assigned ds is wrong").isEqualTo(dsA); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isEqualTo(dsA); + .getInstalledDistributionSet()).as("installed ds is wrong").isEqualTo(dsA); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.IN_SYNC); - assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0); + .as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC); + assertThat(deploymentManagement.findActiveActionsByTarget(t)).as("no actions should be active").hasSize(0); } // deploy dsA to the target which already have dsB deployed -> must @@ -586,18 +604,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // UpdateAction for dsA final Iterable deployed2DS = deploymentManagement .assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets(); - final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1); + actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1); - assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets()); - assertThat(deployed2DS).hasSameSizeAs(deployResWithDsB.getDeployedTargets()); + assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsB.getDeployedTargets()); + assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsB.getDeployedTargets()); for (final Target t_ : deployed2DS) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); - assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA); + assertThat(t.getAssignedDistributionSet()).as("assigned ds is wrong").isEqualTo(dsA); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + .getInstalledDistributionSet()).as("installed ds should be null").isNull(); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING); } } @@ -630,22 +648,22 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { distributionSetManagement.deleteDistributionSet(dsA.getId()); dsA = distributionSetManagement.findDistributionSetById(dsA.getId()); - assertThat(dsA).isNull(); + assertThat(dsA).as("ds should be null").isNull(); // // verify that the ds is not physically deleted for (final DistributionSet ds : deploymentResult.getDistributionSets()) { distributionSetManagement.deleteDistributionSet(ds.getId()); final DistributionSet foundDS = distributionSetManagement.findDistributionSetById(ds.getId()); - assertThat(foundDS).isNotNull(); - assertThat(foundDS.isDeleted()).isTrue(); + assertThat(foundDS).as("founded should not be null").isNotNull(); + assertThat(foundDS.isDeleted()).as("founded ds should be deleted").isTrue(); } // verify that deleted attribute is used correctly List allFoundDS = distributionSetManagement.findDistributionSetsAll(pageReq, false, true) .getContent(); - assertThat(allFoundDS.size()).isEqualTo(0); + assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0); allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, true, true).getContent(); - assertThat(allFoundDS).hasSize(noOfDistributionSets); + assertThat(allFoundDS).as("wrong size of founded ds").hasSize(noOfDistributionSets); for (final DistributionSet ds : deploymentResult.getDistributionSets()) { sendUpdateActionStatusToTargets(ds, deploymentResult.getDeployedTargets(), Status.FINISHED, @@ -659,9 +677,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // successfully and no activeAction is referring to created distribution // sets allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, false, true).getContent(); - assertThat(allFoundDS.size()).isEqualTo(0); + assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0); allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, true, true).getContent(); - assertThat(allFoundDS).hasSize(noOfDistributionSets); + assertThat(allFoundDS).as("size of founded ds is wrong").hasSize(noOfDistributionSets); } @@ -685,15 +703,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { "blabla alles gut"); } - assertThat(targetManagement.countTargetsAll()).isNotZero(); - assertThat(actionStatusRepository.count()).isNotZero(); + assertThat(targetManagement.countTargetsAll()).as("size of targets is wrong").isNotZero(); + assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero(); targetManagement .deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets])); targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets])); - assertThat(targetManagement.countTargetsAll()).isZero(); - assertThat(actionStatusRepository.count()).isZero(); + assertThat(targetManagement.countTargetsAll()).as("size of targets should be zero").isZero(); + assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero(); } private List sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable targs, @@ -744,7 +762,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // checking the revisions of the created entities // verifying that the revision of the object and the revision within the // DB has not changed - assertThat(dsA.getOptLockRevision()).isEqualTo( + assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo( distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision()); // verifying that the assignment is correct @@ -795,12 +813,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { public void checkThatDsRevisionsIsNotChangedWithTargetAssignment() { final DistributionSet dsA = TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement); - final DistributionSet dsB = TestDataUtil.generateDistributionSet("b", softwareManagement, - distributionSetManagement); + TestDataUtil.generateDistributionSet("b", softwareManagement, distributionSetManagement); Target targ = targetManagement .createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description")); - assertThat(dsA.getOptLockRevision()).isEqualTo( + assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo( distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision()); final List targs = new ArrayList(); @@ -808,7 +825,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Iterable savedTargs = deploymentManagement.assignDistributionSet(dsA, targs).getAssignedTargets(); targ = savedTargs.iterator().next(); - assertThat(dsA.getOptLockRevision()).isEqualTo( + assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo( distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision()); } @@ -825,14 +842,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0)); // verify preparation Action findAction = deploymentManagement.findAction(action.getId()); - assertThat(findAction.getActionType()).isEqualTo(ActionType.SOFT); + assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.SOFT); // test deploymentManagement.forceTargetAction(action.getId()); // verify test findAction = deploymentManagement.findAction(action.getId()); - assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED); + assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED); } @Test @@ -848,15 +865,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0)); // verify perparation Action findAction = deploymentManagement.findAction(action.getId()); - assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED); + assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED); // test final Action forceTargetAction = deploymentManagement.forceTargetAction(action.getId()); // verify test - assertThat(forceTargetAction.getActionType()).isEqualTo(ActionType.FORCED); + assertThat(forceTargetAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED); findAction = deploymentManagement.findAction(action.getId()); - assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED); + assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED); } /** @@ -918,14 +935,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { if (event.getControllerId().equals(myt.getControllerId())) { found = true; final List activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt); - assertThat(activeActionsByTarget).isNotEmpty(); - assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()) - .as("Action id in database and event do not match"); - assertThat(event.getSoftwareModules()) + assertThat(activeActionsByTarget).as("size of active actions for target is wrong").isNotEmpty(); + assertThat(event.getActionId()).as("Action id in database and event do not match") + .isEqualTo(activeActionsByTarget.get(0).getId()); + assertThat(event.getSoftwareModules()).as("softwaremodule size is not correct") .containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()])); } } - assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId()); + assertThat(found).as("No event found for controller " + myt.getControllerId()).isTrue(); } } @@ -944,42 +961,19 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { private final List deployedTargets = new ArrayList(); private final List distributionSets = new ArrayList(); - private final String undeployedTargetPrefix; - private final String deployedTargetPrefix; - private final String distributionSetPrefix; - public DeploymentResult(final Iterable deployedTs, final Iterable undeployedTs, final Iterable dss, final String deployedTargetPrefix, final String undeployedTargetPrefix, final String distributionSetPrefix) { - this.undeployedTargetPrefix = undeployedTargetPrefix; - this.deployedTargetPrefix = deployedTargetPrefix; - this.distributionSetPrefix = distributionSetPrefix; - Iterables.addAll(deployedTargets, deployedTs); Iterables.addAll(undeployedTargets, undeployedTs); Iterables.addAll(distributionSets, dss); - deployedTargets.forEach(new Consumer() { - @Override - public void accept(final Target t) { - deployedTargetIDs.add(t.getId()); - } - }); + deployedTargets.forEach(t -> deployedTargetIDs.add(t.getId())); - undeployedTargets.forEach(new Consumer() { - @Override - public void accept(final Target t) { - undeployedTargetIDs.add(t.getId()); - } - }); + undeployedTargets.forEach(t -> undeployedTargetIDs.add(t.getId())); - distributionSets.forEach(new Consumer() { - @Override - public void accept(final DistributionSet ds) { - distributionSetIDs.add(ds.getId()); - } - }); + distributionSets.forEach(ds -> distributionSetIDs.add(ds.getId())); } @@ -1018,27 +1012,6 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { return deployedTargets; } - /** - * @return the noOfUndeployedTargets - */ - public int getNoOfUndeployedTargets() { - return undeployedTargetIDs.size(); - } - - /** - * @return the noOfDeployedTargets - */ - public int getNoOfDeployedTargets() { - return deployedTargetIDs.size(); - } - - /** - * @return the noOfDistributionSets - */ - public int getNoOfDistributionSets() { - return distributionSets.size(); - } - /** * @return the undeployedTargetIDs */ @@ -1046,26 +1019,6 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { return undeployedTargetIDs; } - /** - * @return the undeployedTargetPrefix - */ - public String getUndeployedTargetPrefix() { - return undeployedTargetPrefix; - } - - /** - * @return the deployedTargetPrefix - */ - public String getDeployedTargetPrefix() { - return deployedTargetPrefix; - } - - /** - * @return the distributionSetPrefix - */ - public String getDistributionSetPrefix() { - return distributionSetPrefix; - } } private static class EventHandlerMock { @@ -1090,9 +1043,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { latch.await(timeout, unit); final List handledEvents = new LinkedList( events); - assertThat(handledEvents).hasSize(expectedNumberOfEvents) - .as("Did not receive the expected amount of events (" + expectedNumberOfEvents - + ") within timeout. Received events are " + handledEvents); + assertThat(handledEvents).as("Did not receive the expected amount of events (" + expectedNumberOfEvents + + ") within timeout. Received events are " + handledEvents).hasSize(expectedNumberOfEvents); + return handledEvents; } } @@ -1118,9 +1071,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { throws InterruptedException { latch.await(timeout, unit); final List handledEvents = new LinkedList(events); - assertThat(handledEvents).hasSize(expectedNumberOfEvents) - .as("Did not receive the expected amount of events (" + expectedNumberOfEvents - + ") within timeout. Received events are " + handledEvents); + assertThat(handledEvents).as("Did not receive the expected amount of events (" + expectedNumberOfEvents + + ") within timeout. Received events are " + handledEvents).hasSize(expectedNumberOfEvents); return handledEvents; } } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java index 0f91fb521..0184a9d26 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java @@ -18,7 +18,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.List; -import java.util.concurrent.Callable; import java.util.stream.Collectors; import org.eclipse.hawkbit.AbstractIntegrationTest; @@ -96,7 +95,8 @@ public class ReportManagementTest extends AbstractIntegrationTest { // +1 because we go back #maxMonthBackAmountReportTargets but in the // report the current month // is included for sure, so from this month we go back - assertThat(targetsCreatedOverPeriod.getData()).hasSize(maxMonthBackAmountReportTargets + 1); + assertThat(targetsCreatedOverPeriod.getData()).as("created over period has wrong size") + .hasSize(maxMonthBackAmountReportTargets + 1); for (final DataReportSeriesItem reportItem : targetsCreatedOverPeriod.getData()) { // only one target is created for each month assertThat(reportItem.getData().intValue()).as("Target for each month").isEqualTo(1); @@ -147,10 +147,11 @@ public class ReportManagementTest extends AbstractIntegrationTest { // +1 because we go back #maxMonthBackAmountReportTargets but in the // report the current month // is included for sure, so from this month we go back - assertThat(feedbackReceivedOverTime.getData()).hasSize(maxMonthBackAmountReportTargets + 1); + assertThat(feedbackReceivedOverTime.getData()).as("feedback receiver has wrong data size") + .hasSize(maxMonthBackAmountReportTargets + 1); for (final DataReportSeriesItem reportItem : feedbackReceivedOverTime.getData()) { // only one target feedback is created for each month - assertThat(reportItem.getData().intValue()).isEqualTo(1); + assertThat(reportItem.getData().intValue()).as("data size is wrong").isEqualTo(1); } // check cache evict @@ -165,7 +166,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { } feedbackReceivedOverTime = reportManagement.feedbackReceivedOverTime(DateTypes.perMonth(), from, to); for (final DataReportSeriesItem reportItem : feedbackReceivedOverTime.getData()) { - assertThat(reportItem.getData().intValue()).isEqualTo(2); + assertThat(reportItem.getData().intValue()).as("report item has wrong data size").isEqualTo(2); } } @@ -227,12 +228,12 @@ public class ReportManagementTest extends AbstractIntegrationTest { .isEqualTo(3L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(Arrays.stream(outerData).map(DataReportSeriesItem::getType).collect(Collectors.toList())) - .contains("0.0.0", "0.0.1"); + .as("versio item contains wrong version").contains("0.0.0", "0.0.1"); } else if (dataReportSeriesItem.getType().equals("ds2")) { assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 2 in statistics") .isEqualTo(1L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); - assertThat(outerData).hasSize(1); + assertThat(outerData).as("Version/Item type has wrong size").hasSize(1); assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 2 in statistics") .isEqualTo("0.0.2"); } else if (dataReportSeriesItem.getType().equals("ds3")) { @@ -240,7 +241,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 3 in statistics") .isEqualTo(0L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); - assertThat(outerData).hasSize(1); + assertThat(outerData).as("Version/Item type has wrong size").hasSize(1); assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 3 in statistics") .isEqualTo("0.0.3"); } else { @@ -395,13 +396,13 @@ public class ReportManagementTest extends AbstractIntegrationTest { final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); assertThat(Arrays.stream(outerData).map(DataReportSeriesItem::getType).collect(Collectors.toList())) - .contains("0.0.0", "0.0.1"); + .as("Out series contains wrong version").contains("0.0.0", "0.0.1"); } else if (dataReportSeriesItem.getType().equals("ds2")) { assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 2 in statistics") .isEqualTo(1L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); - assertThat(outerData).hasSize(1); + assertThat(outerData).as("out series has wrong size").hasSize(1); assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 2 in statistics") .isEqualTo("0.0.2"); @@ -409,7 +410,7 @@ public class ReportManagementTest extends AbstractIntegrationTest { assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 3 in statistics") .isEqualTo(0L); final DataReportSeriesItem[] outerData = innerOuterDataReportSeries.getOuterSeries().getData(); - assertThat(outerData).hasSize(1); + assertThat(outerData).as("out series has wrong size").hasSize(1); assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 3 in statistics") .isEqualTo("0.0.3"); } else { @@ -487,33 +488,26 @@ public class ReportManagementTest extends AbstractIntegrationTest { final int targetCreateAmount = 10; // create targets for another tenant - securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), new Callable() { - @Override - public Void call() throws Exception { - for (int index = 0; index < targetCreateAmount; index++) { - targetManagement.createTarget(new Target("t" + index)); - } - return null; + securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), () -> { + for (int index = 0; index < targetCreateAmount; index++) { + targetManagement.createTarget(new Target("t" + index)); } + return null; }); // ensure targets has been created for 'anotherTenant' final Slice targetsForAnotherTenant = securityRule.runAs( - WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), new Callable>() { - @Override - public Slice call() throws Exception { - return targetManagement.findTargetsAll(new PageRequest(0, 1000)); - } - }); - assertThat(targetsForAnotherTenant).hasSize(targetCreateAmount); + WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), + () -> targetManagement.findTargetsAll(new PageRequest(0, 1000))); + assertThat(targetsForAnotherTenant).as("targets has wrong size").hasSize(targetCreateAmount); final LocalDateTime to = LocalDateTime.now(); final LocalDateTime from = to.minusMonths(targetCreateAmount); // now retrieve the report for the 'mytenant' final DataReportSeries targetsCreatedOverPeriod = reportManagement .targetsCreatedOverPeriod(DateTypes.perMonth(), from, to); - // final no targets should final be created for this tenant - assertThat(targetsCreatedOverPeriod.getData()).hasSize(0); + assertThat(targetsCreatedOverPeriod.getData()).as("final no targets should final be created for this tenant") + .hasSize(0); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java index eb8ed75e1..ef4b17da7 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java @@ -37,8 +37,8 @@ import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -import com.vaadin.ui.UI; import com.vaadin.ui.Table.TableTransferable; +import com.vaadin.ui.UI; /** * Upload view footer layout implementation. @@ -71,12 +71,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { @Autowired private UploadViewAcceptCriteria uploadViewAcceptCriteria; - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init() - */ + @Override @PostConstruct protected void init() { super.init(); @@ -134,23 +129,11 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * hasDeletePermission() - */ @Override protected boolean hasDeletePermission() { return permChecker.hasDeleteDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * hasUpdatePermission() - */ @Override protected boolean hasUpdatePermission() { /** @@ -161,12 +144,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * getDeleteAreaLabel() - */ @Override protected String getDeleteAreaLabel() { return i18n.get("label.software.module.drop.area"); @@ -177,29 +154,17 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { return SPUIComponetIdProvider.DELETE_BUTTON_WRAPPER_ID; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * getDeleteLayoutAcceptCriteria() - */ @Override protected AcceptCriterion getDeleteLayoutAcceptCriteria() { return uploadViewAcceptCriteria; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * processDroppedComponent(com.vaadin .event.dd.DragAndDropEvent) - */ @Override protected void processDroppedComponent(final DragAndDropEvent event) { final Component sourceComponent = event.getTransferable().getSourceComponent(); if (sourceComponent instanceof Table) { final Table sourceTable = (Table) event.getTransferable().getSourceComponent(); - addToDeleteList(sourceTable,(TableTransferable) event.getTransferable()); + addToDeleteList(sourceTable, (TableTransferable) event.getTransferable()); updateSWActionCount(); } if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { @@ -223,11 +188,11 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { private void deleteSWModuleType(final String swModuleTypeName) { artifactUploadState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName); } - + private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) { @SuppressWarnings("unchecked") final Set swModuleSelected = (Set) sourceTable.getValue(); - final Set swModuleIdNameSet = new HashSet(); + final Set swModuleIdNameSet = new HashSet<>(); if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) { swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID)); } else { @@ -239,33 +204,18 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { artifactUploadState.getDeleteSofwareModules().put(id, swModuleName); }); } - - /** - * Update the software module delete count. - */ + private void updateSWActionCount() { final int count = artifactUploadState.getDeleteSofwareModules().size() + artifactUploadState.getSelectedDeleteSWModuleTypes().size(); updateActionsCount(count); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * getNoActionsButtonLabel() - */ @Override protected String getNoActionsButtonLabel() { return i18n.get("button.no.actions"); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# - * getActionsButtonLabel() - */ @Override protected String getActionsButtonLabel() { return i18n.get("button.actions"); @@ -276,25 +226,11 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { updateSWActionCount(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getUnsavedActionsWindowCaption () - */ @Override protected String getUnsavedActionsWindowCaption() { return i18n.get("caption.save.window"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * unsavedActionsWindowClosed() - */ @Override protected void unsavedActionsWindowClosed() { final String message = uploadViewConfirmationWindowLayout.getConsolidatedMessage(); @@ -303,26 +239,12 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * getUnsavedActionsWindowContent () - */ @Override protected Component getUnsavedActionsWindowContent() { uploadViewConfirmationWindowLayout.init(); return uploadViewConfirmationWindowLayout; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# - * hasUnsavedActions() - */ @Override protected boolean hasUnsavedActions() { return !artifactUploadState.getDeleteSofwareModules().isEmpty() @@ -339,23 +261,11 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# - * isBulkUploadAllowed() - */ @Override protected boolean hasBulkUploadPermission() { return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# - * showBulkUploadWindow() - */ @Override protected void showBulkUploadWindow() { /** @@ -363,12 +273,6 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { */ } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# - * restoreBulkUploadStatusCount() - */ @Override protected void restoreBulkUploadStatusCount() { /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java index 674152164..6eb3e3d5d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java @@ -70,6 +70,7 @@ public class SoftwareModuleDetails extends AbstractTableDetailsLayout { /** * Initialize the component. */ + @Override @PostConstruct protected void init() { super.init(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java index b7db0096a..71605ec9f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java @@ -62,6 +62,7 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { /** * Initialize the components. */ + @Override @PostConstruct protected void init() { super.init(); @@ -84,55 +85,26 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { eventbus.unsubscribe(this); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getHeaderCaption - * () - */ @Override protected String getHeaderCaption() { return i18n.get("upload.swModuleTable.header"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getSearchBoxId() - */ @Override protected String getSearchBoxId() { return SPUIComponetIdProvider.SW_MODULE_SEARCH_TEXT_FIELD; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#getSearchRestIconId() - */ @Override protected String getSearchRestIconId() { return SPUIComponetIdProvider.SW_MODULE_SEARCH_RESET_ICON; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getAddIconId() - */ @Override protected String getAddIconId() { return SPUIComponetIdProvider.SW_MODULE_ADD_BUTTON; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#onLoadSearchBoxValue() - */ @Override protected String onLoadSearchBoxValue() { if (artifactUploadState.getSoftwareModuleFilters().getSearchText().isPresent()) { @@ -141,68 +113,34 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getDropFilterId( - * ) - */ @Override protected String getDropFilterId() { /* No dropping on software module table header in Upload View */ return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#hasCreatePermission() - */ @Override protected boolean hasCreatePermission() { return permChecker.hasCreateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#isDropHintRequired() - */ @Override protected boolean isDropHintRequired() { /* No dropping on software module table header in Upload View */ return false; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#isDropFilterRequired() - */ @Override protected boolean isDropFilterRequired() { /* No dropping on software module table header in Upload View */ return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTableHeader# - * getShowFilterButtonLayoutId() - */ @Override protected String getShowFilterButtonLayoutId() { return "show.type.icon"; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#showFilterButtonsLayout - * () - */ @Override protected void showFilterButtonsLayout() { artifactUploadState.setSwTypeFilterClosed(false); @@ -210,39 +148,19 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#resetSearchText( - * ) - */ @Override protected void resetSearchText() { - if(artifactUploadState.getSoftwareModuleFilters().getSearchText().isPresent()){ + if (artifactUploadState.getSoftwareModuleFilters().getSearchText().isPresent()) { artifactUploadState.getSoftwareModuleFilters().setSearchText(null); eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getMaxMinIconId( - * ) - */ @Override protected String getMaxMinIconId() { return SPUIComponetIdProvider.SW_MAX_MIN_TABLE_ICON; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#maximizeTable() - */ @Override public void maximizeTable() { artifactUploadState.setSwModuleTableMaximized(Boolean.TRUE); @@ -250,58 +168,28 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#minimizeTable() - */ @Override public void minimizeTable() { artifactUploadState.setSwModuleTableMaximized(Boolean.FALSE); eventbus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.MINIMIZED, null)); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#onLoadIsTableMaximized( - * ) - */ @Override public Boolean onLoadIsTableMaximized() { return artifactUploadState.isSwModuleTableMaximized(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTableHeader# - * onLoadIsShowFilterButtonDisplayed() - */ @Override public Boolean onLoadIsShowFilterButtonDisplayed() { return artifactUploadState.isSwTypeFilterClosed(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#searchBy(java.lang. - * String) - */ @Override protected void searchBy(final String newSearchText) { artifactUploadState.getSoftwareModuleFilters().setSearchText(newSearchText); eventbus.publish(this, SMFilterEvent.FILTER_BY_TEXT); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#addNewItem(com.vaadin. - * ui.Button.ClickEvent) - */ @Override protected void addNewItem(final ClickEvent event) { final Window addSoftwareModule = softwareModuleAddUpdateWindow.createAddSoftwareModuleWindow(); @@ -310,11 +198,6 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { addSoftwareModule.setVisible(Boolean.TRUE); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#canAddNewItem() - */ @Override protected Boolean isAddNewItemAllowed() { return Boolean.TRUE; @@ -335,47 +218,21 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getBulkUploadIconId() - */ @Override protected String getBulkUploadIconId() { return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#bulkUpload(com. - * vaadin.ui.Button.ClickEvent ) - */ @Override protected void bulkUpload(final ClickEvent event) { - /** - * No implementation as no bulk upload is supported. - */ + // No implementation as no bulk upload is supported. } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isBulkUploadAllowed() - */ @Override protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# - * isBulkUploadInProgress() - */ @Override protected boolean isBulkUploadInProgress() { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java index 43c2452c2..9f2aa9602 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java @@ -35,8 +35,6 @@ import com.vaadin.spring.annotation.ViewScope; /** * Software module type filter buttons. * - * - * */ @SpringComponent @ViewScope @@ -59,6 +57,7 @@ public class SMTypeFilterButtons extends AbstractFilterButtons { * @param filterButtonClickBehaviour * the clickable behaviour. */ + @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); eventBus.subscribe(this); @@ -86,58 +85,28 @@ public class SMTypeFilterButtons extends AbstractFilterButtons { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.layouts.SPFilterButtons#getButtonsTableId() - */ @Override protected String getButtonsTableId() { return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.layouts.SPFilterButtons# - * createButtonsLazyQueryContainer() - */ @Override protected LazyQueryContainer createButtonsLazyQueryContainer() { return HawkbitCommonUtil.createLazyQueryContainer( new BeanQueryFactory(SoftwareModuleTypeBeanQuery.class)); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.layouts.SPFilterButtons#isClickedByDefault(java. - * lang.Long) - */ @Override protected boolean isClickedByDefault(final Long buttonId) { return artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && artifactUploadState .getSoftwareModuleFilters().getSoftwareModuleType().get().getId().equals(buttonId); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.layouts.SPFilterButtons#createButtonId(java.lang. - * String) - */ @Override protected String createButtonId(final String name) { return SPUIComponetIdProvider.SM_TYPE_FILTER_BTN_ID + name; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.filterlayout.SPFilterButtons# - * getFilterButtonDropHandler() - */ @Override protected DropHandler getFilterButtonDropHandler() { return new DropHandler() { @@ -155,13 +124,6 @@ public class SMTypeFilterButtons extends AbstractFilterButtons { }; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButttonWrapperId() - */ @Override protected String getButttonWrapperIdPrefix() { return SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java index d0292dd48..b79ecb742 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java @@ -28,9 +28,6 @@ import com.vaadin.ui.Window; /** * Software module type filter buttons header. - * - * - * */ @SpringComponent @ViewScope @@ -53,6 +50,7 @@ public class SMTypeFilterHeader extends AbstractFilterHeader { /** * Initialize the components. */ + @Override @PostConstruct protected void init() { super.init(); @@ -61,32 +59,16 @@ public class SMTypeFilterHeader extends AbstractFilterHeader { } } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.layouts.SPFilterHeader#hasCreateUpdatePermission() - */ @Override protected boolean hasCreateUpdatePermission() { return permChecker.hasCreateDistributionPermission() || permChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.layouts.SPFilterHeader#getTitle() - */ @Override protected String getTitle() { return SPUILabelDefinitions.TYPE; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.layouts.SPFilterHeader#settingsIconClicked(com. - * vaadin.ui.Button.ClickEvent ) - */ @Override protected void settingsIconClicked(final ClickEvent event) { final Window addUpdateWindow = createUpdateSWTypeLayout.getWindow(); @@ -94,58 +76,27 @@ public class SMTypeFilterHeader extends AbstractFilterHeader { addUpdateWindow.setVisible(Boolean.TRUE); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.layouts.SPFilterHeader#dropHitsRequired() - */ @Override protected boolean dropHitsRequired() { return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.filterlayout.SPFilterHeader# - * hideFilterButtonLayout() - */ @Override protected void hideFilterButtonLayout() { artifactUploadState.setSwTypeFilterClosed(true); eventbus.publish(this, UploadArtifactUIEvent.HIDE_FILTER_BY_TYPE); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.filterlayout.SPFilterHeader# - * getConfigureFilterButtonId() - */ @Override protected String getConfigureFilterButtonId() { return SPUIDefinitions.ADD_SOFTWARE_MODULE_TYPE; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getHideButtonId() - */ @Override protected String getHideButtonId() { return SPUIComponetIdProvider.SM_SHOW_FILTER_BUTTON_ID; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader# - * isAddTagRequired() - */ @Override protected boolean isAddTagRequired() { return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java index 7ee6de97c..c0f42909d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java @@ -29,9 +29,6 @@ import com.vaadin.ui.themes.ValoTheme; * * module. * - * - * - * */ public class ConfirmationDialog implements Button.ClickListener { /** Serial version UID. */ @@ -127,6 +124,7 @@ public class ConfirmationDialog implements Button.ClickListener { * @param event * the click event. */ + @Override public void buttonClick(final ClickEvent event) { if (window.getParent() != null) { UI.getCurrent().removeWindow(window); @@ -146,6 +144,7 @@ public class ConfirmationDialog implements Button.ClickListener { /** * Interface for confirmation dialog callbacks. */ + @FunctionalInterface public interface ConfirmationDialogCallback { /** * The user response. diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java index af02169f0..c8824e455 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java @@ -87,34 +87,16 @@ public class DistributionTagToken extends AbstractTagToken { } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.tagDetails.AbstractTagToken#getTagStyleName - * () - */ @Override protected String getTagStyleName() { return "distribution-tag-"; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.tagDetails.AbstractTagToken# - * getTokenInputPrompt() - */ @Override protected String getTokenInputPrompt() { return i18n.get("combo.type.tag.name"); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.tagDetails.AbstractTagToken#assignTag(java. - * lang.String) - */ @Override protected void assignTag(final String tagNameSelected) { if (tagNameSelected != null) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java index e96a2824f..ee0fa0a93 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java @@ -14,29 +14,11 @@ import com.vaadin.ui.themes.ValoTheme; /** * Style for button: Primary. - * - * - * - * - * - * */ public class SPUIButtonStylePrimarySmall implements SPUIButtonDecorator { - /** - * Decorate Button and return. - * - * @param button - * as Button - * @param style - * as String - * @param setStyle - * as String - * @param icon - * as resource - * @return Button - */ - public Button decorate(Button button, String style, boolean setStyle, Resource icon) { + @Override + public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) { button.addStyleName(ValoTheme.BUTTON_PRIMARY + " " + ValoTheme.BUTTON_SMALL); // Set Style if (null != style) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java index 5b67572c9..6166dbf5a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java @@ -14,29 +14,12 @@ import com.vaadin.ui.themes.ValoTheme; /** * Style for button: Small. - * - * - * - * - * * */ public class SPUIButtonStyleSmall implements SPUIButtonDecorator { - /** - * Decorate Button and return. - * - * @param button - * as Button - * @param style - * as String - * @param setStyle - * as String - * @param icon - * as resource - * @return Button - */ - public Button decorate(Button button, String style, boolean setStyle, Resource icon) { + @Override + public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) { button.addStyleName(ValoTheme.BUTTON_SMALL); // Set Style if (null != style) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java index 612f954cf..5b4dae0a3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java @@ -14,29 +14,12 @@ import com.vaadin.ui.themes.ValoTheme; /** * Style for button: Small NoBorder Height UnDefined. - * - * - * - * - * * */ public class SPUIButtonStyleSmallNoBorderUH implements SPUIButtonDecorator { - /** - * Decorate Button and return. - * - * @param button - * as Button - * @param style - * as String - * @param setStyle - * as String - * @param icon - * as resource - * @return Button - */ - public Button decorate(Button button, String style, boolean setStyle, Resource icon) { + @Override + public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) { button.addStyleName(ValoTheme.BUTTON_SMALL); button.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); button.setHeightUndefined(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java index e75fdcfa8..f06fbd413 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java @@ -14,29 +14,12 @@ import com.vaadin.ui.themes.ValoTheme; /** * Style for button: Small NoBorder Height and size UnDefined. - * - * - * - * - * * */ public class SPUIButtonStyleSmallNoBorderUHS implements SPUIButtonDecorator { - /** - * Decorate Button and return. - * - * @param button - * as Button - * @param style - * as String - * @param setStyle - * as String - * @param icon - * as resource - * @return Button - */ - public Button decorate(Button button, String style, boolean setStyle, Resource icon) { + @Override + public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) { button.addStyleName(ValoTheme.BUTTON_SMALL); button.addStyleName(ValoTheme.BUTTON_BORDERLESS); button.setHeightUndefined(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java index 4dbe4b304..eaa319929 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java @@ -14,29 +14,12 @@ import com.vaadin.ui.themes.ValoTheme; /** * Style for button: Small. - * - * - * - * - * * */ public class SPUIButtonStyleTiny implements SPUIButtonDecorator { - /** - * Decorate Button and return. - * - * @param button - * as Button - * @param style - * as String - * @param setStyle - * as String - * @param icon - * as resource - * @return Button - */ - public Button decorate(Button button, String style, boolean setStyle, Resource icon) { + @Override + public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) { button.addStyleName(ValoTheme.BUTTON_TINY); // Set Style if (null != style) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java index 2ecca2b4f..014bdbfb9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java @@ -16,27 +16,10 @@ import com.vaadin.ui.themes.ValoTheme; /** * Style for button: Tag. - * - * - * - * - * - * */ public class SPUITagButtonStyle implements SPUIButtonDecorator { - /** - * Decorate Button and return. - * - * @param button - * as Button - * @param style - * as String - * @param setStyle - * as String - * @param icon - * as resource - * @return Button - */ + + @Override public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) { /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index ff52208c6..4fed0dd4b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -474,7 +474,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co @SuppressWarnings("unchecked") private void getSelectedTableItemData(final Long id) { - Item saveTblitem = null; + Item saveTblitem; if (null != selectedTablecontainer) { saveTblitem = selectedTablecontainer.addItem(id); saveTblitem.getItemProperty(DIST_TYPE_NAME).setValue( diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java index 542c4c12d..cd36918e8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java @@ -60,44 +60,24 @@ public class DSTypeFilterButtons extends AbstractFilterButtons { * @param filterButtonClickBehaviour * the clickable behaviour. */ + @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); eventBus.subscribe(this); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButtonsTableId() - */ @Override protected String getButtonsTableId() { return SPUIComponetIdProvider.DISTRIBUTION_SET_TYPE_TABLE_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonsLazyQueryContainer () - */ @Override protected LazyQueryContainer createButtonsLazyQueryContainer() { return HawkbitCommonUtil.createLazyQueryContainer( new BeanQueryFactory(DistributionSetTypeBeanQuery.class)); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * isClickedByDefault(java.lang .Long) - */ @Override protected boolean isClickedByDefault(final Long buttonId) { @@ -105,26 +85,12 @@ public class DSTypeFilterButtons extends AbstractFilterButtons { && manageDistUIState.getManageDistFilters().getClickedDistSetType().getId().equals(buttonId); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * createButtonId(java.lang. String) - */ @Override protected String createButtonId(final String name) { return SPUIComponetIdProvider.DS_TYPE_FILTER_BTN_ID + name; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getFilterButtonDropHandler() - */ @Override protected DropHandler getFilterButtonDropHandler() { @@ -148,13 +114,6 @@ public class DSTypeFilterButtons extends AbstractFilterButtons { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterButtons# - * getButttonWrapperId() - */ @Override protected String getButttonWrapperIdPrefix() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java index 9092293db..068c28065 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java @@ -27,9 +27,6 @@ import com.vaadin.ui.Window; /** * Distribution Set Type filter buttons header. - * - * - * */ @SpringComponent @ViewScope @@ -49,9 +46,7 @@ public class DSTypeFilterHeader extends AbstractFilterHeader { @Autowired private CreateUpdateDistSetTypeLayout createUpdateDistSetTypeLayout; - /** - * Initialize the components. - */ + @Override @PostConstruct public void init() { super.init(); @@ -60,37 +55,16 @@ public class DSTypeFilterHeader extends AbstractFilterHeader { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hasCreateUpdatePermission() - */ @Override protected boolean hasCreateUpdatePermission() { - return permChecker.hasCreateDistributionPermission() || permChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.filterlayout.AbstractFilterHeader#getTitle( - * ) - */ @Override protected String getTitle() { return SPUILabelDefinitions.TYPE; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * settingsIconClicked(com.vaadin .ui.Button.ClickEvent) - */ @Override protected void settingsIconClicked(final ClickEvent event) { final Window addUpdateWindow = createUpdateDistSetTypeLayout.getWindow(); @@ -99,25 +73,11 @@ public class DSTypeFilterHeader extends AbstractFilterHeader { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * dropHitsRequired() - */ @Override protected boolean dropHitsRequired() { return false; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hideFilterButtonLayout() - */ @Override protected void hideFilterButtonLayout() { manageDistUIState.setDistTypeFilterClosed(true); @@ -125,38 +85,17 @@ public class DSTypeFilterHeader extends AbstractFilterHeader { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getConfigureFilterButtonId() - */ @Override protected String getConfigureFilterButtonId() { return SPUIDefinitions.ADD_DISTRIBUTION_TYPE_TAG; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getHideButtonId() - */ @Override protected String getHideButtonId() { - return SPUIDefinitions.HIDE_FILTER_DIST_TYPE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader# - * isAddTagRequired() - */ @Override protected boolean isAddTagRequired() { return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java index a39f32f6e..f8cb7a45b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java @@ -36,8 +36,6 @@ import com.vaadin.ui.Window; /** * Distribution table header. - * - * */ @SpringComponent @ViewScope @@ -60,9 +58,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { @Autowired private DistributionAddUpdateWindowLayout addUpdateWindowLayout; - /** - * Initialize the component. - */ + @Override @PostConstruct protected void init() { super.init(); @@ -76,54 +72,26 @@ public class DistributionSetTableHeader extends AbstractTableHeader { } } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getHeaderCaption( - * ) - */ @Override protected String getHeaderCaption() { return i18n.get("header.dist.table"); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getSearchBoxId() - */ @Override protected String getSearchBoxId() { return SPUIComponetIdProvider.DIST_SEARCH_TEXTFIELD; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getSearchRestIconId() - */ @Override protected String getSearchRestIconId() { return SPUIComponetIdProvider.DIST_SEARCH_ICON; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getAddIconId() - */ @Override protected String getAddIconId() { return SPUIComponetIdProvider.DIST_ADD_ICON; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * onLoadSearchBoxValue() - */ @Override protected String onLoadSearchBoxValue() { if (manageDistUIstate.getManageDistFilters().getSearchText().isPresent()) { @@ -132,11 +100,6 @@ public class DistributionSetTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getDropFilterId() - */ @Override protected String getDropFilterId() { return null; @@ -170,7 +133,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { @Override protected void resetSearchText() { - if(manageDistUIstate.getManageDistFilters().getSearchText().isPresent()){ + if (manageDistUIstate.getManageDistFilters().getSearchText().isPresent()) { manageDistUIstate.getManageDistFilters().setSearchText(null); eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT); } @@ -223,11 +186,6 @@ public class DistributionSetTableHeader extends AbstractTableHeader { eventbus.unsubscribe(this); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#canAddNewItem() - */ @Override protected Boolean isAddNewItemAllowed() { return Boolean.TRUE; @@ -248,47 +206,21 @@ public class DistributionSetTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getBulkUploadIconId() - */ @Override protected String getBulkUploadIconId() { return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#bulkUpload(com. - * vaadin.ui.Button.ClickEvent ) - */ @Override protected void bulkUpload(final ClickEvent event) { - /** - * No implementation as no bulk upload is supported. - */ + // No implementation as no bulk upload is supported. } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isBulkUploadAllowed() - */ @Override protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# - * isBulkUploadInProgress() - */ @Override protected boolean isBulkUploadInProgress() { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java index 9d31763ff..3b1a2cad6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java @@ -39,9 +39,6 @@ import com.vaadin.ui.Window; /** * Implementation of software module details block using generic abstract * details style . - * - * - * */ @SpringComponent @ViewScope @@ -70,9 +67,7 @@ public class SwModuleDetails extends AbstractTableDetailsLayout { private SoftwareModule selectedSwModule; - /** - * Initialize the component. - */ + @Override @PostConstruct protected void init() { super.init(); @@ -133,49 +128,21 @@ public class SwModuleDetails extends AbstractTableDetailsLayout { detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout# - * getDefaultCaption() - */ @Override protected String getDefaultCaption() { return i18n.get("upload.swModuleTable.header"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout# - * onLoadIsSwModuleSelected() - */ @Override protected Boolean onLoadIsTableRowSelected() { return !manageDistUIState.getSelectedSoftwareModules().isEmpty(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout# - * onLoadIsTableMaximized() - */ @Override protected Boolean onLoadIsTableMaximized() { return manageDistUIState.isSwModuleTableMaximized(); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.detailslayout.TableDetailsLayout# - * populateDetailsWidget() - */ @Override protected void populateDetailsWidget() { populateDetailsWidget(selectedSwModule); @@ -191,12 +158,6 @@ public class SwModuleDetails extends AbstractTableDetailsLayout { return permissionChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * getTabSheetId() - */ @Override protected String getTabSheetId() { return null; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java index d8d018e27..56d7706fc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java @@ -36,9 +36,6 @@ import com.vaadin.ui.Window; /** * Implementation of software module Header block using generic abstract details * style . - * - * - * */ @SpringComponent @ViewScope @@ -61,9 +58,7 @@ public class SwModuleTableHeader extends AbstractTableHeader { @Autowired private SoftwareModuleAddUpdateWindow softwareModuleAddUpdateWindow; - /** - * Initialize the components. - */ + @Override @PostConstruct protected void init() { super.init(); @@ -82,45 +77,21 @@ public class SwModuleTableHeader extends AbstractTableHeader { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getHeaderCaption - * () - */ @Override protected String getHeaderCaption() { return i18n.get("upload.swModuleTable.header"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getSearchBoxId() - */ @Override protected String getSearchBoxId() { return SPUIComponetIdProvider.SW_MODULE_SEARCH_TEXT_FIELD; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#getSearchRestIconId() - */ @Override protected String getSearchRestIconId() { return SPUIComponetIdProvider.SW_MODULE_SEARCH_RESET_ICON; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getAddIconId() - */ @Override protected String getAddIconId() { return SPUIComponetIdProvider.SW_MODULE_ADD_BUTTON; @@ -134,99 +105,47 @@ public class SwModuleTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getDropFilterId( - * ) - */ @Override protected String getDropFilterId() { /* not required */ return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isDropHintRequired() - */ @Override protected boolean isDropHintRequired() { - /* not required */ return false; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#isDropFilterRequired() - */ @Override protected boolean isDropFilterRequired() { /* Not Yet Implemented */ return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTableHeader# - * getShowFilterButtonLayoutId() - */ @Override protected String getShowFilterButtonLayoutId() { return "show.type.icon"; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#showFilterButtonsLayout - * () - */ @Override protected void showFilterButtonsLayout() { manageDistUIState.setSwTypeFilterClosed(false); eventbus.publish(this, DistributionsUIEvent.SHOW_SM_FILTER_BY_TYPE); - } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#resetSearchText( - * ) - */ @Override protected void resetSearchText() { - if(manageDistUIState.getSoftwareModuleFilters().getSearchText().isPresent()){ + if (manageDistUIState.getSoftwareModuleFilters().getSearchText().isPresent()) { manageDistUIState.getSoftwareModuleFilters().setSearchText(null); eventbus.publish(this, SMFilterEvent.REMOVER_FILTER_BY_TEXT); } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#getMaxMinIconId( - * ) - */ @Override protected String getMaxMinIconId() { return SPUIComponetIdProvider.SW_MAX_MIN_TABLE_ICON; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#maximizeTable() - */ @Override public void maximizeTable() { manageDistUIState.setSwModuleTableMaximized(Boolean.TRUE); @@ -234,58 +153,28 @@ public class SwModuleTableHeader extends AbstractTableHeader { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.table.SPTableHeader#minimizeTable() - */ @Override public void minimizeTable() { manageDistUIState.setSwModuleTableMaximized(Boolean.FALSE); eventbus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.MINIMIZED, null)); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#onLoadIsTableMaximized( - * ) - */ @Override public Boolean onLoadIsTableMaximized() { return manageDistUIState.isSwModuleTableMaximized(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.SPTableHeader# - * onLoadIsShowFilterButtonDisplayed() - */ @Override public Boolean onLoadIsShowFilterButtonDisplayed() { return manageDistUIState.isSwTypeFilterClosed(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#searchBy(java.lang. - * String) - */ @Override protected void searchBy(final String newSearchText) { manageDistUIState.getSoftwareModuleFilters().setSearchText(newSearchText); eventbus.publish(this, SMFilterEvent.FILTER_BY_TEXT); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#addNewItem(com.vaadin. - * ui.Button.ClickEvent) - */ @Override protected void addNewItem(final ClickEvent event) { final Window addSoftwareModule = softwareModuleAddUpdateWindow.createAddSoftwareModuleWindow(); @@ -294,22 +183,11 @@ public class SwModuleTableHeader extends AbstractTableHeader { addSoftwareModule.setVisible(Boolean.TRUE); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.SPTableHeader#hasCreatePermission() - */ @Override protected boolean hasCreatePermission() { return permChecker.hasCreateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isAddNewItemAllowed() - */ @Override protected Boolean isAddNewItemAllowed() { return true; @@ -330,47 +208,21 @@ public class SwModuleTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getBulkUploadIconId() - */ @Override protected String getBulkUploadIconId() { return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#bulkUpload(com. - * vaadin.ui.Button.ClickEvent ) - */ @Override protected void bulkUpload(final ClickEvent event) { - /** - * No implementation as no bulk upload is supported. - */ + // No implementation as no bulk upload is supported. } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isBulkUploadAllowed() - */ @Override protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# - * isBulkUploadInProgress() - */ @Override protected boolean isBulkUploadInProgress() { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java index 53d6555da..d3251cf9b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java @@ -56,12 +56,6 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { @Autowired private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria; - /** - * Initialize component. - * - * @param filterButtonClickBehaviour - * the clickable behaviour. - */ @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); @@ -70,7 +64,6 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { @Override protected String getButtonsTableId() { - return SPUIComponetIdProvider.SW_MODULE_TYPE_TABLE_ID; } @@ -120,7 +113,6 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons { @Override protected String getButttonWrapperIdPrefix() { - return SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java index 316d30f64..edf20b206 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java @@ -29,9 +29,6 @@ import com.vaadin.ui.Window; /** * Software Module Type filter buttons header. - * - * - * */ @SpringComponent @ViewScope @@ -51,9 +48,7 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader { @Autowired private CreateUpdateSoftwareTypeLayout createUpdateSWTypeLayout; - /** - * Initialize the components. - */ + @Override @PostConstruct public void init() { super.init(); @@ -62,50 +57,21 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getHideButtonId() - */ @Override protected String getHideButtonId() { return SPUIComponetIdProvider.SM_SHOW_FILTER_BUTTON_ID; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hasCreateUpdatePermission() - */ @Override protected boolean hasCreateUpdatePermission() { - return permChecker.hasCreateDistributionPermission() || permChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.filterlayout.AbstractFilterHeader#getTitle( - * ) - */ @Override protected String getTitle() { - return SPUILabelDefinitions.TYPE; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * settingsIconClicked(com.vaadin .ui.Button.ClickEvent) - */ @Override protected void settingsIconClicked(final ClickEvent event) { final Window addUpdateWindow = createUpdateSWTypeLayout.getWindow(); @@ -114,51 +80,22 @@ public class DistSMTypeFilterHeader extends AbstractFilterHeader { } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * dropHitsRequired() - */ @Override protected boolean dropHitsRequired() { - return false; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hideFilterButtonLayout() - */ @Override protected void hideFilterButtonLayout() { manageDistUIState.setSwTypeFilterClosed(true); eventBus.publish(this, DistributionsUIEvent.HIDE_SM_FILTER_BY_TYPE); - } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getConfigureFilterButtonId() - */ @Override protected String getConfigureFilterButtonId() { return SPUIDefinitions.ADD_SOFTWARE_MODULE_TYPE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader# - * isAddTagRequired() - */ @Override protected boolean isAddTagRequired() { return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java index 54d549055..ecc4a26c6 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java @@ -39,9 +39,6 @@ import com.vaadin.ui.Window; /** * Distribution set details layout. - * - * - * */ @SpringComponent @ViewScope @@ -75,9 +72,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { private UI ui; - /** - * softwareLayout Initialize the component. - */ + @Override @PostConstruct protected void init() { eventBus.subscribe(this); @@ -116,23 +111,11 @@ public class DistributionDetails extends AbstractTableDetailsLayout { } } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * getDefaultCaption() - */ @Override protected String getDefaultCaption() { return i18n.get("distribution.details.header"); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * addTabs(com.vaadin. ui.TabSheet) - */ @Override protected void addTabs(final TabSheet detailsTab) { detailsTab.addTab(createDetailsLayout(), i18n.get("caption.tab.details"), null); @@ -142,12 +125,6 @@ public class DistributionDetails extends AbstractTableDetailsLayout { detailsTab.addTab(createLogLayout(), i18n.get("caption.logs.tab"), null); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * onEdit(com.vaadin.ui .Button.ClickEvent) - */ @Override protected void onEdit(final ClickEvent event) { final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(); @@ -157,79 +134,37 @@ public class DistributionDetails extends AbstractTableDetailsLayout { newDistWindow.setVisible(Boolean.TRUE); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * getEditButtonId() - */ @Override protected String getEditButtonId() { return SPUIComponetIdProvider.DS_EDIT_BUTTON; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * onLoadIsTableRowSelected () - */ @Override protected Boolean onLoadIsTableRowSelected() { return !(managementUIState.getSelectedDsIdName().isPresent() && managementUIState.getSelectedDsIdName().get().isEmpty()); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * onLoadIsTableMaximized () - */ @Override protected Boolean onLoadIsTableMaximized() { return managementUIState.isDsTableMaximized(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * populateDetailsWidget() - */ @Override protected void populateDetailsWidget() { populateDetailsWidget(selectedDsModule); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * clearDetails() - */ @Override protected void clearDetails() { populateDetailsWidget(null); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * hasEditPermission() - */ @Override protected Boolean hasEditPermission() { return permissionChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# - * getTabSheetId() - */ @Override protected String getTabSheetId() { return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_TABSHEET; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java index 00be91ca4..4f4aa8b2f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -73,7 +73,6 @@ import com.vaadin.ui.UI; /** * Distribution set table. - * */ @SpringComponent @ViewScope @@ -111,9 +110,6 @@ public class DistributionTable extends AbstractTable { private Button distributinPinnedBtn; - /** - * Initialize the distribution table. - */ @Override @PostConstruct protected void init() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java index 32a3e914d..d2ac628a8 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java @@ -58,9 +58,7 @@ public class DistributionTableHeader extends AbstractTableHeader { @Autowired private DistributionAddUpdateWindowLayout distributionAddUpdateWindowLayout; - /** - * Initialize the component. - */ + @Override @PostConstruct protected void init() { super.init(); @@ -81,54 +79,26 @@ public class DistributionTableHeader extends AbstractTableHeader { } } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getHeaderCaption( - * ) - */ @Override protected String getHeaderCaption() { return i18n.get("header.dist.table"); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getSearchBoxId() - */ @Override protected String getSearchBoxId() { return SPUIComponetIdProvider.DIST_SEARCH_TEXTFIELD; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getSearchRestIconId() - */ @Override protected String getSearchRestIconId() { return SPUIComponetIdProvider.DIST_SEARCH_ICON; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getAddIconId() - */ @Override protected String getAddIconId() { return SPUIComponetIdProvider.DIST_ADD_ICON; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * onLoadSearchBoxValue() - */ @Override protected String onLoadSearchBoxValue() { if (managementUIState.getDistributionTableFilters().getSearchText().isPresent()) { @@ -137,157 +107,78 @@ public class DistributionTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getDropFilterId() - */ @Override protected String getDropFilterId() { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * hasCreatePermission() - */ @Override protected boolean hasCreatePermission() { return permChecker.hasCreateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isDropHintRequired() - */ @Override protected boolean isDropHintRequired() { return true; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isDropFilterRequired() - */ @Override protected boolean isDropFilterRequired() { return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getShowFilterButtonLayoutId() - */ @Override protected String getShowFilterButtonLayoutId() { return "show.dist.tags.icon"; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * showFilterButtonsLayout() - */ @Override protected void showFilterButtonsLayout() { managementUIState.setDistTagFilterClosed(false); eventbus.publish(this, ManagementUIEvent.SHOW_DISTRIBUTION_TAG_LAYOUT); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#resetSearchText() - */ @Override protected void resetSearchText() { - if( managementUIState.getDistributionTableFilters().getSearchText().isPresent()){ + if (managementUIState.getDistributionTableFilters().getSearchText().isPresent()) { managementUIState.getDistributionTableFilters().setSearchText(null); eventbus.publish(this, DistributionTableFilterEvent.REMOVE_FILTER_BY_TEXT); } } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#getMaxMinIconId() - */ @Override protected String getMaxMinIconId() { return SPUIComponetIdProvider.DS_MAX_MIN_TABLE_ICON; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#maximizeTable() - */ @Override public void maximizeTable() { managementUIState.setDsTableMaximized(Boolean.TRUE); eventbus.publish(this, new DistributionTableEvent(DistributionComponentEvent.MAXIMIZED, null)); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#minimizeTable() - */ @Override public void minimizeTable() { managementUIState.setDsTableMaximized(Boolean.FALSE); eventbus.publish(this, new DistributionTableEvent(DistributionComponentEvent.MINIMIZED, null)); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * onLoadIsTableMaximized() - */ @Override public Boolean onLoadIsTableMaximized() { return managementUIState.isDsTableMaximized(); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * onLoadIsShowFilterButtonDisplayed() - */ @Override public Boolean onLoadIsShowFilterButtonDisplayed() { return managementUIState.isDistTagFilterClosed(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#searchBy(java. - * lang.String) - */ @Override protected void searchBy(final String newSearchText) { managementUIState.getDistributionTableFilters().setSearchText(newSearchText); eventbus.publish(this, DistributionTableFilterEvent.FILTER_BY_TEXT); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#addNewItem(com. - * vaadin.ui.Button.ClickEvent ) - */ @Override protected void addNewItem(final ClickEvent event) { final Window newDistWindow = distributionAddUpdateWindowLayout.getWindow(); @@ -297,12 +188,6 @@ public class DistributionTableHeader extends AbstractTableHeader { eventbus.publish(this, DragEvent.HIDE_DROP_HINT); } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isAddNewItemAllowed() - */ @Override protected Boolean isAddNewItemAllowed() { return Boolean.FALSE; @@ -323,47 +208,21 @@ public class DistributionTableHeader extends AbstractTableHeader { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * getBulkUploadIconId() - */ @Override protected String getBulkUploadIconId() { return null; } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.table.AbstractTableHeader#bulkUpload(com. - * vaadin.ui.Button.ClickEvent ) - */ @Override protected void bulkUpload(final ClickEvent event) { - /** - * No implementation as no bulk upload is supported. - */ + // No implementation as no bulk upload is supported. } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# - * isBulkUploadAllowed() - */ @Override protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# - * isBulkUploadInProgress() - */ @Override protected boolean isBulkUploadInProgress() { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java index 3c1bfcd0a..98c48d235 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java @@ -64,12 +64,6 @@ public class DistributionTagButtons extends AbstractFilterButtons { @Autowired private ManagementUIState managementUIState; - /** - * Initialize component. - * - * @param filterButtonClickBehaviour - * the clickable behaviour. - */ @Override public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) { super.init(filterButtonClickBehaviour); @@ -99,7 +93,6 @@ public class DistributionTagButtons extends AbstractFilterButtons { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final DragEvent dragEvent) { - if (dragEvent == DragEvent.DISTRIBUTION_DRAG) { UI.getCurrent().access(() -> addStyleName(SPUIStyleDefinitions.SHOW_DROP_HINT_FILTER_BUTTON)); } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java index 5e19e05f8..2d58849dc 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java @@ -50,9 +50,7 @@ public class DistributionTagHeader extends AbstractFilterHeader { @Autowired private CreateUpdateDistributionTagLayoutWindow createORUpdateDistributionTagLayout; - /** - * Initialize the components. - */ + @Override @PostConstruct public void init() { super.init(); @@ -61,100 +59,45 @@ public class DistributionTagHeader extends AbstractFilterHeader { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getHideButtonId() - */ @Override protected String getHideButtonId() { return "hide.distribution.tags"; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hasCreateUpdatePermission() - */ @Override protected boolean hasCreateUpdatePermission() { return permChecker.hasCreateDistributionPermission() || permChecker.hasUpdateDistributionPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.filterlayout.AbstractFilterHeader#getTitle( - * ) - */ @Override protected String getTitle() { return i18n.get("header.filter.tag", new Object[] {}); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * settingsIconClicked(com.vaadin .ui.Button.ClickEvent) - */ @Override protected void settingsIconClicked(final ClickEvent event) { final Window addUpdateWindow = createORUpdateDistributionTagLayout.getWindow(); UI.getCurrent().addWindow(addUpdateWindow); addUpdateWindow.setModal(true); addUpdateWindow.setVisible(Boolean.TRUE); - } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * dropHitsRequired() - */ @Override protected boolean dropHitsRequired() { return true; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hideFilterButtonLayout() - */ @Override protected void hideFilterButtonLayout() { managementUIState.setDistTagFilterClosed(true); eventbus.publish(this, ManagementUIEvent.HIDE_DISTRIBUTION_TAG_LAYOUT); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getConfigureFilterButtonId() - */ @Override protected String getConfigureFilterButtonId() { return SPUIComponetIdProvider.ADD_DISTRIBUTION_TAG; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader# - * isAddTagRequired() - */ @Override protected boolean isAddTagRequired() { return true; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java index f0cdbdd23..05b6bfe4d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -89,9 +89,6 @@ public class TargetTableHeader extends AbstractTableHeader { private Boolean isComplexFilterViewDisplayed = Boolean.FALSE; - /** - * Initialization of Target Header Component. - */ @Override @PostConstruct protected void init() { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java index 5175f5f60..7d0b5c76c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java @@ -25,9 +25,6 @@ import com.vaadin.ui.Button.ClickEvent; /** * Target Tag filter by Tag Header. - * - * - * */ @SpringComponent @ViewScope @@ -50,9 +47,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader { @Autowired private ManagementUIState managementUIState; - /** - * Initialize Tag Header. - */ + @Override @PostConstruct public void init() { super.init(); @@ -61,101 +56,45 @@ public class TargetTagFilterHeader extends AbstractFilterHeader { } } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getHideButtonId() - */ @Override protected String getHideButtonId() { return SPUIComponetIdProvider.HIDE_TARGET_TAGS; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hasCreateUpdatePermission() - */ @Override protected boolean hasCreateUpdatePermission() { return permChecker.hasCreateTargetPermission() || permChecker.hasUpdateTargetPermission(); } - /* - * (non-Javadoc) - * - * @see hawkbit.server.ui.common.filterlayout.AbstractFilterHeader#getTitle( - * ) - */ @Override protected String getTitle() { return i18n.get("header.target.filter.tag", new Object[] {}); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * settingsIconClicked(com.vaadin .ui.Button.ClickEvent) - */ @Override protected void settingsIconClicked(final ClickEvent event) { - /** - * Add tag icon not displayed. - */ + // Add tag icon not displayed. } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * dropHitsRequired() - */ @Override protected boolean dropHitsRequired() { return true; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * hideFilterButtonLayout() - */ @Override protected void hideFilterButtonLayout() { managementUIState.setTargetTagFilterClosed(true); eventbus.publish(this, ManagementUIEvent.HIDE_TARGET_TAG_LAYOUT); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.server.ui.common.filterlayout.AbstractFilterHeader# - * getConfigureFilterButtonId() - */ @Override protected String getConfigureFilterButtonId() { return null; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterHeader# - * isAddTagRequired() - */ @Override protected boolean isAddTagRequired() { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRollout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRollout.java index efe065b85..92f30293a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRollout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRollout.java @@ -24,10 +24,6 @@ public class ProxyRollout extends Rollout { private String modifiedDate; - private String createdBy; - - private String lastModifiedBy; - private Long numberOfGroups; private Long runningTargetsCount; @@ -106,36 +102,6 @@ public class ProxyRollout extends Rollout { this.modifiedDate = modifiedDate; } - /** - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * @param createdBy - * the createdBy to set - */ - public void setCreatedBy(final String createdBy) { - this.createdBy = createdBy; - } - - /** - * @return the lastModifiedBy - */ - public String getLastModifiedBy() { - return lastModifiedBy; - } - - /** - * @param lastModifiedBy - * the lastModifiedBy to set - */ - public void setLastModifiedBy(final String lastModifiedBy) { - this.lastModifiedBy = lastModifiedBy; - } - /** * @return the runningTargetsCount */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRolloutGroup.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRolloutGroup.java index 8373fcf08..da49d843a 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRolloutGroup.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/ProxyRolloutGroup.java @@ -22,10 +22,6 @@ public class ProxyRolloutGroup extends RolloutGroup { private String modifiedDate; - private String createdBy; - - private String lastModifiedBy; - private String finishedPercentage; private Long runningTargetsCount; @@ -74,36 +70,6 @@ public class ProxyRolloutGroup extends RolloutGroup { this.modifiedDate = modifiedDate; } - /** - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * @param createdBy - * the createdBy to set - */ - public void setCreatedBy(final String createdBy) { - this.createdBy = createdBy; - } - - /** - * @return the lastModifiedBy - */ - public String getLastModifiedBy() { - return lastModifiedBy; - } - - /** - * @param lastModifiedBy - * the lastModifiedBy to set - */ - public void setLastModifiedBy(final String lastModifiedBy) { - this.lastModifiedBy = lastModifiedBy; - } - /** * @return the finishedPercentage */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListHeader.java index 562569136..19a504384 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListHeader.java @@ -53,6 +53,7 @@ public class RolloutGroupTargetsListHeader extends AbstractSimpleTableHeader { private Button rolloutsGroupViewLink; private Label headerCaption; + @Override @PostConstruct protected void init() { super.init(); @@ -78,8 +79,8 @@ public class RolloutGroupTargetsListHeader extends AbstractSimpleTableHeader { headerCaption.setCaption(rolloutGroup.getName()); } - rolloutsGroupViewLink.setCaption(rolloutUiState.getRolloutName().isPresent() ? rolloutUiState.getRolloutName() - .get() : ""); + rolloutsGroupViewLink + .setCaption(rolloutUiState.getRolloutName().isPresent() ? rolloutUiState.getRolloutName().get() : ""); } @Override @@ -103,9 +104,7 @@ public class RolloutGroupTargetsListHeader extends AbstractSimpleTableHeader { @Override protected void searchBy(final String newSearchText) { - /** - * No implementation required. - */ + // No implementation required. } @@ -162,12 +161,6 @@ public class RolloutGroupTargetsListHeader extends AbstractSimpleTableHeader { return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.rollout.AbstractSimpleTableHeader# - * getHeaderCaptionLayout() - */ @Override protected HorizontalLayout getHeaderCaptionLayout() { headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION); @@ -204,12 +197,6 @@ public class RolloutGroupTargetsListHeader extends AbstractSimpleTableHeader { eventBus.publish(this, RolloutEvent.SHOW_ROLLOUTS); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.ui.rollout.AbstractSimpleTableHeader#restoreCaption() - */ @Override protected void restoreCaption() { setCaptionDetails(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListTable.java index 95eba8380..bb037231b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupTargetsListTable.java @@ -61,6 +61,7 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { @Autowired private transient RolloutUIState rolloutUIState; + @Override @PostConstruct protected void init() { super.init(); @@ -88,8 +89,8 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.15f)); columnList .add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.15f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), - 0.15f)); + columnList.add( + new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.15f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.15f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_TARGET_STATUS, i18n.get("header.status"), 0.1f)); @@ -101,15 +102,16 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { protected Container createContainer() { final BeanQueryFactory rolloutgrouBeanQueryFactory = new BeanQueryFactory<>( RolloutGroupTargetsBeanQuery.class); - return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, - SPUILabelDefinitions.VAR_ID), rolloutgrouBeanQueryFactory); + return new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_ID), + rolloutgrouBeanQueryFactory); } @Override protected void addContainerProperties(final Container container) { final LazyQueryContainer rolloutGroupTargetTableContainer = (LazyQueryContainer) container; - rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", - false, false); + rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", false, + false); rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, true); rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, Status.class, @@ -124,10 +126,10 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { false, true); rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); - rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, + rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, + false, true); + rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); - rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, - String.class, null, false, true); rolloutGroupTargetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); } @@ -140,23 +142,20 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { @Override protected void onValueChange() { - /** - * No implementation required. - */ + // No implementation required. } @Override protected void addCustomGeneratedColumns() { - addGeneratedColumn(SPUILabelDefinitions.VAR_TARGET_STATUS, (source, itemId, columnId) -> getStatusLabel(itemId)); + addGeneratedColumn(SPUILabelDefinitions.VAR_TARGET_STATUS, + (source, itemId, columnId) -> getStatusLabel(itemId)); setColumnAlignment(SPUILabelDefinitions.VAR_TARGET_STATUS, Align.CENTER); } @Override protected void setCollapsiblecolumns() { - /** - * No implementation required. - */ + // No implementation required. } private Label getStatusLabel(final Object itemId) { @@ -171,8 +170,8 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { private void setStatusIcon(final Object itemId, final Label statusLabel) { final Item item = getItem(itemId); - final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent() ? rolloutUIState - .getRolloutGroup().get() : null; + final RolloutGroup rolloutGroup = rolloutUIState.getRolloutGroup().isPresent() + ? rolloutUIState.getRolloutGroup().get() : null; if (item != null) { final Status status = (Status) item.getItemProperty(SPUILabelDefinitions.VAR_STATUS).getValue(); if (status == null) { @@ -184,10 +183,10 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { statusLabel.setValue(FontAwesome.MINUS_CIRCLE.getHtml()); statusLabel.addStyleName("statusIconBlue"); - final String dsNameVersion = (String) item.getItemProperty( - SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER).getValue(); - statusLabel.setDescription(i18n - .get("message.dist.already.assigned", new Object[] { dsNameVersion })); + final String dsNameVersion = (String) item + .getItemProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER).getValue(); + statusLabel + .setDescription(i18n.get("message.dist.already.assigned", new Object[] { dsNameVersion })); } } else { setRolloutStatusIcon(status, statusLabel); @@ -197,36 +196,36 @@ public class RolloutGroupTargetsListTable extends AbstractSimpleTable { } private void setRolloutStatusIcon(final Status targetUpdateStatus, final Label statusLabel) { - switch (targetUpdateStatus) { - case ERROR: - statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); - statusLabel.addStyleName("statusIconRed"); - break; - case SCHEDULED: - statusLabel.setValue(FontAwesome.BULLSEYE.getHtml()); - statusLabel.addStyleName("statusIconBlue"); - break; - case FINISHED: - statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); - statusLabel.addStyleName("statusIconGreen"); - break; - case RUNNING: - case RETRIEVED: - case WARNING: - case DOWNLOAD: - statusLabel.setValue(FontAwesome.ADJUST.getHtml()); - statusLabel.addStyleName("statusIconYellow"); - break; - case CANCELED: - statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml()); - statusLabel.addStyleName("statusIconGreen"); - break; - case CANCELING: - statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml()); - statusLabel.addStyleName("statusIconPending"); - break; - default: - break; - } + switch (targetUpdateStatus) { + case ERROR: + statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); + statusLabel.addStyleName("statusIconRed"); + break; + case SCHEDULED: + statusLabel.setValue(FontAwesome.BULLSEYE.getHtml()); + statusLabel.addStyleName("statusIconBlue"); + break; + case FINISHED: + statusLabel.setValue(FontAwesome.CHECK_CIRCLE.getHtml()); + statusLabel.addStyleName("statusIconGreen"); + break; + case RUNNING: + case RETRIEVED: + case WARNING: + case DOWNLOAD: + statusLabel.setValue(FontAwesome.ADJUST.getHtml()); + statusLabel.addStyleName("statusIconYellow"); + break; + case CANCELED: + statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml()); + statusLabel.addStyleName("statusIconGreen"); + break; + case CANCELING: + statusLabel.setValue(FontAwesome.TIMES_CIRCLE.getHtml()); + statusLabel.addStyleName("statusIconPending"); + break; + default: + break; + } } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupsListHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupsListHeader.java index 58cc2a753..3c89518e1 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupsListHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutGroupsListHeader.java @@ -52,6 +52,7 @@ public class RolloutGroupsListHeader extends AbstractSimpleTableHeader { private Label headerCaption; + @Override @PostConstruct protected void init() { super.init(); @@ -71,54 +72,42 @@ public class RolloutGroupsListHeader extends AbstractSimpleTableHeader { } private void setCaptionDetails() { - headerCaption.setCaption(rolloutUiState.getRolloutName().isPresent() ? rolloutUiState.getRolloutName().get() - : ""); + headerCaption + .setCaption(rolloutUiState.getRolloutName().isPresent() ? rolloutUiState.getRolloutName().get() : ""); } @Override protected void resetSearchText() { - /** - * No implementation required. - */ + // No implementation required. } @Override protected String getSearchBoxId() { - /** - * No implementation required. - */ + // No implementation required. return null; } @Override protected String getSearchRestIconId() { - /** - * No implementation required. - */ + // No implementation required. return null; } @Override protected void searchBy(final String newSearchText) { - /** - * No implementation required. - */ + // No implementation required. } @Override protected String getAddIconId() { - /** - * No implementation required. - */ + // No implementation required. return null; } @Override protected void addNewItem(final ClickEvent event) { - /** - * No implementation required. - */ + // No implementation required. } @Override @@ -129,7 +118,6 @@ public class RolloutGroupsListHeader extends AbstractSimpleTableHeader { @Override protected boolean hasCreatePermission() { - return true; } @@ -140,7 +128,6 @@ public class RolloutGroupsListHeader extends AbstractSimpleTableHeader { @Override protected boolean showCloseButton() { - return true; } @@ -159,12 +146,6 @@ public class RolloutGroupsListHeader extends AbstractSimpleTableHeader { return false; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.rollout.AbstractSimpleTableHeader# - * getHeaderCaptionLayout() - */ @Override protected HorizontalLayout getHeaderCaptionLayout() { headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION); @@ -184,12 +165,6 @@ public class RolloutGroupsListHeader extends AbstractSimpleTableHeader { return headerCaptionLayout; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.ui.rollout.AbstractSimpleTableHeader#restoreCaption() - */ @Override protected void restoreCaption() { setCaptionDetails(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutListHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutListHeader.java index 6abfdb584..26bf021c4 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutListHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/RolloutListHeader.java @@ -50,9 +50,7 @@ public class RolloutListHeader extends AbstractSimpleTableHeader { @Autowired private AddUpdateRolloutWindowLayout addUpdateRolloutWindow; - /** - * Initialization of Target Header Component. - */ + @Override @PostConstruct protected void init() { super.init(); @@ -101,9 +99,7 @@ public class RolloutListHeader extends AbstractSimpleTableHeader { @Override protected void onClose(final ClickEvent event) { - /** - * No implementation required. - */ + // No implementation required. } @Override @@ -133,16 +129,9 @@ public class RolloutListHeader extends AbstractSimpleTableHeader { @Override protected boolean isRollout() { - return true; } - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.ui.rollout.AbstractSimpleTableHeader# - * getHeaderCaptionLayout() - */ @Override protected HorizontalLayout getHeaderCaptionLayout() { final Label headerCaption = SPUIComponentProvider.getLabel(getHeaderCaption(), @@ -153,17 +142,9 @@ public class RolloutListHeader extends AbstractSimpleTableHeader { return headerCaptionLayout; } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.hawkbit.ui.rollout.AbstractSimpleTableHeader#restoreCaption() - */ @Override protected void restoreCaption() { - /** - * No implementation required. - */ + // No implementation required. } } From f969d6f4c2f06e564abf1cae66e775c493209f99 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 25 Feb 2016 14:38:25 +0100 Subject: [PATCH 40/45] clean code refactorings - add description to assertions in unit tests - make inner classes static - remove out-commented code Signed-off-by: Michael Hirsch --- .../AmqpMessageDispatcherServiceTest.java | 43 ++++++++++------ .../event/AbstractPropertyChangeEvent.java | 2 +- .../repository/ArtifactManagementTest.java | 8 +-- .../repository/SoftwareManagementTest.java | 50 +++++++++---------- .../repository/rsql/RSQLActionFieldsTest.java | 2 +- .../repository/rsql/RSQLUtilityTest.java | 16 +++--- .../rest/resource/SoftwareModuleResource.java | 46 ----------------- .../resource/model/ExceptionInfoTest.java | 13 +++-- ...ExcludePathAwareShallowETagFilterTest.java | 3 +- .../org/eclipse/hawkbit/util/IpUtilTest.java | 38 ++++++++------ 10 files changed, 99 insertions(+), 122 deletions(-) diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 348e8dea4..4d313dd2c 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -91,7 +91,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = createArgumentCapture(targetAssignDistributionSetEvent.getTargetAdress().getHost()); final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage); - assertTrue(downloadAndUpdateRequest.getSoftwareModules().isEmpty()); + assertTrue("No softwaremmodule should be contained in the request", + downloadAndUpdateRequest.getSoftwareModules().isEmpty()); } @Test @@ -104,17 +105,22 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = createArgumentCapture(targetAssignDistributionSetEvent.getTargetAdress().getHost()); final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage); - assertEquals(3, downloadAndUpdateRequest.getSoftwareModules().size()); + assertEquals("Expecting a size of 3 software modules in the reuqest", 3, + downloadAndUpdateRequest.getSoftwareModules().size()); for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule softwareModule : downloadAndUpdateRequest .getSoftwareModules()) { - assertTrue(softwareModule.getArtifacts().isEmpty()); + assertTrue("Artifact list for softwaremodule should be empty", softwareModule.getArtifacts().isEmpty()); for (final SoftwareModule softwareModule2 : dsA.getModules()) { - assertNotNull(softwareModule.getModuleId()); + assertNotNull("Sofware module ID should be set", softwareModule.getModuleId()); if (!softwareModule.getModuleId().equals(softwareModule2.getId())) { continue; } - assertEquals(softwareModule.getModuleType(), softwareModule2.getType().getKey()); - assertEquals(softwareModule.getModuleVersion(), softwareModule2.getVersion()); + assertEquals( + "Software module type in event should be the same as the softwaremodule in the distribution set", + softwareModule.getModuleType(), softwareModule2.getType().getKey()); + assertEquals( + "Software module version in event should be the same as the softwaremodule in the distribution set", + softwareModule.getModuleVersion(), softwareModule2.getVersion()); } } } @@ -138,13 +144,14 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); final Message sendMessage = createArgumentCapture(targetAssignDistributionSetEvent.getTargetAdress().getHost()); final DownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage); - assertEquals(3, downloadAndUpdateRequest.getSoftwareModules().size()); + assertEquals("DownloadAndUpdateRequest event should contains 3 software modules", 3, + downloadAndUpdateRequest.getSoftwareModules().size()); for (final org.eclipse.hawkbit.dmf.json.model.SoftwareModule softwareModule : downloadAndUpdateRequest .getSoftwareModules()) { if (!softwareModule.getModuleId().equals(module.getId())) { continue; } - assertFalse(softwareModule.getArtifacts().isEmpty()); + assertFalse("The software module artifacts should not be empty", softwareModule.getArtifacts().isEmpty()); } } @@ -164,8 +171,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit private void assertCancelMessage(final Message sendMessage) { assertEventMessage(sendMessage); final Long actionId = convertMessage(sendMessage, Long.class); - assertEquals(actionId, Long.valueOf(1)); - assertEquals(EventTopic.CANCEL_DOWNLOAD, + assertEquals("Action ID should be 1", actionId, Long.valueOf(1)); + assertEquals("The topc in the message should be a CANCEL_DOWNLOAD value", EventTopic.CANCEL_DOWNLOAD, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC)); } @@ -174,8 +181,9 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit assertEventMessage(sendMessage); final DownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(sendMessage, DownloadAndUpdateRequest.class); - assertEquals(downloadAndUpdateRequest.getActionId(), Long.valueOf(1)); - assertEquals(EventTopic.DOWNLOAD_AND_INSTALL, + assertEquals("The action ID of the downloadAndUpdateRequest event shuold be 1", + downloadAndUpdateRequest.getActionId(), Long.valueOf(1)); + assertEquals("The topic of the event shuold contain DOWNLOAD_AND_INSTALL", EventTopic.DOWNLOAD_AND_INSTALL, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC)); return downloadAndUpdateRequest; @@ -185,11 +193,14 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit * @param sendMessage */ private void assertEventMessage(final Message sendMessage) { - assertNotNull(sendMessage); + assertNotNull("The message should not be null", sendMessage); - assertEquals(CONTROLLER_ID, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.THING_ID)); - assertEquals(MessageType.EVENT, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TYPE)); - assertEquals(MessageProperties.CONTENT_TYPE_JSON, sendMessage.getMessageProperties().getContentType()); + assertEquals("The value of the message header THING_ID should be " + CONTROLLER_ID, CONTROLLER_ID, + sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.THING_ID)); + assertEquals("The value of the message header TYPE should be EVENT", MessageType.EVENT, + sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TYPE)); + assertEquals("The content type message should be " + MessageProperties.CONTENT_TYPE_JSON, + MessageProperties.CONTENT_TYPE_JSON, sendMessage.getMessageProperties().getContentType()); } protected Message createArgumentCapture(final String exchange) { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java index 8a596eeb5..86251e675 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java @@ -47,7 +47,7 @@ public class AbstractPropertyChangeEvent extends AbstractB * Carries old value and new value of a property . * */ - public class Values { + public static class Values { private final Object oldValue; private final Object newValue; diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java index 5585aab95..2929110dd 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java @@ -150,14 +150,14 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB { ExternalArtifact result = artifactManagement.createExternalArtifact(provider, null, sm.getId()); - assertNotNull(result); + assertNotNull("The result of an external artifact should not be null", result); assertThat(externalArtifactRepository.findAll()).contains(result).hasSize(1); assertThat(result.getSoftwareModule().getId()).isEqualTo(sm.getId()); assertThat(result.getUrl()).isEqualTo("https://fhghdfjgh/{version}/"); assertThat(result.getExternalArtifactProvider()).isEqualTo(provider); result = artifactManagement.createExternalArtifact(provider, "/test", sm2.getId()); - assertNotNull(result); + assertNotNull("The newly created external artifact should not be null", result); assertThat(externalArtifactRepository.findAll()).contains(result).hasSize(2); assertThat(result.getUrl()).isEqualTo("https://fhghdfjgh/test"); assertThat(result.getExternalArtifactProvider()).isEqualTo(provider); @@ -176,7 +176,7 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB { "https://fhghdfjgh", "/{version}/"); final ExternalArtifact result = artifactManagement.createExternalArtifact(provider, null, sm.getId()); - assertNotNull(result); + assertNotNull("The newly created external artifact should not be null", result); assertThat(externalArtifactRepository.findAll()).contains(result).hasSize(1); artifactManagement.deleteExternalArtifact(result.getId()); @@ -348,7 +348,7 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB { final LocalArtifact result = artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false); - assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(random), + assertTrue("The stored binary matches the given binary", IOUtils.contentEquals(new ByteArrayInputStream(random), artifactManagement.loadLocalArtifactBinary(result).getFileInputStream())); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java index dc9a654c7..49776e392 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java @@ -159,10 +159,10 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { public void hardDeleteOfNotAssignedArtifact() { // [STEP1]: Create SoftwareModuleX with Artifacts - SoftwareModule unassignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2); - Iterator artifactsIt = unassignedModule.getArtifacts().iterator(); - Artifact artifact1 = artifactsIt.next(); - Artifact artifact2 = artifactsIt.next(); + final SoftwareModule unassignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2); + final Iterator artifactsIt = unassignedModule.getArtifacts().iterator(); + final Artifact artifact1 = artifactsIt.next(); + final Artifact artifact2 = artifactsIt.next(); // [STEP2]: Delete unassigned SoftwareModule softwareManagement.deleteSoftwareModule(unassignedModule); @@ -185,7 +185,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { public void softDeleteOfAssignedArtifact() { // Init DistributionSet - DistributionSet disSet = distributionSetManagement + final DistributionSet disSet = distributionSetManagement .createDistributionSet(new DistributionSet("ds1", "v1.0", "test ds", standardDsType, null)); // [STEP1]: Create SoftwareModuleX with ArtifactX @@ -200,14 +200,14 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { // [VERIFY EXPECTED RESULT]: // verify: assignedModule is marked as deleted assignedModule = softwareManagement.findSoftwareModuleById(assignedModule.getId()); - assertTrue(assignedModule.isDeleted()); + assertTrue("The module should be flagged as deleted", assignedModule.isDeleted()); assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(softwareModuleRepository.findAll()).hasSize(1); // verify: binary data is deleted - Iterator artifactsIt = assignedModule.getArtifacts().iterator(); - Artifact artifact1 = artifactsIt.next(); - Artifact artifact2 = artifactsIt.next(); + final Iterator artifactsIt = assignedModule.getArtifacts().iterator(); + final Artifact artifact1 = artifactsIt.next(); + final Artifact artifact2 = artifactsIt.next(); assertArtfiactNull(artifact1, artifact2); // verify: artifact meta data is still available @@ -221,7 +221,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { // Init target and DistributionSet final Target target = targetManagement.createTarget(new Target("test123")); - DistributionSet disSet = distributionSetManagement + final DistributionSet disSet = distributionSetManagement .createDistributionSet(new DistributionSet("ds1", "v1.0", "test ds", standardDsType, null)); // [STEP1]: Create SoftwareModuleX and include the new ArtifactX @@ -242,14 +242,14 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { // [VERIFY EXPECTED RESULT]: // verify: assignedModule is marked as deleted assignedModule = softwareManagement.findSoftwareModuleById(assignedModule.getId()); - assertTrue(assignedModule.isDeleted()); + assertTrue("The found module should be flagged deleted", assignedModule.isDeleted()); assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(softwareModuleRepository.findAll()).hasSize(1); // verify: binary data is deleted - Iterator artifactsIt = assignedModule.getArtifacts().iterator(); - Artifact artifact1 = artifactsIt.next(); - Artifact artifact2 = artifactsIt.next(); + final Iterator artifactsIt = assignedModule.getArtifacts().iterator(); + final Artifact artifact1 = artifactsIt.next(); + final Artifact artifact2 = artifactsIt.next(); assertArtfiactNull(artifact1, artifact2); // verify: artifact meta data is still available @@ -265,7 +265,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { assertThat(operations.find(new Query())).hasSize(0); // Init artifact binary data, target and DistributionSets - byte[] source = RandomUtils.nextBytes(1024); + final byte[] source = RandomUtils.nextBytes(1024); // [STEP1]: Create SoftwareModuleX and add a new ArtifactX SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0); @@ -273,7 +273,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { // [STEP2]: Create newArtifactX and add it to SoftwareModuleX artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false); moduleX = softwareManagement.findSoftwareModuleWithDetails(moduleX.getId()); - Artifact artifactX = moduleX.getArtifacts().iterator().next(); + final Artifact artifactX = moduleX.getArtifacts().iterator().next(); // [STEP3]: Create SoftwareModuleY and add the same ArtifactX SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0); @@ -281,7 +281,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { // [STEP4]: Assign the same ArtifactX to SoftwareModuleY artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false); moduleY = softwareManagement.findSoftwareModuleWithDetails(moduleY.getId()); - Artifact artifactY = moduleY.getArtifacts().iterator().next(); + final Artifact artifactY = moduleY.getArtifacts().iterator().next(); // verify: that only one entry was created in mongoDB assertThat(operations.find(new Query())).hasSize(1); @@ -325,14 +325,14 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false); moduleX = softwareManagement.findSoftwareModuleWithDetails(moduleX.getId()); - Artifact artifactX = moduleX.getArtifacts().iterator().next(); + final Artifact artifactX = moduleX.getArtifacts().iterator().next(); // [STEP2]: Create SoftwareModuleY and add the same ArtifactX SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0); artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false); moduleY = softwareManagement.findSoftwareModuleWithDetails(moduleY.getId()); - Artifact artifactY = moduleY.getArtifacts().iterator().next(); + final Artifact artifactY = moduleY.getArtifacts().iterator().next(); // verify: that only one entry was created in mongoDB assertThat(operations.find(new Query())).hasSize(1); @@ -358,8 +358,8 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { // verify: SoftwareModuleX and SofwtareModule are marked as deleted assertThat(moduleX).isNotNull(); assertThat(moduleY).isNotNull(); - assertTrue(moduleX.isDeleted()); - assertTrue(moduleY.isDeleted()); + assertTrue("The module should be flagged deleted", moduleX.isDeleted()); + assertTrue("The module should be flagged deleted", moduleY.isDeleted()); assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(softwareModuleRepository.findAll()).hasSize(2); @@ -370,10 +370,10 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { assertThat(artifactRepository.findOne(artifactY.getId())).isNotNull(); } - private SoftwareModule createSoftwareModuleWithArtifacts(SoftwareModuleType type, String name, String version, - int numberArtifacts) { + private SoftwareModule createSoftwareModuleWithArtifacts(final SoftwareModuleType type, final String name, + final String version, final int numberArtifacts) { - long countSoftwareModule = softwareModuleRepository.count(); + final long countSoftwareModule = softwareModuleRepository.count(); // create SoftwareModule SoftwareModule softwareModule = softwareManagement @@ -388,7 +388,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB { softwareModule = softwareManagement.findSoftwareModuleWithDetails(softwareModule.getId()); assertThat(softwareModuleRepository.findAll()).hasSize((int) countSoftwareModule + 1); - List artifacts = softwareModule.getArtifacts(); + final List artifacts = softwareModule.getArtifacts(); assertThat(artifacts).hasSize(numberArtifacts); if (numberArtifacts != 0) { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java index 71cf511ae..139b0a88d 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLActionFieldsTest.java @@ -72,7 +72,7 @@ public class RSQLActionFieldsTest extends AbstractIntegrationTest { try { assertRSQLQuery(ActionFields.STATUS.name() + "==true", 5); - fail(); + fail("Missing expected RSQLParameterUnsupportedFieldException because status cannot be compared with 'true'"); } catch (final RSQLParameterUnsupportedFieldException e) { } } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java index 3b923d167..bcfade8d5 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLUtilityTest.java @@ -63,7 +63,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterSyntaxException e) { } } @@ -75,7 +75,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing an expected RSQLParameterUnsupportedFieldException because of unknown RSQL field"); } catch (final RSQLParameterUnsupportedFieldException e) { } @@ -87,7 +87,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterUnsupportedFieldException e) { } @@ -95,7 +95,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterUnsupportedFieldException e) { } @@ -103,7 +103,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, DistributionSetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterUnsupportedFieldException e) { } @@ -115,7 +115,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterUnsupportedFieldException e) { } @@ -123,7 +123,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterUnsupportedFieldException e) { } @@ -131,7 +131,7 @@ public class RSQLUtilityTest { try { RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); - fail(); + fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax"); } catch (final RSQLParameterUnsupportedFieldException e) { } } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java index 9ce1a2975..dfbac1a6f 100644 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java @@ -99,52 +99,6 @@ public class SoftwareModuleResource implements SoftwareModuleRestAPI { return new ResponseEntity<>(SoftwareModuleMapper.artifactsToResponse(module.getArtifacts()), HttpStatus.OK); } - /** - * Handles the GET request for downloading an artifact. - * - * @param softwareModuleId - * of the parent SoftwareModule - * @param artifactId - * of the related LocalArtifact - * @param servletResponse - * of the servlet - * @param request - * of the client - * - * @return responseEntity with status ok if successful - */ - // @RequestMapping(method = RequestMethod.GET, value = - // RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - // + "/{softwareModuleId}/artifacts/{artifactId}/download") - // @ResponseBody - // public ResponseEntity downloadArtifact(@PathVariable final Long - // softwareModuleId, - // @PathVariable final Long artifactId, final HttpServletResponse - // servletResponse, - // final HttpServletRequest request) { - // final SoftwareModule module = - // findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); - // - // if (null == module || !module.getLocalArtifact(artifactId).isPresent()) { - // return new ResponseEntity<>(HttpStatus.NOT_FOUND); - // } - // - // final LocalArtifact artifact = module.getLocalArtifact(artifactId).get(); - // final DbArtifact file = - // artifactManagement.loadLocalArtifactBinary(artifact); - // - // final String ifMatch = request.getHeader("If-Match"); - // if (ifMatch != null && - // !RestResourceConversionHelper.matchesHttpHeader(ifMatch, - // artifact.getSha1Hash())) { - // return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED); - // } - // - // return RestResourceConversionHelper.writeFileResponse(artifact, - // servletResponse, request, file); - // - // } - @Override public ResponseEntity getArtifact(@PathVariable final Long softwareModuleId, @PathVariable final Long artifactId) { diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java index e9601d693..ab5012d73 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java @@ -32,10 +32,15 @@ public class ExceptionInfoTest { underTest.setMessage(knownMessage); underTest.setParameters(knownParameters); - assertThat(underTest.getErrorCode()).isEqualTo(knownErrorCode); - assertThat(underTest.getExceptionClass()).isEqualTo(knownExceptionClass); - assertThat(underTest.getMessage()).isEqualTo(knownMessage); - assertThat(underTest.getParameters()).isEqualTo(knownParameters); + assertThat(underTest.getErrorCode()).as("The error code should match with the known error code in the test") + .isEqualTo(knownErrorCode); + assertThat(underTest.getExceptionClass()) + .as("The exception class should match with the known error code in the test") + .isEqualTo(knownExceptionClass); + assertThat(underTest.getMessage()).as("The message should match with the known error code in the test") + .isEqualTo(knownMessage); + assertThat(underTest.getParameters()).as("The parameters should match with the known error code in the test") + .isEqualTo(knownParameters); } } diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java index ce663fbfb..d3dc066f1 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java @@ -56,7 +56,8 @@ public class ExcludePathAwareShallowETagFilterTest { filterUnderTest.doFilterInternal(servletRequestMock, servletResponseMock, filterChainMock); // verify no eTag header is set and response has not been changed - assertThat(servletResponseMock.getHeader("ETag")).isNull(); + assertThat(servletResponseMock.getHeader("ETag")) + .as("ETag header should not be set during downloading, too expensive").isNull(); // the servlet response must be the same mock! verify(filterChainMock, times(1)).doFilter(servletRequestMock, servletResponseMock); } diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java index e1e809ab8..d56c59252 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java @@ -53,7 +53,8 @@ public class IpUtilTest { final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, "bumlux"); // verify - assertThat(remoteAddr).isEqualTo(knownRemoteClientIP); + assertThat(remoteAddr).as("The remote address should be as the known client IP address") + .isEqualTo(knownRemoteClientIP); verify(requestMock, times(1)).getHeader("bumlux"); verify(requestMock, times(1)).getRemoteAddr(); } @@ -71,7 +72,8 @@ public class IpUtilTest { final URI remoteAddr = IpUtil.getClientIpFromRequest(requestMock, "X-Forwarded-For"); // verify - assertThat(remoteAddr).isEqualTo(knownRemoteClientIP); + assertThat(remoteAddr).as("The remote address should be as the known client IP address") + .isEqualTo(knownRemoteClientIP); verify(requestMock, times(1)).getHeader(HttpHeaders.X_FORWARDED_FOR); verify(requestMock, times(0)).getRemoteAddr(); } @@ -94,10 +96,10 @@ public class IpUtilTest { } private void assertHttpUri(final String host, final URI httpUri) { - assertTrue(IpUtil.isHttpUri(httpUri)); - assertFalse(IpUtil.isAmqpUri(httpUri)); - assertEquals(host, httpUri.getHost()); - assertEquals("http", httpUri.getScheme()); + assertTrue("The given URI has an http scheme", IpUtil.isHttpUri(httpUri)); + assertFalse("The given URI is not an AMQP scheme", IpUtil.isAmqpUri(httpUri)); + assertEquals("The URI hosts matches the given host", host, httpUri.getHost()); + assertEquals("The given URI scheme is http", "http", httpUri.getScheme()); } @Test @@ -117,22 +119,26 @@ public class IpUtilTest { } private void assertAmqpUri(final String host, final URI httpUri) { - assertTrue(IpUtil.isAmqpUri(httpUri)); - assertFalse(IpUtil.isHttpUri(httpUri)); - assertEquals(host, httpUri.getHost()); - assertEquals("amqp", httpUri.getScheme()); + assertTrue("The given URI is an AMQP scheme", IpUtil.isAmqpUri(httpUri)); + assertFalse("The given URI is not an HTTP scheme", IpUtil.isHttpUri(httpUri)); + assertEquals("The given host matches the URI host", host, httpUri.getHost()); + assertEquals("The given URI has an AMQP scheme", "amqp", httpUri.getScheme()); } - @Test(expected = IllegalArgumentException.class) + @Test @Description("Tests create invalid uri") public void testCreateInvalidUri() { final String host = "10.99.99.1"; final URI testUri = IpUtil.createUri("test", host); - assertFalse(IpUtil.isAmqpUri(testUri)); - assertFalse(IpUtil.isHttpUri(testUri)); - assertEquals(host, testUri.getHost()); - IpUtil.createUri(":/", host); - fail(); + assertFalse("The given URI is not an AMQP address", IpUtil.isAmqpUri(testUri)); + assertFalse("The given URI is not an HTTP address", IpUtil.isHttpUri(testUri)); + assertEquals("The given host matches the URI host", host, testUri.getHost()); + try { + IpUtil.createUri(":/", host); + fail("Missing expected IllegalArgumentException due invalid URI"); + } catch (final IllegalArgumentException e) { + // expected + } } } From 62d96a4ac67abca2d21ea715618fe9bde124febc Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Thu, 25 Feb 2016 14:51:45 +0100 Subject: [PATCH 41/45] remove static modifier from inner class Signed-off-by: Michael Hirsch --- .../hawkbit/eventbus/event/AbstractPropertyChangeEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java index 86251e675..8a596eeb5 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractPropertyChangeEvent.java @@ -47,7 +47,7 @@ public class AbstractPropertyChangeEvent extends AbstractB * Carries old value and new value of a property . * */ - public static class Values { + public class Values { private final Object oldValue; private final Object newValue; From 0b5c0673b1601ed838d668a4a45608bb9aa3a3ed Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Thu, 25 Feb 2016 17:43:28 +0100 Subject: [PATCH 42/45] fix Signed-off-by: asharani-murugesh --- .../org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index 2e8c6a51e..665fbcb6f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -191,12 +191,13 @@ public class UploadLayout extends VerticalLayout { ((WrapperTransferable) event.getTransferable()).getDraggedComponent(); final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); if (files != null) { + //reset the flag + hasDirectory = Boolean.FALSE; for (final Html5File file : files) { if (!isDirectory(file)) { if (!checkForDuplicate(file.getFileName())) { numberOfFileUploadsExpected.incrementAndGet(); file.setStreamVariable(createStreamVariable(file)); - hasDirectory = Boolean.FALSE; } } else { hasDirectory = Boolean.TRUE; From b8ed510e8a5bb5dba93156779092867610f811ce Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Thu, 25 Feb 2016 17:54:50 +0100 Subject: [PATCH 43/45] reset the has directory flag Signed-off-by: asharani-murugesh --- .../eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java | 2 ++ .../org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java index 3d7ce0886..cac4ef2f9 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java @@ -108,6 +108,8 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene public OutputStream receiveUpload(final String fileName, final String mimeType) { this.fileName = fileName; this.mimeType = mimeType; + //reset has directory flag before upload + view.setHasDirectory(false); try { if (view.validate()) { if (view.checkForDuplicate(fileName)) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index 665fbcb6f..c254a8b18 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -633,4 +633,8 @@ public class UploadLayout extends VerticalLayout { return uiNotification; } + + public void setHasDirectory(Boolean hasDirectory) { + this.hasDirectory = hasDirectory; + } } From 92811f1a22c516684a774e1feec23eebee05ad6b Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Fri, 26 Feb 2016 08:47:21 +0100 Subject: [PATCH 44/45] review comment addressed Signed-off-by: asharani-murugesh --- .../ui/artifacts/upload/UploadLayout.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index c254a8b18..9a7969f05 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -59,6 +59,7 @@ import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; +import com.vaadin.ui.Component; import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; import com.vaadin.ui.HorizontalLayout; @@ -187,21 +188,13 @@ public class UploadLayout extends VerticalLayout { @Override public void drop(final DragAndDropEvent event) { - if (validate()) { - ((WrapperTransferable) event.getTransferable()).getDraggedComponent(); + if (event.getTransferable() instanceof WrapperTransferable && validate()) { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); if (files != null) { - //reset the flag + // reset the flag hasDirectory = Boolean.FALSE; for (final Html5File file : files) { - if (!isDirectory(file)) { - if (!checkForDuplicate(file.getFileName())) { - numberOfFileUploadsExpected.incrementAndGet(); - file.setStreamVariable(createStreamVariable(file)); - } - } else { - hasDirectory = Boolean.TRUE; - } + processFile(file); } if (numberOfFileUploadsExpected.get() > 0) { processBtn.setEnabled(false); @@ -216,6 +209,17 @@ public class UploadLayout extends VerticalLayout { } } } + + private void processFile(final Html5File file) { + if (!isDirectory(file)) { + if (!checkForDuplicate(file.getFileName())) { + numberOfFileUploadsExpected.incrementAndGet(); + file.setStreamVariable(createStreamVariable(file)); + } + } else { + hasDirectory = Boolean.TRUE; + } + } } private static boolean isDirectory(final Html5File file) { From 80366b03be121fa4b3fc539256c15578ffa2bb9f Mon Sep 17 00:00:00 2001 From: asharani-murugesh Date: Sat, 27 Feb 2016 09:24:18 +0100 Subject: [PATCH 45/45] Review comments addresses Signed-off-by: asharani-murugesh --- .../ui/artifacts/upload/UploadHandler.java | 2 +- .../ui/artifacts/upload/UploadLayout.java | 60 ++++++++++++------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java index cac4ef2f9..8c1feeb33 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java @@ -111,7 +111,7 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene //reset has directory flag before upload view.setHasDirectory(false); try { - if (view.validate()) { + if (view.checkIfSoftwareModuleIsSelected()) { if (view.checkForDuplicate(fileName)) { view.showDuplicateMessage(); } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java index 9a7969f05..994a9786f 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java @@ -59,7 +59,6 @@ import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; -import com.vaadin.ui.Component; import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.DragAndDropWrapper.WrapperTransferable; import com.vaadin.ui.HorizontalLayout; @@ -188,24 +187,22 @@ public class UploadLayout extends VerticalLayout { @Override public void drop(final DragAndDropEvent event) { - if (event.getTransferable() instanceof WrapperTransferable && validate()) { + if (validate(event)) { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); - if (files != null) { - // reset the flag - hasDirectory = Boolean.FALSE; - for (final Html5File file : files) { - processFile(file); - } - if (numberOfFileUploadsExpected.get() > 0) { - processBtn.setEnabled(false); - // reset before we start - uploadInfoWindow.uploadSessionStarted(); - } else { - // If the upload is not started, it signifies all - // dropped files as either duplicate or directory.So - // display message accordingly - displayCompositeMessage(); - } + // reset the flag + hasDirectory = Boolean.FALSE; + for (final Html5File file : files) { + processFile(file); + } + if (numberOfFileUploadsExpected.get() > 0) { + processBtn.setEnabled(false); + // reset before we start + uploadInfoWindow.uploadSessionStarted(); + } else { + // If the upload is not started, it signifies all + // dropped files as either duplicate or directory.So + // display message accordingly + displayCompositeMessage(); } } } @@ -354,10 +351,33 @@ public class UploadLayout extends VerticalLayout { } } - Boolean validate() { + Boolean validate(DragAndDropEvent event) { + // check if drop is valid.If valid ,check if software module is + // selected. + if(!isFilesDropped(event)){ + uiNotification.displayValidationError(i18n.get("message.action.not.allowed")); + return false; + } + return checkIfSoftwareModuleIsSelected(); + } + + private boolean isFilesDropped(DragAndDropEvent event) { + if (event.getTransferable() instanceof WrapperTransferable) { + final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); + // other components can also be wrapped in WrapperTransferable , so + // additional check on files + if (files == null) { + return false; + } + return true; + } else { + return false; + } + } + + Boolean checkIfSoftwareModuleIsSelected() { if (!isSoftwareModuleSelected()) { uiNotification.displayValidationError(i18n.get("message.error.noSwModuleSelected")); - return false; } return true;