Search in sources :

Example 1 with CacheableInfo

use of org.entando.entando.aps.system.services.cache.CacheableInfo 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)

Example 2 with CacheableInfo

use of org.entando.entando.aps.system.services.cache.CacheableInfo in project entando-core by entando.

the class SocialActivityStreamManager method getActionLikeRecords.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamLikeRecords_id_'.concat(#id)")
@CacheableInfo(groups = "'ActivityStreamLikeRecords_cacheGroup'")
public List<ActivityStreamLikeInfo> getActionLikeRecords(int id) throws ApsSystemException {
    List<ActivityStreamLikeInfo> infos = null;
    try {
        infos = this.getSocialActivityStreamDAO().getActionLikeRecords(id);
        if (null != infos) {
            for (int i = 0; i < infos.size(); i++) {
                ActivityStreamLikeInfo asli = infos.get(i);
                String username = asli.getUsername();
                IUserProfile profile = this.getUserProfileManager().getProfile(username);
                String displayName = (null != profile) ? profile.getDisplayName() : username;
                asli.setDisplayName(displayName);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting activity stream like records", t);
        throw new ApsSystemException("Error extracting activity stream like records", t);
    }
    return infos;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ActivityStreamLikeInfo(org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Example 3 with CacheableInfo

use of org.entando.entando.aps.system.services.cache.CacheableInfo in project entando-core by entando.

the class SocialActivityStreamManager method getActionCommentRecords.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamCommentRecords_id_'.concat(#id)")
@CacheableInfo(groups = "'ActivityStreamCommentRecords_cacheGroup'")
public List<ActivityStreamComment> getActionCommentRecords(int id) throws ApsSystemException {
    List<ActivityStreamComment> infos = null;
    try {
        infos = this.getSocialActivityStreamDAO().getActionCommentRecords(id);
        if (null != infos) {
            for (int i = 0; i < infos.size(); i++) {
                ActivityStreamComment comment = infos.get(i);
                String username = comment.getUsername();
                IUserProfile profile = this.getUserProfileManager().getProfile(username);
                String displayName = (null != profile) ? profile.getDisplayName() : username;
                comment.setDisplayName(displayName);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting activity stream like records for stream with id {}", id, t);
        throw new ApsSystemException("Error extracting activity stream like records", t);
    }
    return infos;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ActivityStreamComment(org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamComment) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Example 4 with CacheableInfo

use of org.entando.entando.aps.system.services.cache.CacheableInfo in project entando-core by entando.

the class ContentAuthorizationHelper method getAuthorizationInfo.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "T(com.agiletec.plugins.jacms.aps.system.JacmsSystemConstants).CONTENT_AUTH_INFO_CACHE_PREFIX.concat(#contentId)")
@CacheableInfo(groups = "T(com.agiletec.plugins.jacms.aps.system.services.cache.CmsCacheWrapperManager).getContentCacheGroupsCsv(#contentId)")
public PublicContentAuthorizationInfo getAuthorizationInfo(String contentId) {
    PublicContentAuthorizationInfo authInfo = null;
    try {
        Content content = this.getContentManager().loadContent(contentId, true);
        if (null == content) {
            _logger.debug("public content {} doesn't exist", contentId);
            return null;
        }
        authInfo = new PublicContentAuthorizationInfo(content, this.getLangManager().getLangs());
    } catch (Throwable t) {
        _logger.error("error in getAuthorizationInfo for content {}", contentId, t);
    }
    return authInfo;
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Example 5 with CacheableInfo

use of org.entando.entando.aps.system.services.cache.CacheableInfo in project entando-core by entando.

the class ContentListHelper method getContentsId.

@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "T(com.agiletec.plugins.jacms.aps.system.services.content.widget.ContentListHelper).buildCacheKey(#bean, #reqCtx)", condition = "#bean.cacheable && !T(com.agiletec.plugins.jacms.aps.system.services.content.widget.ContentListHelper).isUserFilterExecuted(#bean)")
@CacheableInfo(groups = "T(com.agiletec.plugins.jacms.aps.system.services.cache.CmsCacheWrapperManager).getContentListCacheGroupsCsv(#bean, #reqCtx)", expiresInMinute = 30)
public List<String> getContentsId(IContentListTagBean bean, RequestContext reqCtx) throws Throwable {
    this.releaseCache(bean, reqCtx);
    List<String> contentsId = null;
    try {
        contentsId = this.extractContentsId(bean, reqCtx);
        contentsId = this.executeFullTextSearch(bean, contentsId, reqCtx);
    } catch (Throwable t) {
        _logger.error("Error extracting contents id", t);
        throw new ApsSystemException("Error extracting contents id", t);
    }
    return contentsId;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Aggregations

CacheableInfo (org.entando.entando.aps.system.services.cache.CacheableInfo)8 CachePut (org.springframework.cache.annotation.CachePut)8 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)6 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)2 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 UserProfileRecord (org.entando.entando.aps.system.services.userprofile.model.UserProfileRecord)1 ActivityStreamComment (org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamComment)1 ActivityStreamLikeInfo (org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo)1