Search in sources :

Example 1 with IUserProfile

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

the class UserProfileAttributeTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    try {
        IUserProfile profile = this.getUserProfile();
        if (null == profile) {
            return super.doStartTag();
        }
        Object value = null;
        if (null != this.getAttributeRoleName()) {
            ITextAttribute textAttribute = (ITextAttribute) profile.getAttributeByRole(this.getAttributeRoleName());
            value = (null != textAttribute) ? textAttribute.getText() : null;
        } else {
            value = profile.getValue(this.getAttributeName());
        }
        if (null == value) {
            return super.doStartTag();
        }
        if (this.getVar() != null) {
            this.pageContext.setAttribute(this.getVar(), value);
        } else {
            if (this.getEscapeXml()) {
                out(this.pageContext, this.getEscapeXml(), value);
            } else {
                this.pageContext.getOut().print(value);
            }
        }
    } catch (Throwable t) {
        _logger.error("error in doStartTag", t);
        // ApsSystemUtils.logThrowable(t, this, "doStartTag");
        throw new JspException("Error during tag initialization", t);
    }
    return super.doStartTag();
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) JspException(javax.servlet.jsp.JspException) IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile)

Example 2 with IUserProfile

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

the class UserProfileDAO method buildAddEntityStatement.

@Override
protected void buildAddEntityStatement(IApsEntity entity, PreparedStatement stat) throws Throwable {
    IUserProfile profile = (IUserProfile) entity;
    stat.setString(1, profile.getUsername());
    stat.setString(2, profile.getTypeCode());
    stat.setString(3, profile.getXML());
    if (profile.isPublicProfile()) {
        stat.setInt(4, 1);
    } else {
        stat.setInt(4, 0);
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile)

Example 3 with IUserProfile

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

the class UserProfileManager method getDefaultProfileType.

@Override
public IUserProfile getDefaultProfileType() {
    IUserProfile profileType = (IUserProfile) super.getEntityPrototype(SystemConstants.DEFAULT_PROFILE_TYPE_CODE);
    if (null == profileType) {
        List<String> entityTypes = new ArrayList<>();
        entityTypes.addAll(this.getEntityPrototypes().keySet());
        if (!entityTypes.isEmpty()) {
            Collections.sort(entityTypes);
            profileType = (IUserProfile) super.getEntityPrototype(entityTypes.get(0));
        }
    }
    return profileType;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ArrayList(java.util.ArrayList)

Example 4 with IUserProfile

use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile 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 5 with IUserProfile

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

the class UserProfileManager method getProfile.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
@CacheableInfo(groups = "'UserProfileTypes_cacheGroup'")
public IUserProfile getProfile(String username) throws ApsSystemException {
    IUserProfile profile = null;
    try {
        UserProfileRecord profileVO = (UserProfileRecord) this.getProfileDAO().loadEntityRecord(username);
        if (profileVO != null) {
            profile = (IUserProfile) this.createEntityFromXml(profileVO.getTypeCode(), profileVO.getXml());
            profile.setPublicProfile(profileVO.isPublicProfile());
        }
    } catch (Throwable t) {
        logger.error("Error loading profile. user: {} ", username, t);
        throw new ApsSystemException("Error loading profile", t);
    }
    return profile;
}
Also used : UserProfileRecord(org.entando.entando.aps.system.services.userprofile.model.UserProfileRecord) IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

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