From 8db334e45bcb81aaa8e9c5fd79bd362fd95685b7 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 22 Sep 2015 15:51:15 -0700 Subject: [PATCH] Revert "[LinkService] Reorder/refactor validation" This reverts commit c17269ba8bc7cff3ee2481d1b2c9b14bbba7c34f. --- .../entanglement/src/services/LinkService.js | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/platform/entanglement/src/services/LinkService.js b/platform/entanglement/src/services/LinkService.js index 465a07f3de..40d809ebcb 100644 --- a/platform/entanglement/src/services/LinkService.js +++ b/platform/entanglement/src/services/LinkService.js @@ -39,17 +39,20 @@ define( } LinkService.prototype.validate = function (object, parentCandidate) { - var objectId = object.getId(); - return !!parentCandidate && - !!parentCandidate.getId && - parentCandidate.getId() !== objectId && - parentCandidate.hasCapability("composition") && - parentCandidate.getModel().composition.indexOf(objectId) === -1 && - this.policyService.allow( - "composition", - parentCandidate.getCapability('type'), - object.getCapability('type') - ); + if (!parentCandidate || !parentCandidate.getId) { + return false; + } + if (parentCandidate.getId() === object.getId()) { + 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) {