use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method recreate.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("recreate")
public String recreate(Integer id, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
SysTask entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
service.updateStatus(id, ScheduledTask.TASK_STATUS_READY);
scheduledTask.create(site, entity.getId(), entity.getCronExpression());
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class SysUserAdminController method save.
/**
* @param entity
* @param repassword
* @param roleIds
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("save")
public String save(SysUser entity, String repassword, Integer[] roleIds, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
entity.setName(StringUtils.trim(entity.getName()));
entity.setNickName(StringUtils.trim(entity.getNickName()));
entity.setPassword(StringUtils.trim(entity.getPassword()));
repassword = StringUtils.trim(repassword);
if (ControllerUtils.verifyNotEmpty("username", entity.getName(), model) || ControllerUtils.verifyNotEmpty("nickname", entity.getNickName(), model) || verifyNotUserName("username", entity.getName(), model) || verifyNotNickName("nickname", entity.getNickName(), model)) {
return TEMPLATE_ERROR;
}
if (entity.isSuperuserAccess()) {
entity.setRoles(arrayToCommaDelimitedString(roleIds));
} else {
roleIds = null;
entity.setRoles(null);
entity.setDeptId(null);
}
if (null != entity.getId()) {
SysUser oldEntity = service.getEntity(entity.getId());
if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
SysUser user = service.getEntity(entity.getId());
if ((!user.getName().equals(entity.getName()) && ControllerUtils.verifyHasExist("username", service.findByName(site.getId(), entity.getName()), model)) || (!user.getNickName().equals(entity.getNickName()) && ControllerUtils.verifyHasExist("nickname", service.findByNickName(site.getId(), entity.getNickName()), model))) {
return TEMPLATE_ERROR;
}
if (CommonUtils.notEmpty(entity.getPassword())) {
if (ControllerUtils.verifyNotEquals("repassword", entity.getPassword(), repassword, model)) {
return TEMPLATE_ERROR;
}
entity.setPassword(VerificationUtils.md5Encode(entity.getPassword()));
} else {
entity.setPassword(user.getPassword());
if (CommonUtils.empty(entity.getEmail()) || !entity.getEmail().equals(user.getEmail())) {
entity.setEmailChecked(false);
}
}
entity = service.update(entity.getId(), entity, ignoreProperties);
if (null != entity) {
roleUserService.dealRoleUsers(entity.getId(), roleIds);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.user", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
} else {
if (ControllerUtils.verifyNotEmpty("password", entity.getPassword(), model) || ControllerUtils.verifyNotEquals("repassword", entity.getPassword(), repassword, model) || ControllerUtils.verifyHasExist("username", service.findByName(site.getId(), entity.getName()), model)) {
return TEMPLATE_ERROR;
}
entity.setSiteId(site.getId());
entity.setPassword(VerificationUtils.md5Encode(entity.getPassword()));
service.save(entity);
if (CommonUtils.notEmpty(roleIds)) {
for (Integer roleId : roleIds) {
roleUserService.save(new SysRoleUser(new SysRoleUserId(roleId, entity.getId())));
}
}
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.user", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class TaskTemplateAdminController method save.
/**
* @param path
* @param content
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("save")
public String save(String path, String content, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (CommonUtils.notEmpty(path)) {
try {
String filePath = siteComponent.getTaskTemplateFilePath(site, path);
File templateFile = new File(filePath);
if (CommonUtils.notEmpty(templateFile)) {
fileComponent.updateFile(templateFile, content);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.task.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
} else {
fileComponent.createFile(templateFile, content);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.task.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
}
templateComponent.clearTaskTemplateCache();
} catch (IOException e) {
model.addAttribute(ERROR, e.getMessage());
log.error(e.getMessage(), e);
return TEMPLATE_ERROR;
}
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class TaskTemplateAdminController method delete.
/**
* @param path
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("delete")
public String delete(String path, HttpServletRequest request, HttpSession session, ModelMap model) {
if (CommonUtils.notEmpty(path)) {
SysSite site = getSite(request);
String filePath = siteComponent.getTaskTemplateFilePath(site, path);
if (ControllerUtils.verifyCustom("notExist.template", !fileComponent.deleteFile(filePath), model)) {
return TEMPLATE_ERROR;
}
templateComponent.clearTaskTemplateCache();
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.task.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.
the class ContentController method save.
/**
* 保存内容
*
* @param entity
* @param attribute
* @param contentParamters
* @param returnUrl
* @param request
* @param session
* @param response
* @param model
* @return view name
*/
@RequestMapping(value = "save", method = RequestMethod.POST)
public String save(CmsContent entity, CmsContentAttribute attribute, @ModelAttribute CmsContentParamters contentParamters, String returnUrl, HttpServletRequest request, HttpSession session, HttpServletResponse response, ModelMap model) {
SysSite site = getSite(request);
if (CommonUtils.empty(returnUrl)) {
returnUrl = site.getDynamicPath();
}
SysUser user = getUserFromSession(session);
CmsCategoryModel categoryModel = categoryModelService.getEntity(new CmsCategoryModelId(entity.getCategoryId(), entity.getModelId()));
if (ControllerUtils.verifyNotEmpty("categoryModel", categoryModel, model) || ControllerUtils.verifyCustom("contribute", null == user, model)) {
return REDIRECT + returnUrl;
}
CmsCategory category = categoryService.getEntity(entity.getCategoryId());
if (null != category && (site.getId() != category.getSiteId() || !category.isAllowContribute())) {
category = null;
}
CmsModel cmsModel = modelComponent.getMap(site).get(entity.getModelId());
if (ControllerUtils.verifyNotEmpty("category", category, model) || ControllerUtils.verifyNotEmpty("model", cmsModel, model)) {
return REDIRECT + returnUrl;
}
entity.setHasFiles(cmsModel.isHasFiles());
entity.setHasImages(cmsModel.isHasImages());
entity.setOnlyUrl(cmsModel.isOnlyUrl());
entity.setStatus(CmsContentService.STATUS_PEND);
if (null != entity.getId()) {
CmsContent oldEntity = service.getEntity(entity.getId());
if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
return REDIRECT + returnUrl;
}
entity = service.update(entity.getId(), entity, entity.isOnlyUrl() ? ignoreProperties : ignorePropertiesWithUrl);
if (null != entity.getId()) {
logOperateService.save(new LogOperate(site.getId(), user.getId(), LogLoginService.CHANNEL_WEB, "update.content", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
} else {
entity.setSiteId(site.getId());
entity.setUserId(user.getId());
service.save(entity);
if (CommonUtils.notEmpty(entity.getParentId())) {
service.updateChilds(entity.getParentId(), 1);
}
logOperateService.save(new LogOperate(site.getId(), user.getId(), LogLoginService.CHANNEL_WEB, "save.content", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
if (entity.isHasImages() || entity.isHasFiles()) {
contentFileService.update(entity.getId(), user.getId(), entity.isHasFiles() ? contentParamters.getFiles() : null, // 更新保存图集,附件
entity.isHasImages() ? contentParamters.getImages() : null);
}
if (null != attribute.getText()) {
attribute.setWordCount(HtmlUtils.removeHtmlTag(attribute.getText()).length());
}
List<ExtendField> modelExtendList = cmsModel.getExtendList();
Map<String, String> map = ExtendUtils.getExtentDataMap(contentParamters.getModelExtendDataList(), modelExtendList);
if (null != category && null != extendService.getEntity(category.getExtendId())) {
List<SysExtendField> categoryExtendList = extendFieldService.getList(category.getExtendId());
Map<String, String> categoryMap = ExtendUtils.getSysExtentDataMap(contentParamters.getCategoryExtendDataList(), categoryExtendList);
if (CommonUtils.notEmpty(map)) {
map.putAll(categoryMap);
} else {
map = categoryMap;
}
}
if (CommonUtils.notEmpty(map)) {
attribute.setData(ExtendUtils.getExtendString(map));
} else {
attribute.setData(null);
}
// 更新保存扩展字段,文本字段
attributeService.updateAttribute(entity.getId(), attribute);
return REDIRECT + returnUrl;
}
Aggregations