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);
}
}
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);
}
}
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");
}
}
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;
}
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;
}
Aggregations