Ensure the session is receivable. If the session not receivable then an
exception thrown.

@param activityName is the activity name.
@throws IOException if the session not receivable.
187973
protected void ensureReceivable(String activityName) throws IOException {
        // TODO uudashr: do we have to use another exception for this checking?
        SessionState currentState = getSessionState();
        if (!currentState.isReceivable()) {
            throw new IOException("Cannot " + activityName + " while session " + sessionId + " in state " + currentState);
        }
    }
1087565
@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        sessionTracker.getSession().onActivityResult(this.getActivity(), requestCode, resultCode, data);
    }
444210
@Override
    public Object evaluate() throws ActivityException {
        try {
            scriptLanguage = getAttributeValue(SCRIPT_LANGUAGE);
            expression = getAttributeValue(EXPRESSION);
            if (StringHelper.isEmpty(expression)){
                throw new ActivityException("Expression content has not been defined");
            }

            String name = ScriptNaming.getValidName(getProcessDefinition().getLabel() + "_"
                    + getActivityName() + "_" + getActivityId());
            name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
            Object obj = evaluateExpression(name, scriptLanguage, expression);
            if ((obj == null || obj.toString().isEmpty()) && isBooleanExpression(scriptLanguage, expression))
                obj = Boolean.FALSE;
            return obj;
        }
        catch (ExecutionException ex) {
            logger.severeException(ex.getMessage(), ex);
            throw new ActivityException(-1, ex.getMessage(), ex);
        }
    }
800114
public void sessionAttributeAccessed(ISession session, Object name, Object value) {
        _sessionStateEventDispatcher.sessionAttributeAccessed(session, name, value);

    }
80994
public static SqlSession getSession() throws IOException {
		SqlSession session = (SqlSession) THREAD_SESSION.get();  
	    try {  
	        if (session == null) {  
	        	session = getSessionFactory().getSession();
	        	THREAD_SESSION.set(session);  
	        }  
	    } catch (Exception e) {  
	        throw new IOException(e);  
	    }  
	    return session;  
	}
201423
public void messageReceived(IoSession session, Object message)
            throws Exception {
        SingleSessionIoHandler handler = (SingleSessionIoHandler) session
                .getAttribute(HANDLER);
        handler.messageReceived(message);
    }
467229
public void requestAfterExplanation(@NonNull String permissionName) {
        if (isPermissionDeclined(permissionName)) {
            ActivityCompat.requestPermissions(context, new String[]{permissionName}, REQUEST_PERMISSIONS);
        } else {
            permissionCallback.onPermissionPreGranted(permissionName);
        }
    }
66589
@Override
  public void completing(DelegateExecution execution, DelegateExecution subProcessInstance) throws Exception {
    if (activityBehaviorInstance == null) {
      activityBehaviorInstance = getActivityBehaviorInstance();
    }

    if (activityBehaviorInstance instanceof SubProcessActivityBehavior) {
      ((SubProcessActivityBehavior) activityBehaviorInstance).completing(execution, subProcessInstance);
    } else {
      throw new ActivitiException("completing() can only be called on a " + SubProcessActivityBehavior.class.getName() + " instance");
    }
  }
699094
void failActivityInstance(InternalEvent event,
            ProcessInstance processInst, Long activityId, Long activityInstId,
            BaseActivity activity, Throwable cause) throws DataAccessException, MdwException, SQLException {

        String tag = logtag(processInst.getProcessId(), processInst.getId(), activityId, activityInstId);
        logger.severeException("Failed to execute activity - " + cause.getClass().getName(), cause);
        String compCode = null;
        String statusMsg = buildStatusMessage(cause);
        try {
            ActivityInstance actInstVO = null;
            if (activity != null && activityInstId != null) {
                activity.setReturnMessage(statusMsg);
                actInstVO = edao.getActivityInstance(activityInstId);
                failActivityInstance(actInstVO, statusMsg, processInst, tag, cause.getClass().getName());
                compCode = activity.getReturnCode();
            }
            if (!AdapterActivity.COMPCODE_AUTO_RETRY.equals(compCode)) {
                DocumentReference docRef = createActivityExceptionDocument(processInst, actInstVO, activity, cause);
                InternalEvent outgoingMsg =
                    InternalEvent.createActivityErrorMessage(activityId, activityInstId, processInst.getId(), compCode,
                        event.getMasterRequestId(), statusMsg.length() > 2000 ? statusMsg.substring(0, 1999) : statusMsg, docRef.getDocumentId());
                sendInternalEvent(outgoingMsg);
            }
        }
        catch (Exception ex) {
            logger.severeException("Exception thrown during failActivityInstance", ex);
            throw ex;
        }
    }
1046146
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
   {
      String action = request.getParameter(ACTION_PARAM);

      if (action == null)
         action = DISPLAY_MBEANS_ACTION;

      if (action.equals(DISPLAY_MBEANS_ACTION))
         displayMBeans(request, response);
      else if (action.equals(INSPECT_MBEAN_ACTION))
         inspectMBean(request, response);
      else if (action.equals(UPDATE_ATTRIBUTES_ACTION))
         updateAttributes(request, response);
      else if (action.equals(INVOKE_OP_ACTION))
         invokeOp(request, response);
      else if (action.equals(INVOKE_OP_BY_NAME_ACTION))
         invokeOpByName(request, response);
   }
1351882
@Override
    public void messageReceived(IoSession session, Object buf) {
        final IoSessionInputStream in = (IoSessionInputStream) session
                .getAttribute(KEY_IN);
        in.write((IoBuffer) buf);
    }
929986
public void goBackToActivity(String name)
	{
		ArrayList<Activity> activitiesOpened = getAllOpenedActivities();
		boolean found = false;	
		for(int i = 0; i < activitiesOpened.size(); i++){
			if(activitiesOpened.get(i).getClass().getSimpleName().equals(name)){
				found = true;
				break;
			}
		}
		if(found){
			while(!getCurrentActivity().getClass().getSimpleName().equals(name))
			{
				try{
					inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
				}catch(SecurityException ignored){}	
			}
		}
		else{
			for (int i = 0; i < activitiesOpened.size(); i++){
				Log.d(LOG_TAG, "Activity priorly opened: "+ activitiesOpened.get(i).getClass().getSimpleName());
			}
			Assert.fail("No Activity named: '" + name + "' has been priorly opened");
		}
	}
684522
public boolean waitForActivity(String applicationName, String activityName, int retryTime) {
        ComponentName componentName = new ComponentName(applicationName, activityName);
        return waitForActivity(componentName, retryTime);
    }
1324985
public void closeSession() throws HibernateException
    {
        Session s = threadSession.get();
        threadSession.set(null);
        if (s != null)
        {
            s.close();
        }
        
        Transaction tx = threadTransaction.get();
        if (tx != null)
        {
            threadTransaction.set(null);
            //log warning todo
        }
    }
939856
public void handleError(final Throwable error) throws IOException {

		LOG.debug("Start handleError...");

		// Should the session be removed upon error?
		boolean terminate = ConfigurationProperties.getTerminateSessionOnError();
		// If we are unfriendly, terminate the session
		if (terminate) {
			invalidateSession();
		}

		// Are we in developer friendly error mode?
		boolean friendly = ConfigurationProperties.getDeveloperErrorHandling();

		FatalErrorPageFactory factory = Factory.newInstance(FatalErrorPageFactory.class);
		WComponent errorPage = factory.createErrorPage(friendly, error);

		String html = renderErrorPageToHTML(errorPage);

		// Setup the response
		Response response = getResponse();
		response.setContentType(WebUtilities.CONTENT_TYPE_HTML);

		// Make sure not cached
		getResponse().setHeader("Cache-Control", CacheType.NO_CACHE.getSettings());
		getResponse().setHeader("Pragma", "no-cache");
		getResponse().setHeader("Expires", "-1");

		getPrintWriter().println(html);

		LOG.debug("End handleError");
	}
1112614
public void billingAccount_easyHunting_serviceName_PUT(String billingAccount, String serviceName, OvhEasyHunting body) throws IOException {
		String qPath = "/telephony/{billingAccount}/easyHunting/{serviceName}";
		StringBuilder sb = path(qPath, billingAccount, serviceName);
		exec(qPath, "PUT", sb.toString(), body);
	}
750118
private SMPPSession getSession() throws IOException {
    if (session == null) {
      LOGGER.info("Initiate session for the first time to {}:{}", remoteIpAddress, remotePort);
      session = newSession();
    }
    else if (!session.getSessionState().isBound()) {
      throw new IOException("We have no valid session yet");
    }
    return session;
  }