You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2016/02/16 11:51:10 UTC

ignite git commit: IGNITE-843 Fixed domain save.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 1921dcd1b -> aa8c1a9cd


IGNITE-843 Fixed domain save.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aa8c1a9c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aa8c1a9c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aa8c1a9c

Branch: refs/heads/ignite-843-rc2
Commit: aa8c1a9cd69f9813dd9a1a92ceea8866a688f545
Parents: 1921dcd
Author: Andrey <an...@gridgain.com>
Authored: Tue Feb 16 17:51:32 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Feb 16 17:51:32 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/domains.js         | 70 ++++++++++----------
 1 file changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/aa8c1a9c/modules/control-center-web/src/main/js/serve/routes/domains.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/domains.js b/modules/control-center-web/src/main/js/serve/routes/domains.js
index ff9a29b..d1cd8d0 100644
--- a/modules/control-center-web/src/main/js/serve/routes/domains.js
+++ b/modules/control-center-web/src/main/js/serve/routes/domains.js
@@ -74,7 +74,7 @@ module.exports.factory = (_, express, mongo) => {
         }
 
         function _saveDomainModel(domain, savedDomains) {
-            return new Promise((resolve) => {
+            return new Promise((resolve, reject) => {
                 const caches = domain.caches;
                 const cacheStoreChanges = domain.cacheStoreChanges;
                 const domainId = domain._id;
@@ -88,7 +88,8 @@ module.exports.factory = (_, express, mongo) => {
 
                             _updateCacheStore(cacheStoreChanges);
                         })
-                        .then(() => resolve());
+                        .then(resolve)
+                        .catch(reject);
                 }
                 else {
                     mongo.DomainModel.findOne({space: domain.space, valueType: domain.valueType}).exec()
@@ -104,7 +105,8 @@ module.exports.factory = (_, express, mongo) => {
                             return mongo.Cache.update({_id: {$in: caches}}, {$addToSet: {domains: savedDomain._id}}, {multi: true}).exec();
                         })
                         .then(() => _updateCacheStore(cacheStoreChanges))
-                        .then(() => resolve());
+                        .then(resolve)
+                        .catch(reject);
                 }
             });
         }
@@ -116,38 +118,36 @@ module.exports.factory = (_, express, mongo) => {
                 const promises = [];
 
                 _.forEach(domains, (domain) => {
-                    promises.push(new Promise((resolve) => {
-                        if (domain.newCache) {
-                            mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
-                                .then((cache) => {
-                                    if (cache) {
-                                        // Cache already exists, just save domain model.
-                                        domain.caches = [cache._id];
-
-                                        _saveDomainModel(domain, savedDomains).then(() => resolve());
-                                    }
-                                    else {
-                                        // If cache not found, then create it and associate with domain model.
-                                        const newCache = domain.newCache;
-                                        newCache.space = domain.space;
-
-                                        (new mongo.Cache(newCache)).save()
-                                            .then((generatedCache) => {
-                                                const cacheId = generatedCache._id;
-
-                                                generatedCaches.push(generatedCache);
-
-                                                domain.caches = [cacheId];
-
-                                                return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
-                                            })
-                                            .then(() => _saveDomainModel(domain, savedDomains).then(() => resolve()));
-                                    }
-                                });
-                        }
-                        else
-                            _saveDomainModel(domain, savedDomains).then(() => resolve());
-                    }));
+                    if (domain.newCache) {
+                        mongo.Cache.findOne({space: domain.space, name: domain.newCache.name}).exec()
+                            .then((cache) => {
+                                if (cache) {
+                                    // Cache already exists, just save domain model.
+                                    domain.caches = [cache._id];
+
+                                    promises.push(_saveDomainModel(domain, savedDomains))
+                                }
+                                else {
+                                    // If cache not found, then create it and associate with domain model.
+                                    const newCache = domain.newCache;
+                                    newCache.space = domain.space;
+
+                                    (new mongo.Cache(newCache)).save()
+                                        .then((generatedCache) => {
+                                            const cacheId = generatedCache._id;
+
+                                            generatedCaches.push(generatedCache);
+
+                                            domain.caches = [cacheId];
+
+                                            return mongo.Cluster.update({_id: {$in: generatedCache.clusters}}, {$addToSet: {caches: cacheId}}, {multi: true}).exec();
+                                        })
+                                        .then(() => promises.push(_saveDomainModel(domain, savedDomains)))
+                                }
+                            });
+                    }
+                    else
+                        promises.push(_saveDomainModel(domain, savedDomains));
                 });
 
                 Promise.all(promises)