An error occurred while processing the template.
The following has evaluated to null or missing:
==> entries?first.getCategoryIds()?first  [in template "20097#20125#35643" at line 225, column 34]

----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: #assign entriesCategoryId = entries?f...  [in template "20097#20125#35643" in function "hasNestedCategories" at line 225, column 5]
----
1<#-- Шаблон публикатора "Библиотека документов" --> 
2 
3<#assign assetCategoryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetCategoryLocalService") /> 
4<#assign dLAppLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLAppLocalService") /> 
5<#assign classNameService = serviceLocator.findService("com.liferay.portal.kernel.service.ClassNameLocalService") /> 
6<#assign dlUtil = staticUtil["com.liferay.document.library.kernel.util.DLUtil"]> 
7 
8<div class="knd_document_list"> 
9    <#if entries?has_content> 
10        <#assign 
11            hasNestedCategories = hasNestedCategories(entries) 
12            parentCategoryId = 0 
13             
14            <#-- Страница категории первого уровня --> 
15            firstLevelCategoryPage = false 
16        /> 
17        <#if renderRequest.getParameter("categoryId")??> 
18            <#assign 
19                categoryId = renderRequest.getParameter("categoryId")?number?long 
20                category = assetCategoryLocalService.getCategory(categoryId) 
21            /> 
22 
23            <#if category.getParentCategoryId() != 0> 
24                <#assign 
25                    parentCategory = assetCategoryLocalService.getCategory(category.getParentCategoryId()) 
26                    parentCategoryId = parentCategory.getCategoryId() 
27                /> 
28                <h2>${parentCategory.getName()}</h2> 
29                <h3>${category.getName()}</h3> 
30            <#else> 
31                <h2>${category.getName()}</h2> 
32 
33                <#assign firstLevelCategoryPage = true /> 
34                 
35                <#assign entriesCategoryId = entries?first.getCategoryIds()?first /> 
36                <#if entriesCategoryId != categoryId> 
37                    <#assign 
38                        entriesCategory = assetCategoryLocalService.getCategory(entriesCategoryId) 
39                        parentCategoryId = entriesCategory.getParentCategoryId() 
40                    /> 
41                    <h3>${entriesCategory.getName()}</h3> 
42                </#if> 
43            </#if> 
44        <#else> 
45            <h1>Все документы</h1> 
46 
47            <#assign 
48                entries = sortDocsByCategory(entries) 
49                entriesCategoryId = entries?first.getCategoryIds()?first 
50                hasNestedCategories = true 
51                entriesCategory = assetCategoryLocalService.getCategory(entriesCategoryId) 
52            /> 
53 
54            <h2>${entriesCategory.getName()}</h2> 
55 
56        </#if> 
57        <#list entries as curEntry> 
58            <#assign classNameId = curEntry.classNameId?number /> 
59            <#assign className = classNameService.fetchByClassNameId(classNameId).value /> 
60 
61            <#if className == "com.liferay.document.library.kernel.model.DLFileEntry" > 
62                <#assign assetPk = curEntry.classPK?number /> 
63                <#assign file = dLAppLocalService.getFileEntry(assetPk) /> 
64 
65                <#assign url = dlUtil.getDownloadURL(file, file.getFileVersion(), themeDisplay, "") /> 
66                <#assign name = curEntry.getTitle(locale) /> 
67                <#assign extension = file.extension /> 
68 
69                <#if file.size < 1024 * 1024 > 
70                    <#assign size = file.size / 1024  /> 
71                    <#assign sizeLiter = "КБ"/> 
72                <#else> 
73                    <#assign size = file.size / 1024 / 1024 /> 
74                    <#assign sizeLiter = "МБ"/> 
75                </#if> 
76 
77                <#if name?ends_with("." + extension) > 
78                    <#assign name = name?keep_before_last(".") /> 
79                </#if> 
80 
81                <#if hasNestedCategories && curEntry.getCategoryIds()?first != entriesCategoryId > 
82                    <#assign 
83                        entriesCategoryId = curEntry.getCategoryIds()?first 
84                        entriesCategory = assetCategoryLocalService.getCategory(entriesCategoryId) 
85                    /> 
86 
87                    <#-- Родительская категория ранее не отображалась или изменилась --> 
88                    <#if entriesCategory.getParentCategoryId() != 0 
89                        && entriesCategory.getParentCategoryId() != parentCategoryId 
90                        && !firstLevelCategoryPage 
91
92                        <#assign 
93                            parentCategoryId = entriesCategory.getParentCategoryId() 
94                            parentCategory = assetCategoryLocalService.getCategory(parentCategoryId) 
95                        /> 
96                        <h2>${parentCategory.getName()}</h2> 
97                    </#if> 
98                    <h3>${entriesCategory.getName()}</h3> 
99 
100                </#if> 
101 
102                <a class="knd_document_list__item" href="${url}"> 
103                    <div class="knd_file_icon"></div> 
104                    <div class="knd_document_list__dec"> 
105                        <div class="knd_document_list__dec__name"> 
106                            ${name} 
107                        </div> 
108                        <div class="knd_text_additional"> 
109                            ${extension?upper_case} ${size?string["0.#"]} ${sizeLiter} 
110                        </div> 
111                        <div class="knd_document_list__tag_list"> 
112                            <#list curEntry.tagNames as tag> 
113                                <#if tag != 'документ'> 
114                                    <div class="label label-dismissible label-secondary" href="?tag=${tag}"> 
115                                        <span class="label-item label-item-expand"> 
116                                            ${tag} 
117                                        </span> 
118                                    </div> 
119                                </#if> 
120                            </#list> 
121                        </div> 
122                    </div> 
123                </a> 
124            </#if> 
125        </#list> 
126    </#if> 
127</div> 
128 
129<#function sortDocsByCategory entries> 
130 
131    <#assign 
132        rootCategories = [] 
133        ownCategories = [] 
134        entriesProcessed = [] 
135        entriesSorted = [] 
136    /> 
137 
138    <#list entries as entry> 
139        <#if entry.getCategories()?has_content > 
140            <#assign 
141                category = entry.getCategories()?first 
142                rootCategory = getFirstChildInTree(category) 
143            /> 
144 
145            <#if category.getCategoryId() == rootCategory.getCategoryId()> 
146                <#if !rootCategories?seq_contains(category.getCategoryId())> 
147                    <#assign rootCategories += [category.getCategoryId()] /> 
148                </#if> 
149            <#else> 
150                <#if !rootCategories?seq_contains(rootCategory.getCategoryId())> 
151                    <#assign rootCategories += [rootCategory.getCategoryId()] /> 
152                </#if> 
153 
154                <#if !ownCategories?seq_contains(category.getCategoryId())> 
155                    <#assign ownCategories += [category.getCategoryId()] /> 
156                </#if> 
157            </#if> 
158 
159            <#assign 
160                entriesProcessed += [{ 
161                    "entry": entry, 
162                    "categoryId": category.getCategoryId(), 
163                    "modifiedDate": entry.getModifiedDate() 
164                }] 
165            /> 
166        </#if> 
167    </#list> 
168 
169    <#assign 
170        rootCategories = rootCategories 
171            ?map(x -> { 
172                "id": x, 
173                "modifiedDate": assetCategoryLocalService.getAssetCategory(x).getModifiedDate() 
174            }) 
175            ?sort_by("modifiedDate") 
176    /> 
177 
178    <#assign 
179        ownCategories = ownCategories 
180            ?map(x -> { 
181                "id": x, 
182                "parentId": assetCategoryLocalService.getAssetCategory(x).getParentCategoryId(), 
183                "modifiedDate": assetCategoryLocalService.getAssetCategory(x).getModifiedDate() 
184            }) 
185    /> 
186 
187    <#list rootCategories as root > 
188        <#assign 
189            subCategories = ownCategories 
190                ?filter(x -> x.parentId == root.id) 
191                ?sort_by("modifiedDate") 
192        /> 
193 
194        <#if subCategories?has_content> 
195            <#list subCategories as sub> 
196                <#assign entriesSorted += getSortedCategoryEntries(sub, entriesProcessed) /> 
197            </#list> 
198        <#else> 
199            <#assign entriesSorted += getSortedCategoryEntries(root, entriesProcessed) /> 
200        </#if> 
201    </#list> 
202 
203    <#return entriesSorted> 
204 
205</#function> 
206 
207<#function getFirstChildInTree category > 
208    <#if category.getParentCategoryId() != 0> 
209        <#assign parent = getFirstChildInTree(category.getParentCategory()) /> 
210    <#else> 
211        <#return category /> 
212    </#if> 
213</#function> 
214 
215<#function getSortedCategoryEntries category allEntries> 
216    <#return 
217        allEntries 
218            ?filter(x -> x.categoryId == category.id) 
219            ?sort_by("modifiedDate") 
220            ?map(y -> y.entry) 
221    /> 
222</#function> 
223 
224<#function hasNestedCategories entries> 
225    <#assign entriesCategoryId = entries?first.getCategoryIds()?first /> 
226 
227    <#list entries as entry> 
228        <#assign entryCategoryId = entry.getCategoryIds()?first /> 
229        <#if entryCategoryId != entriesCategoryId> 
230            <#return true /> 
231        </#if> 
232    </#list> 
233 
234    <#return false /> 
235</#function> 
236 
237<style> 
238    .knd_document_list h1, 
239    .knd_document_list h2, 
240    .knd_document_list h3 
241
242        margin-bottom: 1rem; 
243
244</style>