Example usage for javax.xml.parsers ParserConfigurationException printStackTrace

List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.parsers ParserConfigurationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.xmobileapp.rockplayer.LastFmAlbumArtImporter.java

/*********************************
 * //w  w w .j a va2  s.c  o  m
 * getArtistArt
 * 
 *********************************/
private String getArtistArt(String artistName) {
    try {
        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        SAXParser saxParser;
        saxParser = saxParserFactory.newSAXParser();
        XMLReader xmlReader;
        xmlReader = saxParser.getXMLReader();
        XMLArtistInfoHandler xmlHandler = new XMLArtistInfoHandler();
        xmlReader.setContentHandler(xmlHandler);
        /*
         * Get artist art from Last.FM
         */
        String artistNameFiltered = filterString(artistName);
        URL lastFmApiRequest = new URL(
                this.LAST_FM_ARTIST_GETINFO_URL + "&artist=" + URLEncoder.encode(artistNameFiltered));
        BufferedReader in = new BufferedReader(new InputStreamReader(lastFmApiRequest.openStream()));
        xmlReader.parse(new InputSource(in));

        if (xmlHandler.xlargeAlbumArt != null) {
            return xmlHandler.xlargeAlbumArt;
        } else if (xmlHandler.largeAlbumArt != null) {
            return xmlHandler.largeAlbumArt;
        } else if (xmlHandler.mediumAlbumArt != null) {
            return xmlHandler.mediumAlbumArt;
        }

        return null;
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return null;
    } catch (SAXException e) {
        e.printStackTrace();
        return null;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.xmobileapp.rockplayer.LastFmAlbumArtImporter.java

/*********************************
 * /*from   ww  w. ja va 2s .  c  o m*/
 * getAlbumArtByAlbumName
 * 
 *********************************/
private String getAlbumArtByAlbumName(String albumName, String artistName) {
    try {
        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        SAXParser saxParser;
        saxParser = saxParserFactory.newSAXParser();
        XMLReader xmlReader;
        xmlReader = saxParser.getXMLReader();
        XMLAlbumSearchHandler xmlHandler = new XMLAlbumSearchHandler();
        xmlReader.setContentHandler(xmlHandler);
        /*
         * Get artist art from Last.FM
         */
        String artistNameFiltered = filterString(artistName);
        String albumNameFiltered = filterString(albumName);
        URL lastFmApiRequest = new URL(
                this.LAST_FM_ALBUM_SEARCH_URL + "&album=" + URLEncoder.encode(albumNameFiltered));
        BufferedReader in = new BufferedReader(new InputStreamReader(lastFmApiRequest.openStream()));
        xmlReader.parse(new InputSource(in));

        for (int i = 0; i < xmlHandler.albumSearchList.size(); i++) {
            AlbumSearch albumSearch = xmlHandler.albumSearchList.get(i);
            if (artistNameIsSimilarEnough(filterString(albumSearch.artistName), artistNameFiltered)) {
                if (albumSearch.xlargeAlbumArt != null) {
                    return albumSearch.xlargeAlbumArt;
                } else if (albumSearch.largeAlbumArt != null) {
                    return albumSearch.largeAlbumArt;
                } else if (albumSearch.mediumAlbumArt != null) {
                    return albumSearch.mediumAlbumArt;
                }
            }
        }
        return null;
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return null;
    } catch (SAXException e) {
        e.printStackTrace();
        return null;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.idega.xroad.client.business.impl.XRoadServicesImpl.java

@Override
public Document getPreffiledDocumentInXML(String applicationID, String taskID, User user, String language) {
    InputStream documentInputStream = getPreffiledDocument(applicationID, taskID, user, language);
    if (documentInputStream == null) {
        return null;
    }//from   w ww. j a  va  2 s.c o  m

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setXIncludeAware(true);
    DocumentBuilder documentBuilder;
    Document document = null;
    try {
        documentBuilder = factory.newDocumentBuilder();
        document = documentBuilder.parse(documentInputStream);
    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SAXException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return document;
}

From source file:es.ehu.si.ixa.pipe.convert.Convert.java

/**
 * Process the ancora constituent XML annotation into Penn Treebank bracketing
 * style.//from ww w .j  a v a 2s.c om
 * 
 * @param inXML
 *          the ancora xml constituent document
 * @return the ancora trees in penn treebank one line format
 * @throws IOException
 *           if io exception
 */
public String ancora2treebank(File inXML) throws IOException {
    String filteredTrees = null;
    if (inXML.isFile()) {

        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        SAXParser saxParser;
        try {
            saxParser = saxParserFactory.newSAXParser();
            AncoraTreebank ancoraParser = new AncoraTreebank();
            saxParser.parse(inXML, ancoraParser);
            String trees = ancoraParser.getTrees();
            // remove empty trees created by "missing" and "elliptic" attributes
            filteredTrees = trees.replaceAll("\\(\\SN\\)", "");
            // format correctly closing brackets
            filteredTrees = filteredTrees.replace(") )", "))");
            // remove double spaces
            filteredTrees = filteredTrees.replaceAll("  ", " ");
            // remove empty sentences created by <sentence title="yes"> elements
            filteredTrees = filteredTrees.replaceAll("\\(SENTENCE \\)\n", "");
        } catch (ParserConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SAXException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        System.out.println("Please choose a valid file as input");
    }
    return filteredTrees;
}

From source file:com.example.findmygf.MapActivity.java

private Document convertStringToDocument(String src) {
    Document dest = null;//from w ww . j av  a  2 s  .c o  m

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser;

    try {
        parser = dbFactory.newDocumentBuilder();
        dest = parser.parse(new ByteArrayInputStream(src.getBytes()));
    } catch (ParserConfigurationException e1) {
        e1.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return dest;
}

From source file:me.willowcheng.makerthings.ui.OpenHABMainActivity.java

private void loadSitemapList(String baseUrl) {
    Log.d(TAG, "Loading sitemap list from " + baseUrl + "rest/sitemaps");
    startProgressIndicator();//  w ww .j a  v a  2s.c o m
    mAsyncHttpClient.get(baseUrl + "rest/sitemaps", new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            stopProgressIndicator();
            mSitemapList.clear();
            // If openHAB's version is 1, get sitemap list from XML
            if (mOpenHABVersion == 1) {
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                try {
                    DocumentBuilder builder = dbf.newDocumentBuilder();
                    Document sitemapsXml = builder.parse(new ByteArrayInputStream(responseBody));
                    mSitemapList.addAll(Util.parseSitemapList(sitemapsXml));
                } catch (ParserConfigurationException e) {
                    e.printStackTrace();
                } catch (SAXException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                // Later versions work with JSON
            } else {
                try {
                    String jsonString = new String(responseBody, "UTF-8");
                    JSONArray jsonArray = new JSONArray(jsonString);
                    mSitemapList.addAll(Util.parseSitemapList(jsonArray));
                    Log.d(TAG, jsonArray.toString());
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            if (mSitemapList.size() == 0) {
                return;
            }
            loadDrawerItems();
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
            stopProgressIndicator();
            if (error instanceof HttpResponseException) {
                switch (((HttpResponseException) error).getStatusCode()) {
                case 401:
                    showAlertDialog(getString(R.string.error_authentication_failed));
                    break;
                default:
                    showAlertDialog("HTTP Error: " + error.getMessage());
                    Log.e(TAG,
                            String.format("Http code = %d", ((HttpResponseException) error).getStatusCode()));
                    break;
                }
            } else if (error instanceof org.apache.http.conn.HttpHostConnectException) {
                Log.e(TAG, "Error connecting to host");
                if (error.getMessage() != null) {
                    Log.e(TAG, error.getMessage());
                    showAlertDialog(error.getMessage());
                } else {
                    showAlertDialog(getString(R.string.error_connection_failed));
                }
            } else if (error instanceof java.net.UnknownHostException) {
                Log.e(TAG, "Unable to resolve hostname");
                if (error.getMessage() != null) {
                    Log.e(TAG, error.getMessage());
                    showAlertDialog(error.getMessage());
                } else {
                    showAlertDialog(getString(R.string.error_connection_failed));
                }
            } else {
                Log.e(TAG, error.getClass().toString());
            }
        }
    });
}

From source file:me.willowcheng.makerthings.ui.OpenHABMainActivity.java

/**
 * Get sitemaps from openHAB, if user already configured preffered sitemap
 * just open it. If no preffered sitemap is configured - let user select one.
 *
 * @param baseUrl an absolute base URL of openHAB to open
 * @return void//  www.  j  a  va2  s  .c o  m
 */

private void selectSitemap(final String baseUrl, final boolean forceSelect) {
    Log.d(TAG, "Loading sitemap list from " + baseUrl + "rest/sitemaps");
    startProgressIndicator();
    mAsyncHttpClient.get(baseUrl + "rest/sitemaps", new AsyncHttpResponseHandler() {

        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            Log.d(TAG, new String(responseBody));
            stopProgressIndicator();
            mSitemapList.clear();
            // If openHAB's version is 1, get sitemap list from XML
            if (mOpenHABVersion == 1) {
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                try {
                    DocumentBuilder builder = dbf.newDocumentBuilder();
                    Document sitemapsXml = builder.parse(new ByteArrayInputStream(responseBody));
                    mSitemapList.addAll(Util.parseSitemapList(sitemapsXml));
                } catch (ParserConfigurationException e) {
                    e.printStackTrace();
                } catch (SAXException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                // Later versions work with JSON
            } else {
                try {
                    String jsonString = new String(responseBody, "UTF-8");
                    JSONArray jsonArray = new JSONArray(jsonString);
                    mSitemapList.addAll(Util.parseSitemapList(jsonArray));
                    Log.d(TAG, jsonArray.toString());
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            // Now work with sitemaps list
            if (mSitemapList.size() == 0) {
                // Got an empty sitemap list!
                Log.e(TAG, "openHAB returned empty sitemap list");
                showAlertDialog(getString(R.string.error_empty_sitemap_list));
                return;
            }
            loadDrawerItems();
            // If we are forced to do selection, just open selection dialog
            if (forceSelect) {
                showSitemapSelectionDialog(mSitemapList);
            } else {
                // Check if we have a sitemap configured to use
                SharedPreferences settings = PreferenceManager
                        .getDefaultSharedPreferences(OpenHABMainActivity.this);
                String configuredSitemap = settings.getString(Constants.PREFERENCE_SITEMAP, "");
                // If we have sitemap configured
                if (configuredSitemap.length() > 0) {
                    // Configured sitemap is on the list we got, open it!
                    if (Util.sitemapExists(mSitemapList, configuredSitemap)) {
                        Log.d(TAG, "Configured sitemap is on the list");
                        OpenHABSitemap selectedSitemap = Util.getSitemapByName(mSitemapList, configuredSitemap);
                        openSitemap(selectedSitemap.getHomepageLink());
                        // Configured sitemap is not on the list we got!
                    } else {
                        Log.d(TAG, "Configured sitemap is not on the list");
                        if (mSitemapList.size() == 1) {
                            Log.d(TAG, "Got only one sitemap");
                            SharedPreferences.Editor preferencesEditor = settings.edit();
                            preferencesEditor.putString(Constants.PREFERENCE_SITEMAP,
                                    mSitemapList.get(0).getName());
                            preferencesEditor.commit();
                            openSitemap(mSitemapList.get(0).getHomepageLink());
                        } else {
                            Log.d(TAG, "Got multiply sitemaps, user have to select one");
                            showSitemapSelectionDialog(mSitemapList);
                        }
                    }
                    // No sitemap is configured to use
                } else {
                    // We got only one single sitemap from openHAB, use it
                    if (mSitemapList.size() == 1) {
                        Log.d(TAG, "Got only one sitemap");
                        SharedPreferences.Editor preferencesEditor = settings.edit();
                        preferencesEditor.putString(Constants.PREFERENCE_SITEMAP,
                                mSitemapList.get(0).getName());
                        preferencesEditor.commit();
                        openSitemap(mSitemapList.get(0).getHomepageLink());
                    } else {
                        Log.d(TAG, "Got multiply sitemaps, user have to select one");
                        showSitemapSelectionDialog(mSitemapList);
                    }
                }
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
            stopProgressIndicator();
            if (error instanceof HttpResponseException) {
                switch (((HttpResponseException) error).getStatusCode()) {
                case 401:
                    showAlertDialog(getString(R.string.error_authentication_failed));
                    break;
                default:
                    Log.e(TAG,
                            String.format("Http code = %d", ((HttpResponseException) error).getStatusCode()));
                    showAlertDialog("HTTP Error: " + error.getMessage());
                    break;
                }
            } else if (error instanceof org.apache.http.conn.HttpHostConnectException) {
                Log.e(TAG, "Error connecting to host");
                if (error.getMessage() != null) {
                    Log.e(TAG, error.getMessage());
                    showAlertDialog(error.getMessage());
                } else {
                    showAlertDialog(getString(R.string.error_connection_failed));
                }
            } else if (error instanceof java.net.UnknownHostException) {
                Log.e(TAG, "Unable to resolve hostname");
                if (error.getMessage() != null) {
                    Log.e(TAG, error.getMessage());
                    showAlertDialog(error.getMessage());
                } else {
                    showAlertDialog(getString(R.string.error_connection_failed));
                }
            } else {
                Log.e(TAG, error.getClass().toString());
            }
        }
    });
}

From source file:com.BeatYourRecord.SubmitActivity.java

private String gdataUpload(File file, String uploadUrl, int start, int end) throws IOException {
    int chunk = end - start + 1;
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
    FileInputStream fileStream = new FileInputStream(file);

    HttpURLConnection urlConnection = getGDataUrlConnection(uploadUrl);
    // some mobile proxies do not support PUT, using X-HTTP-Method-Override to get around this problem
    if (isFirstRequest()) {
        Log.d(LOG_TAG, String.format("Uploaded %d bytes so far, using POST method.", (int) totalBytesUploaded));
        urlConnection.setRequestMethod("POST");
    } else {/*  ww  w .j a v  a  2  s.com*/
        urlConnection.setRequestMethod("POST");
        urlConnection.setRequestProperty("X-HTTP-Method-Override", "PUT");
        Log.d(LOG_TAG,
                String.format("Uploaded %d bytes so far, using POST with X-HTTP-Method-Override PUT method.",
                        (int) totalBytesUploaded));
    }
    urlConnection.setDoOutput(true);
    urlConnection.setFixedLengthStreamingMode(chunk);
    urlConnection.setRequestProperty("Content-Type", "video/3gpp");
    urlConnection.setRequestProperty("Content-Range",
            String.format("bytes %d-%d/%d", start, end, file.length()));
    Log.d(LOG_TAG, urlConnection.getRequestProperty("Content-Range"));
    //////may be
    //log.v("id man id",urlConnection.getRequestProperty("Content-Range"));
    OutputStream outStreamWriter = urlConnection.getOutputStream();

    fileStream.skip(start);

    int bytesRead;
    int totalRead = 0;
    while ((bytesRead = fileStream.read(buffer, 0, bufferSize)) != -1) {
        outStreamWriter.write(buffer, 0, bytesRead);
        totalRead += bytesRead;
        this.totalBytesUploaded += bytesRead;

        double percent = (totalBytesUploaded / currentFileSize) * 99;

        /*
        Log.d(LOG_TAG, String.format(
        "fileSize=%f totalBytesUploaded=%f percent=%f", currentFileSize,
        totalBytesUploaded, percent));
        */

        dialog.setProgress((int) percent);

        if (totalRead == (end - start + 1)) {
            break;
        }
    }

    outStreamWriter.close();

    int responseCode = urlConnection.getResponseCode();

    Log.d(LOG_TAG, "responseCode=" + responseCode);
    Log.d(LOG_TAG, "responseMessage=" + urlConnection.getResponseMessage());

    try {
        if (responseCode == 201) {
            String videoId = parseVideoId(urlConnection.getInputStream());
            //log.v("Video ID", videoId);
            vidId = videoId;
            String latLng = null;
            if (this.videoLocation != null) {
                latLng = String.format("lat=%f lng=%f", this.videoLocation.getLatitude(),
                        this.videoLocation.getLongitude());
            }

            submitToYtdDomain(this.ytdDomain, this.assignmentId, videoId, this.youTubeName,
                    SubmitActivity.this.clientLoginToken, getTitleText(), getDescriptionText(), this.dateTaken,
                    latLng, this.tags);
            dialog.setProgress(100);
            //log.v("10video id",videoId);
            return videoId;
        } else if (responseCode == 200) {
            Set<String> keySet = urlConnection.getHeaderFields().keySet();
            String keys = urlConnection.getHeaderFields().keySet().toString();
            Log.d(LOG_TAG, String.format("Headers keys %s.", keys));
            //////////////may be
            for (String key : keySet) {
                Log.d(LOG_TAG,
                        String.format("Header key %s value %s.", key, urlConnection.getHeaderField(key)));
            }
            Log.w(LOG_TAG, "Received 200 response during resumable uploading");
            throw new IOException(String.format("Unexpected response code : responseCode=%d responseMessage=%s",
                    responseCode, urlConnection.getResponseMessage()));
        } else {
            if ((responseCode + "").startsWith("5")) {
                String error = String.format("responseCode=%d responseMessage=%s", responseCode,
                        urlConnection.getResponseMessage());
                Log.w(LOG_TAG, error);
                // TODO - this exception will trigger retry mechanism to kick in
                // TODO - even though it should not, consider introducing a new type so
                // TODO - resume does not kick in upon 5xx
                throw new IOException(error);
            } else if (responseCode == 308) {
                // OK, the chunk completed succesfully 
                Log.d(LOG_TAG, String.format("responseCode=%d responseMessage=%s", responseCode,
                        urlConnection.getResponseMessage()));
            } else {
                // TODO - this case is not handled properly yet
                Log.w(LOG_TAG, String.format("Unexpected return code : %d %s while uploading :%s", responseCode,
                        urlConnection.getResponseMessage(), uploadUrl));
            }
        }
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java

private String gdataUpload(File file, String uploadUrl, int start, int end) throws IOException {
    int chunk = end - start + 1;
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
    FileInputStream fileStream = new FileInputStream(file);

    HttpURLConnection urlConnection = getGDataUrlConnection(uploadUrl);
    // some mobile proxies do not support PUT, using X-HTTP-Method-Override
    // to get around this problem
    if (isFirstRequest()) {
        Log.d(TAG, String.format("Uploaded %d bytes so far, using POST method.", (int) totalBytesUploaded));
        urlConnection.setRequestMethod("POST");
    } else {/*  ww  w  . j a v a 2s .c  o  m*/
        urlConnection.setRequestMethod("POST");
        urlConnection.setRequestProperty("X-HTTP-Method-Override", "PUT");
        Log.d(TAG, String.format("Uploaded %d bytes so far, using POST with X-HTTP-Method-Override PUT method.",
                (int) totalBytesUploaded));
    }
    urlConnection.setDoOutput(true);
    urlConnection.setFixedLengthStreamingMode(chunk);
    // /XXX hardcoded video mimetype
    urlConnection.setRequestProperty("Content-Type", "video/mp4");
    urlConnection.setRequestProperty("Content-Range",
            String.format("bytes %d-%d/%d", start, end, file.length()));
    Log.d(TAG, urlConnection.getRequestProperty("Content-Range"));

    OutputStream outStreamWriter = urlConnection.getOutputStream();

    fileStream.skip(start);

    int bytesRead;
    int totalRead = 0;
    while ((bytesRead = fileStream.read(buffer, 0, bufferSize)) != -1) {
        outStreamWriter.write(buffer, 0, bytesRead);
        totalRead += bytesRead;
        this.totalBytesUploaded += bytesRead;

        // double percent = (totalBytesUploaded / currentFileSize) * 99;

        /*
         * Log.d(TAG, String.format(
         * "fileSize=%f totalBytesUploaded=%f percent=%f", currentFileSize,
         * totalBytesUploaded, percent));
         */

        if (totalRead == (end - start + 1)) {
            break;
        }
    }

    outStreamWriter.close();

    int responseCode = urlConnection.getResponseCode();

    Log.d(TAG, "responseCode=" + responseCode);
    Log.d(TAG, "responseMessage=" + urlConnection.getResponseMessage());

    try {
        if (responseCode == 201) {
            String videoId = parseVideoId(urlConnection.getInputStream());

            Log.i(TAG, "Youtube video submitted - new video id is " + videoId);

            // 100% finished here.

            // dialog.setProgress(100);

            return videoId;
        } else if (responseCode == 200) {
            Set<String> keySet = urlConnection.getHeaderFields().keySet();
            String keys = urlConnection.getHeaderFields().keySet().toString();
            Log.d(TAG, String.format("Headers keys %s.", keys));
            for (String key : keySet) {
                Log.d(TAG, String.format("Header key %s value %s.", key, urlConnection.getHeaderField(key)));
            }
            Log.w(TAG, "Received 200 response during resumable uploading");
            throw new IOException(String.format("Unexpected response code : responseCode=%d responseMessage=%s",
                    responseCode, urlConnection.getResponseMessage()));
        } else {
            if ((responseCode + "").startsWith("5")) {
                String error = String.format("responseCode=%d responseMessage=%s", responseCode,
                        urlConnection.getResponseMessage());
                Log.w(TAG, error);
                // TODO - this exception will trigger retry mechanism to
                // kick in
                // TODO - even though it should not, consider introducing a
                // new type so
                // TODO - resume does not kick in upon 5xx
                throw new IOException(error);
            } else if (responseCode == 308) {
                // OK, the chunk completed successfully
                Log.d(TAG, String.format("responseCode=%d responseMessage=%s", responseCode,
                        urlConnection.getResponseMessage()));
            } else {
                // TODO - this case is not handled properly yet
                Log.w(TAG, String.format("Unexpected return code : %d %s while uploading :%s", responseCode,
                        urlConnection.getResponseMessage(), uploadUrl));
            }
        }
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    }

    return null;
}