<commit_before>/*
 * Copyright 2009 The Kuali Foundation
 * 
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl2.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.kfs.sys.batch.service.impl;

import org.kuali.kfs.sys.batch.service.CacheService;
import org.kuali.kfs.sys.service.NonTransactional;
import org.kuali.rice.core.framework.parameter.ParameterService;
import org.kuali.rice.kim.api.common.template.Template;
import org.kuali.rice.kim.api.responsibility.Responsibility;
import org.kuali.rice.kim.api.role.RoleService;
import org.kuali.rice.kim.api.services.IdentityManagementService;
import org.kuali.rice.location.framework.campus.CampusValuesFinder;
import org.springframework.cache.annotation.CacheEvict;

/**
 * @see org.kuali.kfs.sys.batch.service.CacheService
 */
@NonTransactional
public class CacheServiceImpl implements CacheService {
    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CacheServiceImpl.class);

    private RoleService roleManagementService;
    private IdentityManagementService identityManagementService;
    private ParameterService parameterService;

    /**
     * @see org.kuali.kfs.sys.batch.service.CacheService#clearSystemCache()
     */
    public void clearSystemCache() {
        clearMethodCache();
        clearKIMCache();
        clearParameterCache();
        new CampusValuesFinder().clearInternalCache();
    }

    /**
     * Clears out service methods cache by calling adminstrators flushAll
     */
    @CacheEvict(allEntries=true, value = { "" })
    protected void clearMethodCache() {
        LOG.info("clearing spring method cache ...");
    }

    /**
     * Clears out KIM cache by calling flush methods on role and identity services
     */
    @CacheEvict(value={Responsibility.Cache.NAME, Template.Cache.NAME + "{Responsibility}"}, allEntries = true)
    protected void clearKIMCache() {
        LOG.info("clearing KIM role & identity service cache ...");

        roleManagementService.flushRoleCaches();
        identityManagementService.flushAllCaches();
        //RICE20 need to find out how to flush the Responsibility Cache in rice; can we flush this on our own?? 
        //       added @CacheEvict to function (ref - org.kuali.rice.kim.api.responsibility.ResponsibilityService) 
        //SpringContext.getBean(RiceCacheAdministrator.class).flushGroup("ResponsibilityImpl");
    }

    /**
     * Clears out parameter cache by calling flush method on parameter service
     */
    protected void clearParameterCache() {
        LOG.info("clearing parameter cache ...");

        parameterService.clearCache();
    }
    
    /**
     * Gets the roleManagementService attribute.
     * 
     * @return Returns the roleManagementService.
     */
    protected RoleService getRoleService() {
        return roleManagementService;<commit_msg>KFSMI-7110: Fixing - commented flush calls..<commit_after>/*
 * Copyright 2009 The Kuali Foundation
 * 
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl2.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.kfs.sys.batch.service.impl;

import org.kuali.kfs.sys.batch.service.CacheService;
import org.kuali.kfs.sys.service.NonTransactional;
import org.kuali.rice.core.framework.parameter.ParameterService;
import org.kuali.rice.kim.api.common.template.Template;
import org.kuali.rice.kim.api.responsibility.Responsibility;
import org.kuali.rice.kim.api.role.RoleService;
import org.kuali.rice.kim.api.services.IdentityManagementService;
import org.kuali.rice.location.framework.campus.CampusValuesFinder;
import org.springframework.cache.annotation.CacheEvict;

/**
 * @see org.kuali.kfs.sys.batch.service.CacheService
 */
@NonTransactional
public class CacheServiceImpl implements CacheService {
    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(CacheServiceImpl.class);

    private RoleService roleManagementService;
    private IdentityManagementService identityManagementService;
    private ParameterService parameterService;

    /**
     * @see org.kuali.kfs.sys.batch.service.CacheService#clearSystemCache()
     */
    public void clearSystemCache() {
        clearMethodCache();
        clearKIMCache();
        clearParameterCache();
        new CampusValuesFinder().clearInternalCache();
    }

    /**
     * Clears out service methods cache by calling adminstrators flushAll
     */
    @CacheEvict(allEntries=true, value = { "" })
    protected void clearMethodCache() {
        LOG.info("clearing spring method cache ...");
    }

    /**
     * Clears out KIM cache by calling flush methods on role and identity services
     */
    @CacheEvict(value={Responsibility.Cache.NAME, Template.Cache.NAME + "{Responsibility}"}, allEntries = true)
    protected void clearKIMCache() {
        LOG.info("clearing KIM role & identity service cache ...");

      //RICE20: clearCache method does not exist in ParameterService..        
       // roleManagementService.flushRoleCaches();
        identityManagementService.flushAllCaches();
        //RICE20 need to find out how to flush the Responsibility Cache in rice; can we flush this on our own?? 
        //       added @CacheEvict to function (ref - org.kuali.rice.kim.api.responsibility.ResponsibilityService) 
        //SpringContext.getBean(RiceCacheAdministrator.class).flushGroup("ResponsibilityImpl");
    }

    /**
     * Clears out parameter cache by calling flush method on parameter service
     */
    protected void clearParameterCache() {
        LOG.info("clearing parameter cache ...");
        //RICE20: clearCache method does not exist in ParameterService..
     //   parameterService.clearCache();
    }
    
    /**
     * Gets the roleManagementService attribute.
     * 
     * @return Returns the roleManagementService.
     */
    protected RoleService getRoleService() {
        return roleManagementService;
{'fraction_non_alphanumeric': 0.09564836448598131, 'fraction_numerical': 0.004380841121495327, 'mean_word_length': 3.4911475409836066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '679246', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1824, 'n_words': 503}