From 6e5b9075f92c1f4f478a09f78d9b710613f8e601 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Thu, 9 Jan 2020 11:44:36 +0200 Subject: [PATCH] BrowseContext creation fails when including invalid contributions gitlab #439 Change-Id: Ie985db8ac57c43c081a77df390c48e7b32c1042f --- .../model/browsecontexts/BrowseContext.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContext.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContext.java index 42ac58420..c4f8c2682 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContext.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/BrowseContext.java @@ -57,6 +57,7 @@ import org.simantics.browsing.ui.model.visuals.VisualsContribution; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; +import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ResourceNotFoundException; import org.simantics.db.layer0.variable.Variable; @@ -125,24 +126,32 @@ public class BrowseContext { for(Resource childContributionResource : g.getObjects(browseContextResource, vr.BrowseContext_HasChildContribution)) { - ChildContribution contribution = ChildContribution.create(g, childContributionResource); - browseContext.childContributions.put(contribution.getParentNodeType(), contribution); - browseContext.parentContributions.put(contribution.getChildNodeType(), contribution); + try { + ChildContribution contribution = ChildContribution.create(g, childContributionResource); + browseContext.childContributions.put(contribution.getParentNodeType(), contribution); + browseContext.parentContributions.put(contribution.getChildNodeType(), contribution); + } catch (DatabaseException e) { + LOGGER.error("Failed to load child contribution " + NameUtils.getSafeName(g, childContributionResource), e); + } } for(Resource visualsContributionResource : g.getObjects(browseContextResource, vr.BrowseContext_HasVisualsContribution)) { - VisualsContribution.load(g, visualsContributionResource, - browseContext.labelContributions, - browseContext.imageContributions, - browseContext.checkedStateContributions, - browseContext.labelDecorationContributions, - browseContext.imageDecorationContributions, - browseContext.modifierContributions, - browseContext.sorterContributions, - browseContext.flatNodeContributions, - browseContext.tooltipContributions + try { + VisualsContribution.load(g, visualsContributionResource, + browseContext.labelContributions, + browseContext.imageContributions, + browseContext.checkedStateContributions, + browseContext.labelDecorationContributions, + browseContext.imageDecorationContributions, + browseContext.modifierContributions, + browseContext.sorterContributions, + browseContext.flatNodeContributions, + browseContext.tooltipContributions ); + } catch (DatabaseException e) { + LOGGER.error("Failed to load visuals contribution " + NameUtils.getSafeName(g, visualsContributionResource), e); + } } } //browseContext.visualize(); -- 2.47.1