Search in sources :

Example 11 with CmsPlaceMetadata

use of com.publiccms.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.

the class IncludePlaceDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    String path = handler.getString("path");
    String[] paths = handler.getStringArray("paths");
    if (CommonUtils.notEmpty(path)) {
        SysSite site = getSite(handler);
        CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + path));
        if (site.isUseSsi()) {
            handler.print(new StringBuilder("<!--#include virtual=\"/").append(TemplateComponent.INCLUDE_DIRECTORY).append(path).append("\"-->").toString());
        } else {
            templateComponent.printPlace(handler.getWriter(), site, path, metadata);
        }
    } else if (CommonUtils.notEmpty(paths)) {
        SysSite site = getSite(handler);
        Map<String, String> map = new ConcurrentHashMap<>();
        if (site.isUseSsi()) {
            for (String p : paths) {
                map.put(p, new StringBuilder("<!--#include virtual=\"/").append(TemplateComponent.INCLUDE_DIRECTORY).append(p).append("\"-->").toString());
            }
            handler.put("map", map).render();
        } else {
            Set<String> set = new HashSet<>();
            for (String p : paths) {
                set.add(p);
            }
            for (String p : set) {
                pool.execute(new RanderTask(p, set.size(), map, getSite(handler), handler));
            }
            handler.setRenderd();
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CmsPlaceMetadata(com.publiccms.views.pojo.entities.CmsPlaceMetadata) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) SysSite(com.publiccms.entities.sys.SysSite)

Example 12 with CmsPlaceMetadata

use of com.publiccms.views.pojo.entities.CmsPlaceMetadata 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)

Aggregations

CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)12 SysSite (com.publiccms.entities.sys.SysSite)7 IOException (java.io.IOException)7 File (java.io.File)6 LogOperate (com.publiccms.entities.log.LogOperate)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 TemplateException (freemarker.template.TemplateException)4 CmsPlace (com.publiccms.entities.cms.CmsPlace)3 SysUser (com.publiccms.entities.sys.SysUser)3 LinkedHashMap (java.util.LinkedHashMap)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 FileInfo (com.publiccms.logic.component.site.FileComponent.FileInfo)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1