Skip to content

Commit

Permalink
[4050] Give a chance to report an error on document upload
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#4050
Signed-off-by: Arthur Daussy <[email protected]>
  • Loading branch information
adaussy committed Oct 1, 2024
1 parent 065fa30 commit 6ffdace
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ The new option ALWAYS allows the separator to be displayed in every case.
- https://github.com/eclipse-sirius/sirius-web/issues/4008[#4008] [diagram] Prevent `detailsEvent` to be triggered twice when selecting a multi-represented element in the diagram
- https://github.com/eclipse-sirius/sirius-web/issues/4032[#4032] [diagram] Fix an issue where separator list compartment is missing
- https://github.com/eclipse-sirius/sirius-web/issues/4028[#4028] [trees] Fixed an issue where special characters (e.g. #) could not be used in the treeId due to URL parsing limitations.
- https://github.com/eclipse-sirius/sirius-web/issues/4050[#4050] Feedback messages are not display on upload error payload

=== New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.sirius.components.core.api.ErrorPayload;
import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.core.api.IEditingContextSearchService;
import org.eclipse.sirius.components.core.api.IFeedbackMessageService;
import org.eclipse.sirius.components.core.api.IInput;
import org.eclipse.sirius.components.core.api.IPayload;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
Expand Down Expand Up @@ -64,11 +65,15 @@ public class UploadDocumentEventHandler implements IEditingContextEventHandler {

private final Counter counter;

public UploadDocumentEventHandler(IEditingContextSearchService editingContextSearchService, List<IUploadDocumentReportProvider> uploadDocumentReportProviders, IMessageService messageService, IUploadFileLoader uploadDocumentLoader, MeterRegistry meterRegistry) {
private IFeedbackMessageService feedbackMessageService;

public UploadDocumentEventHandler(IEditingContextSearchService editingContextSearchService, List<IUploadDocumentReportProvider> uploadDocumentReportProviders, IMessageService messageService,
IUploadFileLoader uploadDocumentLoader, MeterRegistry meterRegistry, IFeedbackMessageService feedbackMessageService) {
this.editingContextSearchService = Objects.requireNonNull(editingContextSearchService);
this.uploadDocumentReportProviders = Objects.requireNonNull(uploadDocumentReportProviders);
this.messageService = Objects.requireNonNull(messageService);
this.uploadDocumentLoader = Objects.requireNonNull(uploadDocumentLoader);
this.feedbackMessageService = Objects.requireNonNull(feedbackMessageService);
this.counter = Counter.builder(Monitoring.EVENT_HANDLER)
.tag(Monitoring.NAME, this.getClass().getSimpleName())
.register(meterRegistry);
Expand Down Expand Up @@ -102,6 +107,7 @@ public void handle(Sinks.One<IPayload> payloadSink, Sinks.Many<ChangeDescription
.map(ResourceMetadataAdapter.class::cast)
.findFirst()
.map(ResourceMetadataAdapter::getName);

if (newResource.isPresent() && optionalId.isPresent() && optionalName.isPresent()) {
var uploadedResource = newResource.get();
var id = optionalId.get();
Expand All @@ -110,6 +116,8 @@ public void handle(Sinks.One<IPayload> payloadSink, Sinks.Many<ChangeDescription
String report = this.getReport(uploadedResource);
payload = new UploadDocumentSuccessPayload(input.id(), new DocumentDTO(id, name, ExplorerDescriptionProvider.DOCUMENT_KIND), report);
changeDescription = new ChangeDescription(ChangeKind.SEMANTIC_CHANGE, editingContext.getId(), input);
} else if (!this.feedbackMessageService.getFeedbackMessages().isEmpty()) {
payload = new ErrorPayload(input.id(), this.feedbackMessageService.getFeedbackMessages());
}
}

Expand Down

0 comments on commit 6ffdace

Please sign in to comment.