vicinityManager/server/services/items/registration.js
/*
Creates user in commServer
Adds user to communication server
If the oid exists in the commServer is deleted and created anew
*/
Creates user in commServer
Adds user to communication server
If the oid exists in the commServer is deleted and created anew
Creates user in commServer Adds user to communication server If the oid exists in the commServer is deleted and created anew
function commServerProcess(docOid, docName, docPassword){
  var payload = {
    username : docOid,
    name: docName,
    password: docPassword,
    };
    return commServer.callCommServer({}, 'users/' +  docOid, 'GET')
      .then(
        function(response){
          return commServer.callCommServer(payload, 'users/' +  docOid, 'DELETE') 
          .then(function(response){ return commServer.callCommServer(payload, 'users', 'POST');})
          .catch(function(err){ return new Promise(function(resolve, reject) { reject('Error in commServer: ' + err) ;} ); } );
        },
        function(err){
          if(err.statusCode !== 404){
            return new Promise(function(resolve, reject) { reject('Error in commServer: ' + err) ;} ); 
          } else {
            return commServer.callCommServer(payload, 'users', 'POST')
            .catch(function(err){ return new Promise(function(resolve, reject) { reject('Error in commServer: ' + err) ;} ); } );
          }
        }
      );
    }
function commServerProcess ( docOid , docName , docPassword ) { var payload = { username : docOid , name : docName , password : docPassword , } ; return commServer . callCommServer ( { } , 'users/' + docOid , 'GET' ) . then ( function ( response ) { return commServer . callCommServer ( payload , 'users/' + docOid , 'DELETE' ) . then ( function ( response ) { return commServer . callCommServer ( payload , 'users' , 'POST' ) ; } ) . catch ( function ( err ) { return new Promise ( function ( resolve , reject ) { reject ( 'Error in commServer: ' + err ) ; } ) ; } ) ; } , function ( err ) { if ( err . statusCode !== 404 ) { return new Promise ( function ( resolve , reject ) { reject ( 'Error in commServer: ' + err ) ; } ) ; } else { return commServer . callCommServer ( payload , 'users' , 'POST' ) . catch ( function ( err ) { return new Promise ( function ( resolve , reject ) { reject ( 'Error in commServer: ' + err ) ; } ) ; } ) ; } } ) ; }
Creates user in commServer
Adds user to communication server
If the oid exists in the commServer is deleted and created anew
Creates user in commServer Adds user to communication server If the oid exists in the commServer is deleted and created anew
// DELETE + POST instead of PUT because the OID might have changed the agent //           .then(function(response){ return commServer.callCommServer({}, 'users/' + docOid + '/groups/' + docOwner + '_ownDevices', 'POST');}) // Add to company group //           .then(function(response){ return commServer.callCommServer({}, 'users/' + docOid + '/groups/' + docAdid, 'POST');}) // Add to agent group // return rejected promise because we got a non controlled error //             .then(function(response){ return commServer.callCommServer({}, 'users/' + docOid + '/groups/' + docOwner + '_ownDevices', 'POST');}) // Add to company group //             .then(function(response){ return commServer.callCommServer({}, 'users/' + docOid + '/groups/' + docAdid, 'POST');}) // Add to agent group