@Test public void testIgnoredOnSystemCall() { TenantContext.setIsSystemCall(true); deltaJournal.journal("test", "userSession", false); verify(template, never()).upsert(any(Query.class), any(Update.class), anyString()); TenantContext.setIsSystemCall(false); }
public void journal(Collection<String> ids, String collection, boolean isDelete) { if ( collection.equals("applicationAuthorization") ) { return; } if (deltasEnabled && !TenantContext.isSystemCall()) { if (subdocCollectionsToCollapse.containsKey(collection)) { journalCollapsedSubDocs(ids, collection); } long now = new Date().getTime(); Update update = new Update(); update.set("t", now); update.set("c", collection); if (isDelete) { update.set("d", now); } else { update.set("u", now); } for (String id : ids) { List<byte[]> idbytes = getByteId(id); if(idbytes.size() > 1) { update.set("i", idbytes.subList(1, idbytes.size())); } template.upsert(Query.query(where("_id").is(idbytes.get(0))), update, DELTA_COLLECTION); } } }
DeltaJournal implements InitializingBean { public void journal(Collection<String> ids, String collection, boolean isDelete) { if ( collection.equals("applicationAuthorization") ) { return; } if (deltasEnabled && !TenantContext.isSystemCall()) { if (subdocCollectionsToCollapse.containsKey(collection)) { journalCollapsedSubDocs(ids, collection); } long now = new Date().getTime(); Update update = new Update(); update.set("t", now); update.set("c", collection); if (isDelete) { update.set("d", now); } else { update.set("u", now); } for (String id : ids) { List<byte[]> idbytes = getByteId(id); if(idbytes.size() > 1) { update.set("i", idbytes.subList(1, idbytes.size())); } template.upsert(Query.query(where("_id").is(idbytes.get(0))), update, DELTA_COLLECTION); } } } }
DeltaJournal implements InitializingBean { public void journal(Collection<String> ids, String collection, boolean isDelete) { if ( collection.equals("applicationAuthorization") ) { return; } if (deltasEnabled && !TenantContext.isSystemCall()) { if (subdocCollectionsToCollapse.containsKey(collection)) { journalCollapsedSubDocs(ids, collection); } long now = new Date().getTime(); Update update = new Update(); update.set("t", now); update.set("c", collection); if (isDelete) { update.set("d", now); } else { update.set("u", now); } for (String id : ids) { List<byte[]> idbytes = getByteId(id); if(idbytes.size() > 1) { update.set("i", idbytes.subList(1, idbytes.size())); } template.upsert(Query.query(where("_id").is(idbytes.get(0))), update, DELTA_COLLECTION); } } }  }
DeltaJournal implements InitializingBean { public void journal(Collection<String> ids, String collection, boolean isDelete) { if ( collection.equals("applicationAuthorization") ) { return; } if (deltasEnabled && !TenantContext.isSystemCall()) { if (subdocCollectionsToCollapse.containsKey(collection)) { journalCollapsedSubDocs(ids, collection); } long now = new Date().getTime(); Update update = new Update(); update.set("t", now); update.set("c", collection); if (isDelete) { update.set("d", now); } else { update.set("u", now); } for (String id : ids) { List<byte[]> idbytes = getByteId(id); if(idbytes.size() > 1) { update.set("i", idbytes.subList(1, idbytes.size())); } template.upsert(Query.query(where("_id").is(idbytes.get(0))), update, DELTA_COLLECTION); } } }  @Override void afterPropertiesSet(); void journal(Collection<String> ids, String collection, boolean isDelete); static List<byte[]> getByteId(String id); static String getEntityId(Map<String, Object> deltaRecord); void journal(String id, String collection, boolean isDelete); void journalCollapsedSubDocs(Collection<String> ids, String collection); void journalPurge(long timeOfPurge); Iterator<Map<String, Object>> findDeltaRecordBetween(final long start, final long end); void removeDeltaJournals(String tenant, long cleanUptoTime); }
DeltaJournal implements InitializingBean { public void journal(Collection<String> ids, String collection, boolean isDelete) { if ( collection.equals("applicationAuthorization") ) { return; } if (deltasEnabled && !TenantContext.isSystemCall()) { if (subdocCollectionsToCollapse.containsKey(collection)) { journalCollapsedSubDocs(ids, collection); } long now = new Date().getTime(); Update update = new Update(); update.set("t", now); update.set("c", collection); if (isDelete) { update.set("d", now); } else { update.set("u", now); } for (String id : ids) { List<byte[]> idbytes = getByteId(id); if(idbytes.size() > 1) { update.set("i", idbytes.subList(1, idbytes.size())); } template.upsert(Query.query(where("_id").is(idbytes.get(0))), update, DELTA_COLLECTION); } } }  @Override void afterPropertiesSet(); void journal(Collection<String> ids, String collection, boolean isDelete); static List<byte[]> getByteId(String id); static String getEntityId(Map<String, Object> deltaRecord); void journal(String id, String collection, boolean isDelete); void journalCollapsedSubDocs(Collection<String> ids, String collection); void journalPurge(long timeOfPurge); Iterator<Map<String, Object>> findDeltaRecordBetween(final long start, final long end); void removeDeltaJournals(String tenant, long cleanUptoTime); static final String DELTA_COLLECTION; static final String PURGE; }