org.activiti.engine.impl.identity.Authentication.getAuthenticatedUserId()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(15.6k)|赞(0)|评价(0)|浏览(253)

本文整理了Java中org.activiti.engine.impl.identity.Authentication.getAuthenticatedUserId()方法的一些代码示例,展示了Authentication.getAuthenticatedUserId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authentication.getAuthenticatedUserId()方法的具体详情如下:
包路径:org.activiti.engine.impl.identity.Authentication
类名称:Authentication
方法名:getAuthenticatedUserId

Authentication.getAuthenticatedUserId介绍

暂无

代码示例

代码示例来源:origin: Activiti/Activiti

} else if (LOGGED_IN_USER_KEY.equals(property)) {
  context.setPropertyResolved(true);
  return Authentication.getAuthenticatedUserId();
} else {
  if (variableScope.hasVariable(variable)) {

代码示例来源:origin: Activiti/Activiti

protected EventLogEntryEntity createEventLogEntry(String type, String processDefinitionId, String processInstanceId, String executionId, String taskId, Map<String, Object> data) {
 EventLogEntryEntity eventLogEntry = Context.getCommandContext().getEventLogEntryEntityManager().create();
 eventLogEntry.setProcessDefinitionId(processDefinitionId);
 eventLogEntry.setProcessInstanceId(processInstanceId);
 eventLogEntry.setExecutionId(executionId);
 eventLogEntry.setTaskId(taskId);
 eventLogEntry.setType(type);
 eventLogEntry.setTimeStamp(timeStamp);
 putInMapIfNotNull(data, Fields.TIMESTAMP, timeStamp);
 // Current user
 String userId = Authentication.getAuthenticatedUserId();
 if (userId != null) {
  eventLogEntry.setUserId(userId);
  putInMapIfNotNull(data, "userId", userId);
 }
 // Current tenant
 if (!data.containsKey(Fields.TENANT_ID) && processDefinitionId != null) {
  ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId);
  if (processDefinition != null && !ProcessEngineConfigurationImpl.NO_TENANT_ID.equals(processDefinition.getTenantId())) {
   putInMapIfNotNull(data, Fields.TENANT_ID, processDefinition.getTenantId());
  }
 }
 try {
  eventLogEntry.setData(objectMapper.writeValueAsBytes(data));
 } catch (Exception e) {
  logger.warn("Could not serialize event data. Data will not be written to the database", e);
 }
 return eventLogEntry;
}

代码示例来源:origin: Activiti/Activiti

@Override
public ExecutionEntity createSubprocessInstance(ProcessDefinition processDefinition, ExecutionEntity superExecutionEntity, String businessKey) {
 ExecutionEntity subProcessInstance = executionDataManager.create(); 
 inheritCommonProperties(superExecutionEntity, subProcessInstance);
 subProcessInstance.setProcessDefinitionId(processDefinition.getId());
 subProcessInstance.setProcessDefinitionKey(processDefinition.getKey());
 subProcessInstance.setSuperExecution(superExecutionEntity);
 subProcessInstance.setRootProcessInstanceId(superExecutionEntity.getRootProcessInstanceId());
 subProcessInstance.setScope(true); // process instance is always a scope for all child executions
 subProcessInstance.setStartUserId(Authentication.getAuthenticatedUserId());
 subProcessInstance.setBusinessKey(businessKey);
 // Store in database
 insert(subProcessInstance, false);
 
 if (logger.isDebugEnabled()) {
  logger.debug("Child execution {} created with super execution {}", subProcessInstance, superExecutionEntity.getId());
 }
 subProcessInstance.setProcessInstanceId(subProcessInstance.getId());
 superExecutionEntity.setSubProcessInstance(subProcessInstance);
 if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
  Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, subProcessInstance));
 }
 return subProcessInstance;
}

代码示例来源:origin: Activiti/Activiti

@Override
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
 if (isHistoryEnabled()) {
  String userId = Authentication.getAuthenticatedUserId();
  CommentEntity comment = getCommentEntityManager().create();
  comment.setUserId(userId);
  comment.setType(CommentEntity.TYPE_EVENT);
  comment.setTime(getClock().getCurrentTime());
  comment.setTaskId(taskId);
  comment.setProcessInstanceId(processInstanceId);
  if (create) {
   comment.setAction(Event.ACTION_ADD_ATTACHMENT);
  } else {
   comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
  }
  comment.setMessage(attachmentName);
  getCommentEntityManager().insert(comment);
 }
}

代码示例来源:origin: Activiti/Activiti

protected void executeTaskComplete(CommandContext commandContext, TaskEntity taskEntity, Map<String, Object> variables, boolean localScope) {
 // Task complete logic
 if (taskEntity.getDelegationState() != null && taskEntity.getDelegationState().equals(DelegationState.PENDING)) {
  throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead.");
 }
 commandContext.getProcessEngineConfiguration().getListenerNotificationHelper().executeTaskListeners(taskEntity, TaskListener.EVENTNAME_COMPLETE);
 if (Authentication.getAuthenticatedUserId() != null && taskEntity.getProcessInstanceId() != null) {
  ExecutionEntity processInstanceEntity = commandContext.getExecutionEntityManager().findById(taskEntity.getProcessInstanceId());
  commandContext.getIdentityLinkEntityManager().involveUser(processInstanceEntity, Authentication.getAuthenticatedUserId(),IdentityLinkType.PARTICIPANT);
 }
 ActivitiEventDispatcher eventDispatcher = Context.getProcessEngineConfiguration().getEventDispatcher();
 if (eventDispatcher.isEnabled()) {
  if (variables != null) {
   eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityWithVariablesEvent(ActivitiEventType.TASK_COMPLETED, taskEntity, variables, localScope));
  } else {
   eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TASK_COMPLETED, taskEntity));
  }
 }
 commandContext.getTaskEntityManager().deleteTask(taskEntity, null, false, false);
 // Continue process (if not a standalone task)
 if (taskEntity.getExecutionId() != null) {
  ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(taskEntity.getExecutionId());
  Context.getAgenda().planTriggerExecutionOperation(executionEntity);
 }
}

代码示例来源:origin: Activiti/Activiti

String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = commandContext.getCommentEntityManager().create(); 
comment.setUserId(userId);

代码示例来源:origin: Activiti/Activiti

@Override
public void createIdentityLinkComment(String taskId, String userId, String groupId, String type, boolean create, boolean forceNullUserId) {
 if (isHistoryEnabled()) {
  String authenticatedUserId = Authentication.getAuthenticatedUserId();
  CommentEntity comment = getCommentEntityManager().create(); 
  comment.setUserId(authenticatedUserId);
  comment.setType(CommentEntity.TYPE_EVENT);
  comment.setTime(getClock().getCurrentTime());
  comment.setTaskId(taskId);
  if (userId != null || forceNullUserId) {
   if (create) {
    comment.setAction(Event.ACTION_ADD_USER_LINK);
   } else {
    comment.setAction(Event.ACTION_DELETE_USER_LINK);
   }
   comment.setMessage(new String[] { userId, type });
  } else {
   if (create) {
    comment.setAction(Event.ACTION_ADD_GROUP_LINK);
   } else {
    comment.setAction(Event.ACTION_DELETE_GROUP_LINK);
   }
   comment.setMessage(new String[] { groupId, type });
  }
  
  getCommentEntityManager().insert(comment);
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
public void createProcessInstanceIdentityLinkComment(String processInstanceId, String userId, String groupId, String type, boolean create, boolean forceNullUserId) {
 if (isHistoryEnabled()) {
  String authenticatedUserId = Authentication.getAuthenticatedUserId();
  CommentEntity comment = getCommentEntityManager().create();
  comment.setUserId(authenticatedUserId);
  comment.setType(CommentEntity.TYPE_EVENT);
  comment.setTime(getClock().getCurrentTime());
  comment.setProcessInstanceId(processInstanceId);
  if (userId != null || forceNullUserId) {
   if (create) {
    comment.setAction(Event.ACTION_ADD_USER_LINK);
   } else {
    comment.setAction(Event.ACTION_DELETE_USER_LINK);
   }
   comment.setMessage(new String[] { userId, type });
  } else {
   if (create) {
    comment.setAction(Event.ACTION_ADD_GROUP_LINK);
   } else {
    comment.setAction(Event.ACTION_DELETE_GROUP_LINK);
   }
   comment.setMessage(new String[] { groupId, type });
  }
  getCommentEntityManager().insert(comment);
 }
}

代码示例来源:origin: Activiti/Activiti

String authenticatedUserId = Authentication.getAuthenticatedUserId();

代码示例来源:origin: bluejoe2008/openwebflow

/**
 * 后加签
 */
@Override
public ActivityImpl[] insertTasksAfter(String targetTaskDefinitionKey, String... assignees) throws Exception
{
  List<String> assigneeList = new ArrayList<String>();
  assigneeList.add(Authentication.getAuthenticatedUserId());
  assigneeList.addAll(CollectionUtils.arrayToList(assignees));
  String[] newAssignees = assigneeList.toArray(new String[0]);
  ActivityImpl prototypeActivity = ProcessDefinitionUtils.getActivity(_processEngine, _processDefinition.getId(),
    targetTaskDefinitionKey);
  return cloneAndMakeChain(targetTaskDefinitionKey, prototypeActivity.getOutgoingTransitions().get(0)
      .getDestination().getId(), newAssignees);
}

代码示例来源:origin: Activiti/Activiti

attachment.setType(attachmentType);
attachment.setUrl(url);
attachment.setUserId(Authentication.getAuthenticatedUserId());
attachment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());

代码示例来源:origin: org.activiti/activiti-explorer

public static String getReportDisplayName(HistoricProcessInstance historicProcessInstance) {
  if(historicProcessInstance.getBusinessKey() != null && !historicProcessInstance.getBusinessKey().isEmpty()) {
   if(Authentication.getAuthenticatedUserId() != null) {
    return historicProcessInstance.getBusinessKey().replaceFirst(Authentication.getAuthenticatedUserId() + "\\_", "");
   } else {
    return historicProcessInstance.getBusinessKey();
   }
  } else {
   return DateFormat.getDateTimeInstance().format(historicProcessInstance.getEndTime());
  }
 }
}

代码示例来源:origin: org.activiti/activiti-explorer

protected HistoricProcessInstanceQuery createQuery() {
 // TODO: Add additional "processDefinitionCategory" on HistoricProcessInstanceQuery instead of
 // using variables to find all completed reports. This is more robust and performant
 return historyService.createHistoricProcessInstanceQuery()
     .finished()
     .startedBy(Authentication.getAuthenticatedUserId())
     .variableValueNotEquals("reportData", null);
}

代码示例来源:origin: com.bbossgroups.activiti/activiti-engine

public HistoricProcessInstanceEntity(ExecutionEntity processInstance) {
 id = processInstance.getId();
 processInstanceId = processInstance.getId();
 businessKey = processInstance.getBusinessKey();
 processDefinitionId = processInstance.getProcessDefinitionId();
 startTime = ClockUtil.getCurrentTime();
 this.startTimeLong = this.startTime.getTime();
 startUserId = Authentication.getAuthenticatedUserId();
 startActivityId = processInstance.getActivityId();
 superProcessInstanceId = processInstance.getSuperExecution() != null ? processInstance.getSuperExecution().getProcessInstanceId() : null;
}

代码示例来源:origin: com.bbossgroups.activiti/activiti-engine

protected Object execute(CommandContext commandContext, TaskEntity task) {
 String userId = Authentication.getAuthenticatedUserId();
 CommentEntity comment = new CommentEntity();
 comment.setUserId(userId);
 comment.setType(CommentEntity.TYPE_COMMENT);
 comment.setTime(ClockUtil.getCurrentTime());
 comment.setTaskId(taskId);
 comment.setProcessInstanceId(processInstanceId);
 comment.setAction(Event.ACTION_ADD_COMMENT);
 
 String eventMessage = message.replaceAll("\\s+", " ");
 if (eventMessage.length()>163) {
  eventMessage = eventMessage.substring(0, 160)+"...";
 }
 comment.setMessage(eventMessage);
 
 comment.setFullMessage(message);
 
 commandContext
  .getCommentEntityManager()
  .insert(comment);
 
 return null;
}

代码示例来源:origin: org.activiti/activiti-engine

@Override
public ExecutionEntity createSubprocessInstance(ProcessDefinition processDefinition, ExecutionEntity superExecutionEntity, String businessKey) {
 ExecutionEntity subProcessInstance = executionDataManager.create(); 
 inheritCommonProperties(superExecutionEntity, subProcessInstance);
 subProcessInstance.setProcessDefinitionId(processDefinition.getId());
 subProcessInstance.setProcessDefinitionKey(processDefinition.getKey());
 subProcessInstance.setSuperExecution(superExecutionEntity);
 subProcessInstance.setRootProcessInstanceId(superExecutionEntity.getRootProcessInstanceId());
 subProcessInstance.setScope(true); // process instance is always a scope for all child executions
 subProcessInstance.setStartUserId(Authentication.getAuthenticatedUserId());
 subProcessInstance.setBusinessKey(businessKey);
 // Store in database
 insert(subProcessInstance, false);
 
 if (logger.isDebugEnabled()) {
  logger.debug("Child execution {} created with super execution {}", subProcessInstance, superExecutionEntity.getId());
 }
 subProcessInstance.setProcessInstanceId(subProcessInstance.getId());
 superExecutionEntity.setSubProcessInstance(subProcessInstance);
 if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
  Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, subProcessInstance));
 }
 return subProcessInstance;
}

代码示例来源:origin: com.bbossgroups.activiti/activiti-engine

/**
 * Creates a new comment to indicate a new attachment has been created or deleted, 
 * if history is enabled. 
 */
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
 if (isHistoryEnabled()) {
  String userId = Authentication.getAuthenticatedUserId();
  CommentEntity comment = new CommentEntity();
  comment.setUserId(userId);
  comment.setType(CommentEntity.TYPE_EVENT);
  comment.setTime(ClockUtil.getCurrentTime());
  comment.setTaskId(taskId);
  comment.setProcessInstanceId(processInstanceId);
  if(create) {
   comment.setAction(Event.ACTION_ADD_ATTACHMENT);
  } else {
   comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
  }
  comment.setMessage(attachmentName);
  getSession(CommentEntityManager.class).insert(comment);
 }
}

代码示例来源:origin: org.activiti/activiti-engine

@Override
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
 if (isHistoryEnabled()) {
  String userId = Authentication.getAuthenticatedUserId();
  CommentEntity comment = getCommentEntityManager().create();
  comment.setUserId(userId);
  comment.setType(CommentEntity.TYPE_EVENT);
  comment.setTime(getClock().getCurrentTime());
  comment.setTaskId(taskId);
  comment.setProcessInstanceId(processInstanceId);
  if (create) {
   comment.setAction(Event.ACTION_ADD_ATTACHMENT);
  } else {
   comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
  }
  comment.setMessage(attachmentName);
  getCommentEntityManager().insert(comment);
 }
}

代码示例来源:origin: org.flowable/flowable5-engine

@Override
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
  if (isHistoryEnabled()) {
    String userId = Authentication.getAuthenticatedUserId();
    CommentEntity comment = new CommentEntity();
    comment.setUserId(userId);
    comment.setType(CommentEntity.TYPE_EVENT);
    comment.setTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime());
    comment.setTaskId(taskId);
    comment.setProcessInstanceId(processInstanceId);
    if (create) {
      comment.setAction(Event.ACTION_ADD_ATTACHMENT);
    } else {
      comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
    }
    comment.setMessage(attachmentName);
    getSession(CommentEntityManager.class).insert(comment);
  }
}

代码示例来源:origin: org.flowable/flowable5-engine

public HistoricProcessInstanceEntity(ExecutionEntity processInstance) {
  id = processInstance.getId();
  processInstanceId = processInstance.getId();
  businessKey = processInstance.getBusinessKey();
  processDefinitionId = processInstance.getProcessDefinitionId();
  processDefinitionKey = processInstance.getProcessDefinitionKey();
  processDefinitionName = processInstance.getProcessDefinitionName();
  processDefinitionVersion = processInstance.getProcessDefinitionVersion();
  deploymentId = processInstance.getDeploymentId();
  startTime = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
  startUserId = Authentication.getAuthenticatedUserId();
  startActivityId = processInstance.getActivityId();
  superProcessInstanceId = processInstance.getSuperExecution() != null ? processInstance.getSuperExecution().getProcessInstanceId() : null;
  // Inherit tenant id (if applicable)
  if (processInstance.getTenantId() != null) {
    tenantId = processInstance.getTenantId();
  }
}

相关文章