Example #1
0
 /** Existing agents are detected based on email address as well as URI key. */
 @Override
 public Agent getExistingRecord(RequestContext request) throws ResponseContextException {
   // Try super method first
   Agent existingAgent = super.getExistingRecord(request);
   if (existingAgent != null) {
     return existingAgent;
   }
   // If not, it's time for some Agent-specific searching
   Entry entry = getEntryFromRequest(request);
   for (Link link : entry.getLinks(Constants.REL_MBOX)) {
     InternetAddress emailAddress = getAdapterInputHelper().getEmailFromHref(link.getHref());
     existingAgent = getAgentWithEmail(emailAddress);
     if (existingAgent != null) {
       return existingAgent;
     }
   }
   return null;
 }
Example #2
0
 private static IRI getEditUri(Entry entry) throws Exception {
   IRI editUri = null;
   List<Link> editLinks = entry.getLinks("edit");
   for (Link link : editLinks) {
     // if there is more than one edit link, we should not automatically
     // assume that it's always going to point to an Atom document
     // representation.
     if (link.getMimeType() != null) {
       if (link.getMimeType().match("application/atom+xml")) {
         editUri = link.getResolvedHref();
         break;
       }
     } else { // assume that an edit link with no type attribute is the right one to use
       editUri = link.getResolvedHref();
       break;
     }
   }
   return editUri;
 }