public static OperationRequest getRequest(Context context, Uri operationUri) {
    Cursor cursor = null;
    try {
      cursor =
          context
              .getContentResolver()
              .query(operationUri, OperationSchema.COLUMN_ALL, null, null, null);
      cursor.moveToFirst();
      int operationId = cursor.getInt(OperationSchema.COLUMN_REQUEST_TYPE_ID);

      String s =
          ConfigUtils.getString(
              context, ConfigUtils.FAMILY_OPERATION, Integer.toString(operationId));
      if (s == null) {
        Log.e("ApplicationManager", "Error during OperationRequest creation : " + operationId);
        return null;
      }
      return createRequest(cursor, s);
    } catch (Exception e) {
      Log.e("ApplicationManager", "Error during OperationRequest creation : " + operationUri);
    } finally {
      CursorUtils.closeCursor(cursor);
    }
    return null;
  }
 private static OperationRequest createRequest(Cursor cursor, String className) {
   OperationRequest s = null;
   try {
     Constructor<?> t = Class.forName(className).getDeclaredConstructor(Cursor.class);
     s = (OperationRequest) t.newInstance(cursor);
   } catch (Exception e) {
     Log.e("ApplicationManager", "Error during OperationRequest creation : " + className);
   } finally {
     CursorUtils.closeCursor(cursor);
   }
   return s;
 }
  @Subscribe
  public void onDocumentUpdated(UpdateNodeEvent event) {
    if (event.hasException) {
      return;
    }
    Node updatedNode = event.data;
    if (updatedNode == null) {
      return;
    }

    Cursor syncCursor = null;
    try {
      syncCursor =
          getActivity()
              .getContentResolver()
              .query(
                  SyncContentProvider.CONTENT_URI,
                  SyncContentSchema.COLUMN_ALL,
                  SyncContentProvider.getAccountFilter(acc)
                      + " AND "
                      + SyncContentSchema.COLUMN_NODE_ID
                      + " LIKE '"
                      + NodeRefUtils.getCleanIdentifier(updatedNode.getIdentifier())
                      + "%'",
                  null,
                  null);
      boolean hasSynced = (syncCursor.getCount() == 1);
      if (hasSynced && !hasSynchroActive) {
        syncCursor.moveToFirst();
        ContentValues cValues = new ContentValues();
        cValues.put(SyncContentSchema.COLUMN_NODE_ID, updatedNode.getIdentifier());
        cValues.put(
            SyncContentSchema.COLUMN_SERVER_MODIFICATION_TIMESTAMP,
            updatedNode.getModifiedAt().getTimeInMillis());
        getActivity()
            .getContentResolver()
            .update(
                SyncContentManager.getUri(syncCursor.getLong(SyncContentSchema.COLUMN_ID_ID)),
                cValues,
                null,
                null);
      }
    } catch (Exception e) {
      // Do nothing
    } finally {
      CursorUtils.closeCursor(syncCursor);
    }
  }
 // ////////////////////////////////////////////////////
 // REQUEST
 // ////////////////////////////////////////////////////
 public static boolean canRetry(Context context, Uri operationUri) {
   Cursor cursor = null;
   try {
     cursor =
         context
             .getContentResolver()
             .query(operationUri, OperationSchema.COLUMN_ALL, null, null, null);
     if (cursor.getCount() == 0) {
       return false;
     }
     cursor.moveToFirst();
     int status = cursor.getInt(OperationSchema.COLUMN_STATUS_ID);
     return (status == Operation.STATUS_FAILED);
   } catch (Exception e) {
     Log.e("ApplicationManager", "Error during OperationRequest creation : " + operationUri);
   } finally {
     CursorUtils.closeCursor(cursor);
   }
   return false;
 }
  private Node getOfflineNode(String nodeIdentifier) {
    Node syncedNode = null;
    try {
      SyncContentManager syncManager = SyncContentManager.getInstance(getActivity());
      // Retrieve Sync Cursor for the specified node
      Uri localUri = syncManager.getUri(acc, nodeIdentifier);
      Cursor syncCursor =
          getActivity()
              .getContentResolver()
              .query(localUri, SyncContentSchema.COLUMN_ALL, null, null, null);
      if (syncCursor.getCount() == 1 && syncCursor.moveToFirst()) {
        Map<String, Serializable> properties = retrievePropertiesMap(syncCursor);
        syncedNode = new NodeSyncPlaceHolder(properties);
      }
      CursorUtils.closeCursor(syncCursor);
    } catch (Exception e) {
      // Do Nothing
    }

    return syncedNode;
  }