Search in sources :

Example 6 with ActivitiIllegalArgumentException

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

the class UserQueryTest method testQueryByInvalidMemberOf.

public void testQueryByInvalidMemberOf() {
    UserQuery query = identityService.createUserQuery().memberOfGroup("invalid");
    verifyQueryResults(query, 0);
    try {
        identityService.createUserQuery().memberOfGroup(null).list();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UserQuery(org.activiti.engine.identity.UserQuery)

Example 7 with ActivitiIllegalArgumentException

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

the class UserQueryTest method testQueryByInvalidFirstName.

public void testQueryByInvalidFirstName() {
    UserQuery query = identityService.createUserQuery().userFirstName("invalid");
    verifyQueryResults(query, 0);
    try {
        identityService.createUserQuery().userFirstName(null).singleResult();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UserQuery(org.activiti.engine.identity.UserQuery)

Example 8 with ActivitiIllegalArgumentException

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

the class UserQueryTest method testQueryByInvalidLastName.

public void testQueryByInvalidLastName() {
    UserQuery query = identityService.createUserQuery().userLastName("invalid");
    verifyQueryResults(query, 0);
    try {
        identityService.createUserQuery().userLastName(null).singleResult();
        fail();
    } catch (ActivitiIllegalArgumentException e) {
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) UserQuery(org.activiti.engine.identity.UserQuery)

Example 9 with ActivitiIllegalArgumentException

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

the class FormDataResource method getFormData.

@RequestMapping(value = "/form/form-data", method = RequestMethod.GET, produces = "application/json")
public FormDataResponse getFormData(@RequestParam(value = "taskId", required = false) String taskId, @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId, HttpServletRequest request) {
    if (taskId == null && processDefinitionId == null) {
        throw new ActivitiIllegalArgumentException("The taskId or processDefinitionId parameter has to be provided");
    }
    if (taskId != null && processDefinitionId != null) {
        throw new ActivitiIllegalArgumentException("Not both a taskId and a processDefinitionId parameter can be provided");
    }
    FormData formData = null;
    String id = null;
    if (taskId != null) {
        formData = formService.getTaskFormData(taskId);
        id = taskId;
    } else {
        formData = formService.getStartFormData(processDefinitionId);
        id = processDefinitionId;
    }
    if (formData == null) {
        throw new ActivitiObjectNotFoundException("Could not find a form data with id '" + id + "'.", FormData.class);
    }
    return restResponseFactory.createFormDataResponse(formData);
}
Also used : FormData(org.activiti.engine.form.FormData) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with ActivitiIllegalArgumentException

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

the class HistoricProcessInstanceBaseResource method addVariables.

protected void addVariables(HistoricProcessInstanceQuery processInstanceQuery, List<QueryVariable> variables) {
    for (QueryVariable variable : variables) {
        if (variable.getVariableOperation() == null) {
            throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
        }
        if (variable.getValue() == null) {
            throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
        }
        boolean nameLess = variable.getName() == null;
        Object actualValue = restResponseFactory.getVariableValue(variable);
        // A value-only query is only possible using equals-operator
        if (nameLess && variable.getVariableOperation() != QueryVariableOperation.EQUALS) {
            throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is only supported when using 'equals' operation.");
        }
        switch(variable.getVariableOperation()) {
            case EQUALS:
                if (nameLess) {
                    processInstanceQuery.variableValueEquals(actualValue);
                } else {
                    processInstanceQuery.variableValueEquals(variable.getName(), actualValue);
                }
                break;
            case EQUALS_IGNORE_CASE:
                if (actualValue instanceof String) {
                    processInstanceQuery.variableValueEqualsIgnoreCase(variable.getName(), (String) actualValue);
                } else {
                    throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
                }
                break;
            case NOT_EQUALS:
                processInstanceQuery.variableValueNotEquals(variable.getName(), actualValue);
                break;
            case LIKE:
                if (actualValue instanceof String) {
                    processInstanceQuery.variableValueLike(variable.getName(), (String) actualValue);
                } else {
                    throw new ActivitiIllegalArgumentException("Only string variable values are supported for like, but was: " + actualValue.getClass().getName());
                }
                break;
            case LIKE_IGNORE_CASE:
                if (actualValue instanceof String) {
                    processInstanceQuery.variableValueLikeIgnoreCase(variable.getName(), (String) actualValue);
                } else {
                    throw new ActivitiIllegalArgumentException("Only string variable values are supported for like, but was: " + actualValue.getClass().getName());
                }
                break;
            case GREATER_THAN:
                processInstanceQuery.variableValueGreaterThan(variable.getName(), actualValue);
                break;
            case GREATER_THAN_OR_EQUALS:
                processInstanceQuery.variableValueGreaterThanOrEqual(variable.getName(), actualValue);
                break;
            case LESS_THAN:
                processInstanceQuery.variableValueLessThan(variable.getName(), actualValue);
                break;
            case LESS_THAN_OR_EQUALS:
                processInstanceQuery.variableValueLessThanOrEqual(variable.getName(), actualValue);
                break;
            default:
                throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
        }
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) QueryVariable(org.activiti.rest.service.api.engine.variable.QueryVariable)

Aggregations

ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)180 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)47 ActivitiException (org.activiti.engine.ActivitiException)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)27 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)23 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)19 RestVariable (org.wso2.carbon.bpmn.rest.engine.variable.RestVariable)15 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)12 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)12 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)11 VariableInstance (org.activiti.engine.impl.persistence.entity.VariableInstance)10 MultipartHttpServletRequest (org.springframework.web.multipart.MultipartHttpServletRequest)10 Path (javax.ws.rs.Path)9 TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)9 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)9 QueryVariable (org.wso2.carbon.bpmn.rest.engine.variable.QueryVariable)9 IOException (java.io.IOException)8 Date (java.util.Date)8 Produces (javax.ws.rs.Produces)8