use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method delete.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("delete")
public String delete(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.delete(id);
scheduledTask.delete(id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class SysTaskAdminController method runOnce.
/**
* @param id
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("runOnce")
public String runOnce(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;
}
scheduledTask.runOnce(site, id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "runOnce.task", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite 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.sys.SysSite 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.sys.SysSite 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;
}
Aggregations