@Override
 public Node commitNodeImpl(OsmPoint.Action action, Node n, EntityInfo info, String comment) {
   Node newNode = n;
   if (n.getId() == -1) {
     newNode = new Node(n, --nextid); // generate local id for the created node
   }
   OpenstreetmapPoint p = new OpenstreetmapPoint();
   p.setEntity(newNode);
   p.setAction(action);
   p.setComment(comment);
   if (p.getAction() == OsmPoint.Action.DELETE && newNode.getId() < 0) { // if it is our local poi
     db.deletePOI(p);
   } else {
     db.addOpenstreetmap(p);
   }
   return newNode;
 }
 private void writeContent(XmlSerializer sz, OsmPoint[] points, Action a)
     throws IllegalArgumentException, IllegalStateException, IOException {
   for (OsmPoint point : points) {
     if (point.getGroup() == OsmPoint.Group.POI) {
       OpenstreetmapPoint p = (OpenstreetmapPoint) point;
       if (p.getAction() == a) {
         sz.startTag("", "node");
         sz.attribute("", "lat", p.getLatitude() + "");
         sz.attribute("", "lon", p.getLongitude() + "");
         sz.attribute("", "id", p.getId() + "");
         for (String tag : p.getEntity().getTagKeySet()) {
           String val = p.getEntity().getTag(tag);
           sz.startTag("", "tag");
           sz.attribute("", "k", tag);
           sz.attribute("", "v", val);
           sz.endTag("", "tag");
         }
         sz.endTag("", "node");
       }
     } else if (point.getGroup() == OsmPoint.Group.BUG) {
       OsmNotesPoint p = (OsmNotesPoint) point;
       if (p.getAction() == a) {
         sz.startTag("", "note");
         sz.attribute("", "lat", p.getLatitude() + "");
         sz.attribute("", "lon", p.getLongitude() + "");
         sz.attribute("", "id", p.getId() + "");
         sz.startTag("", "comment");
         sz.attribute("", "text", p.getText() + "");
         sz.endTag("", "comment");
         sz.endTag("", "note");
       }
     }
   }
 }
    @Override
    protected Integer doInBackground(OsmPoint... points) {
      int uploaded = 0;

      for (OsmPoint point : points) {
        if (interruptUploading) break;

        if (point.getGroup() == OsmPoint.Group.POI) {
          OpenstreetmapPoint p = (OpenstreetmapPoint) point;
          EntityInfo entityInfo = null;
          if (OsmPoint.Action.CREATE != p.getAction()) {
            entityInfo = remotepoi.loadNode(p.getEntity());
          }
          Node n =
              remotepoi.commitNodeImpl(
                  p.getAction(), p.getEntity(), entityInfo, p.getComment(), false);
          if (n != null) {
            dbpoi.deletePOI(p);
            publishProgress(p);
            uploaded++;
          }
        } else if (point.getGroup() == OsmPoint.Group.BUG) {
          OsmNotesPoint p = (OsmNotesPoint) point;
          boolean success = false;
          if (p.getAction() == OsmPoint.Action.CREATE) {
            success =
                remotebug.createNewBug(p.getLatitude(), p.getLongitude(), p.getText()) == null;
          } else if (p.getAction() == OsmPoint.Action.MODIFY) {
            success = remotebug.addingComment(p.getId(), p.getText()) == null;
          } else if (p.getAction() == OsmPoint.Action.DELETE) {
            success = remotebug.closingBug(p.getId(), p.getText()) == null;
          }
          if (success) {
            dbbug.deleteAllBugModifications(p);
            uploaded++;
            publishProgress(p);
          }
        }
      }

      return Integer.valueOf(uploaded);
    }