public boolean addNote(Note bug,NoteComment comment){
  if (bug.isNew()) {
    Log.d(DEBUG_TAG,"adding note");
    HttpURLConnection connection=null;
    try {
      try {
        String encodedComment=URLEncoder.encode(comment.getText(),"UTF-8");
        URL addNoteUrl=getAddNoteUrl((bug.getLat() / 1E7d),(bug.getLon() / 1E7d),encodedComment);
        connection=openConnectionForWriteAccess(addNoteUrl,"POST","text/xml");
        OutputStreamWriter out=new OutputStreamWriter(connection.getOutputStream(),Charset.defaultCharset());
        out.flush();
        if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
          throwUnexpectedRequestException(connection);
        }
        parseBug(bug,connection.getInputStream());
        return true;
      }
 catch (      XmlPullParserException e) {
        Log.e(DEBUG_TAG,"addNote:Exception",e);
      }
catch (      IOException e) {
        Log.e(DEBUG_TAG,"addNote:Exception",e);
      }
    }
  finally {
      disconnect(connection);
    }
  }
  return false;
}

public boolean addNote ( Note bug , NoteComment comment ) { if ( bug . isNew ( ) ) { Log . d ( DEBUG_TAG , "adding note" ) ; HttpURLConnection connection = null ; try { try { String encodedComment = URLEncoder . encode ( comment . getText ( ) , "UTF-8" ) ; URL addNoteUrl = getAddNoteUrl ( ( bug . getLat ( ) / 1E7d ) , ( bug . getLon ( ) / 1E7d ) , encodedComment ) ; connection = openConnectionForWriteAccess ( addNoteUrl , "POST" , "text/xml" ) ; OutputStreamWriter out = new OutputStreamWriter ( connection . getOutputStream ( ) , Charset . defaultCharset ( ) ) ; out . flush ( ) ; if ( connection . getResponseCode ( ) != HttpURLConnection . HTTP_OK ) { throwUnexpectedRequestException ( connection ) ; } parseBug ( bug , connection . getInputStream ( ) ) ; return true ; } catch ( XmlPullParserException e ) { Log . e ( DEBUG_TAG , "addNote:Exception" , e ) ; } catch ( IOException e ) { Log . e ( DEBUG_TAG , "addNote:Exception" , e ) ; } } finally { disconnect ( connection ) ; } } return false ; }
perform an http request to add the specified bug to the openstreetbugs database . blocks until the request is complete .
