log.fine("Checking for targets to synchronize...");
final Date thisSync = new Date();
try {
Iterator<SyncProcess> procs = db.getSyncProcesses();
while (procs.hasNext()) {
SyncProcess proc = procs.next();
try {
proc.unmarshall();
if (proc.isPullSynchronization()) {
continue;
}
proc.getSyncTarget().unmarshall();
proc.getRemoteApp().unmarshall();
log.info("Synchronizing process "+proc.getName()+": target="+proc.getSyncTarget().getName()+", app="+proc.getRemoteApp().getName());
PushSynchronizer push = new PushSynchronizer(log,db,storage,proc);
push.setSynchronizationAt(thisSync);
try {
push.sync();
} catch (TargetNotAvailableException ex) {
allOK.set(false);
log.warning(ex.getMessage());
} catch (SyncException ex) {
log.log(Level.SEVERE,"Failure to sync process "+proc.getName(),ex);
allOK.set(false);
}
log.info("Finished sync process "+proc.getName());
} catch (Exception ex) {
// No error should happen.. but hey...
log.log(Level.SEVERE,"Cannot unmarshall document.",ex);
continue;
}