use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class HistoricProcessInstanceCommentCollectionResource method createComment.
@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments", method = RequestMethod.POST, produces = "application/json")
public CommentResponse createComment(@PathVariable String processInstanceId, @RequestBody CommentResponse comment, HttpServletRequest request, HttpServletResponse response) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
if (comment.getMessage() == null) {
throw new ActivitiIllegalArgumentException("Comment text is required.");
}
Comment createdComment = taskService.addComment(null, instance.getId(), comment.getMessage());
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createRestComment(createdComment);
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class HistoricVariableInstanceBaseResource method addVariables.
protected void addVariables(HistoricVariableInstanceQuery variableInstanceQuery, 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) {
throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is not supported");
}
switch(variable.getVariableOperation()) {
case EQUALS:
variableInstanceQuery.variableValueEquals(variable.getName(), actualValue);
break;
default:
throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
}
}
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class GroupMembershipCollectionResource method createMembership.
@RequestMapping(value = "/identity/groups/{groupId}/members", method = RequestMethod.POST, produces = "application/json")
public MembershipResponse createMembership(@PathVariable String groupId, @RequestBody MembershipRequest memberShip, HttpServletRequest request, HttpServletResponse response) {
Group group = getGroupFromRequest(groupId);
if (memberShip.getUserId() == null) {
throw new ActivitiIllegalArgumentException("UserId cannot be null.");
}
// Check if user is member of group since API doesn't return typed exception
if (identityService.createUserQuery().memberOfGroup(group.getId()).userId(memberShip.getUserId()).count() > 0) {
throw new ActivitiConflictException("User '" + memberShip.getUserId() + "' is already part of group '" + group.getId() + "'.");
}
identityService.createMembership(memberShip.getUserId(), group.getId());
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createMembershipResponse(memberShip.getUserId(), group.getId());
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class UserCollectionResource method createUser.
@RequestMapping(value = "/identity/users", method = RequestMethod.POST, produces = "application/json")
public UserResponse createUser(@RequestBody UserRequest userRequest, HttpServletRequest request, HttpServletResponse response) {
if (userRequest.getId() == null) {
throw new ActivitiIllegalArgumentException("Id cannot be null.");
}
// Check if a user with the given ID already exists so we return a CONFLICT
if (identityService.createUserQuery().userId(userRequest.getId()).count() > 0) {
throw new ActivitiConflictException("A user with id '" + userRequest.getId() + "' already exists.");
}
User created = identityService.newUser(userRequest.getId());
created.setEmail(userRequest.getEmail());
created.setFirstName(userRequest.getFirstName());
created.setLastName(userRequest.getLastName());
created.setPassword(userRequest.getPassword());
identityService.saveUser(created);
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createUserResponse(created, true);
}
use of org.activiti.engine.ActivitiIllegalArgumentException in project Activiti by Activiti.
the class LDAPUserManager method findUserByQueryCriteria.
@Override
public List<User> findUserByQueryCriteria(final UserQueryImpl query, final Page page) {
if (query.getId() != null) {
List<User> result = new ArrayList<User>();
result.add(findUserById(query.getId()));
return result;
} else if (query.getFullNameLike() != null) {
final String fullNameLike = query.getFullNameLike().replaceAll("%", "");
LDAPTemplate ldapTemplate = new LDAPTemplate(ldapConfigurator);
return ldapTemplate.execute(new LDAPCallBack<List<User>>() {
public List<User> executeInContext(InitialDirContext initialDirContext) {
List<User> result = new ArrayList<User>();
try {
String searchExpression = ldapConfigurator.getLdapQueryBuilder().buildQueryByFullNameLike(ldapConfigurator, fullNameLike);
String baseDn = ldapConfigurator.getUserBaseDn() != null ? ldapConfigurator.getUserBaseDn() : ldapConfigurator.getBaseDn();
NamingEnumeration<?> namingEnum = initialDirContext.search(baseDn, searchExpression, createSearchControls());
while (namingEnum.hasMore()) {
SearchResult searchResult = (SearchResult) namingEnum.next();
UserEntity user = new UserEntity();
mapSearchResultToUser(searchResult, user);
result.add(user);
}
namingEnum.close();
} catch (NamingException ne) {
logger.debug("Could not execute LDAP query: " + ne.getMessage(), ne);
return null;
}
return result;
}
});
} else {
throw new ActivitiIllegalArgumentException("Query is currently not supported by LDAPUserManager.");
}
}
Aggregations