From: Antti Villberg Date: Thu, 9 Jan 2020 09:44:36 +0000 (+0200) Subject: BrowseContext creation fails when including invalid contributions X-Git-Tag: v1.43.0~136^2~10 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F63%2F3763%2F1;p=simantics%2Fplatform.git BrowseContext creation fails when including invalid contributions gitlab #439 Change-Id: Ie985db8ac57c43c081a77df390c48e7b32c1042f --- 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();