Search in sources :

Example 71 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class GroupMembershipResource method deleteMembership.

@RequestMapping(value = "/identity/groups/{groupId}/members/{userId}", method = RequestMethod.DELETE)
public void deleteMembership(@PathVariable("groupId") String groupId, @PathVariable("userId") String userId, HttpServletRequest request, HttpServletResponse response) {
    Group group = getGroupFromRequest(groupId);
    // Check if user is not a member of group since API doesn't return typed exception
    if (identityService.createUserQuery().memberOfGroup(group.getId()).userId(userId).count() != 1) {
        throw new ActivitiObjectNotFoundException("User '" + userId + "' is not part of group '" + group.getId() + "'.", null);
    }
    identityService.deleteMembership(userId, group.getId());
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
Also used : Group(org.activiti.engine.identity.Group) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 72 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class HistoricDetailDataResource method getVariableFromRequest.

public RestVariable getVariableFromRequest(boolean includeBinary, String detailId, HttpServletRequest request) {
    Object value = null;
    HistoricVariableUpdate variableUpdate = null;
    HistoricDetail detailObject = historyService.createHistoricDetailQuery().id(detailId).singleResult();
    if (detailObject instanceof HistoricVariableUpdate) {
        variableUpdate = (HistoricVariableUpdate) detailObject;
        value = variableUpdate.getValue();
    }
    if (value == null) {
        throw new ActivitiObjectNotFoundException("Historic detail '" + detailId + "' doesn't have a variable value.", VariableInstanceEntity.class);
    } else {
        return restResponseFactory.createRestVariable(variableUpdate.getVariableName(), value, null, detailId, RestResponseFactory.VARIABLE_HISTORY_DETAIL, includeBinary);
    }
}
Also used : HistoricVariableUpdate(org.activiti.engine.history.HistoricVariableUpdate) HistoricDetail(org.activiti.engine.history.HistoricDetail) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 73 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class HistoricDetailDataResource method getVariableData.

@RequestMapping(value = "/history/historic-detail/{detailId}/data", method = RequestMethod.GET)
@ResponseBody
public byte[] getVariableData(@PathVariable("detailId") String detailId, HttpServletRequest request, HttpServletResponse response) {
    try {
        byte[] result = null;
        RestVariable variable = getVariableFromRequest(true, detailId, request);
        if (RestResponseFactory.BYTE_ARRAY_VARIABLE_TYPE.equals(variable.getType())) {
            result = (byte[]) variable.getValue();
            response.setContentType("application/octet-stream");
        } else if (RestResponseFactory.SERIALIZABLE_VARIABLE_TYPE.equals(variable.getType())) {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutputStream outputStream = new ObjectOutputStream(buffer);
            outputStream.writeObject(variable.getValue());
            outputStream.close();
            result = buffer.toByteArray();
            response.setContentType("application/x-java-serialized-object");
        } else {
            throw new ActivitiObjectNotFoundException("The variable does not have a binary data stream.", null);
        }
        return result;
    } catch (IOException ioe) {
        // Re-throw IOException
        throw new ActivitiException("Unexpected exception getting variable data", ioe);
    }
}
Also used : RestVariable(org.activiti.rest.service.api.engine.variable.RestVariable) ActivitiException(org.activiti.engine.ActivitiException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 74 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class HistoricProcessInstanceCommentResource method getComment.

@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}", method = RequestMethod.GET, produces = "application/json")
public CommentResponse getComment(@PathVariable("processInstanceId") String processInstanceId, @PathVariable("commentId") String commentId, HttpServletRequest request) {
    HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
    Comment comment = taskService.getComment(commentId);
    if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
        throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
    }
    return restResponseFactory.createRestComment(comment);
}
Also used : Comment(org.activiti.engine.task.Comment) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 75 with ActivitiObjectNotFoundException

use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.

the class HistoricProcessInstanceVariableDataResource method getVariableFromRequest.

public RestVariable getVariableFromRequest(boolean includeBinary, String processInstanceId, String variableName, HttpServletRequest request) {
    HistoricProcessInstance processObject = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();
    if (processObject == null) {
        throw new ActivitiObjectNotFoundException("Historic process instance '" + processInstanceId + "' couldn't be found.", HistoricProcessInstanceEntity.class);
    }
    Object value = processObject.getProcessVariables().get(variableName);
    if (value == null) {
        throw new ActivitiObjectNotFoundException("Historic process instance '" + processInstanceId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class);
    } else {
        return restResponseFactory.createRestVariable(variableName, value, null, processInstanceId, RestResponseFactory.VARIABLE_HISTORY_PROCESS, includeBinary);
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Aggregations

ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)87 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)27 ActivitiException (org.activiti.engine.ActivitiException)25 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)25 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)16 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)15 Task (org.activiti.engine.task.Task)12 User (org.activiti.engine.identity.User)8 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)8 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 IOException (java.io.IOException)7 ObjectOutputStream (java.io.ObjectOutputStream)7 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)7 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)6 RestVariableScope (org.activiti.rest.service.api.engine.variable.RestVariable.RestVariableScope)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 Comment (org.activiti.engine.task.Comment)5 DeploymentEntity (org.activiti.engine.impl.persistence.entity.DeploymentEntity)4