Creates a session state object from the values of the current role, current
warehouse, etc., returned in the result response.

@param responseData

@returns {Object}
199954
function createSessionState(responseData)
{
  var currentRole             = responseData.finalRoleName;
  var currentWarehouse        = responseData.finalWarehouseName;
  var currentDatabaseProvider = responseData.databaseProvider;
  var currentDatabase         = responseData.finalDatabaseName;
  var currentSchema           = responseData.finalSchemaName;

  return {
    getCurrentRole: function()
    {
      return currentRole;
    },
    getCurrentWarehouse: function()
    {
      return currentWarehouse;
    },
    getCurrentDatabaseProvider: function()
    {
      return currentDatabaseProvider;
    },
    getCurrentDatabase: function()
    {
      return currentDatabase;
    },
    getCurrentSchema: function()
    {
      return currentSchema;
    }
  };
}
380205
function createAgentChildState (appname, moduleName, state, parentStateName, moduleUrl) {
  var controllerPath = path.join(appname, 'generated', 'agents', moduleName, 'controllers'),
    partialPath = path.join(appname, 'generated', 'partials', 'agents', moduleName)

  state['name'] = state.subPath.replace('/', '')

  fs.mkdir(path.join(controllerPath, parentStateName), function (response) {
    createTemplate(appname, path.join('generated', 'agents', 'agentChildController.js'), {
      moduleName: moduleName,
      state: state
    })
    var oldControllerPath = path.join(appname, 'generated', 'agents', 'agentChildController.js'),
      newControllerPath = path.join(controllerPath, parentStateName, state.name + '.js')
    fs.renameSync(oldControllerPath, newControllerPath)
  })

  fs.mkdir(path.join(partialPath, parentStateName), function (response) {
    createTemplate(appname, path.join('generated', 'agents', 'agentChild.html'), {
      moduleName: moduleName,
      parentStateName: parentStateName,
      state: state,
      moduleUrl: moduleUrl

    })

    var oldHtmlPath = path.join(appname, 'generated', 'agents', 'agentChild.html'), newHtmlPath = path.join(partialPath,
        parentStateName, state.name + '.html')
    fs.renameSync(oldHtmlPath, newHtmlPath)
  })
}
131967
function parseResponse(response) {
  let text;

  if (response && response.content && (typeof response.content === 'string')) {
    text = response.content;
  }

  if (response && response.text && (typeof response.text === 'string')) {
    text = response.text;
  }

  if (!text) {
    console.error('Did not supply any matching response format. Response is:', text);
    return null;
  }

  try {
    const parsedResponse = JSON.parse(text);

    if (
      parsedResponse
      && parsedResponse.data
      && (parsedResponse.data instanceof Object === true)
    ) {
      return parsedResponse.data;
    }
  } catch (err) {
    console.error('Error while parsing JSON', err);
  }

  return null;
}
252414
def load(self):
        

        response = self.table.get_item(
            Key={'session_key': self.session_key},
            ConsistentRead=ALWAYS_CONSISTENT)
        if 'Item' in response:
            session_data = response['Item']['data']
            return self.decode(session_data)
        else:
            self.create()
            return {}
1282437
function resp(response) {
        if (!request.session) {
          debug("no session")
          return response
        }

        if (utils.shouldSetCookie(request) === false) {
          return response
        }

        // only send secure cookies via https
        if (request.session.cookie.secure && !utils.issecure(request, trustProxy)) {
          debug("not secured")
          return response
        }
        // touch session
        request.session.touch()
        // set cookie
        utils.setcookie(response, name, request.sessionID, secrets[0], request.session.cookie.data)

        if (utils.shouldDestroy(request)) {
          debug("destroying")
          store.destroy(request.sessionID, function ondestroy(err) {
            if (err) throw err
            debug("destroyed")
          })
        } else if (utils.shouldSave(request)) {
          request.session.save(function onsave(err) {
            if (err) throw err
          })
        } else if (utils.storeImplementsTouch && utils.shouldTouch(request)) {
          // store implements touch method
          debug("touching")
          store.touch(request.sessionID, request.session, function ontouch(err) {
            if (err) throw err
            debug("touched")
          })
        }

        return response
      }
348928
private function withSessionCookie(ResponseInterface $response, string $session_id): ResponseInterface
    {
        // Merge session cookie options.
        $default = session_get_cookie_params();

        $default = array_change_key_case($default, CASE_LOWER);
        $options = array_change_key_case($this->options, CASE_LOWER);

        $options = array_merge($default, $options);

        if ($options['lifetime'] < 0) $options['lifetime'] = 0;

        // Create a session cookie and attach it to the response.
        $cookie = SetCookie::create($this->name, $session_id)
            ->withMaxAge($options['lifetime'])
            ->withPath($options['path'])
            ->withDomain($options['domain'])
            ->withSecure($options['secure'])
            ->withHttpOnly($options['httponly']);

        if ($options['lifetime'] > 0) {

            $cookie = $cookie->withExpires(time() + $options['lifetime']);

        }

        return FigResponseCookies::set($response, $cookie);
    }
909727
def from_response(cls, response):
        
        hash_key = None
        range_key = None
        # KeySchema may not be in the response if the TableStatus is DELETING.
        if 'KeySchema' in response:
            attrs = dict(((d['AttributeName'],
                           DynamoKey(d['AttributeName'], d['AttributeType']))
                          for d in response['AttributeDefinitions']))
            hash_key = attrs[response['KeySchema'][0]['AttributeName']]
            if len(response['KeySchema']) > 1:
                range_key = attrs[response['KeySchema'][1]['AttributeName']]

        indexes = []
        for idx in response.get('LocalSecondaryIndexes', []):
            indexes.append(LocalIndex.from_response(idx, attrs))
        global_indexes = []
        for idx in response.get('GlobalSecondaryIndexes', []):
            global_indexes.append(GlobalIndex.from_response(idx, attrs))

        table = cls(
            name=response['TableName'],
            hash_key=hash_key,
            range_key=range_key,
            indexes=indexes,
            global_indexes=global_indexes,
            throughput=Throughput.from_response(
                response['ProvisionedThroughput']),
            status=response['TableStatus'],
            size=response['TableSizeBytes'],
        )
        table.response = response
        return table
119303
function createAction(config){
    // make a copy of config with defaults
    config = basis.object.extend({
      prepare: nothingToDo,
      request: nothingToDo
    }, config);

    // if body is function take in account special action context
    if (typeof config.body == 'function')
    {
      var bodyFn = config.body;
      config.body = function(){
        return bodyFn.apply(this.context, this.args);
      };
    }

    // splice properties
    var fn = basis.object.splice(config, ['prepare', 'request']);
    var callback = basis.object.merge(
      DEFAULT_CALLBACK,
      basis.object.splice(config, ['start', 'success', 'failure', 'abort', 'complete'])
    );

    // lazy transport
    var getTransport = basis.fn.lazyInit(function(){
      var transport = resolveTransport(config);

      transport.addHandler(CALLBACK_HANDLER, callback);

      return transport;
    });

    return function action(){
      // this - instance of AbstractData
      if (this.state != STATE_PROCESSING)
      {
        if (fn.prepare.apply(this, arguments))
        {
          /** @cut */ basis.dev.info('Prepare handler returns trulthy result. Operation aborted. Context: ', this);
          return Promise.reject('Prepare handler returns trulthy result. Operation aborted. Context: ', this);
        }

        var request;
        var requestData = basis.object.complete({
          origin: this,
          bodyContext: {
            context: this,
            args: basis.array(arguments)
          }
        }, fn.request.apply(this, arguments));

        // if body is function take in account special action context
        if (typeof requestData.body == 'function')
        {
          var bodyFn = requestData.body;
          requestData.body = function(){
            return bodyFn.apply(this.context, this.args);
          };
        }

        // do a request
        if (request = getTransport().request(requestData))
          return new Promise(function(fulfill, reject){
            request.addHandler(PROMISE_REQUEST_HANDLER, {
              request: request,
              fulfill: fulfill,
              reject: reject
            });
          });

        return Promise.reject('Request is not performed');
      }
      else
      {
        /** @cut */ basis.dev.warn('Context in processing state. Operation aborted. Context: ', this);
        return Promise.reject('Context in processing state, request is not performed');
      }
    };
  }
28462
function (responseV1) {
        var response = {},
            self = this,
            originalRequest;

        originalRequest = self.savedRequest(responseV1);

        // add ids to the v2 result only if both: the id and retainIds are truthy.
        // this prevents successive exports to v2 from being overwhelmed by id diffs
        self.options.retainIds && (response.id = responseV1.id || util.uid());

        response.name = responseV1.name || 'response';
        response.originalRequest = originalRequest ? self.request(originalRequest) : undefined;
        response.status = responseV1.responseCode && responseV1.responseCode.name || undefined;
        response.code = responseV1.responseCode && responseV1.responseCode.code || undefined;
        response._postman_previewlanguage = responseV1.language;
        response._postman_previewtype = responseV1.previewType;
        response.header = responseV1.headers;
        response.cookie = _.map(responseV1.cookies, function (cookie) {
            return self.cookie(cookie);
        });
        response.responseTime = responseV1.time;
        response.body = responseV1.text;

        return response;
    }
1256694
function onQuery(data) {
                let entities = data[0];
                const info = data[1];

                // Add id property to entities and suppress properties
                // where "read" setting is set to false
                entities = entities.map(entity => (
                    datastoreSerializer.fromDatastore.call(Model, entity, options)
                ));

                const response = {
                    entities,
                };

                if (info.moreResults !== Model.gstore.ds.NO_MORE_RESULTS) {
                    response.nextPageCursor = info.endCursor;
                }

                return response;
            }
10791
function createResponse(request, response, body){
  return {
    statusCode: response.statusCode,
    statusText: response.statusMessage,
    headers: response.headers,
    originalUrl: request.url,
    effectiveUrl: request.url,
    redirected: false,
    requestMethod: request.method,
    requestHeaders: request.headers,
    body: body,
    retries: 0,
    throttled: false
  };
}
1040146
function createSession(){

    // can also check if any ealier session can be used
    if (!currentSession){
        
        const createNewSession = _setSessionReferrer();
        const currentSessionCookie = utils.getCookie(constants.sessionCookieName);

        if (currentSessionCookie && !createNewSession){

            const currentSessionSplit = currentSessionCookie.split('__');
            currentSession = new session(currentSessionSplit[0], 
                parseInt(currentSessionSplit[1]), {});
            
            logger.debug('Found existing session', currentSessionSplit[0], 
                currentSessionSplit[1]);

        } else{

            currentSession = new session(null, null, {});
            setSessionCookie();

            logger.debug('Creating new session', currentSession.getSessionToken(), 
                currentSession.getSessionUnixTime());

        }

        // associate session referrer with the session
        if (sessionReferrer){

            currentSession.setExtra('referrer', sessionReferrer);
            
        }
        
    }

    return currentSession;

}
755352
function(state, data){
      if (this.delegate)
        return this.root.setState(state, data);
      else
        return AbstractData.prototype.setState.call(this, state, data);
    }
337912
function(callback){
			var self = this;
			if(!this.id){
				return process.nextTick(function(){
					callback(new Error("Invalid session ID"));
				});
			}

			options.client.get(options.keyspace + self.id, function(error, resp){
				if(error)
					return callback(error);
				try{
					resp = JSON.parse(resp);
				}catch(e){
					return callback(e);
				}
				extendSession(self, resp);
				callback();
			});
		}
657678
function loadMockDbResponse (mockData, options) {
    immutableAutomock.dbResponseMocks[mockData.data.dbQueryId] = mockData.data
}
1181594
function(session) {
        if (session && session.user) {
            if (session.user.roles)
                return { roles: session.user.roles };
            return { roles: "user" };
        }
        return { roles: "public" };
    }
122080
public String createStateCookie(HttpServletRequest request, HttpServletResponse response) {
        String stateValue = SocialUtil.generateRandom();
        String loginHint = socialWebUtils.getLoginHint(request);
        if (!request.getMethod().equalsIgnoreCase("GET") && loginHint != null) {
            stateValue = stateValue + loginHint;
        }
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Setting cookie " + ClientConstants.COOKIE_NAME_STATE_KEY + " to " + stateValue);
        }
        Cookie stateCookie = referrerURLCookieHandler.createCookie(ClientConstants.COOKIE_NAME_STATE_KEY, stateValue, request);
        response.addCookie(stateCookie);
        return stateValue;
    }