* for detailed error information.
*/
public boolean UpLoadSiteHostedPicture(PictureInfo picInfo, UploadSiteHostedPicturesRequestType request) {
//get ApiLogging
ApiLogging apiLogging = apiContext.getApiLogging();
try{
//Serialize the request into the XML Document
Document doc = this.marshal(request);
//Add eBay API token to the document
addAuthToken(doc);
if (apiLogging != null && apiLogging.isLogSOAPMessages()) {
String formattedReqXmlString = XmlUtil.getXmlStringFromDom(doc);
logMessage("UploadSiteHostedPicturesRequest", formattedReqXmlString);
}
//Convert XML Document to XML String
String requestXmlString = xmlToString(doc);
//Send file and get response string
String respString = sendFile(picInfo.getPictureFilePath(), requestXmlString);
if (apiLogging != null && apiLogging.isLogSOAPMessages()) {
Document respDom = XmlUtil.createDom(respString);
String formattedRespXmlString = XmlUtil.getXmlStringFromDom(respDom);
logMessage("UploadSiteHostedPicturesResponse", formattedRespXmlString);
}
//Deserialize the response String into UploadSiteHostedPicturesResponseType object
UploadSiteHostedPicturesResponseType response = unmarshal(respString);
//Update PictureInfo object
picInfo.setReponse(response);
//success case
if ( response.getErrors() == null || response.getErrors().length == 0 ) {
picInfo.setURL(response.getSiteHostedPictureDetails().getFullURL());
return true;
}
//warning case
if ( response.getErrors().length > 0 && response.getAck() == AckCodeType.WARNING) {
picInfo.setURL(response.getSiteHostedPictureDetails().getFullURL());
picInfo.setErrorType("PICTURE SERVICE RESPONSE WARNING");
picInfo.setErrorMessage(response.getErrors()[0].getShortMessage());
if (apiLogging != null && apiLogging.isLogExceptions()) {
log.warn("PICTURE SERVICE RESPONSE WARNING");
log.warn(response.getErrors()[0].getShortMessage());
}
return true;
}
//error case
picInfo.setErrorType("PICTURE SERVICE RESPONSE ERROR");
picInfo.setErrorMessage(response.getErrors()[0].getShortMessage());
if (apiLogging != null && apiLogging.isLogExceptions()) {
log.error("PICTURE SERVICE RESPONSE ERROR");
log.error(response.getErrors()[0].getShortMessage());
}
return false;
} catch (Exception e) {
picInfo.setErrorType("PICTURE SERVICE UPLOAD ERROR");
picInfo.setErrorMessage(e.getMessage());
if (apiLogging != null && apiLogging.isLogExceptions()) {
log.error("fail to upload picture to eBay picture server!");
log.error(e.getMessage());
}
return false;