use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class BaseJPARestTestCase method createUsers.
protected void createUsers() {
User user = identityService.newUser("kermit");
user.setFirstName("Kermit");
user.setLastName("the Frog");
user.setPassword("kermit");
identityService.saveUser(user);
Group group = identityService.newGroup("admin");
group.setName("Administrators");
identityService.saveGroup(group);
identityService.createMembership(user.getId(), group.getId());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserInfoCollectionResource method setUserInfo.
@RequestMapping(value = "/identity/users/{userId}/info", method = RequestMethod.POST, produces = "application/json")
public UserInfoResponse setUserInfo(@PathVariable String userId, @RequestBody UserInfoRequest userRequest, HttpServletRequest request, HttpServletResponse response) {
User user = getUserFromRequest(userId);
if (userRequest.getKey() == null) {
throw new ActivitiIllegalArgumentException("The key cannot be null.");
}
if (userRequest.getValue() == null) {
throw new ActivitiIllegalArgumentException("The value cannot be null.");
}
String existingValue = identityService.getUserInfo(user.getId(), userRequest.getKey());
if (existingValue != null) {
throw new ActivitiConflictException("User info with key '" + userRequest.getKey() + "' already exists for this user.");
}
identityService.setUserInfo(user.getId(), userRequest.getKey(), userRequest.getValue());
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createUserInfoResponse(userRequest.getKey(), userRequest.getValue(), user.getId());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserInfoResource method setUserInfo.
@RequestMapping(value = "/identity/users/{userId}/info/{key}", method = RequestMethod.PUT, produces = "application/json")
public UserInfoResponse setUserInfo(@PathVariable("userId") String userId, @PathVariable("key") String key, @RequestBody UserInfoRequest userRequest, HttpServletRequest request) {
User user = getUserFromRequest(userId);
String validKey = getValidKeyFromRequest(user, key);
if (userRequest.getValue() == null) {
throw new ActivitiIllegalArgumentException("The value cannot be null.");
}
if (userRequest.getKey() == null || validKey.equals(userRequest.getKey())) {
identityService.setUserInfo(user.getId(), key, userRequest.getValue());
} else {
throw new ActivitiIllegalArgumentException("Key provided in request body doesn't match the key in the resource URL.");
}
return restResponseFactory.createUserInfoResponse(key, userRequest.getValue(), user.getId());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserInfoResource method deleteUserInfo.
@RequestMapping(value = "/identity/users/{userId}/info/{key}", method = RequestMethod.DELETE)
public void deleteUserInfo(@PathVariable("userId") String userId, @PathVariable("key") String key, HttpServletResponse response) {
User user = getUserFromRequest(userId);
String validKey = getValidKeyFromRequest(user, key);
identityService.setUserInfo(user.getId(), validKey, null);
response.setStatus(HttpStatus.NO_CONTENT.value());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserInfoResource method getUserInfo.
@RequestMapping(value = "/identity/users/{userId}/info/{key}", method = RequestMethod.GET, produces = "application/json")
public UserInfoResponse getUserInfo(@PathVariable("userId") String userId, @PathVariable("key") String key, HttpServletRequest request) {
User user = getUserFromRequest(userId);
String existingValue = identityService.getUserInfo(user.getId(), key);
if (existingValue == null) {
throw new ActivitiObjectNotFoundException("User info with key '" + key + "' does not exists for user '" + user.getId() + "'.", null);
}
return restResponseFactory.createUserInfoResponse(key, existingValue, user.getId());
}
Aggregations