@@ -184,12 +184,22 @@ public Response construct(InfModel infModel)
184
184
185
185
public void sendEmail (Resource owner , Resource accessRequest ) throws MessagingException , UnsupportedEncodingException
186
186
{
187
- // TO-DO: trim values
188
- String givenName = owner .getRequiredProperty (com .atomgraph .linkeddatahub .vocabulary .FOAF .givenName ).getString ();
189
- String familyName = owner .getRequiredProperty (com .atomgraph .linkeddatahub .vocabulary .FOAF .familyName ).getString ();
190
- String fullName = givenName + " " + familyName ;
187
+ // TO-DO: trim values?
188
+ final String name ;
189
+ if (owner .hasProperty (FOAF .givenName ) && owner .hasProperty (FOAF .familyName ))
190
+ {
191
+ String givenName = owner .getProperty (FOAF .givenName ).getString ();
192
+ String familyName = owner .getProperty (FOAF .familyName ).getString ();
193
+ name = givenName + " " + familyName ;
194
+ }
195
+ else
196
+ {
197
+ if (owner .hasProperty (FOAF .name )) name = owner .getProperty (FOAF .name ).getString ();
198
+ else throw new IllegalStateException ("Owner Agent '" + owner + "' does not have either foaf:givenName/foaf:familyName or foaf:name" );
199
+ }
200
+
191
201
// we expect foaf:mbox value as mailto: URI (it gets converted from literal in Model provider)
192
- String mbox = owner .getRequiredProperty (com . atomgraph . linkeddatahub . vocabulary . FOAF .mbox ).getResource ().getURI ().substring ("mailto:" .length ());
202
+ String mbox = owner .getRequiredProperty (FOAF .mbox ).getResource ().getURI ().substring ("mailto:" .length ());
193
203
194
204
Resource requestAgent = accessRequest .getPropertyResourceValue (LACL .requestAgent );
195
205
Resource accessTo = accessRequest .getPropertyResourceValue (LACL .requestAccessTo );
@@ -198,7 +208,7 @@ public void sendEmail(Resource owner, Resource accessRequest) throws MessagingEx
198
208
subject (String .format (getEmailSubject (),
199
209
getApplication ().getProperty (DCTerms .title ).getString ())).
200
210
from (getNotificationAddress ()).
201
- to (mbox , fullName ).
211
+ to (mbox , name ).
202
212
textBodyPart (String .format (getEmailText (), requestAgent .getURI (), accessTo .getURI (), accessRequest .getURI ())).
203
213
build ());
204
214
}
0 commit comments