Search in sources :

Example 51 with SysSite

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;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysTask(com.publiccms.entities.sys.SysTask) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 52 with SysSite

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;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysTask(com.publiccms.entities.sys.SysTask) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 53 with SysSite

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;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysTask(com.publiccms.entities.sys.SysTask) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 54 with SysSite

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;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysUser(com.publiccms.entities.sys.SysUser) SysRoleUserId(com.publiccms.entities.sys.SysRoleUserId) SysSite(com.publiccms.entities.sys.SysSite) SysRoleUser(com.publiccms.entities.sys.SysRoleUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 55 with SysSite

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;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) IOException(java.io.IOException) File(java.io.File) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SysSite (com.publiccms.entities.sys.SysSite)175 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)135 LogOperate (com.publiccms.entities.log.LogOperate)117 IOException (java.io.IOException)33 SysUser (com.publiccms.entities.sys.SysUser)21 LinkedHashMap (java.util.LinkedHashMap)19 TemplateException (freemarker.template.TemplateException)15 File (java.io.File)14 CmsContent (com.publiccms.entities.cms.CmsContent)12 CmsCategory (com.publiccms.entities.cms.CmsCategory)11 MultipartFile (org.springframework.web.multipart.MultipartFile)10 SysTask (com.publiccms.entities.sys.SysTask)9 HashMap (java.util.HashMap)8 LogUpload (com.publiccms.entities.log.LogUpload)7 SysDept (com.publiccms.entities.sys.SysDept)7 SysUserToken (com.publiccms.entities.sys.SysUserToken)7 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)7 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)6 CmsPlace (com.publiccms.entities.cms.CmsPlace)5 SysDomain (com.publiccms.entities.sys.SysDomain)5