Search in sources :

Example 11 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.

the class SocialActivityStreamManager method addActionCommentRecord.

@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamCommentRecords_id_'.concat(#streamId)")
public void addActionCommentRecord(String username, String commentText, int streamId) throws ApsSystemException {
    try {
        Integer key = null;
        ActionLogRecord record = null;
        do {
            key = this.getKeyGeneratorManager().getUniqueKeyCurrentValue();
            record = this.getActionLogManager().getActionRecord(key);
        } while (null != record);
        this.getSocialActivityStreamDAO().addActionCommentRecord(key, streamId, username, commentText);
        this.getActionLogManager().updateRecordDate(streamId);
    } catch (Throwable t) {
        _logger.error("Error adding a comment record to stream with id:{}", streamId, t);
        throw new ApsSystemException("Error adding a comment record", t);
    }
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 12 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.

the class SocialActivityStreamManager method deleteActionCommentRecord.

@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamCommentRecords_id_'.concat(#streamId)")
public void deleteActionCommentRecord(int id, int streamId) throws ApsSystemException {
    try {
        this.getSocialActivityStreamDAO().deleteActionCommentRecord(id);
        this.getActionLogManager().updateRecordDate(streamId);
    } catch (Throwable t) {
        _logger.error("Error deleting comment with id {} from stream with id {}", id, streamId, t);
        throw new ApsSystemException("Error deleting comment", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 13 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.

the class GuiFragmentManager method deleteGuiFragment.

@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'GuiFragment_'.concat(#code)")
// TODO improve group handling
@CacheInfoEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, groups = "'GuiFragment_uniqueByWidgetTypeGroup,GuiFragment_codesByWidgetTypeGroup'")
public void deleteGuiFragment(String code) throws ApsSystemException {
    try {
        GuiFragment guiFragment = this.getGuiFragment(code);
        this.getGuiFragmentDAO().removeGuiFragment(code);
        this.notifyGuiFragmentChangedEvent(guiFragment, GuiFragmentChangedEvent.REMOVE_OPERATION_CODE);
    } catch (Throwable t) {
        logger.error("Error deleting GuiFragment with code {}", code, t);
        throw new ApsSystemException("Error deleting GuiFragment with code:" + code, t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict) CacheInfoEvict(org.entando.entando.aps.system.services.cache.CacheInfoEvict)

Example 14 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project openmrs-core by openmrs.

the class AdministrationServiceImpl method saveGlobalProperty.

/**
 * @see org.openmrs.api.AdministrationService#saveGlobalProperty(org.openmrs.GlobalProperty)
 */
@Override
@CacheEvict(value = "userSearchLocales", allEntries = true)
public GlobalProperty saveGlobalProperty(GlobalProperty gp) throws APIException {
    // only try to save it if the global property has a key
    if (gp.getProperty() != null && gp.getProperty().length() > 0) {
        if (gp.getProperty().equals(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST)) {
            if (gp.getPropertyValue() != null) {
                List<Locale> localeList = new ArrayList<>();
                for (String localeString : gp.getPropertyValue().split(",")) {
                    localeList.add(LocaleUtility.fromSpecification(localeString.trim()));
                }
                if (!localeList.contains(LocaleUtility.getDefaultLocale())) {
                    gp.setPropertyValue(StringUtils.join(getAllowedLocales(), ", "));
                    throw new APIException(Context.getMessageSourceService().getMessage("general.locale.localeListNotIncludingDefaultLocale", new Object[] { LocaleUtility.getDefaultLocale() }, null));
                }
            }
        } else if (gp.getProperty().equals(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE) && gp.getPropertyValue() != null) {
            List<Locale> localeList = getAllowedLocales();
            if (!localeList.contains(LocaleUtility.fromSpecification(gp.getPropertyValue().trim()))) {
                String value = gp.getPropertyValue();
                gp.setPropertyValue(LocaleUtility.getDefaultLocale().toString());
                throw new APIException((Context.getMessageSourceService().getMessage("general.locale.defaultNotInAllowedLocalesList", new Object[] { value }, null)));
            }
        }
        CustomDatatypeUtil.saveIfDirty(gp);
        dao.saveGlobalProperty(gp);
        notifyGlobalPropertyChange(gp);
        return gp;
    }
    return gp;
}
Also used : Locale(java.util.Locale) APIException(org.openmrs.api.APIException) ArrayList(java.util.ArrayList) OpenmrsObject(org.openmrs.OpenmrsObject) ArrayList(java.util.ArrayList) List(java.util.List) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 15 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project new-cloud by xie-summer.

the class UserController method removeToken.

/**
 * 清除Redis中 accesstoken refreshtoken
 *
 * @param accesstoken  accesstoken
 * @param refreshToken refreshToken
 * @return true/false
 */
@PostMapping("/removeToken")
@CacheEvict(value = SecurityConstants.TOKEN_USER_DETAIL, key = "#accesstoken")
public R<Boolean> removeToken(String accesstoken, String refreshToken) {
    RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
    tokenStore.removeRefreshToken(refreshToken);
    tokenStore.removeAccessToken(accesstoken);
    return new R<>(Boolean.TRUE);
}
Also used : R(com.auth.common.util.R) RedisTokenStore(org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore) PostMapping(org.springframework.web.bind.annotation.PostMapping) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Aggregations

CacheEvict (org.springframework.cache.annotation.CacheEvict)53 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)14 Transactional (org.springframework.transaction.annotation.Transactional)13 Date (java.util.Date)8 ArrayList (java.util.ArrayList)6 CacheInfoEvict (org.entando.entando.aps.system.services.cache.CacheInfoEvict)5 QUser (com.github.liuweijw.business.admin.domain.QUser)3 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)3 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)3 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)3 QMenu (com.github.liuweijw.business.admin.domain.QMenu)2 QRole (com.github.liuweijw.business.admin.domain.QRole)2 QUserRole (com.github.liuweijw.business.admin.domain.QUserRole)2 Role (com.github.liuweijw.business.admin.domain.Role)2 User (com.github.liuweijw.business.admin.domain.User)2 UserRole (com.github.liuweijw.business.admin.domain.UserRole)2 AuthUser (com.github.liuweijw.system.api.model.AuthUser)2 RoleMenuDO (io.github.tesla.ops.system.domain.RoleMenuDO)2 Connection (java.sql.Connection)2 HashMap (java.util.HashMap)2