Skip to content

Commit

Permalink
Replaced callback with return callback in many functions
Browse files Browse the repository at this point in the history
Replaced callback with return callback in many functions
  • Loading branch information
silvae86 committed Jun 15, 2017
1 parent 880006e commit b9d8575
Show file tree
Hide file tree
Showing 54 changed files with 895 additions and 891 deletions.
6 changes: 4 additions & 2 deletions conf/deployment_configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"active": true,
"database" :{
"log_all_queries": false,
"destroy_all_graphs_on_startup" : false
"destroy_all_graphs_on_startup" : false,
"log_query_timeouts" : false
},
"session": {
"auto_login": false,
Expand Down Expand Up @@ -451,7 +452,8 @@
"active": true,
"database" :{
"log_all_queries": false,
"destroy_all_graphs_on_startup" : false
"destroy_all_graphs_on_startup" : false,
"log_query_timeouts" : false
},
"session": {
"auto_login": false,
Expand Down
68 changes: 34 additions & 34 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ const init = function(callback)
//set default connection. If you want to add other connections, add them in succession.
GLOBAL.db.default.connection = db;

callback(null);
return callback(null);
}
});
},
Expand All @@ -429,7 +429,7 @@ const init = function(callback)
conn.deleteGraph(graphUri, function(err){
if(err)
{
callback(err);
return callback(err);
}
else
{
Expand All @@ -448,12 +448,12 @@ const init = function(callback)
});
}, function(err, res)
{
callback(err);
return callback(err);
});
}
else
{
callback(null);
return callback(null);
}
},
function(callback) {
Expand Down Expand Up @@ -485,7 +485,7 @@ const init = function(callback)
if(!err)
{
console.log("[INFO] Deleted all cache records on Redis instance \""+ redisConn.id +"\" during bootup");
callback(null);
return callback(null);
}
else
{
Expand All @@ -499,7 +499,7 @@ const init = function(callback)
if(!err)
{
console.log("[INFO] All Redis instances are up and running!");
callback(null);
return callback(null);
}
else
{
Expand All @@ -511,7 +511,7 @@ const init = function(callback)
else
{
console.log("[INFO] Cache not active in deployment configuration. Continuing Dendro startup without connecting to cache server.");
callback(null);
return callback(null);
}
},
function(callback) {
Expand All @@ -527,7 +527,7 @@ const init = function(callback)
{
GLOBAL.allOntologies = ontologies;
console.log("[OK] Ontology information successfully loaded from database.");
callback(null);
return callback(null);
}
else
{
Expand All @@ -542,7 +542,7 @@ const init = function(callback)
if(!err)
{
GLOBAL.allOntologies = ontologies;
callback(null);
return callback(null);
}
else
{
Expand All @@ -562,7 +562,7 @@ const init = function(callback)
if(!err)
{
console.log("[OK] All ontologies and descriptors seem correctly set up.");
callback(null);
return callback(null);
}
else
{
Expand All @@ -585,7 +585,7 @@ const init = function(callback)
console.log("[ERROR] Unable to create connection to index " + IndexConnection.indexes.dendro.short_name);
process.exit(1);
}
callback(null);
return callback(null);
});
},
function(callback) {
Expand All @@ -600,7 +600,7 @@ const init = function(callback)
else
{
console.log("[OK] Indexes are up and running on "+ Config.elasticSearchHost + ":" + Config.elasticSearchPort);
callback(null);
return callback(null);
}
});
},
Expand All @@ -623,7 +623,7 @@ const init = function(callback)
{
console.log("[OK] Connected to MongoDB file storage running on " + Config.mongoDBHost + ":" + Config.mongoDbPort);
GLOBAL.gfs.default.connection = gfs;
callback(null);
return callback(null);
}
});
},
Expand All @@ -640,7 +640,7 @@ const init = function(callback)
function (error, response) {
if (!error) {
console.log("[OK] Successfully connected to Dendro Recommender instance, version " + response.body.version + " at " + Config.recommendation.modes.dendro_recommender.host + ":" + Config.recommendation.modes.dendro_recommender.port + " :-)");
callback(null);
return callback(null);
}
else {
console.log("[ERROR] Unable to connect to Dendro Recommender at " + Config.recommendation.modes.dendro_recommender.host + ":" + Config.recommendation.modes.dendro_recommender.port + "! Aborting startup.");
Expand All @@ -663,7 +663,7 @@ const init = function(callback)
const poolOK = function (pool) {
console.log("[OK] Connected to MySQL Database server running on " + Config.mySQLHost + ":" + Config.mySQLPort);
GLOBAL.mysql.pool = pool;
callback(null);
return callback(null);
};

//connection.connect(function (err)
Expand Down Expand Up @@ -771,7 +771,7 @@ const init = function(callback)
{
if (!err)
{
callback(null);
return callback(null);
}
});
}
Expand Down Expand Up @@ -837,7 +837,7 @@ const init = function(callback)
if(!err)
{
console.log("[OK] Temporary files directory successfully set up at " + Config.tempFilesDir);
callback(null);
return callback(null);
}
else
{
Expand All @@ -857,7 +857,7 @@ const init = function(callback)
connectionsInitializedPromise.reject(results);
}

callback(err, results);
return callback(err, results);
});
};

Expand All @@ -875,18 +875,18 @@ const loadData = function(callback)
if (!err) {
if (isNull(user)) {
//everything ok, user simply does not exist
callback(null, null);
return callback(null, null);
}
else {
console.log("[INFO] Demo user with username " + user.ddr.username + " found. Attempting to delete...");
user.deleteAllMyTriples(function (err, result) {
callback(err, result);
return callback(err, result);
});
}
}
else {
console.log("[ERROR] Unable to delete user with username " + demoUser.username + ". Error: " + user);
callback(err, user);
return callback(err, user);
}
});
};
Expand Down Expand Up @@ -915,11 +915,11 @@ const loadData = function(callback)
},
function (err, newUser) {
if (!err && !isNull(newUser)) {
callback(null, newUser);
return callback(null, newUser);
}
else {
console.log("[ERROR] Error creating new demo User " + JSON.stringify(user));
callback(err, user);
return callback(err, user);
}
});
};
Expand All @@ -928,7 +928,7 @@ const loadData = function(callback)
if(!err)
{
console.log("[INFO] Existing demo users recreated. ");
callback(err);
return callback(err);
}
else
{
Expand All @@ -938,16 +938,16 @@ const loadData = function(callback)
}
else
{
callback(null);
return callback(null);
}
}
else
{
callback(null);
return callback(null);
}
}
else {
callback(err);
return callback(err);
}
});
},
Expand Down Expand Up @@ -976,7 +976,7 @@ const loadData = function(callback)

if (!err && !isNull(user)) {
user.makeGlobalAdmin(function (err, result) {
callback(err, result);
return callback(err, result);
});
}
else {
Expand All @@ -996,13 +996,13 @@ const loadData = function(callback)
function (err, newUser) {
if (!err && !isNull(newUser) && newUser instanceof User) {
newUser.makeGlobalAdmin(function (err, newUser) {
callback(err, newUser);
return callback(err, newUser);
});
}
else {
const msg = "Error creating new User" + JSON.stringify(newUser);
console.error(msg);
callback(err, msg);
return callback(err, msg);
}
});
}
Expand All @@ -1018,14 +1018,14 @@ const loadData = function(callback)
console.log("[ERROR] Unable to load admins. Error : " + err);
}

callback(err);
return callback(err);
});
}
],
function(err, results){
if(!err)
{
callback(null);
return callback(null);
}
else
{
Expand All @@ -1035,12 +1035,12 @@ const loadData = function(callback)
}
else
{
callback(null);
return callback(null);
}
}],
function(err, results)
{
callback(err, results);
return callback(err, results);
}
);
};
Expand Down
16 changes: 8 additions & 8 deletions src/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports.reload = function(req, res)
deleteGraph("http://dbpedia.org",
function(err, resultOrErrorMessage)
{
callback(err, [resultOrErrorMessage]);
return callback(err, [resultOrErrorMessage]);
});
},
function(callback, result)
Expand Down Expand Up @@ -180,13 +180,13 @@ var rebuildIndex = function(indexConnection, graphShortName, deleteBeforeReindex
if(!err && result)
{
console.log("Index "+indexConnection.index.short_name+" recreated .");
callback(null);
return callback(null);

}
else
{
console.log("Error recreating index "+indexConnection.index.short_name+" . " + result);
callback(1); //delete success, move on
return callback(1); //delete success, move on
}
});
},
Expand All @@ -209,11 +209,11 @@ var rebuildIndex = function(indexConnection, graphShortName, deleteBeforeReindex
});
}

callback(0, null);
return callback(0, null);
}
else
{
callback(1, "Error fetching all resources in the graph : " + results);
return callback(1, "Error fetching all resources in the graph : " + results);
}
});
}
Expand All @@ -222,17 +222,17 @@ var rebuildIndex = function(indexConnection, graphShortName, deleteBeforeReindex
{
if(!err)
{
callback(null, results);
return callback(null, results);
}
else
{
callback(1, results);
return callback(1, results);
}
});
}
else
{
callback(1, "Non-existent index : " + graphShortName);
return callback(1, "Non-existent index : " + graphShortName);
}
};

Expand Down
Loading

0 comments on commit b9d8575

Please sign in to comment.