Search in sources :

Example 16 with IUserProfile

use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.

the class TestUserProfileAction method testNewProfile.

public void testNewProfile() throws Throwable {
    this.setUserOnSession("admin");
    try {
        this.initAction("/do/userprofile", "saveAndContinue");
        this.addParameter("username", USERNAME_FOR_TEST);
        this.addParameter("profileTypeCode", SystemConstants.DEFAULT_PROFILE_TYPE_CODE);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(UserProfileAction.USERPROFILE_ON_SESSION);
        assertNotNull(currentUserProfile);
        assertEquals(USERNAME_FOR_TEST, currentUserProfile.getUsername());
        assertNotNull(this._profileManager.getProfile(USERNAME_FOR_TEST));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._profileManager.deleteProfile(USERNAME_FOR_TEST);
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile)

Example 17 with IUserProfile

use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.

the class TestUserProfileAction method testSaveProfile.

public void testSaveProfile() throws Throwable {
    this.setUserOnSession("admin");
    this.initAction("/do/userprofile", "saveAndContinue");
    this.addParameter("username", USERNAME_FOR_TEST);
    this.addParameter("profileTypeCode", SystemConstants.DEFAULT_PROFILE_TYPE_CODE);
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    try {
        this.initAction("/do/userprofile", "save");
        this.addParameter("Monotext:fullname", "Eugenio Montale");
        this.addParameter("Monotext:email", "eugenioxxxxx@xxxx.it");
        this.addParameter("Date:birthdate", "12/10/1896");
        this.addParameter("Monotext:language", "it");
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        IUserProfile userProfile = this._profileManager.getProfile(USERNAME_FOR_TEST);
        assertNotNull(userProfile);
        assertEquals("Eugenio Montale", userProfile.getValue("fullname"));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._profileManager.deleteProfile(USERNAME_FOR_TEST);
        IUserProfile userProfile = this._profileManager.getProfile(USERNAME_FOR_TEST);
        assertNull(userProfile);
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile)

Example 18 with IUserProfile

use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.

the class TestUserProfileAction method testEditProfile_3.

public void testEditProfile_3() throws Throwable {
    IUserProfile prototype = this._profileManager.getDefaultProfileType();
    prototype.setTypeCode("XXX");
    ((IEntityTypesConfigurer) this._profileManager).addEntityPrototype(prototype);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/userprofile", "edit");
        this.addParameter("username", USERNAME_FOR_TEST);
        String result = this.executeAction();
        assertEquals("chooseType", result);
        IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(UserProfileAction.USERPROFILE_ON_SESSION);
        assertNull(currentUserProfile);
    } catch (Throwable t) {
        throw t;
    } finally {
        ((IEntityTypesConfigurer) this._profileManager).removeEntityPrototype("XXX");
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) IEntityTypesConfigurer(com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)

Example 19 with IUserProfile

use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.

the class CurrentUserProfileAction method edit.

@Override
public String edit() {
    try {
        IUserProfile userProfile = null;
        UserDetails currentUser = this.getCurrentUser();
        Object object = currentUser.getProfile();
        if (null != object && object instanceof IUserProfile) {
            // String username = currentUser.getUsername();
            // this.getUserProfileManager().getProfile(username);
            userProfile = (IUserProfile) object;
            this.checkTypeLabels(userProfile);
        } else {
            return "currentUserWithoutProfile";
        }
        IUserProfile currentProfile = this.getUserProfile();
        if (null == currentProfile || !currentProfile.getUsername().equals(currentUser.getUsername())) {
            userProfile.disableAttributes(SystemConstants.USER_PROFILE_ATTRIBUTE_DISABLING_CODE_ON_EDIT);
            this.getRequest().getSession().setAttribute(SESSION_PARAM_NAME_CURRENT_PROFILE, userProfile);
        }
    } catch (Throwable t) {
        _logger.error("error in edit", t);
        // ApsSystemUtils.logThrowable(t, this, "edit");
        return FAILURE;
    }
    return SUCCESS;
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile)

Example 20 with IUserProfile

use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.

the class TestUserManager method createProfile.

private IUserProfile createProfile(String name, String surname, String email, Date birthdate, String language) {
    IUserProfile profile = _profileManager.getDefaultProfileType();
    MonoTextAttribute nameAttr = (MonoTextAttribute) profile.getAttribute("fullname");
    nameAttr.setText(name + " " + surname);
    MonoTextAttribute emailAttr = (MonoTextAttribute) profile.getAttribute("email");
    DateAttribute birthdateAttr = (DateAttribute) profile.getAttribute("birthdate");
    birthdateAttr.setDate(birthdate);
    MonoTextAttribute languageAttr = (MonoTextAttribute) profile.getAttribute("language");
    languageAttr.setText(language);
    emailAttr.setText(email);
    return profile;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) MonoTextAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Aggregations

IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)42 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)10 UserDetails (com.agiletec.aps.system.services.user.UserDetails)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)5 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)3 AbstractUser (com.agiletec.aps.system.services.user.AbstractUser)3 Date (java.util.Date)3 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)3 CacheableInfo (org.entando.entando.aps.system.services.cache.CacheableInfo)3 CachePut (org.springframework.cache.annotation.CachePut)3 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)2 ActionSupport (com.opensymphony.xwork2.ActionSupport)2 ArrayList (java.util.ArrayList)2 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 Test (org.junit.Test)2 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)1 BaseFilterUtils (com.agiletec.aps.system.common.entity.helper.BaseFilterUtils)1 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)1