@Test public void testConvertInvalidXMLInField() { String badField = "{\"type\":\"standard\",\"sgPropertyID\":21}"; SObject sObj = PartnerSObjectImpl.getNew("Contact"); sObj.setField(badField, "val"); try { SObjects.convertFacadeSObjectToStubSObject(sObj); fail(); } catch (SObjectConversionException e) { assertEquals("Couldn't create DOM nodes for field name <" + badField + "> and value <" + "val" + ">", e.getMessage()); assertEquals("INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. ", e.getCause().getMessage()); } }
@Nonnull static com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject convertFacadeSObjectToStubSObject( @Nonnull SObject facadeSObject) throws SObjectConversionException { com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject stub = new com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject(); if (facadeSObject.getId() == null) { stub.setId(null); } else { stub.setId(facadeSObject.getId().toString()); } stub.setType(facadeSObject.getType()); List<Object> stubFields = stub.getAny(); Document doc = DOC_FACTORY.newDocument(); Iterator<String> fieldNameIter = facadeSObject.getAllFields().keySet().iterator(); Element fieldElt; Node valueNode; String fieldName; String value; while (fieldNameIter.hasNext()) { fieldName = fieldNameIter.next(); value = facadeSObject.getField(fieldName); if (value == null) { stub.getFieldsToNull().add(fieldName); } else { try { fieldElt = doc.createElement(fieldName); valueNode = doc.createTextNode(value); fieldElt.appendChild(valueNode); } catch (DOMException e) { throw new SObjectConversionException( "Couldn't create DOM nodes for field name <" + fieldName + "> and value <" + value + ">", e); } stubFields.add(fieldElt); } } return stub; }
SObjects { @Nonnull static com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject convertFacadeSObjectToStubSObject( @Nonnull SObject facadeSObject) throws SObjectConversionException { com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject stub = new com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject(); if (facadeSObject.getId() == null) { stub.setId(null); } else { stub.setId(facadeSObject.getId().toString()); } stub.setType(facadeSObject.getType()); List<Object> stubFields = stub.getAny(); Document doc = DOC_FACTORY.newDocument(); Iterator<String> fieldNameIter = facadeSObject.getAllFields().keySet().iterator(); Element fieldElt; Node valueNode; String fieldName; String value; while (fieldNameIter.hasNext()) { fieldName = fieldNameIter.next(); value = facadeSObject.getField(fieldName); if (value == null) { stub.getFieldsToNull().add(fieldName); } else { try { fieldElt = doc.createElement(fieldName); valueNode = doc.createTextNode(value); fieldElt.appendChild(valueNode); } catch (DOMException e) { throw new SObjectConversionException( "Couldn't create DOM nodes for field name <" + fieldName + "> and value <" + value + ">", e); } stubFields.add(fieldElt); } } return stub; } }
SObjects { @Nonnull static com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject convertFacadeSObjectToStubSObject( @Nonnull SObject facadeSObject) throws SObjectConversionException { com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject stub = new com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject(); if (facadeSObject.getId() == null) { stub.setId(null); } else { stub.setId(facadeSObject.getId().toString()); } stub.setType(facadeSObject.getType()); List<Object> stubFields = stub.getAny(); Document doc = DOC_FACTORY.newDocument(); Iterator<String> fieldNameIter = facadeSObject.getAllFields().keySet().iterator(); Element fieldElt; Node valueNode; String fieldName; String value; while (fieldNameIter.hasNext()) { fieldName = fieldNameIter.next(); value = facadeSObject.getField(fieldName); if (value == null) { stub.getFieldsToNull().add(fieldName); } else { try { fieldElt = doc.createElement(fieldName); valueNode = doc.createTextNode(value); fieldElt.appendChild(valueNode); } catch (DOMException e) { throw new SObjectConversionException( "Couldn't create DOM nodes for field name <" + fieldName + "> and value <" + value + ">", e); } stubFields.add(fieldElt); } } return stub; } private  SObjects(); }
SObjects { @Nonnull static com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject convertFacadeSObjectToStubSObject( @Nonnull SObject facadeSObject) throws SObjectConversionException { com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject stub = new com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject(); if (facadeSObject.getId() == null) { stub.setId(null); } else { stub.setId(facadeSObject.getId().toString()); } stub.setType(facadeSObject.getType()); List<Object> stubFields = stub.getAny(); Document doc = DOC_FACTORY.newDocument(); Iterator<String> fieldNameIter = facadeSObject.getAllFields().keySet().iterator(); Element fieldElt; Node valueNode; String fieldName; String value; while (fieldNameIter.hasNext()) { fieldName = fieldNameIter.next(); value = facadeSObject.getField(fieldName); if (value == null) { stub.getFieldsToNull().add(fieldName); } else { try { fieldElt = doc.createElement(fieldName); valueNode = doc.createTextNode(value); fieldElt.appendChild(valueNode); } catch (DOMException e) { throw new SObjectConversionException( "Couldn't create DOM nodes for field name <" + fieldName + "> and value <" + value + ">", e); } stubFields.add(fieldElt); } } return stub; } private  SObjects();  }
SObjects { @Nonnull static com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject convertFacadeSObjectToStubSObject( @Nonnull SObject facadeSObject) throws SObjectConversionException { com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject stub = new com.palominolabs.crm.sf.soap.jaxwsstub.partner.SObject(); if (facadeSObject.getId() == null) { stub.setId(null); } else { stub.setId(facadeSObject.getId().toString()); } stub.setType(facadeSObject.getType()); List<Object> stubFields = stub.getAny(); Document doc = DOC_FACTORY.newDocument(); Iterator<String> fieldNameIter = facadeSObject.getAllFields().keySet().iterator(); Element fieldElt; Node valueNode; String fieldName; String value; while (fieldNameIter.hasNext()) { fieldName = fieldNameIter.next(); value = facadeSObject.getField(fieldName); if (value == null) { stub.getFieldsToNull().add(fieldName); } else { try { fieldElt = doc.createElement(fieldName); valueNode = doc.createTextNode(value); fieldElt.appendChild(valueNode); } catch (DOMException e) { throw new SObjectConversionException( "Couldn't create DOM nodes for field name <" + fieldName + "> and value <" + value + ">", e); } stubFields.add(fieldElt); } } return stub; } private  SObjects();   }