use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class DeploymentResourceResource method getDeploymentResource.
@RequestMapping(value = "/repository/deployments/{deploymentId}/resources/**", method = RequestMethod.GET, produces = "application/json")
public DeploymentResourceResponse getDeploymentResource(@PathVariable("deploymentId") String deploymentId, HttpServletRequest request) {
// Check if deployment exists
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.");
}
String pathInfo = request.getPathInfo();
String resourceName = pathInfo.replace("/repository/deployments/" + deploymentId + "/resources/", "");
List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
if (resourceList.contains(resourceName)) {
// Build resource representation
DeploymentResourceResponse response = restResponseFactory.createDeploymentResourceResponse(deploymentId, resourceName, contentTypeResolver.resolveContentType(resourceName));
return response;
} else {
// Resource not found in deployment
throw new ActivitiObjectNotFoundException("Could not find a resource with id '" + resourceName + "' in deployment '" + deploymentId + "'.");
}
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class AddCommentCmd method execute.
public Comment execute(CommandContext commandContext) {
// Validate task
if (taskId != null) {
TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
if (task == null) {
throw new ActivitiObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
}
if (task.isSuspended()) {
throw new ActivitiException(getSuspendedTaskException());
}
}
if (processInstanceId != null) {
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + processInstanceId + " doesn't exist", Execution.class);
}
if (execution.isSuspended()) {
throw new ActivitiException(getSuspendedExceptionMessage());
}
}
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
comment.setUserId(userId);
comment.setType((type == null) ? CommentEntity.TYPE_COMMENT : type);
comment.setTime(commandContext.getProcessEngineConfiguration().getClock().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 comment;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class AddIdentityLinkForProcessInstanceCmd method execute.
public Void execute(CommandContext commandContext) {
ExecutionEntity processInstance = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
if (processInstance == null) {
throw new ActivitiObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
}
processInstance.addIdentityLink(userId, groupId, type);
commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, true);
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class ChangeDeploymentTenantIdCmd method execute.
public Void execute(CommandContext commandContext) {
if (deploymentId == null) {
throw new ActivitiIllegalArgumentException("deploymentId is null");
}
// Update all entities
DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId);
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find deployment with id " + deploymentId, Deployment.class);
}
String oldTenantId = deployment.getTenantId();
deployment.setTenantId(newTenantId);
// Doing process instances, executions and tasks with direct SQL updates (otherwise would not be performant)
commandContext.getProcessDefinitionEntityManager().updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getExecutionEntityManager().updateExecutionTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getTaskEntityManager().updateTaskTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getEventSubscriptionEntityManager().updateEventSubscriptionTenantId(oldTenantId, newTenantId);
// Doing process definitions in memory, cause we need to clear the process definition cache
List<ProcessDefinition> processDefinitions = commandContext.getDbSqlSession().createProcessDefinitionQuery().deploymentId(deploymentId).list();
for (ProcessDefinition processDefinition : processDefinitions) {
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().remove(processDefinition.getId());
}
// Clear process definition cache
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().clear();
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class DeleteIdentityLinkForProcessDefinitionCmd method execute.
public Void execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
}
processDefinition.deleteIdentityLink(userId, groupId);
return null;
}
Aggregations