Search in sources :

Example 1 with UserDTO

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);
    }
}
Also used : UserDTO(io.hops.hopsworks.common.dao.user.UserDTO) RemoteUserDTO(io.hops.hopsworks.common.remote.RemoteUserDTO) UserException(io.hops.hopsworks.exceptions.UserException)

Example 2 with UserDTO

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();
}
Also used : UserAccountStatus(io.hops.hopsworks.persistence.entity.user.security.ua.UserAccountStatus) UserDTO(io.hops.hopsworks.common.dao.user.UserDTO) NewUserDTO(io.hops.hopsworks.api.admin.dto.NewUserDTO) Users(io.hops.hopsworks.persistence.entity.user.Users) NewUserDTO(io.hops.hopsworks.api.admin.dto.NewUserDTO) URI(java.net.URI)

Example 3 with UserDTO

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;
}
Also used : FeatureViewDTO(io.hops.hopsworks.common.featurestore.featureview.FeatureViewDTO) UserDTO(io.hops.hopsworks.common.dao.user.UserDTO)

Aggregations

UserDTO (io.hops.hopsworks.common.dao.user.UserDTO)3 NewUserDTO (io.hops.hopsworks.api.admin.dto.NewUserDTO)1 FeatureViewDTO (io.hops.hopsworks.common.featurestore.featureview.FeatureViewDTO)1 RemoteUserDTO (io.hops.hopsworks.common.remote.RemoteUserDTO)1 UserException (io.hops.hopsworks.exceptions.UserException)1 Users (io.hops.hopsworks.persistence.entity.user.Users)1 UserAccountStatus (io.hops.hopsworks.persistence.entity.user.security.ua.UserAccountStatus)1 URI (java.net.URI)1