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