Search in sources :

Example 1 with FileInfo

use of com.publiccms.logic.component.site.FileComponent.FileInfo in project PublicCMS-preview by sanluan.

the class PublishPageDirective method deal.

private Map<String, Boolean> deal(SysSite site, String path) {
    path = path.replace("\\", SEPARATOR).replace("//", SEPARATOR);
    Map<String, Boolean> map = new LinkedHashMap<>();
    Map<String, CmsPageMetadata> metadataMap = metadataComponent.getTemplateMetadataMap(siteComponent.getWebTemplateFilePath(site, path));
    List<FileInfo> list = fileComponent.getFileList(siteComponent.getWebTemplateFilePath(site, path));
    for (FileInfo fileInfo : list) {
        String filePath = path + fileInfo.getFileName();
        if (fileInfo.isDirectory()) {
            map.putAll(deal(site, filePath + SEPARATOR));
        } else {
            CmsPageMetadata metadata = metadataMap.get(fileInfo.getFileName());
            if (null != metadata && CommonUtils.notEmpty(metadata.getPublishPath())) {
                try {
                    templateComponent.createStaticFile(site, SiteComponent.getFullFileName(site, filePath), metadata.getPublishPath(), null, metadata, null);
                    map.put(filePath, true);
                } catch (IOException | TemplateException e) {
                    map.put(filePath, false);
                }
            }
        }
    }
    return map;
}
Also used : CmsPageMetadata(com.publiccms.views.pojo.entities.CmsPageMetadata) FileInfo(com.publiccms.logic.component.site.FileComponent.FileInfo) TemplateException(freemarker.template.TemplateException) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with FileInfo

use of com.publiccms.logic.component.site.FileComponent.FileInfo 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;
}
Also used : FileInfo(com.publiccms.logic.component.site.FileComponent.FileInfo) TemplateException(freemarker.template.TemplateException) CmsPlaceMetadata(com.publiccms.views.pojo.entities.CmsPlaceMetadata) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

FileInfo (com.publiccms.logic.component.site.FileComponent.FileInfo)2 TemplateException (freemarker.template.TemplateException)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 CmsPageMetadata (com.publiccms.views.pojo.entities.CmsPageMetadata)1 CmsPlaceMetadata (com.publiccms.views.pojo.entities.CmsPlaceMetadata)1