Search in sources :

Example 96 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class CmsTemplateAdminController method deletePlace.

/**
 * @param path
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("deletePlace")
public String deletePlace(String path, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (CommonUtils.notEmpty(path)) {
        SysSite site = getSite(request);
        String filePath = siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + path);
        if (ControllerUtils.verifyCustom("notExist.template", !fileComponent.deleteFile(filePath), model)) {
            return TEMPLATE_ERROR;
        }
        metadataComponent.deletePlaceMetadata(filePath);
        cmsPlaceService.delete(site.getId(), path);
        templateComponent.clearTemplateCache();
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.web.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
    }
    return TEMPLATE_DONE;
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 97 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class CmsTemplateAdminController 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.getWebTemplateFilePath(site, path);
            File templateFile = new File(filePath);
            CmsPageMetadata metadata = metadataComponent.getTemplateMetadata(filePath);
            if (CommonUtils.notEmpty(templateFile)) {
                fileComponent.updateFile(templateFile, content);
                if (CommonUtils.notEmpty(metadata.getCacheTime()) && metadata.getCacheTime() > 0) {
                    templateCacheComponent.deleteCachedFile(SiteComponent.getFullFileName(site, path));
                }
                logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.web.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.web.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
            }
            templateComponent.clearTemplateCache();
            cacheComponent.clearViewCache();
            if (CommonUtils.notEmpty(metadata.getPublishPath())) {
                publish(site, path);
            }
        } catch (IOException | TemplateException e) {
            model.addAttribute(ERROR, e.getMessage());
            log.error(e.getMessage(), e);
            return TEMPLATE_ERROR;
        }
    }
    return TEMPLATE_DONE;
}
Also used : CmsPageMetadata(com.publiccms.views.pojo.entities.CmsPageMetadata) LogOperate(com.publiccms.entities.log.LogOperate) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 98 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class CmsTemplateAdminController 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.getWebTemplateFilePath(site, path);
        CmsPageMetadata metadata = metadataComponent.getTemplateMetadata(filePath);
        if (CommonUtils.notEmpty(metadata.getCacheTime()) && metadata.getCacheTime() > 0) {
            templateCacheComponent.deleteCachedFile(SiteComponent.getFullFileName(site, path));
        }
        if (ControllerUtils.verifyCustom("notExist.template", !fileComponent.deleteFile(filePath), model)) {
            return TEMPLATE_ERROR;
        }
        metadataComponent.deleteTemplateMetadata(filePath);
        sysDeptPageService.delete(null, path);
        templateComponent.clearTemplateCache();
        cacheComponent.clearViewCache();
        logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.web.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
    }
    return TEMPLATE_DONE;
}
Also used : CmsPageMetadata(com.publiccms.views.pojo.entities.CmsPageMetadata) LogOperate(com.publiccms.entities.log.LogOperate) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 99 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class CmsTemplateAdminController method publishPlace.

/**
 * @param path
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("publishPlace")
public String publishPlace(String path, HttpServletRequest request, HttpSession session, ModelMap model) {
    try {
        SysSite site = getSite(request);
        if (CommonUtils.notEmpty(path) && site.isUseSsi()) {
            CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + path));
            templateComponent.staticPlace(site, path, metadata);
            logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "static", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
        }
        return TEMPLATE_DONE;
    } catch (IOException | TemplateException e) {
        model.addAttribute(ERROR, e.getMessage());
        log.error(e.getMessage(), e);
        return TEMPLATE_ERROR;
    }
}
Also used : LogOperate(com.publiccms.entities.log.LogOperate) TemplateException(freemarker.template.TemplateException) CmsPlaceMetadata(com.publiccms.views.pojo.entities.CmsPlaceMetadata) IOException(java.io.IOException) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 100 with LogOperate

use of com.publiccms.entities.log.LogOperate in project PublicCMS-preview by sanluan.

the class CmsTemplateAdminController method saveMetadata.

/**
 * @param path
 * @param metadata
 * @param content
 * @param request
 * @param session
 * @param model
 * @return view name
 */
@RequestMapping("saveMetaData")
public String saveMetadata(String path, @ModelAttribute CmsPageMetadata metadata, String content, HttpServletRequest request, HttpSession session, ModelMap model) {
    if (CommonUtils.notEmpty(path)) {
        if (path.endsWith(SEPARATOR) || CommonUtils.empty(path)) {
            path += CommonConstants.getDefaultPage();
        }
        SysSite site = getSite(request);
        String filePath = siteComponent.getWebTemplateFilePath(site, path);
        try {
            File templateFile = new File(filePath);
            if (CommonUtils.empty(templateFile)) {
                fileComponent.createFile(templateFile, content);
            }
            CmsPageMetadata oldmetadata = metadataComponent.getTemplateMetadata(filePath);
            metadata.setExtendDataList(oldmetadata.getExtendDataList());
            metadataComponent.updateTemplateMetadata(filePath, metadata);
            templateComponent.clearTemplateCache();
            cacheComponent.clearViewCache();
            if (CommonUtils.notEmpty(metadata.getPublishPath())) {
                publish(site, path);
            }
            logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.template.meta", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
        } catch (IOException | TemplateException e) {
            model.addAttribute(ERROR, e.getMessage());
            log.error(e.getMessage(), e);
            return TEMPLATE_ERROR;
        }
    }
    return TEMPLATE_DONE;
}
Also used : CmsPageMetadata(com.publiccms.views.pojo.entities.CmsPageMetadata) LogOperate(com.publiccms.entities.log.LogOperate) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) SysSite(com.publiccms.entities.sys.SysSite) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LogOperate (com.publiccms.entities.log.LogOperate)117 SysSite (com.publiccms.entities.sys.SysSite)117 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)115 SysUser (com.publiccms.entities.sys.SysUser)15 IOException (java.io.IOException)13 CmsContent (com.publiccms.entities.cms.CmsContent)9 File (java.io.File)9 MultipartFile (org.springframework.web.multipart.MultipartFile)8 CmsCategory (com.publiccms.entities.cms.CmsCategory)7 TemplateException (freemarker.template.TemplateException)7 SysDept (com.publiccms.entities.sys.SysDept)6 SysTask (com.publiccms.entities.sys.SysTask)6 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)5 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)5 CmsPlace (com.publiccms.entities.cms.CmsPlace)4 CmsWord (com.publiccms.entities.cms.CmsWord)4 SysDomain (com.publiccms.entities.sys.SysDomain)4 SysRoleUser (com.publiccms.entities.sys.SysRoleUser)4 CmsModel (com.publiccms.views.pojo.entities.CmsModel)4 CmsCategoryType (com.publiccms.entities.cms.CmsCategoryType)3