/** * Generate a ContactEntry object for batch processing by setting contact ID. * * @param messageContext ESB message context. * @param entryElement OMElement object containing a batch entry. * @return ContactEntry object for batch operations. */ private ContactEntry generateContactEntry(final MessageContext messageContext, final OMElement entryElement) { final OMElement contactIdElem = entryElement.getFirstChildWithName(new QName(Constants.CONTACT_ID)); final ContactEntry contactEntry = new ContactEntry(); if (contactIdElem != null) { final String requestUrl = getRequestURLBuilder(messageContext, Constants.REQUEST_URL_CONTACTS) .append(Constants.REQUEST_URL_GENERIC_END).append(Constants.FORWARD_SLASH) .append(contactIdElem.getText()).toString(); contactEntry.setId(requestUrl); } return contactEntry; }
/** * Create a contacts batch result for negative case. * * @param contactId ID of the contact. * @return ContactFeed object containing the batch. * @throws ServiceException the service exception. * @throws IOException Signals that an I/O exception has occurred. * @throws MalformedURLException error in the provided URLs. * @throws BatchInterruptedException Batch Interruption failure exception. */ public ContactFeed retrieveBatchContactFeed(final String contactId) throws BatchInterruptedException, MalformedURLException, IOException, ServiceException { final ContactFeed batchFeed = new ContactFeed(); final ContactEntry retrieveEntry = new ContactEntry(); final StringBuilder requestUrlBuilder = new StringBuilder("https://www.google.com/m8/feeds/contacts/").append(emailAddress) .append("/full/").append(contactId); retrieveEntry.setId(requestUrlBuilder.toString()); BatchUtils.setBatchId(retrieveEntry, "retrieveEntry"); BatchUtils.setBatchOperationType(retrieveEntry, BatchOperationType.QUERY); batchFeed.getEntries().add(retrieveEntry); return directInvokerContactsService.batch(new URL( "https://www.google.com/m8/feeds/contacts/default/full/batch"), batchFeed); }