From 97892869ae7f48e7bbfaaf7d47f0932ecc979902 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 22 Sep 2015 15:53:27 -0700 Subject: [PATCH] [Entanglement] Move composition check up Move check for composition up higher in the sequence of if-blocks in the validation step of linking; remove fallback to [] for undefined composition, which is no longer necessary as a consequence of this. nasa/openmctweb#98 --- platform/entanglement/src/services/LinkService.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/entanglement/src/services/LinkService.js b/platform/entanglement/src/services/LinkService.js index 40d809ebcb..5989c3cf06 100644 --- a/platform/entanglement/src/services/LinkService.js +++ b/platform/entanglement/src/services/LinkService.js @@ -45,14 +45,17 @@ define( if (parentCandidate.getId() === object.getId()) { return false; } - if ((parentCandidate.getModel().composition || []).indexOf(object.getId()) !== -1) { + if (!parentCandidate.hasCapability('composition')) { + return false; + } + if (parentCandidate.getModel().composition.indexOf(object.getId()) !== -1) { return false; } return this.policyService.allow( "composition", parentCandidate.getCapability('type'), object.getCapability('type') - ) && parentCandidate.hasCapability('composition'); + ); }; LinkService.prototype.perform = function (object, parentObject) {