use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class UserProfileAction method createNewProfile.
protected String createNewProfile(boolean onlyVoid) {
String username = this.getUsername();
String profileTypeCode = this.getProfileTypeCode();
try {
String check = this.checkUsername(username, false);
if (null != check)
return check;
this.getUserProfileManager().deleteProfile(username);
/*
IUserProfile userProfile = (IUserProfile) this.getUserProfileManager().getProfile(username);
if (null != userProfile) {
this.getRequest().getSession().setAttribute(USERPROFILE_ON_SESSION, userProfile);
return "edit";
}
*/
if (StringUtils.isBlank(profileTypeCode)) {
String[] args = { profileTypeCode };
this.addFieldError("profileTypeCode", this.getText("error.newUserProfile.invalidProfileType", args));
return INPUT;
}
IUserProfile prototype = (IUserProfile) this.getUserProfileManager().getEntityPrototype(profileTypeCode);
if (null == prototype) {
String[] args = { profileTypeCode };
this.addFieldError("profileTypeCode", this.getText("error.newUserProfile.invalidProfileType", args));
return INPUT;
}
prototype.setId(this.getUsername());
this.getUserProfileManager().addProfile(username, prototype);
if (onlyVoid) {
this.getRequest().getSession().removeAttribute(USERPROFILE_ON_SESSION);
} else {
this.getRequest().getSession().setAttribute(USERPROFILE_ON_SESSION, prototype);
}
} catch (Throwable t) {
_logger.error("error in createNewProfile", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class UserProfileAction method view.
@Override
public String view() {
String username = this.getUsername();
try {
String checkUsernameResult = this.checkUsername(username, true);
if (null != checkUsernameResult)
return checkUsernameResult;
IUserProfile userProfile = (IUserProfile) this.getUserProfileManager().getProfile(username);
if (null == userProfile) {
String[] args = { username };
this.addFieldError("username", this.getText("error.viewUserProfile.userWithoutProfile", args));
return INPUT;
}
} catch (Throwable t) {
_logger.error("error in view", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class TestCurrentUserProfileAction method testValidateProfile.
public void testValidateProfile() throws Throwable {
this.setUserOnSession("editorCustomers");
this.initAction("/do/currentuser/profile", "edit");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
this.initAction("/do/currentuser/profile", "save");
this.addParameter("Monotext:fullname", "");
this.addParameter("Monotext:email", "");
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(2, action.getFieldErrors().size());
this.initAction("/do/currentuser/profile", "save");
this.addParameter("Monotext:fullname", "Ronald Rossi");
this.addParameter("Monotext:email", "");
this.addParameter("Date:birthdate", "25/09/1972");
this.addParameter("Monotext:language", "it");
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
assertEquals(1, ((List<String>) action.getFieldErrors().get("Monotext:email")).size());
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(ICurrentUserProfileAction.SESSION_PARAM_NAME_CURRENT_PROFILE);
assertNotNull(currentUserProfile);
assertEquals("editorCustomers", currentUserProfile.getUsername());
assertEquals("Ronald Rossi", currentUserProfile.getValue("fullname"));
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class TestCurrentUserProfileAction method testEditProfile_2.
public void testEditProfile_2() throws Throwable {
this.setUserOnSession("editorCustomers");
this.initAction("/do/currentuser/profile", "edit");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(ICurrentUserProfileAction.SESSION_PARAM_NAME_CURRENT_PROFILE);
assertNotNull(currentUserProfile);
assertEquals("editorCustomers", currentUserProfile.getUsername());
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class TestUserProfileAction method testEditProfile_2.
public void testEditProfile_2() throws Throwable {
this.setUserOnSession("admin");
this.initAction("/do/userprofile", "edit");
this.addParameter("username", "editorCustomers");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(UserProfileAction.USERPROFILE_ON_SESSION);
assertNotNull(currentUserProfile);
assertEquals("editorCustomers", currentUserProfile.getUsername());
}
Aggregations