package com.x.bbs.assemble.control.jaxrs.subjectinfo; 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.jaxrs.WoId; import com.x.base.core.project.logger.Logger; import com.x.base.core.project.logger.LoggerFactory; import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectIdEmpty; import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectNotExists; import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectOperation; import com.x.bbs.assemble.control.jaxrs.subjectinfo.exception.ExceptionSubjectQueryById; import com.x.bbs.entity.BBSSubjectInfo; public class ActionSubjectLock extends BaseAction { private static Logger logger = LoggerFactory.getLogger(ActionSubjectLock.class); protected ActionResult execute(HttpServletRequest request, EffectivePerson effectivePerson, String id) throws Exception { ActionResult result = new ActionResult<>(); BBSSubjectInfo subjectInfo = null; Boolean check = true; if (check) { if (id == null || id.isEmpty()) { check = false; Exception exception = new ExceptionSubjectIdEmpty(); result.error(exception); } } if (check) { try { subjectInfo = subjectInfoServiceAdv.get(id); } catch (Exception e) { check = false; Exception exception = new ExceptionSubjectQueryById(e, id); result.error(exception); logger.error(e, effectivePerson, request, null); } } if (check) { if (subjectInfo == null) { check = false; Exception exception = new ExceptionSubjectNotExists(id); result.error(exception); } } if (check) { try { subjectInfo = subjectInfoServiceAdv.lock(id, true, effectivePerson.getDistinguishedName()); Wo wo = new Wo(); wo.setId( id ); result.setData( wo ); ApplicationCache.notify( BBSSubjectInfo.class ); } catch (Exception e) { check = false; Exception exception = new ExceptionSubjectOperation(e, "用户在锁定主题信息时发生异常!"); result.error(exception); logger.error(e, effectivePerson, request, null); } } return result; } public static class Wo extends WoId { } }