/** * 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; }
/** * Method to generate the ContactEntry object for batch create. * * @param entryElement OMElement object containing a batch entry. * @return ContactEntry object for batch operations. * @throws XMLStreamException unexpected processing conditions. * @throws ParseException unexpected issue in parsing. */ private ContactEntry getCreateContact(final OMElement entryElement) throws XMLStreamException, ParseException { final ContactEntry contactEntry = new ContactEntry(); setContactDetails(contactEntry, entryElement); // Set the batch related details. BatchUtils.setBatchOperationType(contactEntry, BatchOperationType.INSERT); final OMElement batchIdElem = entryElement.getFirstChildWithName(new QName(Constants.ID)); if (batchIdElem != null) { BatchUtils.setBatchId(contactEntry, batchIdElem.getText()); } 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); }
Constants.USER_EMAIL, Constants.RELATIONSHIPS, Constants.NOTE}, messageContext); ContactEntry contactEntry = new ContactEntry();