Notícias - Sicoob Credipinho
Um erro ocorreu enquanto processava o modelo.
The following has evaluated to null or missing:
==> assetRenderer.getArticle [in template "20102#20128#1144095" at line 14, column 39]
----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to be 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 journalArticle = assetRendere... [in template "20102#20128#1144095" at line 14, column 13]
----
1<#assign dlFileEntryLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")>
2<#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService")>
3<#assign vocabularyService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetVocabularyLocalService")>
4
5<#assign targetViewUrl = "/web/sicoob/noticias" />
6<#assign targetPortletID = "xAioIawpOI5S" />
7
8<#if entries?has_content>
9 <#assign dateFormat = "dd/MM/yyyy" />
10
11 <div class="list-news" style="margin-top: 50px;">
12 <#list entries as entry>
13 <#assign assetRenderer = entry.getAssetRenderer() />
14 <#assign journalArticle = assetRenderer.getArticle() />
15 <#assign docXml = saxReaderUtil.read(journalArticle.getContent()) />
16 <#assign categories = entry.getCategories()>
17 <#assign categoryId = -1>
18 <#list categories as category>
19 <#assign categoryId = category.getCategoryId() />
20 </#list>
21 <#assign viewURL = "${targetViewUrl}/-/asset_publisher/${targetPortletID}/content/id/${entry.getEntryId()}${(categoryId != -1)?then('?p_r_p_categoryId=' + categoryId, '')}" />
22 <#assign xmlValue = docXml.valueOf("//dynamic-element[@name='image']/dynamic-content[@language-id='pt_BR']/text()") />
23
24 <#-- Chama a nova função segura -->
25 <#assign pictureURL = getArticleDLEntryUrl(xmlValue) />
26
27 <#assign userLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.UserLocalService")>
28
29 <div class="news">
30 <div class="row">
31 <#if pictureURL?has_content>
32 <div class="col-sm-12 col-md-5">
33 <div class="background-image" style="background-image: url('${pictureURL}');">
34 <#if (categories?size > 0)>
35 <p class="list-category text-truncate">
36 <#list categories as category>
37 <#assign vocabulary = vocabularyService.getVocabulary(category.vocabularyId) />
38 <span class="category">
39 ${category.getName()} <#sep>
40 </span>
41 </#list>
42 </p>
43 </#if>
44 </div>
45 </div>
46 <div class="col-sm-12 col-md-7 text-infos">
47 <#else>
48 <div class="col-12 text-infos">
49 </#if>
50 <span class="info-top hour">${entry.getTitle()} ${dateUtil.getDate(entry.getModifiedDate(), dateFormat, locale)}</span>
51 <h3>
52 <a href="${viewURL}">
53 ${entry.getTitle(locale)}
54 </a>
55 </h3>
56
57 <#if entry.getSummary(locale)?has_content>
58 <div class="summary" style="overflow:hidden;">
59 <#assign content = entry.getSummary(locale)>
60 ${(entry.getSummary(locale)?length < 160)?then(entry.getSummary(locale), entry.getSummary(locale)?substring(0, 160) + '...</i></em>')}
61 </div>
62 </#if>
63
64
65 </div>
66 </div>
67 </div>
68 </#list>
69 </div>
70<#else>
71 <div class="alert alert-info">
72 Não existe notícia cadastrada.
73 </div>
74</#if>
75
76<#-- FUNÇÃO AJUSTADA COM LIMPEZA E TRATAMENTO DE ERRO -->
77<#function getArticleDLEntryUrl rawValue>
78 <#local docUrl = "" />
79
80 <#if rawValue?has_content>
81 <#-- 1. Limpeza de caracteres especiais (Word/Excel copy-paste) -->
82 <#local cleanValue = rawValue?replace("“", "\"")
83 ?replace("”", "\"")
84 ?replace("‘", "'")
85 ?replace("’", "'")
86 ?replace("–", "-")
87 ?replace("—", "-") />
88
89 <#-- 2. Verificação se é JSON -->
90 <#if cleanValue?trim?starts_with("{")>
91 <#attempt>
92 <#local jsonObject = cleanValue?eval />
93
94 <#if jsonObject.uuid?? && jsonObject.groupId??>
95 <#local entryUuid = jsonObject.uuid />
96 <#local entryGroupId = getterUtil.getLong(jsonObject.groupId) />
97 <#local dlFileEntry = dlFileEntryLocalService.getDLFileEntryByUuidAndGroupId(entryUuid, entryGroupId) />
98 <#local assetEntry = assetEntryLocalService.getEntry("com.liferay.document.library.kernel.model.DLFileEntry", dlFileEntry.fileEntryId) />
99 <#local assetRenderer = assetEntry.assetRenderer />
100 <#local docUrl = assetRenderer.getURLDownload(themeDisplay) />
101 </#if>
102 <#recover>
103 <#-- Se falhar o JSON eval ou a busca do arquivo, retorna vazio e não quebra a página -->
104 <#local docUrl = "" />
105 </#recover>
106 <#else>
107 <#-- Fallback: Se não começa com {, assume que pode ser uma URL direta -->
108 <#if cleanValue?contains("/")>
109 <#local docUrl = cleanValue />
110 </#if>
111 </#if>
112 </#if>
113
114 <#return docUrl />
115</#function>
116
117<script>
118 AUI().ready(function(A){
119 if(A.all('.list-news .news .text-infos a')._nodes.length != 0){
120 A.all('.list-news .news .text-infos a')._nodes.forEach(function(z){
121 // Verifica se o href existe antes de tentar o split para evitar erros JS
122 if(z.href && z.href.indexOf('-') > -1) {
123 z.href = window.location.origin + window.location.pathname.split('/').filter(function(a, index){
124 return index <= 3;
125 }).join('/') + '/-' + z.href.split('-')[1];
126 }
127 });
128 }
129 });
130</script>