[ 
https://issues.apache.org/jira/browse/STREAMS-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16667333#comment-16667333
 ] 

ASF GitHub Bot commented on STREAMS-625:
----------------------------------------

steveblackmon closed pull request #465: resolves STREAMS-625 STREAMS-627 
STREAMS-628
URL: https://github.com/apache/streams/pull/465
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl 
b/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl
index b5dfa43956..54f3c2e77a 100644
--- 
a/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl
+++ 
b/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl
@@ -17,9 +17,9 @@
   ~ under the License.
   -->
 <#attempt>
-  <#assign profile_information = pp.loadData('json', 
'profile_information/profile_information.json')>
-  <#recover>
-    <#stop "NO_PROFILE_INFORMATION">
+    <#assign profile_information = pp.loadData('json', 
'profile_information/profile_information.json')>
+    <#recover>
+        <#stop "NO_PROFILE_INFORMATION">
 </#attempt>
 @prefix : <${namespace}#> .
 @prefix as: <http://www.w3.org/ns/activitystreams#> .
@@ -34,14 +34,14 @@
 
 <#-- profile_information/profile_information.json -->
 <#if profile_information.profile.name?is_hash>
-<#assign fullname=profile_information.profile.name.full_name>
+    <#assign fullname=profile_information.profile.name.full_name>
 <#else>
-<#assign fullname=profile_information.profile.name>
+    <#assign fullname=profile_information.profile.name>
 </#if>
 <#attempt>
-<#assign id=fullname?replace("\\W","","r")>
-<#recover>
-<#stop "NO_ID">
+    <#assign id=fullname?replace("\\W","","r")>
+    <#recover>
+        <#stop "NO_ID">
 </#attempt>
 
 :${id} a apst:FacebookProfile .
@@ -50,18 +50,18 @@
 <#if profile_information.profile.username??>
   as:displayName 
"${profile_information.profile.username!profile_information.profile.name.full_name!profile_information.profile.name}"
 ;
 <#elseif profile_information.profile.name??>
-  <#if profile_information.profile.name?is_hash>
+    <#if profile_information.profile.name?is_hash>
     as:displayName "${profile_information.profile.name.full_name}" ;
-  <#else>
+    <#else>
     as:displayName "${profile_information.profile.name}" ;
-  </#if>
+    </#if>
 </#if>
 <#if profile_information.profile.name??>
-  <#if profile_information.profile.name?is_hash>
+    <#if profile_information.profile.name?is_hash>
     vcard:fn "${profile_information.profile.name.full_name}" ;
-  <#else>
+    <#else>
     vcard:fn "${profile_information.profile.name}" ;
-  </#if>
+    </#if>
 </#if>
 <#if profile_information.profile.name?is_hash>
   vcard:given-name "${profile_information.profile.name.first_name}" ;
@@ -71,70 +71,94 @@
   .
 
 <#if profile_information.profile.emails??>
-<#list profile_information.profile.emails.emails![] as email>
+    <#list profile_information.profile.emails.emails![] as email>
 :${id} vcard:email "mailto:${email}"; .
-</#list>
+    </#list>
 </#if>
 
 <#if profile_information.profile.phone_numbers??>
-<#list profile_information.profile.phone_numbers![] as phone_number_obj>
-:${id} vcard:tel "tel:${phone_number_obj.phone_number}" .
-</#list>
+    <#assign telshash = {} />
+    <#list profile_information.profile.phone_numbers![] as phone_number_obj>
+        <#assign phone = pp.loadData('eval', '
+        com.google.i18n.phonenumbers.PhoneNumberUtil phoneUtil = 
com.google.i18n.phonenumbers.PhoneNumberUtil.getInstance();
+        String rawPhoneNumber = "${phone_number_obj.phone_number}";
+        phoneNumber = phoneUtil.parse(rawPhoneNumber, "US");
+        return phoneUtil.format(phoneNumber, 
com.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat.RFC3966);
+      ')>
+        <#assign telshash += { phone: phone } />
+    </#list>
+    <#list telshash?keys as tel>
+:${id} vcard:tel "${tel}" .
+    </#list>
 </#if>
 
 <#if profile_information.profile.address??>
 :${id}
-<#if profile_information.profile.address.street??>
+    <#if profile_information.profile.address.street??>
   vcard:street-address "${profile_information.profile.address.street}" ;
-</#if>
+    </#if>
   vcard:locality "${profile_information.profile.address.city}" ;
   vcard:region "${profile_information.profile.address.region}" ;
   vcard:country-name "${profile_information.profile.address.country}" ;
-<#if profile_information.profile.address.zipcode??>
+    <#if profile_information.profile.address.zipcode??>
   vcard:postal-code "${profile_information.profile.address.zipcode}" ;
-</#if>
+    </#if>
   .
 </#if>
 
 <#attempt>
-  <#assign your_address_books = pp.loadData('json', 
'about_you/your_address_books.json')>
-  <#assign contacts = your_address_books.address_book.address_book>
-  <#recover>
-  <#assign contacts=[]>
+    <#assign your_address_books = pp.loadData('json', 
'about_you/your_address_books.json')>
+    <#assign contacts = your_address_books.address_book.address_book>
+    <#recover>
+        <#assign contacts=[]>
 </#attempt>
 
 <#attempt>
-<#assign friends = pp.loadData('json', 'friends/friends.json')>
-<#recover>
+    <#assign friends = pp.loadData('json', 'friends/friends.json')>
+    <#recover>
 </#attempt>
 
+<#assign friendshash = {} />
 <#if friends??>
-<#list friends.friends as friend>
-<#assign fid=friend.name?replace("\\W","","r")>
-<#assign nameparts=friend.name?split(" ")>
+    <#list friends.friends as friend>
+        <#assign fid=friend.name?replace("\\W","","r") />
+        <#if (fid?length > 0) >
+            <#assign nameparts=friend.name?split(" ") />
+            <#assign friendshash += { fid: nameparts } />
 :${fid}
   a apst:FacebookProfile ;
   vcard:fn "${friend.name}" ;
   vcard:given-name "${nameparts[0]}" ;
-<#if (nameparts?size > 2)>
+            <#if (nameparts?size > 2)>
   vcard:additional-name "${nameparts[1]}" ;
   vcard:family-name "${nameparts[2]}" ;
-<#elseif  (nameparts?size == 2)>
+            <#elseif  (nameparts?size == 2)>
   vcard:family-name "${nameparts[1]}" ;
-</#if>
-<#list contacts as contact>
-  <#if friend.name == contact.name>
-    <#list contact.details![] as detail>
-      <#if detail.contact_point?starts_with("+")>
-      <#attempt>
-        <#assign phone=detail.contact_point>
-  vcard:tel "tel:${phone}" ;
-        <#recover>
-      </#attempt>
-      </#if>
-    </#list>
-  </#if>
-</#list>
+            </#if>
+            <#if contacts??>
+                <#list contacts as contact>
+                    <#if friend.name == contact.name>
+                        <#assign telshash = {} />
+                        <#list contact.details![] as detail>
+                            <#if detail.contact_point??>
+                                <#attempt>
+                                    <#assign phone = pp.loadData('eval', '
+                                        
com.google.i18n.phonenumbers.PhoneNumberUtil phoneUtil = 
com.google.i18n.phonenumbers.PhoneNumberUtil.getInstance();
+                                        String rawPhoneNumber = 
"${detail.contact_point}";
+                                        phoneNumber = 
phoneUtil.parse(rawPhoneNumber, "US");
+                                        return phoneUtil.format(phoneNumber, 
com.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat.RFC3966);
+                                      ')>
+                                    <#assign telshash += { phone: phone } />
+                                    <#recover>
+                                </#attempt>
+                            </#if>
+                        </#list>
+                        <#list telshash?keys as tel>
+:${id} vcard:tel "${tel}" .
+                        </#list>
+                    </#if>
+                </#list>
+            </#if>
   .
 
 :${id}-connect-${fid}
@@ -143,28 +167,24 @@
   as:object :${fid} ;
   as:published "${friend.timestamp}" .
 
-</#list>
+        </#if>
+    </#list>
 </#if>
 
-<#attempt>
-<#assign messages = pp.loadData('json', 'messages/messages.json')>
-<#recover>
-</#attempt>
-
 <#if friends??>
-<#list friends.friends as friend>
-<#assign fid=friend.name?replace("\\W","","r")>
-<#assign nameparts=friend.name?split(" ")>
+    <#list friends.friends as friend>
+        <#assign fid=friend.name?replace("\\W","","r")>
+        <#assign nameparts=friend.name?split(" ")>
 :${fid}
   a apst:FacebookProfile ;
   vcard:fn "${friend.name}" ;
   vcard:given-name "${nameparts[0]}" ;
-<#if (nameparts?size > 2)>
+        <#if (nameparts?size > 2)>
   vcard:additional-name "${nameparts[1]}" ;
   vcard:family-name "${nameparts[2]}" ;
-<#elseif (nameparts?size == 2)>
+        <#elseif (nameparts?size == 2)>
   vcard:family-name "${nameparts[1]}" ;
-</#if>
+        </#if>
   .
 
 :${id}-connect-${fid}
@@ -173,7 +193,7 @@
   as:object :${fid} ;
   as:published "${friend.timestamp}" .
 
-</#list>
+    </#list>
 </#if>
 
 <#assign messagesDirs = pp.loadData('eval', '
@@ -182,35 +202,36 @@
 ')>
 
 <#if messagesDirs??>
-  <#if (messagesDirs?size > 0)>
-    <#list messagesDirs as messageDir>
-      <#attempt>
-        <#assign messages = pp.loadData('json', 
'messages/${messageDir}/message.json')>
-        <#if (messages.participants?? && messages.participants?size == 1 && 
messages.title??)>
-          <#assign fidraw = "${messages.title}">
-          <#assign fid=fidraw?replace("\\W","","r")>
-          <#list messages.messages as message>
-            <#list friends.friends as friend>
-              <#if friend.name == message.sender_name>
-:${fid}-message-${id}-${message.timestamp}
-a as:Note ;
-as:actor :${fid} ;
-as:object :${id} ;
-as:published "${message.timestamp}" .
-
-              <#elseif fullname == message.sender_name>
+    <#if (messagesDirs?size > 0)>
+        <#list messagesDirs as messageDir>
+            <#attempt>
+                <#assign messages = pp.loadData('json', 
'messages/${messageDir}/message.json')>
+                <#if (messages.participants?? && messages.participants?size == 
1 && messages.title?? && messages.title?length > 0)>
+                    <#assign fidraw = "${messages.title}">
+                    <#assign fid=fidraw?replace("\\W","","r")>
+                <#-- only keep the timestamps of direct messages with friends 
-->
+                    <#if (fid?? && friendshash[fid]??)>
+                        <#list messages.messages as message>
+                            <#if fullname == message.sender_name>
 :${id}-message-${fid}-${message.timestamp}
 a as:Note ;
 as:actor :${id} ;
 as:object :${fid} ;
 as:published "${message.timestamp}" .
 
-              </#if>
-            </#list>
-          </#list>
-        </#if>
-      <#recover>
-      </#attempt>
-    </#list>
-  </#if>
+                            <#else>
+:${fid}-message-${id}-${message.timestamp}
+a as:Note ;
+as:actor :${fid} ;
+as:object :${id} ;
+as:published "${message.timestamp}" .
+
+                            </#if>
+                        </#list>
+                    </#if>
+                </#if>
+                <#recover>
+            </#attempt>
+        </#list>
+    </#if>
 </#if>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> facebook.ttl.ftl - detail.contact_point can be null
> ---------------------------------------------------
>
>                 Key: STREAMS-625
>                 URL: https://issues.apache.org/jira/browse/STREAMS-625
>             Project: Streams
>          Issue Type: Bug
>            Reporter: Steve Blackmon
>            Assignee: Steve Blackmon
>            Priority: Major
>
> Following error can occur.  Check for detail.contact_point not null before 
> evaluating ?starts_with
> FreeMarker template error: The following has evaluated to null or missing:
> 16:50:37                      ==> detail.contact_point  [in template 
> "facebook.ttl.ftl" at line 128, column 12]
> 16:50:37                      FTL stack trace ("~" means nesting-related):
> 16:50:37                              - Failed at: #if 
> detail.contact_point?starts_with(...  [in template "facebook.ttl.ftl" at line 
> 128, column 7]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to