summaryrefslogtreecommitdiffstats
path: root/admportal/server/router/routes/user.js
diff options
context:
space:
mode:
authorTimoney, Daniel (dt5972) <dtimoney@att.com>2017-02-15 10:37:53 -0500
committerTimoney, Daniel (dt5972) <dtimoney@att.com>2017-02-15 10:40:37 -0500
commit324ee36fe31763e507b422ab0a88e4230045e205 (patch)
treed0b04520f6657601c918ce63fd27575977624187 /admportal/server/router/routes/user.js
parentf0c97e8db427481e28c0a16b789bc73801b35e47 (diff)
Initial commit for OpenECOMP SDN-C OA&M
Change-Id: I7ab579fd0d206bf356f36d52dcdf4f71f1fa2680 Signed-off-by: Timoney, Daniel (dt5972) <dtimoney@att.com> Former-commit-id: 2a9f0edd09581f907e62ec4689b5ac94dd5382ba
Diffstat (limited to 'admportal/server/router/routes/user.js')
-rw-r--r--admportal/server/router/routes/user.js169
1 files changed, 169 insertions, 0 deletions
diff --git a/admportal/server/router/routes/user.js b/admportal/server/router/routes/user.js
new file mode 100644
index 00000000..116bf932
--- /dev/null
+++ b/admportal/server/router/routes/user.js
@@ -0,0 +1,169 @@
+var express = require('express');
+var router = express.Router();
+var exec = require('child_process').exec;
+var util = require('util');
+var fs = require('fs');
+var dbRoutes = require('./dbRoutes');
+var csp = require('./csp');
+var bodyParser = require('body-parser');
+var sax = require('sax'),strict=true,parser = sax.parser(strict);
+
+// SVC_LOGIC table columns
+var _module=''; // cannot use module its a reserved word
+var version='';
+var rpc='';
+var mode='';
+var xmlfile='';
+
+
+//router.use(bodyParser());
+router.use(bodyParser.urlencoded({
+ extended: true
+}));
+
+
+// GET
+router.get('/listUsers', csp.checkAuth, function(req,res) {
+ dbRoutes.listUsers(req,res, {user:req.session.loggedInAdmin,code:'', msg:''} );
+});
+router.get('/deleteUser', csp.checkAuth, dbRoutes.checkDB, function(req,res) {
+ dbRoutes.deleteUser(req,res, {code:'', msg:''} );
+});
+
+//router.get('/activate', csp.checkAuth, dbRoutes.checkDB, function(req,res){
+
+ //var _module = req.query.module;
+ //var rpc = req.query.rpc;
+ //var version = req.query.version;
+ //var mode = req.query.mode;
+
+ //dbRoutes.activate(req,res,_module,rpc,version,mode);
+//});
+
+//router.get('/deactivate', csp.checkAuth, dbRoutes.checkDB, function(req,res){
+
+ //var _module = req.query.module;
+ //var rpc = req.query.rpc;
+ //var version = req.query.version;
+ //var mode = req.query.mode;
+//
+ //dbRoutes.deactivate(req,res,_module,rpc,version,mode);
+//});
+
+//router.get('/deleteDG', csp.checkAuth, dbRoutes.checkDB, function(req,res){
+
+ //var _module = req.query.module;
+ //var rpc = req.query.rpc;
+ //var version = req.query.version;
+ //var mode = req.query.mode;
+
+ //dbRoutes.deleteDG(req,res,_module,rpc,version,mode);
+//});
+/*
+// SAX
+parser.onerror = function (e) {
+ logger.debug('onerror');
+ // an error happened.
+};
+parser.ontext = function (t) {
+ // got some text. t is the string of text.
+ logger.debug('ontext:'+t);
+};
+parser.onopentag = function (node) {
+ // opened a tag. node has "name" and "attributes"
+ if ( node.name == 'service-logic' )
+ {
+ _module = node.attributes.module;
+ version = node.attributes.version;
+ }
+ if ( node.name == 'method' )
+ {
+ rpc = node.attributes.rpc;
+ mode = node.attributes.mode;
+ }
+};
+parser.onattribute = function (attr) {
+ // an attribute. attr has "name" and "value"
+ logger.debug('onattribute:'+attr);
+};
+parser.onend = function () {
+ // parser stream is done, and ready to have more stuff written to it.
+ logger.debug('onend:');
+};
+*/
+
+
+// POST
+router.post('/updateUser', csp.checkAuth, dbRoutes.checkDB, function(req,res,next){
+ dbRoutes.updateUser(req,res,{code:'',msg:''});
+});
+router.post('/addUser', csp.checkAuth, dbRoutes.checkDB, function(req,res) {
+ dbRoutes.addUser(req,res, {code:'', msg:''} );
+});
+
+//router.post('/upload', csp.checkAuth, dbRoutes.checkDB, function(req, res, next){
+
+/*
+logger.debug("upload");
+ if(req.files.filename){
+ if (req.files.filename.size == 0) {
+ resultObj =
+ {code:'danger', msg:'There was an error uploading the file, please try again.'};
+ dbRoutes.listSLA(req,res, resultObj);
+ }
+ fs.exists(req.files.filename.path, function(exists) {
+ if(exists) {
+ resultObj = {code:'success', msg:'File sucessfully uploaded.'};
+
+ // parse xml
+ try {
+ var file_buf = fs.readFileSync(req.files.filename.path, "utf8");
+logger.debug('file '+req.files.filename);
+
+
+ // call Dan's svclogic shell script from here
+ var commandToExec = process.cwd()
+ + "/shell/svclogic.sh load "
+ + req.files.filename.path + " "
+ + process.cwd()
+ + "/config/svclogic.properties";
+
+ logger.debug("commandToExec:" + commandToExec);
+ child = exec(commandToExec ,function (error,stdout,stderr){
+ if(error){
+ logger.info("error:" + error);
+ }
+ if(stderr){
+ logger.info("stderr:" + stderr);
+ }
+ if(stdout){
+ logger.info("OUTPUT:" + stdout);
+ dbRoutes.listSLA(req,res, resultObj);
+ }
+
+ // remove the grave accents, the sax parser does not like them
+ //parser.write(file_buf.replace(/\`/g,'').toString('utf8')).close();
+ //dbRoutes.addDG(_module,version,rpc,mode,file_buf,req,res);
+ //dbRoutes.listSLA(req,res, resultObj);
+ });
+ } catch(ex) {
+ // keep 'em silent
+ logger.debug('sax error:'+ex);
+ }
+
+ } else {
+ resultObj =
+ {code:'danger', msg:'There was an error uploading the file, please try again.'};
+ dbRoutes.listSLA(req,res, resultObj);
+ }
+ });
+ }
+ else {
+ resultObj =
+ {code:'danger', msg:'There was an error uploading the file, please try again.'};
+ dbRoutes.listSLA(req,res, resultObj);
+ }
+});
+*/
+
+module.exports = router;