ActionListWhatICanViewArticle.java 2.6 KB
Newer Older
R
roo00 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
package com.x.cms.assemble.control.jaxrs.appinfo;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.tools.SortTools;

import net.sf.ehcache.Element;

R
roo00 已提交
18
public class ActionListWhatICanViewArticle extends BaseAction {
R
roo00 已提交
19

R
roo00 已提交
20
	private static  Logger logger = LoggerFactory.getLogger(ActionListWhatICanViewArticle.class);
R
roo00 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

	@SuppressWarnings("unchecked")
	protected ActionResult<List<Wo>> execute(HttpServletRequest request, EffectivePerson effectivePerson)
			throws Exception {
		ActionResult<List<Wo>> result = new ActionResult<>();
		List<Wo> wos = new ArrayList<>();
		List<Wo> wos_out = new ArrayList<>();
		Boolean isXAdmin = false;
		Boolean check = true;
		Boolean isAnonymous = effectivePerson.isAnonymous();
		String personName = effectivePerson.getDistinguishedName();
		
		if( "xadmin".equalsIgnoreCase( effectivePerson.getName() ) ) {
			personName = "xadmin";
		}
		
		try {
R
update  
roo00 已提交
38
			isXAdmin = userManagerService.isManager( effectivePerson );
R
roo00 已提交
39 40 41 42 43 44 45
		} catch (Exception e) {
			check = false;
			Exception exception = new ExceptionAppInfoProcess(e, "系统在检查用户是否是平台管理员时发生异常。Name:" + personName);
			result.error(exception);
			logger.error(e, effectivePerson, request, null);
		}
		
R
roo00 已提交
46
		String cacheKey = ApplicationCache.concreteCacheKey(personName,  "all", "Article", isXAdmin);
R
roo00 已提交
47 48 49 50 51 52 53
		Element element = cache.get(cacheKey);

		if ((null != element) && (null != element.getObjectValue())) {
			wos = (List<Wo>) element.getObjectValue();
			result.setData(wos);
		} else {
			if (check) {
R
update  
roo00 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66
				try {
					wos_out = listViewAbleAppInfoByPermission( personName, isAnonymous, null,  "all", "信息", isXAdmin, 1000 );
				} catch (Exception e) {
					check = false;
					Exception exception = new ExceptionAppInfoProcess(e, "系统在根据用户权限查询所有可见的分类信息时发生异常。Name:" + personName);
					result.error(exception);
					logger.error(e, effectivePerson, request, null);
				}
			}
			if( ListTools.isNotEmpty( wos_out )){
				for( Wo wo : wos_out ) {
					if( ListTools.isNotEmpty( wo.getWrapOutCategoryList() )) {
						wos.add( wo );
R
roo00 已提交
67 68
					}
				}
R
update  
roo00 已提交
69 70 71 72
				//按appInfoSeq列的值, 排个序
				SortTools.asc( wos, "appInfoSeq");
				cache.put(new Element( cacheKey, wos ));
				result.setData( wos );
R
roo00 已提交
73 74 75 76 77
			}
		}
		return result;
	}
}