use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsTagAdminController method save.
/**
* @param entity
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("save")
public String save(CmsTag entity, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (null != entity.getId()) {
CmsTag oldEntity = service.getEntity(entity.getId());
if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
entity = service.update(entity.getId(), entity, ignoreProperties);
if (null != entity) {
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.tag", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
} else {
entity.setSiteId(site.getId());
service.save(entity);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.tag", 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 CmsTagTypeAdminController 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);
CmsTagType entity = service.getEntity(id);
if (null != entity) {
if (ControllerUtils.verifyNotEquals("siteId", site.getId(), entity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
service.delete(id);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "delete.tagType", RequestUtils.getIpAddress(request), CommonUtils.getDate(), id.toString()));
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsTemplateAdminController method savePlaceMetaData.
/**
* @param path
* @param metadata
* @param content
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("savePlaceMetaData")
public String savePlaceMetaData(String path, @ModelAttribute CmsPlaceMetadata metadata, String content, HttpServletRequest request, HttpSession session, ModelMap model) {
if (CommonUtils.notEmpty(path)) {
SysSite site = getSite(request);
String filePath = siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + path);
try {
File templateFile = new File(filePath);
if (CommonUtils.empty(templateFile)) {
fileComponent.createFile(templateFile, content);
}
metadataComponent.updatePlaceMetadata(filePath, metadata);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.template.meta", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
templateComponent.clearTemplateCache();
if (site.isUseSsi()) {
templateComponent.staticPlace(site, path, metadata);
}
} catch (IOException | TemplateException e) {
model.addAttribute(ERROR, e.getMessage());
log.error(e.getMessage(), e);
return TEMPLATE_ERROR;
}
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsTemplateAdminController method savePlace.
/**
* @param path
* @param content
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("savePlace")
public String savePlace(String path, String content, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (CommonUtils.notEmpty(path)) {
try {
String filePath = siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + 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.place.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.place.template", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
}
templateComponent.clearTemplateCache();
if (site.isUseSsi()) {
CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(filePath);
templateComponent.staticPlace(site, path, metadata);
}
} catch (IOException | TemplateException e) {
model.addAttribute(ERROR, e.getMessage());
log.error(e.getMessage(), e);
return TEMPLATE_ERROR;
}
}
return TEMPLATE_DONE;
}
use of com.publiccms.entities.sys.SysSite in project PublicCMS-preview by sanluan.
the class CmsVoteAdminController method save.
/**
* @param entity
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("save")
public String save(CmsVote entity, HttpServletRequest request, HttpSession session, ModelMap model) {
SysSite site = getSite(request);
if (null != entity.getId()) {
CmsVote oldEntity = service.getEntity(entity.getId());
if (null == oldEntity || ControllerUtils.verifyNotEquals("siteId", site.getId(), oldEntity.getSiteId(), model)) {
return TEMPLATE_ERROR;
}
entity = service.update(entity.getId(), entity, ignoreProperties);
if (null != entity) {
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "update.vote", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
} else {
entity.setSiteId(site.getId());
service.save(entity);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "save.vote", RequestUtils.getIpAddress(request), CommonUtils.getDate(), JsonUtils.getString(entity)));
}
return TEMPLATE_DONE;
}
Aggregations