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
|
@Override
|
||||||
public void error(final ErrorEvent event) {
|
public void error(final ErrorEvent event) {
|
||||||
|
|
||||||
LOG.error("Error in UI: ", event.getThrowable());
|
|
||||||
|
|
||||||
final Optional<Page> originError = getPageOriginError(event);
|
final Optional<Page> originError = getPageOriginError(event);
|
||||||
|
|
||||||
if (originError.isPresent()) {
|
if (originError.isPresent()) {
|
||||||
@@ -68,11 +66,15 @@ public class HawkbitUIErrorHandler extends DefaultErrorHandler {
|
|||||||
return Optional.fromNullable(errorOrigin.getUI().getPage());
|
return Optional.fromNullable(errorOrigin.getUI().getPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.absent();
|
return Optional.of(Page.getCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HawkbitErrorNotificationMessage buildNotification(final Throwable exception) {
|
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);
|
final I18N i18n = SpringContextHelper.getBean(I18N.class);
|
||||||
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
|
return new HawkbitErrorNotificationMessage(STYLE, i18n.get("caption.error"),
|
||||||
i18n.get("message.error.temp", exception.getClass().getSimpleName()), false);
|
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.Label;
|
||||||
import com.vaadin.ui.ProgressBar;
|
import com.vaadin.ui.ProgressBar;
|
||||||
import com.vaadin.ui.TextArea;
|
import com.vaadin.ui.TextArea;
|
||||||
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.Upload;
|
import com.vaadin.ui.Upload;
|
||||||
import com.vaadin.ui.Upload.FailedEvent;
|
import com.vaadin.ui.Upload.FailedEvent;
|
||||||
import com.vaadin.ui.Upload.FailedListener;
|
import com.vaadin.ui.Upload.FailedListener;
|
||||||
@@ -173,6 +174,7 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UploadAsync implements Runnable {
|
class UploadAsync implements Runnable {
|
||||||
|
|
||||||
final SucceededEvent event;
|
final SucceededEvent event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,7 +190,6 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
if (tempFile == null) {
|
if (tempFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (InputStream tempStream = new FileInputStream(tempFile)) {
|
try (InputStream tempStream = new FileInputStream(tempFile)) {
|
||||||
readFileStream(tempStream);
|
readFileStream(tempStream);
|
||||||
} catch (final FileNotFoundException e) {
|
} catch (final FileNotFoundException e) {
|
||||||
@@ -196,12 +197,11 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
LOG.error("Error while opening temorary file ", e);
|
LOG.error("Error while opening temorary file ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFileStream(final InputStream tempStream) {
|
private void readFileStream(final InputStream tempStream) {
|
||||||
String line;
|
String line;
|
||||||
try (BufferedReader reader = new BufferedReader(
|
try (final BufferedReader reader = new BufferedReader(
|
||||||
new InputStreamReader(tempStream, Charset.defaultCharset()))) {
|
new InputStreamReader(tempStream, Charset.defaultCharset()))) {
|
||||||
LOG.info("Bulk file upload started");
|
LOG.info("Bulk file upload started");
|
||||||
long innerCounter = 0;
|
long innerCounter = 0;
|
||||||
@@ -213,21 +213,39 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
* below event.
|
* below event.
|
||||||
*/
|
*/
|
||||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
|
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED));
|
||||||
|
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
innerCounter++;
|
innerCounter++;
|
||||||
readEachLine(line, innerCounter, totalFileSize);
|
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) {
|
} catch (final IOException e) {
|
||||||
LOG.error("Error reading file {}", tempFile.getName(), 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 {
|
} finally {
|
||||||
resetCounts();
|
|
||||||
deleteFile();
|
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() {
|
private double getTotalNumberOfLines() {
|
||||||
@@ -452,4 +470,5 @@ public class BulkUploadHandler extends CustomComponent
|
|||||||
eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED));
|
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.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||||
@@ -73,9 +72,6 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient TargetManagement targetManagement;
|
private transient TargetManagement targetManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private transient UINotification uINotification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient EventBus.SessionEventBus eventBus;
|
private transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
@@ -296,8 +292,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
|
|||||||
descTextArea.clear();
|
descTextArea.clear();
|
||||||
targetBulkTokenTags.getTokenField().clear();
|
targetBulkTokenTags.getTokenField().clear();
|
||||||
targetBulkTokenTags.populateContainer();
|
targetBulkTokenTags.populateContainer();
|
||||||
progressBar.setValue(0f);
|
progressBar.setValue(0F);
|
||||||
progressBar.setVisible(false);
|
progressBar.setVisible(false);
|
||||||
|
managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(0F);
|
||||||
targetsCountLabel.setVisible(false);
|
targetsCountLabel.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user