Merge branch 'master' into Feature_Improve_Code_Quality
Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com> # Conflicts: # hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java
This commit is contained in:
@@ -36,8 +36,6 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
@Override
|
||||
public void error(final ErrorEvent event) {
|
||||
|
||||
LOG.error("Error in UI: ", event.getThrowable());
|
||||
|
||||
final Optional<Page> originError = getPageOriginError(event);
|
||||
|
||||
if (originError.isPresent()) {
|
||||
@@ -68,11 +66,15 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
||||
return Optional.fromNullable(errorOrigin.getUI().getPage());
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
return Optional.of(Page.getCurrent());
|
||||
}
|
||||
|
||||
protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) {
|
||||
LOG.error("Error in UI: ", exception);
|
||||
return createHawkbitErrorNotificationMessage(exception);
|
||||
}
|
||||
|
||||
protected HawkbitErrorNotificationMessage createHawkbitErrorNotificationMessage(final Throwable exception) {
|
||||
final I18N i18n = SpringContextHelper.getBean(I18N.class);
|
||||
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
|
||||
i18n.get("message.error.temp", exception.getClass().getSimpleName()), false);
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.ProgressBar;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Upload;
|
||||
import com.vaadin.ui.Upload.FailedEvent;
|
||||
import com.vaadin.ui.Upload.FailedListener;
|
||||
@@ -173,6 +174,7 @@ public class BulkUploadHandler extends CustomComponent
|
||||
}
|
||||
|
||||
class UploadAsync implements Runnable {
|
||||
|
||||
final SucceededEvent event;
|
||||
|
||||
/**
|
||||
@@ -188,7 +190,6 @@ public class BulkUploadHandler extends CustomComponent
|
||||
if (tempFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream tempStream = new FileInputStream(tempFile)) {
|
||||
readFileStream(tempStream);
|
||||
} catch (final FileNotFoundException e) {
|
||||
@@ -196,12 +197,11 @@ public class BulkUploadHandler extends CustomComponent
|
||||
} catch (final IOException e) {
|
||||
LOG.error("Error while opening temorary file ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void readFileStream(final InputStream tempStream) {
|
||||
String line;
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
try (final BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(tempStream, Charset.defaultCharset()))) {
|
||||
LOG.info("Bulk file upload started");
|
||||
long innerCounter = 0;
|
||||
@@ -213,21 +213,39 @@ public class BulkUploadHandler extends CustomComponent
|
||||
* below event.
|
||||
*/
|
||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
innerCounter++;
|
||||
readEachLine(line, innerCounter, totalFileSize);
|
||||
}
|
||||
doAssignments();
|
||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED));
|
||||
|
||||
// Clearing after assignments are done
|
||||
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().clear();
|
||||
} catch (final IOException e) {
|
||||
LOG.error("Error reading file {}", tempFile.getName(), e);
|
||||
} catch (final RuntimeException e) {
|
||||
if (UI.getCurrent() != null) {
|
||||
UI.getCurrent().getErrorHandler().error(new com.vaadin.server.ErrorEvent(e));
|
||||
}
|
||||
} finally {
|
||||
resetCounts();
|
||||
deleteFile();
|
||||
}
|
||||
syncCountAfterUpload();
|
||||
doAssignments();
|
||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED));
|
||||
// Clearing after assignments are done
|
||||
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().clear();
|
||||
resetCounts();
|
||||
}
|
||||
|
||||
private void syncCountAfterUpload() {
|
||||
if (managementUIState.getTargetTableFilters().getBulkUpload()
|
||||
.getSucessfulUploadCount() != successfullTargetCount) {
|
||||
managementUIState.getTargetTableFilters().getBulkUpload()
|
||||
.setSucessfulUploadCount(successfullTargetCount);
|
||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED));
|
||||
}
|
||||
if (managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount() != failedTargetCount) {
|
||||
managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(failedTargetCount);
|
||||
}
|
||||
}
|
||||
|
||||
private double getTotalNumberOfLines() {
|
||||
@@ -452,4 +470,5 @@ public class BulkUploadHandler extends CustomComponent
|
||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||
@@ -73,9 +72,6 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
||||
@Autowired
|
||||
private transient TargetManagement targetManagement;
|
||||
|
||||
@Autowired
|
||||
private transient UINotification uINotification;
|
||||
|
||||
@Autowired
|
||||
private transient EventBus.SessionEventBus eventBus;
|
||||
|
||||
@@ -296,8 +292,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
||||
descTextArea.clear();
|
||||
targetBulkTokenTags.getTokenField().clear();
|
||||
targetBulkTokenTags.populateContainer();
|
||||
progressBar.setValue(0f);
|
||||
progressBar.setValue(0F);
|
||||
progressBar.setVisible(false);
|
||||
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(0F);
|
||||
targetsCountLabel.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user