package com.gaowj.system.back;




import java.util.List;
import java.util.Map;







import com.gaowj.business.SystemCacheBusiness;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils;



public class CacheAction extends BasicAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3824623016480456824L;	


	public String cache() throws BusinessException {
		SystemCacheBusiness systemCacheBusiness = BusinessManager.getBusiness(SystemCacheBusiness.class);
		List<Map<String, Object>> listGrid = systemCacheBusiness.listCache();
		setListdata(listGrid);
	    return "cache";
	}
	
	public String cacheKeys() throws BusinessException {
		String cacheName = RequestUtils.getString(request, "CACHENAME");
		SystemCacheBusiness systemCacheBusiness = BusinessManager.getBusiness(SystemCacheBusiness.class);
		List<Map<String, Object>> listGrid = systemCacheBusiness.listCacheKey(cacheName);
		setListdata(listGrid);
	    return "cacheKeys";
	}
	
	public String shutdown()throws BusinessException {
		String cacheName = RequestUtils.getString(request, "CACHENAME");
		SystemCacheBusiness systemCacheBusiness = BusinessManager.getBusiness(SystemCacheBusiness.class);
		systemCacheBusiness.shutdownCache(cacheName);
		
		List<Map<String, Object>> listGrid = systemCacheBusiness.listCache();
		setListdata(listGrid);
		return "shutdown";
	}
	
	public String create()throws BusinessException {
		String cacheName = RequestUtils.getString(request, "CACHENAME");
		SystemCacheBusiness systemCacheBusiness = BusinessManager.getBusiness(SystemCacheBusiness.class);
		systemCacheBusiness.createCache(cacheName);
		
		List<Map<String, Object>> listGrid = systemCacheBusiness.listCache();
		setListdata(listGrid);
		return "create";
	}
	
	public String deleteKey()throws BusinessException {
		String cacheName = RequestUtils.getString(request, "CACHENAME");
		String keyid = RequestUtils.getString(request, "KEYID");
		SystemCacheBusiness systemCacheBusiness = BusinessManager.getBusiness(SystemCacheBusiness.class);
		systemCacheBusiness.removeCache(cacheName, keyid);
		
		List<Map<String, Object>> listGrid = systemCacheBusiness.listCacheKey(cacheName);
		setListdata(listGrid);
		return "deleteKey";
	}
}
