Rmove all organization's attached policies

@param  {Object}   params { id, organizationId }
@param  {Function} cb
763474
function deleteOrganizationAttachedPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id }, validationRules.deleteOrganizationPolicies, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = id

          next()
        },
        checkOrg,
        clearOrganizationAttachedPolicies
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        organizationOps.readById(id, cb)
      })

      return promise
    }
380804
def detach_user_policy(policy_name, user_name,
                  region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    policy_arn = _get_policy_arn(policy_name, region, key, keyid, profile)
    try:
        conn.detach_user_policy(policy_arn, user_name)
        log.info('Detached %s policy from IAM user %s.', policy_name, user_name)
    except boto.exception.BotoServerError as e:
        log.debug(e)
        log.error('Failed to detach %s policy from IAM user %s.', policy_name, user_name)
        return False
    return True
1019746
function (target, cb) {
      if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
      var cleared = 0, remove = []
      
      function clear () {
        var n = remove.length
        while(remove.length) store.rm(remove.shift(), function () {
          if(--n) return
          if(cleared < target)
            cb(new Error('could not clear requested space'), cleared)
          else
            cb(null, cleared)
        })
      }

      store.ls(function (err, ls) {
        if(err) return cb(err)
        log.unfiltered(function (err, unfiltered) {
          if(err) return cb(err)
          var stored = unfiltered.reverse()
          ls.forEach(function (a) {
            if(!unfiltered.find(function (b) {
              return a.id == b.id
            })) {
              cleared += a.size
              remove.push(a.id)
            }
          })

          for(var i = 0; i < stored.length; i++) {
            var id = stored[i].value
            var item = ls.find(function (e) {
              return e.id === id
            })
            
            if(item) {
              cleared += item.size
              remove.push(id)
              if(cleared >= target) return clear()
            }
          }
          clear()
        })
      })
    }
1186955
function(model, id, settings, options, cb) {
      if (settings == null) {
        settings = {};
      }
      if (options == null) {
        options = {};
      }
      if (cb == null) {
        cb = function() {};
      }
      Hoek.assert(model, i18n.assertModuleRequired);
      Hoek.assert(id, i18n.assertIdRequired);
      return model.findOne({
        _id: asObjectId(id)
      }, function(err, item) {
        if (err) {
          return cb(err);
        }
        if (!item) {
          return cb(null);
        }
        return item.remove(function(err) {
          if (err) {
            return cb(err);
          }
          return cb(null, item);
        });
      });
    }
975592
function addUsersToTeam (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, users, organizationId } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, users, organizationId }, validationRules.addUsersToTeam, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.teamId = id
          job.organizationId = organizationId
          job.params = params

          next()
        },
        (job, next) => {
          utils.checkUsersOrg(job.client, job.params.users, job.organizationId, next)
        },
        checkTeamExists,
        insertTeamMembers
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)
        teamOps.readTeam({ id, organizationId }, cb)
      })

      return promise
    }
1108710
def do_rmr(self, params):
        
        for path in params.paths:
            self._zk.delete(path, recursive=True)
760298
function removeCachedFiles(params, cb) {
  //Cleaning Up Any Files Cached To Render The Submission.
  logger.debug("cacheFiles: mergeSubmissionFiles Removing Cached Files For PDF Generation: ", params.submissionFiles);
  async.eachSeries(params.submissionFiles || [], function(submissionFileDetails, cb) {
    logger.debug("Removing Cached File: ", submissionFileDetails);
    fs.unlink(submissionFileDetails.url, function(err) {
      if (err) {
        logger.error('Error Removing File At' + submissionFileDetails.url);
      }

      return cb();
    });
  }, cb);
}
1048041
function (invoiceitem, cb) {

		Invoiceitem.destroy(invoiceitem.id)
	    .exec(function (err, destroyedInvoiceitems){
	      if (err) return cb(err);
	      if (!destroyedInvoiceitems) return cb(null, null);
	      Invoiceitem.afterStripeInvoiceitemDeleted(destroyedInvoiceitems[0], function(err, invoiceitem){
	      	cb(err, invoiceitem);
	      });
	    });
	}
857582
function updateUser (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId, name, metadata } = params

      Joi.validate({ id, organizationId, name, metadata }, validationRules.updateUser, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          UPDATE users
          SET name = ${name},
          metadata = ${metadata}
          WHERE id = ${id}
          AND org_id = ${organizationId}
        `
        db.query(sqlQuery, (err, result) => {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound(`User ${id} not found`))

          userOps.readUser({ id, organizationId }, cb)
        })
      })

      return promise
    }
306247
function history(params, cb) {
  params.resourcePath = config.addURIParams(constants.STATS_BASE_PATH + "/history", params);
  params.method = 'POST';
  params.data = params.data || {};
  mbaasRequest.admin(params, cb);
}
1049383
function clean (args, cb) {
  if (!cb) cb = args, args = []
  if (!args) args = []
  args = args.join("/").split("@").join("/")
  if (args.substr(-1) === "/") args = args.substr(0, args.length - 1)
  rm(path.join(npm.cache, path.normalize(args)), cb)
}
78398
function filterOutTrailingCbParam(args) { // if has trailing cb | callback param, filter it out
    if (args.length && args[args.length - 1].match(CB_NAMES_RE)) args.pop();
    return args;
  }
395787
function deleteTeamPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params

      Joi.validate({ id, organizationId }, validationRules.deleteTeamPolicies, function (err) {
        if (err) return cb(Boom.badRequest(err))

        clearTeamPolicies({ teamId: id, client: db }, (err, res) => {
          if (err) return cb(err)
          teamOps.readTeam({ id, organizationId }, cb)
        })
      })

      return promise
    }
809315
function deleteUserPolicy (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { userId, organizationId, policyId, instance } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ userId, organizationId, policyId, instance }, validationRules.deleteUserPolicy, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = userId
          job.policyId = policyId
          job.organizationId = organizationId
          job.instance = instance

          next()
        },
        checkUserOrg,
        removeUserPolicy
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        userOps.readUser({ id: userId, organizationId }, cb)
      })

      return promise
    }
466578
function restoreManuallyRemovedItems(cbsConfigFromLS) {
    cbsConfigFromLS[browser_storage_config_1.browserStorageConfig.DB_INITIAL_KEY].map(function (memoryItem) {
        var storageItemValue = getItemValueFromBrowserStorage(memoryItem);
        // the storage item has been removed, put back from memory object
        if (typeof storageItemValue === 'undefined') {
            saveItemToBrowserStorage(memoryItem);
        }
    });
}
1276999
function listAllUserPolicies ({ userId, organizationId }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const rootOrgId = config.get('authorization.superUser.organization.id')
      const sql = SQL`
        WITH user_teams AS (
          SELECT id FROM teams WHERE path @> (
            SELECT array_agg(path) FROM teams
            INNER JOIN team_members tm
            ON tm.team_id = teams.id
            WHERE tm.user_id = ${userId}
          )
        ),
        policies_from_teams AS (
          SELECT
            policy_id, variables
          FROM
            team_policies
          WHERE
            team_id IN (SELECT id FROM user_teams)
        ),
        policies_from_user AS (
          SELECT
            policy_id, variables
          FROM
            user_policies
          WHERE
            user_id = ${userId}
        ),
        policies_from_organization AS (
          SELECT
            op.policy_id, variables
          FROM
            organization_policies op
          LEFT JOIN
            users u ON u.org_id = op.org_id
          WHERE
            u.id = ${userId}
        ),
        is_root_user AS (
          SELECT FROM users WHERE id=${userId} AND org_id = ${rootOrgId}
        )
        SELECT
          id,
          version,
          name,
          statements,
          policies_from_user.variables AS variables
        FROM
          policies
        INNER JOIN
          policies_from_user
        ON
          policies.id = policies_from_user.policy_id
        WHERE (
            org_id = ${organizationId}
          OR (
              EXISTS (SELECT FROM is_root_user)
            AND
              org_id = ${rootOrgId}
          )
          OR org_id IS NULL
        )
        UNION
        SELECT
          id,
          version,
          name,
          statements,
          policies_from_teams.variables AS variables
        FROM
          policies
        INNER JOIN
          policies_from_teams
        ON
          policies.id = policies_from_teams.policy_id
        WHERE (
            org_id = ${organizationId}
          OR (
              EXISTS (SELECT FROM is_root_user)
            AND
              org_id = ${rootOrgId}
          )
          OR org_id IS NULL
        )
        UNION
        SELECT
          id,
          version,
          name,
          statements,
          policies_from_organization.variables
        FROM
          policies
        INNER JOIN
          policies_from_organization
        ON
          policies.id = policies_from_organization.policy_id
        WHERE (
            org_id = ${organizationId}
          OR (
              EXISTS (SELECT FROM is_root_user)
            AND
              org_id = ${rootOrgId}
          )
          OR org_id IS NULL
        )
      `

      db.query(sql, function (err, result) {
        if (err) return cb(Boom.badImplementation(err))
        cb(null, result.rows.map(mapping.policy.iam))
      })

      return promise
    }
1092952
function readSharedPolicy ({ id }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      Joi.validate({ id }, validationRules.readSharedPolicy, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          SELECT  *
          FROM policies
          WHERE id = ${id}
          AND org_id IS NULL
        `
        db.query(sqlQuery, function (err, result) {
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound())

          return cb(null, mapping.policy(result.rows[0]))
        })
      })

      return promise
    }