protected long getUserIdFromSessionInfos() { return SessionInfos.getUserIdFromSession(); }
public static SessionInfos getSessionInfos() { SSession session = getSession(); if (session != null) { return new SessionInfos(session.getUserName(), session.getUserId()); } return new SessionInfos(SessionService.SYSTEM, -1); }
public static long getUserIdFromSession() { return getSessionService().getLoggedUserFromSession(getSessionAccessor()); }
protected Long getExecuteByUserId(final Map<String, Serializable> parameters) { Serializable executeByUserId = parameters.get(USER_ID_KEY); // executeByUserId is not defined when the use is doing the task by himself if (executeByUserId == null) { return SessionInfos.getSessionInfos().getUserId(); } return (Long) executeByUserId; }
protected void executeActivity(final SFlowNodeInstance flowNodeInstance, long executerUserId) throws SFlowNodeReadException, SFlowNodeExecutionException { final TenantServiceAccessor tenantAccessor = TenantServiceSingleton.getInstance(getTenantId()); final ProcessExecutor processExecutor = tenantAccessor.getProcessExecutor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SessionInfos sessionInfos = SessionInfos.getSessionInfos(); final long executerSubstituteId = sessionInfos.getUserId(); // no need to handle failed state, all is in the same tx, if the node fail we just have an exception on client side + rollback processExecutor.executeFlowNode(flowNodeInstance.getId(), executerUserId, executerSubstituteId); if (logger.isLoggable(getClass(), TechnicalLogSeverity.INFO) && flowNodeInstance.getStateId() != 0 /* don't log when create subtask */) { final String message = LogMessageBuilder.buildExecuteTaskContextMessage(flowNodeInstance, sessionInfos.getUsername(), executerUserId, executerSubstituteId, null); // no inputs taken in this LEGACY command for old-version web form execution logger.log(getClass(), TechnicalLogSeverity.INFO, message); } addSystemCommentOnProcessInstanceWhenExecutingTaskFor(flowNodeInstance, executerUserId, executerSubstituteId); }
String getUserNameFromSession() { return SessionInfos.getUserNameFromSession(); }
public void disableProcess(final long processId) throws SProcessDefinitionNotFoundException, SBonitaException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final PlatformServiceAccessor platformServiceAccessor = getPlatformServiceAccessor(); final ProcessDefinitionService processDefinitionService = tenantAccessor.getProcessDefinitionService(); final EventInstanceService eventInstanceService = tenantAccessor.getEventInstanceService(); final SchedulerService schedulerService = platformServiceAccessor.getSchedulerService(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final DisableProcess disableProcess = new DisableProcess(processDefinitionService, processId, eventInstanceService, getConfigurationService(), schedulerService, logger, SessionInfos.getUserNameFromSession(), SessionInfos.getSession().getTenantId()); disableProcess.execute(); }
protected void addSystemCommentOnProcessInstanceWhenExecutingTaskFor(final SFlowNodeInstance flowNodeInstance, final long executerUserId, final long executerSubstituteUserId) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SCommentService commentService = tenantAccessor.getCommentService(); final SessionInfos session = SessionInfos.getSessionInfos(); if (executerUserId != executerSubstituteUserId) { final IdentityService identityService = tenantAccessor.getIdentityService(); try { final SUser executerUser = identityService.getUser(executerUserId); final StringBuilder stb = new StringBuilder(); stb.append("The user " + session.getUsername() + " "); stb.append("acting as delegate of the user " + executerUser.getUserName() + " "); stb.append("has done the task \"" + flowNodeInstance.getDisplayName() + "\"."); commentService.addSystemComment(flowNodeInstance.getParentProcessInstanceId(), stb.toString()); } catch (final SBonitaException e) { logger.log(this.getClass(), TechnicalLogSeverity.ERROR, "Error when adding a comment on the process instance.", e); } } } }
SSession getSession() { return SessionInfos.getSession(); }
private static SessionService getSessionService() { try { final PlatformServiceAccessor platformServiceAccessor = ServiceAccessorFactory.getInstance().createPlatformServiceAccessor(); return platformServiceAccessor.getTenantServiceAccessor(getSessionAccessor().getTenantId()).getSessionService(); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
protected void executeActivity(final SFlowNodeInstance flowNodeInstance, long executerUserId) throws SFlowNodeReadException, SFlowNodeExecutionException { final TenantServiceAccessor tenantAccessor = TenantServiceSingleton.getInstance(getTenantId()); final ProcessExecutor processExecutor = tenantAccessor.getProcessExecutor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SessionInfos sessionInfos = SessionInfos.getSessionInfos(); final long executerSubstituteId = sessionInfos.getUserId(); // no need to handle failed state, all is in the same tx, if the node fail we just have an exception on client side + rollback processExecutor.executeFlowNode(flowNodeInstance.getId(), executerUserId, executerSubstituteId); if (logger.isLoggable(getClass(), TechnicalLogSeverity.INFO) && flowNodeInstance.getStateId() != 0 /* don't log when create subtask */) { final String message = LogMessageBuilder.buildExecuteTaskContextMessage(flowNodeInstance, sessionInfos.getUsername(), executerUserId, executerSubstituteId, null); // no inputs taken in this LEGACY command for old-version web form execution logger.log(getClass(), TechnicalLogSeverity.INFO, message); } addSystemCommentOnProcessInstanceWhenExecutingTaskFor(flowNodeInstance, executerUserId, executerSubstituteId); }
String getUserNameFromSession() { return SessionInfos.getUserNameFromSession(); }
protected Long getExecuteByUserId(final Map<String, Serializable> parameters) { Serializable executeByUserId = parameters.get(USER_ID_KEY); // executeByUserId is not defined when the use is doing the task by himself if (executeByUserId == null) { return SessionInfos.getSessionInfos().getUserId(); } return (Long) executeByUserId; }
public void disableProcess(final long processId) throws SProcessDefinitionNotFoundException, SBonitaException { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final PlatformServiceAccessor platformServiceAccessor = getPlatformServiceAccessor(); final ProcessDefinitionService processDefinitionService = tenantAccessor.getProcessDefinitionService(); final EventInstanceService eventInstanceService = tenantAccessor.getEventInstanceService(); final SchedulerService schedulerService = platformServiceAccessor.getSchedulerService(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final DisableProcess disableProcess = new DisableProcess(processDefinitionService, processId, eventInstanceService, getConfigurationService(), schedulerService, logger, SessionInfos.getUserNameFromSession(), SessionInfos.getSession().getTenantId()); disableProcess.execute(); }
protected void addSystemCommentOnProcessInstanceWhenExecutingTaskFor(final SFlowNodeInstance flowNodeInstance, final long executerUserId, final long executerSubstituteUserId) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final SCommentService commentService = tenantAccessor.getCommentService(); final SessionInfos session = SessionInfos.getSessionInfos(); if (executerUserId != executerSubstituteUserId) { final IdentityService identityService = tenantAccessor.getIdentityService(); try { final SUser executerUser = identityService.getUser(executerUserId); final StringBuilder stb = new StringBuilder(); stb.append("The user " + session.getUsername() + " "); stb.append("acting as delegate of the user " + executerUser.getUserName() + " "); stb.append("has done the task \"" + flowNodeInstance.getDisplayName() + "\"."); commentService.addSystemComment(flowNodeInstance.getParentProcessInstanceId(), stb.toString()); } catch (final SBonitaException e) { logger.log(this.getClass(), TechnicalLogSeverity.ERROR, "Error when adding a comment on the process instance.", e); } } } }
SSession getSession() { return SessionInfos.getSession(); }
private static SessionService getSessionService() { try { final PlatformServiceAccessor platformServiceAccessor = ServiceAccessorFactory.getInstance().createPlatformServiceAccessor(); return platformServiceAccessor.getTenantServiceAccessor(getSessionAccessor().getTenantId()).getSessionService(); } catch (final Exception e) { throw new BonitaRuntimeException(e); } }
protected static long getUserId() { return SessionInfos.getUserIdFromSession(); }
public static long getUserIdFromSession() { return getSessionService().getLoggedUserFromSession(getSessionAccessor()); }
private void logProcessInstanceStartedAndAddComment(final SProcessDefinition sProcessDefinition, final long starterId, final long starterSubstituteId, final SProcessInstance sProcessInstance) { final TenantServiceAccessor tenantAccessor = getTenantAccessor(); final TechnicalLoggerService logger = tenantAccessor.getTechnicalLoggerService(); final StringBuilder stb = new StringBuilder(); stb.append("The user <"); stb.append(SessionInfos.getUserNameFromSession()); if (starterId != starterSubstituteId) { stb.append("> acting as delegate of user with id <"); stb.append(starterId); } stb.append("> has started the process instance <"); stb.append(sProcessInstance.getId()); stb.append("> of process <"); stb.append(sProcessDefinition.getName()); stb.append("> in version <"); stb.append(sProcessDefinition.getVersion()); stb.append("> and id <"); stb.append(sProcessDefinition.getId()); stb.append(">"); if (logger.isLoggable(this.getClass(), TechnicalLogSeverity.INFO)) { logger.log(this.getClass(), TechnicalLogSeverity.INFO, stb.toString()); } addSystemCommentOnProcessInstanceWhenStartingProcessFor(sProcessInstance, starterId, starterSubstituteId); }