Навигация по категориям

Во время обработки запрошенного шаблона произошла ошибка...
The following has evaluated to null or missing:
==> serviceLocator.findService("ru.pragmatic.liferay.category.counter.api.CategoryCounter")  [in template "29173645033645#730199#1110071" at line 5, column 28]

----
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 categoryCounter = serviceLoca...  [in template "29173645033645#730199#1110071" at line 5, column 1]
----
1<#-- @ftlvariable name="entries" type="java.util.List<com.liferay.asset.kernel.model.AssetVocabulary>" --> 
2<#-- @ftlvariable name="assetCategoryPropertyLocalService" type="com.liferay.asset.category.property.service.AssetCategoryPropertyLocalService" --> 
3<#-- @ftlvariable name="categoryCounter" type="ru.pragmatic.liferay.category.counter.api.CategoryCounter" --> 
4 
5<#assign categoryCounter = serviceLocator.findService("ru.pragmatic.liferay.category.counter.api.CategoryCounter")> 
6<#assign assetCategoryPropertyLocalService = serviceLocator.findService("com.liferay.asset.category.property.service.AssetCategoryPropertyLocalService")> 
7 
8<style> 
9    .cat-items { 
10        row-gap: 12px; 
11    } 
12    .category-empty, 
13    .category-usages { 
14        display: none; 
15    } 
16    .has-control-menu .category-empty, 
17    .has-control-menu .category-usages { 
18        display: initial; 
19    } 
20    .has-control-menu.controls-hidden .category-empty, 
21    .has-control-menu.controls-hidden .category-usages { 
22        display: none; 
23    } 
24</style> 
25 
26<#if entries?has_content> 
27    <#assign activeCategoryId = (renderRequest.getParameter('categoryId')?number)!0 /> 
28    <div class="pragm_categories_wrapper"> 
29        <#list entries as vocabulary> 
30            <h2 class="categories_title"> 
31                ${vocabulary.getUnambiguousTitle(entries, themeDisplay.getSiteGroupId(), themeDisplay.getLocale())} 
32            </h2> 
33            <@renderVocabularyCategories vocabulary.getCategories()/> 
34        </#list> 
35    </div> 
36</#if> 
37 
38<#macro renderVocabularyCategories categories> 
39    <#assign activeCategory = getCategoryById(categories,activeCategoryId)!{}/> 
40    <#assign activeVocabularyCategoryId = activeCategory?has_content?then(activeCategoryId,0)/> 
41    <@displayCategories categories activeVocabularyCategoryId /> 
42</#macro> 
43 
44<#macro displayCategories categories layerCategoryId activeChildCategoryId=0> 
45    <#if layerCategoryId != 0> 
46        <#local displayCategoriesLayer = getCategories(categories,layerCategoryId)/> 
47        <#local layerCategory = getCategoryById(categories,layerCategoryId)/> 
48        <#local parentCategoryId = layerCategory.getParentCategoryId()!0/> 
49        <@displayCategories categories parentCategoryId layerCategoryId/> 
50    <#else> 
51        <#local parentCategoryId = 0/> 
52        <#local displayCategoriesLayer = getCategories(categories,0)/> 
53    </#if> 
54 
55    <#if displayCategoriesLayer?has_content> 
56        <ul class="cat-items"> 
57            <#list displayCategoriesLayer as category> 
58                <@displayCategoryLink category activeChildCategoryId /> 
59            </#list> 
60        </ul> 
61    </#if> 
62</#macro> 
63 
64<#macro displayCategoryLink category layerCategoryId> 
65    <#local categoryId = category.getCategoryId() /> 
66    <#assign categoryUsages = categoryCounter.countEntriesWithCategory(themeDisplay, categoryId) /> 
67    <#if categoryUsages gt 0 || themeDisplay.isSignedIn()> 
68        <#local categoryURL = portletURLFactory.create(renderRequest, portletDisplay.getId(), "VIEW" ) /> 
69 
70        ${categoryURL.setParameter("resetCur", "true")} 
71 
72        <#if activeCategoryId == categoryId> 
73            <#local linkClass="active"/> 
74            ${categoryURL.setParameter("categoryId", "")} 
75        <#else> 
76            ${categoryURL.setParameter("categoryId", categoryId?string + "")} 
77            <#if layerCategoryId == categoryId> 
78                <#local linkClass="active_parent"/> 
79            <#else> 
80                <#local linkClass=""/> 
81            </#if> 
82        </#if> 
83        <#assign itemClass = (categoryUsages gt 0)?then("", "category-empty") /> 
84 
85        ${categoryURL.setParameter("scroll", "portlet_" + portletDisplay.getId())} 
86        <li <#if itemClass?has_content>class="${itemClass}"</#if>> 
87            <a <#if linkClass?has_content>class="${linkClass}"</#if> href="${categoryURL}"> 
88                ${category.getName()} 
89                <#if themeDisplay.isSignedIn()> 
90                    <span class="category-usages">(${categoryUsages})</span> 
91                </#if> 
92            </a> 
93        </li> 
94    </#if> 
95</#macro> 
96 
97<#function getCategories categories parentCategoryIdF> 
98    <#local displayCategories = categories?filter(category -> category.getParentCategoryId() == parentCategoryIdF) > 
99 
100    <#local displayCategoriesMap = {}> 
101 
102    <#list displayCategories as category> 
103        <#attempt> 
104            <#local categoryOrderProperty = assetCategoryPropertyLocalService.fetchCategoryProperty(category.getCategoryId(), 'order')!{} > 
105            <#if categoryOrderProperty?has_content> 
106                <#local orderValue = categoryOrderProperty.getValue() > 
107            <#else> 
108                <#local orderValue = '0' > 
109            </#if> 
110            <#recover> 
111                <#local orderValue = '0' > 
112        </#attempt> 
113 
114        <#local key = orderValue + '_' + category.getName()> 
115 
116        <#local displayCategoriesMap += {key: category}> 
117    </#list> 
118 
119    <#local displayCategoriesList = []> 
120 
121    <#list displayCategoriesMap?keys?sort as key> 
122        <#local displayCategoriesList =  displayCategoriesList + [displayCategoriesMap[key]]> 
123    </#list> 
124 
125    <#return displayCategoriesList> 
126</#function> 
127 
128<#function getCategoryById categories categoryId> 
129    <#return categories?filter(category -> category.getCategoryId() == categoryId)?first> 
130</#function>