use of com.publiccms.views.pojo.entities.CmsPageMetadata 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;
}
use of com.publiccms.views.pojo.entities.CmsPageMetadata 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;
}
Aggregations