Search in sources :

Example 46 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class UserDaoTest method shouldThrowConflictExceptionWhenUpdatingUserWithReservedEmail.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenUpdatingUserWithReservedEmail() throws Exception {
    final UserImpl user = users[0];
    user.setEmail(users[1].getEmail());
    userDao.update(user);
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 47 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class UserDaoTest method shouldRemoveUser.

@Test(expectedExceptions = NotFoundException.class, dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingUserById")
public void shouldRemoveUser() throws Exception {
    final UserImpl user = users[0];
    userDao.remove(user.getId());
    userDao.getById(user.getId());
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 48 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class UserService method updatePassword.

@POST
@Path("/password")
@Consumes(APPLICATION_FORM_URLENCODED)
@GenerateLink(rel = LINK_REL_CURRENT_USER_PASSWORD)
@ApiOperation(value = "Update password of logged in user", notes = "Password must contain at least 8 characters, " + "passport must contain letters and digits")
@ApiResponses({ @ApiResponse(code = 204, message = "Password successfully updated"), @ApiResponse(code = 400, message = "Incoming password is invalid value." + "Valid password must contain at least 8 character " + "which are letters and digits"), @ApiResponse(code = 500, message = "Couldn't update password due to internal server error") })
public void updatePassword(@ApiParam(value = "New password", required = true) @FormParam("password") String password) throws NotFoundException, BadRequestException, ServerException, ConflictException {
    userValidator.checkPassword(password);
    final UserImpl user = new UserImpl(userManager.getById(userId()));
    user.setPassword(password);
    userManager.update(user);
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) ApiResponses(io.swagger.annotations.ApiResponses)

Example 49 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class JpaUserDao method doCreate.

@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
protected void doCreate(UserImpl user) throws ConflictException, ServerException {
    EntityManager manage = managerProvider.get();
    manage.persist(user);
    manage.flush();
    eventService.publish(new PostUserPersistedEvent(new UserImpl(user))).propagateException();
}
Also used : EntityManager(javax.persistence.EntityManager) PostUserPersistedEvent(org.eclipse.che.api.user.server.event.PostUserPersistedEvent) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Transactional(com.google.inject.persist.Transactional)

Example 50 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class JpaUserDao method remove.

@Override
public void remove(String id) throws ServerException {
    requireNonNull(id, "Required non-null id");
    try {
        Optional<UserImpl> userOpt = doRemove(id);
        userOpt.ifPresent(user -> eventService.publish(new UserRemovedEvent(user.getId())));
    } catch (RuntimeException x) {
        throw new ServerException(x.getLocalizedMessage(), x);
    }
}
Also used : ServerException(org.eclipse.che.api.core.ServerException) BeforeUserRemovedEvent(org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent) UserRemovedEvent(org.eclipse.che.api.user.server.event.UserRemovedEvent) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl)

Aggregations

UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)65 Test (org.testng.annotations.Test)45 User (org.eclipse.che.api.core.model.user.User)13 Response (com.jayway.restassured.response.Response)10 BeforeMethod (org.testng.annotations.BeforeMethod)9 ServerException (org.eclipse.che.api.core.ServerException)8 Transactional (com.google.inject.persist.Transactional)6 ConflictException (org.eclipse.che.api.core.ConflictException)5 BeforeUserRemovedEvent (org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent)5 EntityManager (javax.persistence.EntityManager)4 NotFoundException (org.eclipse.che.api.core.NotFoundException)4 Page (org.eclipse.che.api.core.Page)4 PostUserPersistedEvent (org.eclipse.che.api.user.server.event.PostUserPersistedEvent)4 ProfileImpl (org.eclipse.che.api.user.server.model.impl.ProfileImpl)4 UserDao (org.eclipse.che.api.user.server.spi.UserDao)4 ArrayList (java.util.ArrayList)3 Inject (javax.inject.Inject)3 UserRemovedEvent (org.eclipse.che.api.user.server.event.UserRemovedEvent)3 UserDto (org.eclipse.che.api.user.shared.dto.UserDto)3 TckRepository (org.eclipse.che.commons.test.tck.repository.TckRepository)3