use of com.publiccms.views.pojo.entities.CmsPlaceMetadata 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.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.
the class PublishPlaceDirective method deal.
private Map<String, Boolean> deal(SysSite site, String path) {
path = path.replace("\\", SEPARATOR).replace("//", SEPARATOR);
Map<String, Boolean> map = new LinkedHashMap<>();
List<FileInfo> list = fileComponent.getFileList(siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + SEPARATOR + path));
Map<String, CmsPlaceMetadata> metadataMap = metadataComponent.getPlaceMetadataMap(siteComponent.getWebTemplateFilePath(site, path));
for (FileInfo fileInfo : list) {
String filePath = path + fileInfo.getFileName();
if (fileInfo.isDirectory()) {
map.putAll(deal(site, filePath + SEPARATOR));
} else {
try {
CmsPlaceMetadata metadata = metadataMap.get(fileInfo.getFileName());
if (null == metadata) {
metadata = new CmsPlaceMetadata();
}
templateComponent.staticPlace(site, filePath, metadata);
map.put(filePath, true);
} catch (IOException | TemplateException e) {
map.put(filePath, false);
}
}
}
return map;
}
use of com.publiccms.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.
the class MetadataComponent method updatePlaceMetadata.
/**
* 更新推荐位元数据
*
* @param filePath
* @param metadata
* @return whether the update is successful
*/
public boolean updatePlaceMetadata(String filePath, CmsPlaceMetadata metadata) {
File file = new File(filePath);
String dirPath = file.getParent();
Map<String, CmsPlaceMetadata> metadataMap = getPlaceMetadataMap(dirPath);
metadataMap.put(file.getName(), metadata);
try {
savePlaceMetadata(dirPath, metadataMap);
return true;
} catch (IOException e) {
return false;
}
}
use of com.publiccms.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.
the class MetadataComponent method getPlaceMetadata.
/**
* 获取推荐位元数据
*
* @param filePath
* @return place metadata
*/
public CmsPlaceMetadata getPlaceMetadata(String filePath) {
File file = new File(filePath);
CmsPlaceMetadata pageMetadata = getPlaceMetadataMap(file.getParent()).get(file.getName());
if (null != pageMetadata) {
return pageMetadata;
}
return new CmsPlaceMetadata();
}
use of com.publiccms.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.
the class MetadataComponent method deletePlaceMetadata.
/**
* 删除推荐位元数据
*
* @param filePath
* @return whether the delete is successful
*/
public boolean deletePlaceMetadata(String filePath) {
File file = new File(filePath);
String dirPath = file.getParent();
Map<String, CmsPlaceMetadata> metadataMap = getPlaceMetadataMap(dirPath);
metadataMap.remove(file.getName());
try {
savePlaceMetadata(dirPath, metadataMap);
return true;
} catch (IOException e) {
return false;
}
}
Aggregations