Пример #1
0
 private int pushDirty()
     throws URISyntaxException, LocalStorageException, IOException, HttpException {
   int count = 0;
   long[] dirtyIDs = local.findUpdated();
   Log.i(TAG, "Uploading " + dirtyIDs.length + " modified resource(s) (if not changed)");
   try {
     for (long id : dirtyIDs) {
       try {
         Resource res = local.findById(id, true);
         String eTag = remote.update(res);
         if (eTag != null) local.updateETag(res, eTag);
         local.clearDirty(res);
         count++;
       } catch (PreconditionFailedException e) {
         Log.i(TAG, "Locally changed resource has been changed on the server in the meanwhile");
       } catch (ValidationException e) {
         Log.e(TAG, "Couldn't create entity for updating: " + e.toString());
       } catch (RecordNotFoundException e) {
         Log.e(TAG, "Couldn't read dirty record", e);
       }
     }
   } finally {
     local.commit();
   }
   return count;
 }