Search in sources :

Example 1 with AbstractUser

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);
            }
        }
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) AbstractUser(com.agiletec.aps.system.services.user.AbstractUser) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Example 2 with AbstractUser

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;
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) AbstractUser(com.agiletec.aps.system.services.user.AbstractUser)

Example 3 with AbstractUser

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;
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) AbstractUser(com.agiletec.aps.system.services.user.AbstractUser)

Aggregations

AbstractUser (com.agiletec.aps.system.services.user.AbstractUser)3 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)3 UserDetails (com.agiletec.aps.system.services.user.UserDetails)2 AfterReturning (org.aspectj.lang.annotation.AfterReturning)1