use of io.hops.hopsworks.common.dao.user.UserDTO in project hopsworks by logicalclocks.
the class Register method createUser.
private void createUser(HttpServletRequest httpServletRequest) {
try {
UserDTO newUser = new UserDTO();
newUser.setEmail(this.email);
newUser.setFirstName(this.firstName);
newUser.setLastName(this.lastName);
newUser.setMaxNumProjects(this.maxNumProjects);
this.password = securityUtils.generateRandomString(UserValidator.TEMP_PASSWORD_LENGTH);
newUser.setChosenPassword(this.password);
newUser.setRepeatedPassword(this.password);
auditedUserAdministration.createUser(newUser, this.role, UserAccountStatus.fromValue(status), UserAccountType.M_ACCOUNT_TYPE, httpServletRequest);
showDialog();
restAll();
MessagesController.addInfoMessage("Success", "User created.", "msg");
} catch (UserException e) {
showErrorMsg("Failed to create user.", e);
}
}
use of io.hops.hopsworks.common.dao.user.UserDTO in project hopsworks by logicalclocks.
the class UsersAdminResource method createUser.
private Response createUser(String email, String password, String givenName, String surname, int maxNumProjects, String role, UserAccountStatus status, UriInfo uriInfo) throws UserException {
UserDTO newUser = new UserDTO();
newUser.setEmail(email);
newUser.setFirstName(givenName);
newUser.setLastName(surname);
newUser.setMaxNumProjects(maxNumProjects > 0 ? maxNumProjects : settings.getMaxNumProjPerUser());
String passwordGen = password != null && !password.isEmpty() ? password : securityUtils.generateRandomString(UserValidator.TEMP_PASSWORD_LENGTH);
newUser.setChosenPassword(passwordGen);
newUser.setRepeatedPassword(passwordGen);
newUser.setTos(true);
userValidator.isValidNewUser(newUser, passwordGen.equals(password));
UserAccountStatus statusDefault = status != null ? status : UserAccountStatus.TEMP_PASSWORD;
Users user = usersController.registerUser(newUser, role != null ? role : Settings.DEFAULT_ROLE, statusDefault, UserAccountType.M_ACCOUNT_TYPE);
NewUserDTO newUserDTO = new NewUserDTO(user);
URI href = uriInfo.getAbsolutePathBuilder().path(user.getUid().toString()).build();
if (!passwordGen.equals(password)) {
newUserDTO.setPassword(passwordGen);
}
return Response.created(href).entity(newUserDTO).build();
}
use of io.hops.hopsworks.common.dao.user.UserDTO in project hopsworks by logicalclocks.
the class FeatureViewBuilder method convertToDTO.
public FeatureViewDTO convertToDTO(FeatureView featureView) {
FeatureViewDTO featureViewDTO = new FeatureViewDTO();
featureViewDTO.setFeaturestoreId(featureView.getFeaturestore().getId());
featureViewDTO.setFeaturestoreName(featureView.getFeaturestore().getProject().getName());
featureViewDTO.setDescription(featureView.getDescription());
featureViewDTO.setCreated(featureView.getCreated());
featureViewDTO.setCreator(new UserDTO(featureView.getCreator()));
featureViewDTO.setVersion(featureView.getVersion());
featureViewDTO.setName(featureView.getName());
featureViewDTO.setId(featureView.getId());
featureViewDTO.setLabel(featureView.getLabel());
return featureViewDTO;
}
Aggregations