syncTask.getResource(), syncTask.getResource().getConnector());
throw new JobExecutionException(msg, e);
}
UMapping uMapping = syncTask.getResource().getUmapping();
if (uMapping != null && uMapping.getAccountIdItem() == null) {
throw new JobExecutionException("Invalid user account id mapping for resource " + syncTask.getResource());
}
RMapping rMapping = syncTask.getResource().getRmapping();
if (rMapping != null && rMapping.getAccountIdItem() == null) {
throw new JobExecutionException("Invalid role account id mapping for resource " + syncTask.getResource());
}
if (uMapping == null && rMapping == null) {
return "No mapping configured for both users and roles: aborting...";
}
LOG.debug("Execute synchronization with token {}", syncTask.getResource().getUsyncToken());
final List<SyncResult> results = new ArrayList<SyncResult>();
final SyncPolicy syncPolicy = syncTask.getResource().getSyncPolicy();
final ConflictResolutionAction resAct = syncPolicy == null || syncPolicy.getSpecification() == null
? ConflictResolutionAction.IGNORE
: ((SyncPolicySpec) syncPolicy.getSpecification()).getConflictResolutionAction();
// Prepare handler for SyncDelta objects
final SyncopeSyncResultHandler handler =
(SyncopeSyncResultHandler) ((DefaultListableBeanFactory) ApplicationContextProvider.
getApplicationContext().getBeanFactory()).createBean(
SyncopeSyncResultHandler.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
handler.setConnector(connector);
handler.setActions(actions);
handler.setDryRun(dryRun);
handler.setResAct(resAct);
handler.setResults(results);
handler.setSyncTask(syncTask);
actions.beforeAll(handler);
try {
if (syncTask.isFullReconciliation()) {
if (uMapping != null) {
connector.getAllObjects(ObjectClass.ACCOUNT, handler,
connector.getOperationOptions(uMapping.getItems()));
}
if (rMapping != null) {
connector.getAllObjects(ObjectClass.GROUP, handler,
connector.getOperationOptions(rMapping.getItems()));
}
} else {
if (uMapping != null) {
connector.sync(ObjectClass.ACCOUNT, syncTask.getResource().getUsyncToken(), handler,
connector.getOperationOptions(uMapping.getItems()));
}
if (rMapping != null) {
connector.sync(ObjectClass.GROUP, syncTask.getResource().getRsyncToken(), handler,
connector.getOperationOptions(rMapping.getItems()));
}