Search in sources :

Example 16 with ProfileImpl

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

the class ProfileDaoTest method shouldCreateProfile.

@Test(dependsOnMethods = { "shouldGetProfileById", "shouldRemoveProfile" })
public void shouldCreateProfile() throws Exception {
    final ProfileImpl profile = profiles[0];
    profileDao.remove(profile.getUserId());
    profileDao.create(profile);
    assertEquals(profileDao.getById(profile.getUserId()), profile);
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Test(org.testng.annotations.Test)

Example 17 with ProfileImpl

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

the class ProfileDaoTest method shouldGetProfileById.

@Test
public void shouldGetProfileById() throws Exception {
    final ProfileImpl profile = profiles[0];
    assertEquals(profileDao.getById(profile.getUserId()), profile);
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Test(org.testng.annotations.Test)

Example 18 with ProfileImpl

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

the class ProfileManager method update.

/**
     * Updates current profile using replace strategy.
     *
     * <p>Note that {@link Profile#getEmail()} can't be updated using this method
     * as it is mirrored from the {@link User#getEmail()}.
     *
     * @param profile
     *         profile update
     * @throws NullPointerException
     *         when {@code profile}  is null
     * @throws NotFoundException
     *         when there is no profile for the user with the id {@code profile.getUserId()}
     * @throws ServerException
     *         when any other error occurs
     */
public void update(Profile profile) throws NotFoundException, ServerException {
    requireNonNull(profile, "Required non-null profile");
    profileDao.update(new ProfileImpl(profile));
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl)

Example 19 with ProfileImpl

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

the class ProfileManager method create.

/**
     * Creates a new user's profile .
     *
     * @param profile
     *         new profile
     * @throws NullPointerException
     *         when profile is null
     * @throws ConflictException
     *         when profile for the user {@code profile.getUserId()} already exists
     * @throws ServerException
     *         when any other error occurs
     */
public void create(Profile profile) throws ServerException, ConflictException {
    requireNonNull(profile, "Required non-null profile");
    profileDao.create(new ProfileImpl(profile));
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl)

Example 20 with ProfileImpl

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

the class ProfileService method updateAttributes.

@PUT
@Path("/attributes")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_CURRENT_PROFILE_ATTRIBUTES)
@ApiOperation(value = "Update the profile attributes of the currently logged in user", notes = "The replace strategy is used for the update, so all the existing profile " + "attributes will be override with incoming values")
public ProfileDto updateAttributes(@ApiParam("New profile attributes") Map<String, String> updates) throws NotFoundException, ServerException, BadRequestException {
    checkAttributes(updates);
    final ProfileImpl profile = new ProfileImpl(profileManager.getById(userId()));
    profile.setAttributes(updates);
    profileManager.update(profile);
    return linksInjector.injectLinks(asDto(profile, userManager.getById(profile.getUserId())), getServiceContext());
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) PUT(javax.ws.rs.PUT)

Aggregations

ProfileImpl (org.eclipse.che.api.user.server.model.impl.ProfileImpl)24 Test (org.testng.annotations.Test)11 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)4 Transactional (com.google.inject.persist.Transactional)3 EntityManager (javax.persistence.EntityManager)3 TypeLiteral (com.google.inject.TypeLiteral)2 Response (com.jayway.restassured.response.Response)2 ApiOperation (io.swagger.annotations.ApiOperation)2 HashMap (java.util.HashMap)2 Consumes (javax.ws.rs.Consumes)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 AccountImpl (org.eclipse.che.account.spi.AccountImpl)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 ServerException (org.eclipse.che.api.core.ServerException)2 Profile (org.eclipse.che.api.core.model.user.Profile)2 PreferenceDao (org.eclipse.che.api.user.server.spi.PreferenceDao)2 ProfileDao (org.eclipse.che.api.user.server.spi.ProfileDao)2 UserDao (org.eclipse.che.api.user.server.spi.UserDao)2