use of com.agiletec.aps.system.services.user.AbstractUser in project entando-core by entando.
the class UserProfileManager method injectProfile.
@AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.getUser(..))", returning = "user")
public void injectProfile(Object user) {
if (user != null) {
AbstractUser userDetails = (AbstractUser) user;
if (null == userDetails.getProfile()) {
try {
IUserProfile profile = this.getProfile(userDetails.getUsername());
userDetails.setProfile(profile);
} catch (Throwable t) {
logger.error("Error injecting profile on user {}", userDetails.getUsername(), t);
}
}
}
}
use of com.agiletec.aps.system.services.user.AbstractUser in project entando-core by entando.
the class CurrentUserProfileAction method save.
@Override
public String save() {
try {
IUserProfile profile = this.getUserProfile();
if (profile == null) {
return FAILURE;
}
UserDetails user = this.getCurrentUser();
((AbstractUser) user).setProfile(profile);
if (null == this.getUserProfileManager().getProfile(user.getUsername())) {
this.getUserProfileManager().addProfile(user.getUsername(), profile);
} else {
this.getUserProfileManager().updateProfile(user.getUsername(), profile);
}
this.getRequest().getSession().removeAttribute(SESSION_PARAM_NAME_CURRENT_PROFILE);
this.addActionMessage(this.getText("message.profileUpdated"));
} catch (Throwable t) {
_logger.error("error in save", t);
// ApsSystemUtils.logThrowable(t, this, "save");
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.user.AbstractUser in project entando-core by entando.
the class UserProfileAction method save.
@Override
public String save() {
try {
IUserProfile userProfile = (IUserProfile) this.getApsEntity();
String username = userProfile.getUsername();
if (null == this.getUserProfileManager().getProfile(userProfile.getUsername())) {
this.getUserProfileManager().addProfile(username, userProfile);
} else {
this.getUserProfileManager().updateProfile(username, userProfile);
}
UserDetails currentUser = super.getCurrentUser();
if (null != currentUser && currentUser.getUsername().equals(username) && (currentUser instanceof AbstractUser)) {
((AbstractUser) currentUser).setProfile(userProfile);
}
} catch (Throwable t) {
_logger.error("error in save", t);
return FAILURE;
}
return SUCCESS;
}
Aggregations