it('should_create_with_exist_dup_fail_works_fine', function (done) {
   dup_controller.createDup('xx-xx/xx.xx', '/app1/key2', 'F', function (err, data) {
     if (err) {
       err.name.should.eql('PATH_DUP_EXISTS');
       done();
     }
   });
 });
 it('should_create_with_no_right_fail_works_fine', function (done) {
   dup_controller.createDup('yy-yy/yy.yy', '/app1/key3', 'F', function (err, data) {
     if (err) {
       err.name.should.eql('ACL_WRITE_NOT_PERMITTED');
       done();
     }
   });
 });
 Factory.getMysql('ui').query('SELECT * FROM ' + tbname + ' WHERE userid = \'xx-xx/xx.xx\'', function (err, data) {
   data.length.should.eql(3);
   //create
   dup_controller.createDup('xx-xx/xx.xx', '/app1/key3', 'F', function (err, data) {
     //after create
     mysql_wrapper.getDups('xx-xx/xx.xx', function (err, data) {
       data.length.should.eql(3);
       done();
     });
   });
 });
Example #4
0
exports.execute = function (req, callback) {
  var user = 'xx-xx/xx.xx';
  var action = req.url.get(0);

  var info = 'User:\'%s\',data:\'%s\',ip:\'%s\''; 
  Factory.getLog('debug').notice(action.toUpperCase(),Util.format(info,user,req.data,req.info.ipaddr));

  switch (action) {
  case 'getdups' :
    dupCtl.getUserDups(user, function (err, data) {
      var ret = {}
      if (err) {
        ret.message = err_check(err) ? 'get dups error' : err.message;
      } else {
        ret.message = '';
        ret.data = data;
      }

      callback(null, JSON.stringify(ret));
    });
    break;

  case 'createdup' :
    var obj = JSON.parse(req.data);
    dupCtl.createDup(user, obj.path, obj.type, function (err) {
      var ret = {}
      if (err) {
        ret.message = err_check(err) ? 'create dup error' : err.message;
      } else {
        ret.message = '';
      }

      callback(null, JSON.stringify(ret));
    });
    break;

  case 'savedup' :
    var obj = JSON.parse(req.data);
    dupCtl.saveDup(user, obj.path, obj.content, function (err) {
      var ret = {}
      if (err) {
        ret.message = err_check(err) ? 'save dup error' : err.message;
      } else {
        ret.message = '';
      }

      callback(null, JSON.stringify(ret));
    });
    break;

  case 'deletedup' :
    dupCtl.deleteDup(user, JSON.parse(req.data).path, function (err) {
      var ret = {}
      if (err) {
        ret.message = err_check(err) ? 'delete dup error' : err.message;
      } else {
        ret.message = '';
      }

      callback(null, JSON.stringify(ret));
    });
    break;

  default :
    break;
  }
}