use of org.eclipse.vorto.repository.domain.User in project vorto by eclipse.
the class UserService method createOrUpdateTechnicalUser.
/**
* Validates and persists the given {@link User} as technical user.<br/>
* This functionality is available to all users regardless of their privileges. <br/>
* Failures in authorization may occur in a broader context, as technical users are created
* and specifically associated to a {@link org.eclipse.vorto.repository.domain.Namespace}, so the
* user performing the operation must have the right authorities to do so in context.
*
* @param technicalUser
* @return
* @throws InvalidUserException
*/
public User createOrUpdateTechnicalUser(User actor, User technicalUser) throws InvalidUserException {
// boilerplate null validation
ServiceValidationUtil.validateNulls(technicalUser);
// validates technical user
userUtil.validateNewUser(technicalUser);
// sets createdby for tech user
technicalUser.setCreatedBy(actor.getId());
// save the technical user
User result = userRepository.save(technicalUser);
if (result != null) {
eventPublisher.publishEvent(new AppEvent(this, technicalUser.getUsername(), EventType.USER_ADDED));
}
return result;
}
Aggregations