[SYNCOPE-855] SyncToken management now more in line with ConnId's semantics


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/6a0a6ffb
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/6a0a6ffb
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/6a0a6ffb

Branch: refs/heads/master
Commit: 6a0a6ffb3dae2cae57679f278d965be0d65d0e30
Parents: c0a9566
Author: Francesco Chicchiriccò <[email protected]>
Authored: Tue May 24 16:34:35 2016 +0200
Committer: Francesco Chicchiriccò <[email protected]>
Committed: Tue May 24 16:34:35 2016 +0200

----------------------------------------------------------------------
 .../console/topology/TopologyTogglePanel.java   |  29 ++-
 .../wicket/markup/html/form/ActionLink.java     |   3 +-
 .../markup/html/form/ActionLinksPanel.java      |  36 +++-
 .../resources/ResourceProvisionPanel.java       |  35 +++-
 .../SyncopeConsoleApplication.properties        |   1 +
 .../SyncopeConsoleApplication_it.properties     |   1 +
 .../SyncopeConsoleApplication_pt_BR.properties  |   1 +
 .../SyncopeConsoleApplication_ru.properties     |   1 +
 .../console/topology/TopologyTogglePanel.html   |   1 +
 .../topology/TopologyTogglePanel.properties     |   1 +
 .../topology/TopologyTogglePanel_it.properties  |   1 +
 .../TopologyTogglePanel_pt_BR.properties        |   1 +
 .../topology/TopologyTogglePanel_ru.properties  |   1 +
 .../markup/html/form/ActionLinksPanel.html      |  11 +-
 .../syncope/common/lib/to/SchedTaskTO.java      |   2 +-
 .../rest/api/service/ResourceService.java       |  21 +++
 .../syncope/core/logic/ResourceLogic.java       |  47 +++++
 .../test/resources/domains/MasterContent.xml    |   4 +-
 .../api/pushpull/ProvisioningProfile.java       |   3 -
 .../provisioning/api/pushpull/PullActions.java  |  27 ++-
 .../api/pushpull/SyncopePullExecutor.java       |  27 +++
 .../api/pushpull/SyncopePullResultHandler.java  |   2 +
 .../java/data/ResourceDataBinderImpl.java       |   4 -
 .../pushpull/AbstractPullResultHandler.java     | 185 +++++++++++--------
 .../java/pushpull/DefaultPullActions.java       |  16 +-
 .../java/pushpull/PullJobDelegate.java          |  31 +++-
 .../rest/cxf/service/ResourceServiceImpl.java   |  10 +
 fit/build-tools/src/main/resources/testdb.sql   |   7 +-
 .../apache/syncope/fit/core/PullTaskITCase.java | 111 +++++++++--
 .../apache/syncope/fit/core/ResourceITCase.java |  46 +++--
 30 files changed, 495 insertions(+), 171 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
index 1edf3e7..5183dcb 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java
@@ -141,9 +141,28 @@ public class TopologyTogglePanel extends 
TogglePanel<Serializable> {
     }
 
     private Fragment getSyncopeFragment(final PageReference pageRef) {
-        final Fragment fragment = new Fragment("actions", "syncopeActions", 
this);
+        Fragment fragment = new Fragment("actions", "syncopeActions", this);
 
-        final AjaxLink<String> tasks = new IndicatingAjaxLink<String>("tasks") 
{
+        AjaxLink<String> reload = new 
IndicatingOnConfirmAjaxLink<String>("reload", "connectors.confirm.reload", 
true) {
+
+            private static final long serialVersionUID = -2075933173666007020L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target) {
+                try {
+                    connectorRestClient.reload();
+                    info(getString(Constants.OPERATION_SUCCEEDED));
+                } catch (Exception e) {
+                    LOG.error("While reloading all connectors", e);
+                    error(StringUtils.isBlank(e.getMessage()) ? 
e.getClass().getName() : e.getMessage());
+                }
+                
SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+            }
+        };
+        fragment.add(reload);
+        MetaDataRoleAuthorizationStrategy.authorize(reload, ENABLE, 
StandardEntitlement.CONNECTOR_RELOAD);
+
+        AjaxLink<String> tasks = new IndicatingAjaxLink<String>("tasks") {
 
             private static final long serialVersionUID = 3776750333491622263L;
 
@@ -155,16 +174,15 @@ public class TopologyTogglePanel extends 
TogglePanel<Serializable> {
             }
         };
         fragment.add(tasks);
-
         MetaDataRoleAuthorizationStrategy.authorize(tasks, ENABLE, 
StandardEntitlement.TASK_LIST);
 
         return fragment;
     }
 
     private Fragment getLocationFragment(final TopologyNode node, final 
PageReference pageRef) {
-        final Fragment fragment = new Fragment("actions", "locationActions", 
this);
+        Fragment fragment = new Fragment("actions", "locationActions", this);
 
-        final AjaxLink<String> create = new 
IndicatingAjaxLink<String>("create") {
+        AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {
 
             private static final long serialVersionUID = 3776750333491622263L;
 
@@ -188,7 +206,6 @@ public class TopologyTogglePanel extends 
TogglePanel<Serializable> {
             }
         };
         fragment.add(create);
-
         MetaDataRoleAuthorizationStrategy.authorize(create, ENABLE, 
StandardEntitlement.CONNECTOR_CREATE);
 
         return fragment;

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLink.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLink.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLink.java
index 6f22c0d..528fa03 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLink.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLink.java
@@ -42,7 +42,8 @@ public abstract class ActionLink<T extends Serializable> 
implements Serializable
 
         MAPPING("update"),
         MUSTCHANGEPASSWORD("update"),
-        RESET_TIME("update"),
+        SET_LATEST_SYNC_TOKEN("update"),
+        REMOVE_SYNC_TOKEN("update"),
         CLONE("create"),
         CREATE("create"),
         TEMPLATE("read"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.java
index 73fd25a..1e153d8 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.java
@@ -57,7 +57,8 @@ public final class ActionLinksPanel<T extends Serializable> 
extends Panel {
         super.add(new Fragment("panelManageGroups", "emptyFragment", this));
         super.add(new Fragment("panelMapping", "emptyFragment", this));
         super.add(new Fragment("panelMustChangePassword", "emptyFragment", 
this));
-        super.add(new Fragment("panelResetTime", "emptyFragment", this));
+        super.add(new Fragment("panelSetLatestSyncToken", "emptyFragment", 
this));
+        super.add(new Fragment("panelRemoveSyncToken", "emptyFragment", this));
         super.add(new Fragment("panelClone", "emptyFragment", this));
         super.add(new Fragment("panelCreate", "emptyFragment", this));
         super.add(new Fragment("panelTemplate", "emptyFragment", this));
@@ -224,10 +225,29 @@ public final class ActionLinksPanel<T extends 
Serializable> extends Panel {
                 }.setVisible(link.isEnabled(model.getObject())));
                 break;
 
-            case RESET_TIME:
-                fragment = new Fragment("panelResetTime", "fragmentResetTime", 
this);
+            case SET_LATEST_SYNC_TOKEN:
+                fragment = new Fragment("panelSetLatestSyncToken", 
"fragmentSetLatestSyncToken", this);
 
-                fragment.addOrReplace(new 
IndicatingAjaxLink<Void>("resetTimeLink") {
+                fragment.addOrReplace(new 
IndicatingAjaxLink<Void>("setLatestSyncTokenLink") {
+
+                    private static final long serialVersionUID = 
-1876519166660008562L;
+
+                    @Override
+                    public void onClick(final AjaxRequestTarget target) {
+                        link.onClick(target, model.getObject());
+                    }
+
+                    @Override
+                    public String getAjaxIndicatorMarkupId() {
+                        return disableIndicator ? StringUtils.EMPTY : 
super.getAjaxIndicatorMarkupId();
+                    }
+                }.setVisible(link.isEnabled(model.getObject())));
+                break;
+
+            case REMOVE_SYNC_TOKEN:
+                fragment = new Fragment("panelRemoveSyncToken", 
"fragmentRemoveSyncToken", this);
+
+                fragment.addOrReplace(new 
IndicatingAjaxLink<Void>("removeSyncTokenLink") {
 
                     private static final long serialVersionUID = 
-7978723352517770644L;
 
@@ -1032,8 +1052,12 @@ public final class ActionLinksPanel<T extends 
Serializable> extends Panel {
                 super.addOrReplace(new Fragment("panelMustChangePassword", 
"emptyFragment", this));
                 break;
 
-            case RESET_TIME:
-                super.addOrReplace(new Fragment("panelResetTime", 
"emptyFragment", this));
+            case SET_LATEST_SYNC_TOKEN:
+                super.addOrReplace(new Fragment("panelSetLatestSyncToken", 
"emptyFragment", this));
+                break;
+
+            case REMOVE_SYNC_TOKEN:
+                super.addOrReplace(new Fragment("panelRemoveSyncToken", 
"emptyFragment", this));
                 break;
 
             case CLONE:

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
index a492269..4456d57 100644
--- 
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
+++ 
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/resources/ResourceProvisionPanel.java
@@ -40,6 +40,7 @@ import org.apache.syncope.common.lib.to.MappingItemTO;
 import org.apache.syncope.common.lib.to.ProvisionTO;
 import org.apache.syncope.common.lib.to.ResourceTO;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
+import org.apache.syncope.common.rest.api.service.ResourceService;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.event.Broadcast;
@@ -106,14 +107,40 @@ public class ResourceProvisionPanel extends 
AbstractModalPanel<Serializable> {
                 }, ActionLink.ActionType.MAPPING, 
StandardEntitlement.RESOURCE_UPDATE).
                 addAction(new ActionLink<ProvisionTO>() {
 
-                    private static final long serialVersionUID = 
-3722207913631435524L;
+                    private static final long serialVersionUID = 
-7780999687733432439L;
 
                     @Override
                     public void onClick(final AjaxRequestTarget target, final 
ProvisionTO provisionTO) {
-                        provisionTO.setSyncToken(null);
-                        send(ResourceProvisionPanel.this, Broadcast.DEPTH, new 
ListViewPanel.ListViewReload(target));
+                        try {
+                            
SyncopeConsoleSession.get().getService(ResourceService.class).
+                                    setLatestSyncToken(resourceTO.getKey(), 
provisionTO.getAnyType());
+                            info(getString(Constants.OPERATION_SUCCEEDED));
+                        } catch (Exception e) {
+                            LOG.error("While setting latest sync token for 
{}/{}",
+                                    resourceTO.getKey(), 
provisionTO.getAnyType(), e);
+                            error(StringUtils.isBlank(e.getMessage()) ? 
e.getClass().getName() : e.getMessage());
+                        }
+                        
SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
+                    }
+                }, ActionLink.ActionType.SET_LATEST_SYNC_TOKEN, 
StandardEntitlement.RESOURCE_UPDATE).
+                addAction(new ActionLink<ProvisionTO>() {
+
+                    private static final long serialVersionUID = 
-7780999687733432439L;
+
+                    @Override
+                    public void onClick(final AjaxRequestTarget target, final 
ProvisionTO provisionTO) {
+                        try {
+                            
SyncopeConsoleSession.get().getService(ResourceService.class).
+                                    removeSyncToken(resourceTO.getKey(), 
provisionTO.getAnyType());
+                            info(getString(Constants.OPERATION_SUCCEEDED));
+                        } catch (Exception e) {
+                            LOG.error("While removing sync token for {}/{}",
+                                    resourceTO.getKey(), 
provisionTO.getAnyType(), e);
+                            error(StringUtils.isBlank(e.getMessage()) ? 
e.getClass().getName() : e.getMessage());
+                        }
+                        
SyncopeConsoleSession.get().getNotificationPanel().refresh(target);
                     }
-                }, ActionLink.ActionType.RESET_TIME, 
StandardEntitlement.RESOURCE_UPDATE).
+                }, ActionLink.ActionType.REMOVE_SYNC_TOKEN, 
StandardEntitlement.RESOURCE_UPDATE).
                 addAction(new ActionLink<ProvisionTO>() {
 
                     private static final long serialVersionUID = 
-3722207913631435534L;

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication.properties
index dba9d59..0214cf6 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication.properties
@@ -72,3 +72,4 @@ OrderByLink.CSS.descending=sorting_desc
 OrderByLink.CSS.none=sorting
 entitlements=Entitlements
 audit=Audit
+connectors.confirm.reload=This request is potentially dangerous for running 
operations, continue?

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_it.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_it.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_it.properties
index 597b625..abc0782 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_it.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_it.properties
@@ -71,3 +71,4 @@ OrderByLink.CSS.descending=sorting_desc
 OrderByLink.CSS.none=sorting
 entitlements=Entitlement
 audit=Audit
+connectors.confirm.reload=Questa richiesta \u00e8 potenzialmente dannosa per 
le operazioni in corso, proseguire?

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_pt_BR.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_pt_BR.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_pt_BR.properties
index a43dfb6..9214454 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_pt_BR.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_pt_BR.properties
@@ -71,3 +71,4 @@ OrderByLink.CSS.descending=sorting_desc
 OrderByLink.CSS.none=sorting
 entitlements=Entitlement
 audit=Audit
+connectors.confirm.reload=Esta requis\u00e7\u00e3o \u00e9 potencialmente 
perigosa para opera\u00e7\u00f5es em execu\u00e7\u00e3o, prosseguir?

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_ru.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_ru.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_ru.properties
index 799a716..0b76c8a 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_ru.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/SyncopeConsoleApplication_ru.properties
@@ -122,3 +122,4 @@ 
OrderByLink.CSS.none=\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043
 # 
entitlements=\u00d0\u009f\u00d0\u00be\u00d0\u00bb\u00d0\u00bd\u00d0\u00be\u00d0\u00bc\u00d0\u00be\u00d1\u0087\u00d0\u00b8\u00d1\u008f
 entitlements=\u041f\u043e\u043b\u043d\u043e\u043c\u043e\u0447\u0438\u044f
 audit=Audit
+connectors.confirm.reload=This request is potentially dangerous for running 
operations, continue?

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.html
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.html
 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.html
index 5eb7db0..c295894 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.html
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.html
@@ -50,6 +50,7 @@ under the License.
 
     <wicket:fragment wicket:id="syncopeActions">
       <ul class="menu">
+        <li><i class="fa fa-refresh"></i><a href="#" 
wicket:id="reload"><wicket:message key="connectors.reload"/></a></li>
         <li><i class="fa fa-tasks"></i><a href="#" 
wicket:id="tasks"><wicket:message key="task.custom.list"/></a></li>
       </ul>
     </wicket:fragment>

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.properties
index cf6482d..e46c1ce 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel.properties
@@ -33,3 +33,4 @@ task.propagation.list=Propagation tasks
 task.pull.list=Pull tasks
 task.push.list=Push tasks
 resource.explore.list=Explore ${key}
+connectors.reload=Reload all connectors

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_it.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_it.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_it.properties
index d83598b..0482bd4 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_it.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_it.properties
@@ -33,3 +33,4 @@ task.propagation.list=Task di propagazione
 task.pull.list=Pull task
 task.push.list=Push task
 resource.explore.list=Esplora ${key}
+connectors.reload=Ricarica tutti i connettori

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_pt_BR.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_pt_BR.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_pt_BR.properties
index 7608438..753e230 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_pt_BR.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_pt_BR.properties
@@ -33,3 +33,4 @@ task.propagation.list=Propagation tasks
 task.pull.list=Pull tasks
 task.push.list=Push tasks
 resource.explore.list=Explorar ${key}
+connectors.reload=Reload all connectors

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_ru.properties
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_ru.properties
 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_ru.properties
index 161d803..e400313 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_ru.properties
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/topology/TopologyTogglePanel_ru.properties
@@ -52,3 +52,4 @@ task.pull.list=\u0417\u0430\u0434\u0430\u0447\u0438 
\u043f\u043e\u043b\u0443\u04
 task.push.list=\u0417\u0430\u0434\u0430\u0447\u0438 
\u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 
\u0434\u0430\u043d\u043d\u044b\u0445
 # 
resource.explore.list=\u00d0\u009f\u00d1\u0080\u00d0\u00be\u00d1\u0081\u00d0\u00bc\u00d0\u00be\u00d1\u0082\u00d1\u0080
 ${key}
 resource.explore.list=\u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 ${key}
+connectors.reload=Reload all connectors

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.html
----------------------------------------------------------------------
diff --git 
a/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.html
 
b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.html
index bb9176a..c9a8aa7 100644
--- 
a/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.html
+++ 
b/client/console/src/main/resources/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksPanel.html
@@ -38,7 +38,8 @@ under the License.
     <span wicket:id="panelNotFound">[plus]</span>
     <span wicket:id="panelView">[plus]</span>
     <span wicket:id="panelMapping">[plus]</span>
-    <span wicket:id="panelResetTime">[plus]</span>
+    <span wicket:id="panelSetLatestSyncToken">[plus]</span>
+    <span wicket:id="panelRemoveSyncToken">[plus]</span>
     <span wicket:id="panelClone">[plus]</span>
     <span wicket:id="panelCreate">[plus]</span>
     <span wicket:id="panelReset">[plus]</span>
@@ -98,8 +99,12 @@ under the License.
       <a href="#" wicket:id="mappingLink" class="btn"><i class="fa 
fa-exchange" alt="mapping icon" title="Mapping"></i></a>
     </wicket:fragment>
 
-    <wicket:fragment wicket:id="fragmentResetTime">
-      <a href="#" wicket:id="resetTimeLink" class="btn"><i class="fa 
fa-hourglass-start" alt="reset time icon" title="Reset Time"></i></a>
+    <wicket:fragment wicket:id="fragmentSetLatestSyncToken">
+      <a href="#" wicket:id="setLatestSyncTokenLink" class="btn"><i class="fa 
fa-hourglass-start" alt="reset time icon" title="Set latest Sync Token"></i></a>
+    </wicket:fragment>
+
+    <wicket:fragment wicket:id="fragmentRemoveSyncToken">
+      <a href="#" wicket:id="removeSyncTokenLink" class="btn"><i class="fa 
fa-hourglass-o" alt="reset time icon" title="Remove Sync Token"></i></a>
     </wicket:fragment>
 
     <wicket:fragment wicket:id="fragmentClone">

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchedTaskTO.java
----------------------------------------------------------------------
diff --git 
a/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchedTaskTO.java 
b/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchedTaskTO.java
index 3fab961..90748ec 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchedTaskTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchedTaskTO.java
@@ -45,7 +45,7 @@ public class SchedTaskTO extends AbstractTaskTO {
 
     private Date nextExec;
 
-    private boolean active;
+    private boolean active = true;
 
     public Date getStartAt() {
         return startAt == null ? null : new Date(startAt.getTime());

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
----------------------------------------------------------------------
diff --git 
a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
 
b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
index 6fa1e82..0de2619 100644
--- 
a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
+++ 
b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ResourceService.java
@@ -119,6 +119,27 @@ public interface ResourceService extends JAXRSService {
     void update(@NotNull ResourceTO resourceTO);
 
     /**
+     * Queries the connector underlying the given resource for the latest sync 
token value associated to the given any
+     * type and stores the value internally, for later usage.
+     *
+     * @param key resource
+     * @param anyTypeKey any type
+     */
+    @POST
+    @Path("{key}/{anyTypeKey}")
+    void setLatestSyncToken(@NotNull @PathParam("key") String key, @NotNull 
@PathParam("anyTypeKey") String anyTypeKey);
+
+    /**
+     * Removes the sync token value associated to the given any type from the 
given resource.
+     *
+     * @param key resource
+     * @param anyTypeKey any type
+     */
+    @DELETE
+    @Path("{key}/{anyTypeKey}")
+    void removeSyncToken(@NotNull @PathParam("key") String key, @NotNull 
@PathParam("anyTypeKey") String anyTypeKey);
+
+    /**
      * Deletes the resource matching the given name.
      *
      * @param key name of resource to be deleted

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
----------------------------------------------------------------------
diff --git 
a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java 
b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
index 5c2dad4..e95e0b9 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ResourceLogic.java
@@ -157,6 +157,53 @@ public class ResourceLogic extends 
AbstractTransactionalLogic<ResourceTO> {
         return binder.getResourceTO(resource);
     }
 
+    @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')")
+    public void setLatestSyncToken(final String key, final String anyTypeKey) {
+        ExternalResource resource = resourceDAO.find(key);
+        if (resource == null) {
+            throw new NotFoundException("Resource '" + key + "'");
+        }
+        AnyType anyType = anyTypeDAO.find(anyTypeKey);
+        if (anyType == null) {
+            throw new NotFoundException("AnyType '" + anyTypeKey + "'");
+        }
+        Provision provision = resource.getProvision(anyType);
+        if (provision == null) {
+            throw new NotFoundException("Provision for AnyType '" + anyTypeKey 
+ "' in Resource '" + key + "'");
+        }
+
+        Connector connector;
+        try {
+            connector = connFactory.getConnector(resource);
+        } catch (Exception e) {
+            SyncopeClientException sce = 
SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
+            sce.getElements().add(e.getMessage());
+            throw sce;
+        }
+
+        
provision.setSyncToken(connector.getLatestSyncToken(provision.getObjectClass()));
+        resourceDAO.save(resource);
+    }
+
+    @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_UPDATE + "')")
+    public void removeSyncToken(final String key, final String anyTypeKey) {
+        ExternalResource resource = resourceDAO.find(key);
+        if (resource == null) {
+            throw new NotFoundException("Resource '" + key + "'");
+        }
+        AnyType anyType = anyTypeDAO.find(anyTypeKey);
+        if (anyType == null) {
+            throw new NotFoundException("AnyType '" + anyTypeKey + "'");
+        }
+        Provision provision = resource.getProvision(anyType);
+        if (provision == null) {
+            throw new NotFoundException("Provision for AnyType '" + anyTypeKey 
+ "' in Resource '" + key + "'");
+        }
+
+        provision.setSyncToken(null);
+        resourceDAO.save(resource);
+    }
+
     @PreAuthorize("hasRole('" + StandardEntitlement.RESOURCE_DELETE + "')")
     public ResourceTO delete(final String resourceName) {
         ExternalResource resource = resourceDAO.find(resourceName);

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml 
b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index 3ab369f..0f8536c 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -1082,10 +1082,10 @@ under the License.
   <AnyTemplatePullTask id="9af0e343-8a37-42d2-9bc7-6e2e3b103219" 
pullTask_id="986867e2-993b-430e-8feb-aa9abb4c1dcd" anyType_id="GROUP"
                        
template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":null,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
   <Task DTYPE="PullTask" id="feae4e57-15ca-40d9-b973-8b9015efca49" name="CSV 
(unlink matching; ignore unmatching)" resource_id="resource-csv"
-        destinationRealm_id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" 
performCreate="1" performUpdate="1" performDelete="1" pullStatus="1" 
pullMode="INCREMENTAL"
+        destinationRealm_id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" 
performCreate="1" performUpdate="1" performDelete="1" pullStatus="1" 
pullMode="FULL_RECONCILIATION"
         unmatchingRule="IGNORE" matchingRule="UNLINK" active="1"/>
   <Task DTYPE="PullTask" id="55d5e74b-497e-4bc0-9156-73abef4b9adc" name="CSV 
(ignore matching; assign unmatching)" resource_id="resource-csv"
-        destinationRealm_id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" 
performCreate="1" performUpdate="1" performDelete="1" pullStatus="1" 
pullMode="INCREMENTAL"
+        destinationRealm_id="e4c28e7a-9dbf-4ee7-9441-93812a0d4a28" 
performCreate="1" performUpdate="1" performDelete="1" pullStatus="1" 
pullMode="FULL_RECONCILIATION"
         unmatchingRule="ASSIGN" matchingRule="IGNORE" active="1"/>
   <Task DTYPE="PropagationTask" id="0f618183-17ce-48bc-80bc-cc535f38983a" 
operation="CREATE"
         objectClassName="__ACCOUNT__" resource_id="resource-testdb" 
anyTypeKind="USER" anyKey="1417acbe-cbf6-4277-9372-e75e04f97000"

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
index 517908d..83eb098 100644
--- 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
+++ 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
@@ -27,9 +27,6 @@ import org.apache.syncope.core.provisioning.api.Connector;
 
 public class ProvisioningProfile<T extends ProvisioningTask, A extends 
ProvisioningActions> {
 
-    /**
-     * Syncing connector.
-     */
     private final Connector connector;
 
     private final T task;

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullActions.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullActions.java
 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullActions.java
index c042ec7..bb145c5 100644
--- 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullActions.java
+++ 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullActions.java
@@ -169,35 +169,34 @@ public interface PullActions extends ProvisioningActions {
             A any) throws JobExecutionException;
 
     /**
-     * Action to be executed when user / group pull goes on error.
+     * Action to be executed after each local user / group pull.
      *
+     * @param <A> concrete any object
      * @param profile profile of the pull being executed.
-     * @param delta retrieved pull information (may be modified by
-     * 'beforeProvision/beforeUpdate/beforeDelete')
+     * @param delta retrieved pull information (may be modified by 
beforeProvision / beforeUpdate /
+     * beforeDelete)
+     * @param any any object
      * @param result global pull results at the current pull step
-     * @param error error being reported
      * @throws JobExecutionException in case of generic failure
      */
-    void onError(
+    <A extends AnyTO> void after(
             ProvisioningProfile<?, ?> profile,
             SyncDelta delta,
-            ProvisioningReport result,
-            Exception error) throws JobExecutionException;
+            A any,
+            ProvisioningReport result) throws JobExecutionException;
 
     /**
-     * Action to be executed after each local user / group pull.
+     * Action to be executed in case an exception is thrown during pull.
      *
-     * @param <A> concrete any object
      * @param profile profile of the pull being executed.
      * @param delta retrieved pull information (may be modified by 
beforeProvision / beforeUpdate /
      * beforeDelete)
-     * @param any any object
-     * @param result global pull results at the current pull step
+     * @param e the exception thrown
+     * @return an instance of the given exception type is that is to be 
thrown; {@code NULL} otherwise
      * @throws JobExecutionException in case of generic failure
      */
-    <A extends AnyTO> void after(
+    IgnoreProvisionException onError(
             ProvisioningProfile<?, ?> profile,
             SyncDelta delta,
-            A any,
-            ProvisioningReport result) throws JobExecutionException;
+            Exception e) throws JobExecutionException;
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullExecutor.java
 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullExecutor.java
new file mode 100644
index 0000000..ab02282
--- /dev/null
+++ 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullExecutor.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.api.pushpull;
+
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.SyncToken;
+
+public interface SyncopePullExecutor {
+
+    void setLatestSyncToken(ObjectClass objectClass, SyncToken 
latestSyncToken);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullResultHandler.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullResultHandler.java
 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullResultHandler.java
index aa99468..8d8efc4 100644
--- 
a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullResultHandler.java
+++ 
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/SyncopePullResultHandler.java
@@ -24,6 +24,8 @@ import 
org.apache.syncope.core.persistence.api.entity.task.PullTask;
 
 public interface SyncopePullResultHandler extends 
SyncopeResultHandler<PullTask, PullActions>, SyncResultsHandler {
 
+    void setPullExecutor(SyncopePullExecutor executor);
+
     @Override
     boolean handle(SyncDelta delta);
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
index 5cfe729..e09972f 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/ResourceDataBinderImpl.java
@@ -153,10 +153,6 @@ public class ResourceDataBinderImpl implements 
ResourceDataBinder {
                     }
                 }
 
-                if (provisionTO.getSyncToken() == null) {
-                    provision.setSyncToken(null);
-                }
-
                 if (provisionTO.getMapping() == null) {
                     provision.setMapping(null);
                 } else {

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
index b111710..e8aaacf 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
@@ -31,6 +31,7 @@ import 
org.apache.syncope.common.lib.types.AuditElements.Result;
 import org.apache.syncope.common.lib.types.MatchingRule;
 import org.apache.syncope.common.lib.types.PatchOperation;
 import org.apache.syncope.common.lib.types.PropagationByResource;
+import org.apache.syncope.common.lib.types.PullMode;
 import org.apache.syncope.common.lib.types.ResourceOperation;
 import org.apache.syncope.common.lib.types.UnmatchingRule;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
@@ -40,20 +41,21 @@ import 
org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
 import org.apache.syncope.core.persistence.api.entity.AnyUtils;
 import org.apache.syncope.core.persistence.api.entity.VirSchema;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
+import org.apache.syncope.core.persistence.api.entity.task.PullTask;
 import org.apache.syncope.core.provisioning.api.ProvisioningManager;
 import org.apache.syncope.core.provisioning.api.cache.VirAttrCache;
 import org.apache.syncope.core.provisioning.api.cache.VirAttrCacheValue;
 import 
org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException;
 import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport;
+import org.apache.syncope.core.provisioning.api.pushpull.PullActions;
+import org.apache.syncope.core.provisioning.api.pushpull.SyncopePullExecutor;
+import 
org.apache.syncope.core.provisioning.api.pushpull.SyncopePullResultHandler;
 import org.identityconnectors.framework.common.objects.Attribute;
 import org.identityconnectors.framework.common.objects.SyncDelta;
 import org.identityconnectors.framework.common.objects.SyncDeltaType;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.apache.syncope.core.persistence.api.entity.task.PullTask;
-import 
org.apache.syncope.core.provisioning.api.pushpull.SyncopePullResultHandler;
-import org.apache.syncope.core.provisioning.api.pushpull.PullActions;
 
 @Transactional(rollbackFor = Throwable.class)
 public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHandler<PullTask, PullActions>
@@ -68,6 +70,10 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
     @Autowired
     protected VirAttrCache virAttrCache;
 
+    protected SyncopePullExecutor executor;
+
+    protected Result latestResult = null;
+
     protected abstract String getName(AnyTO anyTO);
 
     protected abstract ProvisioningManager<?, ?> getProvisioningManager();
@@ -122,6 +128,11 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
     }
 
     @Override
+    public void setPullExecutor(final SyncopePullExecutor executor) {
+        this.executor = executor;
+    }
+
+    @Override
     public boolean handle(final SyncDelta delta) {
         Provision provision = null;
         try {
@@ -132,21 +143,40 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
             }
 
             doHandle(delta, provision);
-            return true;
+
+            LOG.debug("Successfully handled {}", delta);
+
+            if (profile.getTask().getPullMode() != PullMode.INCREMENTAL) {
+                return true;
+            }
+
+            boolean shouldContinue;
+            synchronized (this) {
+                shouldContinue = latestResult == Result.SUCCESS;
+                this.latestResult = null;
+            }
+            if (shouldContinue) {
+                executor.setLatestSyncToken(delta.getObjectClass(), 
delta.getToken());
+            }
+            return shouldContinue;
         } catch (IgnoreProvisionException e) {
-            ProvisioningReport result = new ProvisioningReport();
-            result.setOperation(ResourceOperation.NONE);
-            result.setAnyType(provision == null
+            ProvisioningReport ignoreResult = new ProvisioningReport();
+            ignoreResult.setOperation(ResourceOperation.NONE);
+            ignoreResult.setAnyType(provision == null
                     ? getAnyUtils().getAnyTypeKind().name() : 
provision.getAnyType().getKey());
-            result.setStatus(ProvisioningReport.Status.IGNORE);
-            result.setKey(null);
-            result.setName(delta.getObject().getName().getNameValue());
-            profile.getResults().add(result);
+            ignoreResult.setStatus(ProvisioningReport.Status.IGNORE);
+            ignoreResult.setKey(null);
+            ignoreResult.setName(delta.getObject().getName().getNameValue());
+            profile.getResults().add(ignoreResult);
 
             LOG.warn("Ignoring during pull", e);
+
+            executor.setLatestSyncToken(delta.getObjectClass(), 
delta.getToken());
+
             return true;
         } catch (JobExecutionException e) {
             LOG.error("Pull failed", e);
+
             return false;
         }
     }
@@ -175,7 +205,7 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
         } else {
             SyncDelta actionedDelta = delta;
             for (PullActions action : profile.getActions()) {
-                actionedDelta = action.beforeAssign(this.getProfile(), 
actionedDelta, anyTO);
+                actionedDelta = action.beforeAssign(profile, actionedDelta, 
anyTO);
             }
 
             create(anyTO, actionedDelta, 
UnmatchingRule.toEventName(UnmatchingRule.ASSIGN), result);
@@ -206,7 +236,7 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
         } else {
             SyncDelta actionedDelta = delta;
             for (PullActions action : profile.getActions()) {
-                actionedDelta = action.beforeProvision(this.getProfile(), 
actionedDelta, anyTO);
+                actionedDelta = action.beforeProvision(profile, actionedDelta, 
anyTO);
             }
 
             create(anyTO, actionedDelta, 
UnmatchingRule.toEventName(UnmatchingRule.PROVISION), result);
@@ -215,7 +245,25 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
         return Collections.singletonList(result);
     }
 
-    private void create(
+    protected void throwIgnoreProvisionException(final SyncDelta delta, final 
Exception exception)
+            throws JobExecutionException {
+
+        if (exception instanceof IgnoreProvisionException) {
+            throw IgnoreProvisionException.class.cast(exception);
+        }
+
+        IgnoreProvisionException ipe = null;
+        for (PullActions action : profile.getActions()) {
+            if (ipe == null) {
+                ipe = action.onError(profile, delta, exception);
+            }
+        }
+        if (ipe != null) {
+            throw ipe;
+        }
+    }
+
+    protected void create(
             final AnyTO anyTO,
             final SyncDelta delta,
             final String operation,
@@ -232,33 +280,27 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
             resultStatus = Result.SUCCESS;
 
             for (PullActions action : profile.getActions()) {
-                action.after(this.getProfile(), delta, actual, result);
+                action.after(profile, delta, actual, result);
             }
-        } catch (IgnoreProvisionException e) {
-            throw e;
+
+            LOG.debug("{} {} successfully created", actual.getType(), 
actual.getKey());
         } catch (PropagationException e) {
             // A propagation failure doesn't imply a pull failure.
             // The propagation exception status will be reported into the 
propagation task execution.
             LOG.error("Could not propagate {} {}", anyTO.getType(), 
delta.getUid().getUidValue(), e);
             output = e;
             resultStatus = Result.FAILURE;
-
-            for (PullActions action : profile.getActions()) {
-                action.onError(this.getProfile(), delta, result, e);
-            }
         } catch (Exception e) {
+            throwIgnoreProvisionException(delta, e);
+
             result.setStatus(ProvisioningReport.Status.FAILURE);
             result.setMessage(ExceptionUtils.getRootCauseMessage(e));
             LOG.error("Could not create {} {} ", anyTO.getType(), 
delta.getUid().getUidValue(), e);
             output = e;
             resultStatus = Result.FAILURE;
-
-            for (PullActions action : profile.getActions()) {
-                action.onError(this.getProfile(), delta, result, e);
-            }
         }
 
-        audit(operation, resultStatus, null, output, delta);
+        finalize(operation, resultStatus, null, output, delta);
     }
 
     protected List<ProvisioningReport> update(
@@ -308,21 +350,20 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                                 getAnyUtils());
 
                         for (PullActions action : profile.getActions()) {
-                            workingDelta = 
action.beforeUpdate(this.getProfile(), workingDelta, before, anyPatch);
+                            workingDelta = action.beforeUpdate(profile, 
workingDelta, before, anyPatch);
                         }
 
                         AnyTO updated = doUpdate(before, anyPatch, 
workingDelta, result);
 
                         for (PullActions action : profile.getActions()) {
-                            action.after(this.getProfile(), workingDelta, 
updated, result);
+                            action.after(profile, workingDelta, updated, 
result);
                         }
 
                         output = updated;
                         resultStatus = Result.SUCCESS;
                         result.setName(getName(updated));
+
                         LOG.debug("{} {} successfully updated", 
provision.getAnyType().getKey(), key);
-                    } catch (IgnoreProvisionException e) {
-                        throw e;
                     } catch (PropagationException e) {
                         // A propagation failure doesn't imply a pull failure.
                         // The propagation exception status will be reported 
into the propagation task execution.
@@ -330,24 +371,18 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                                 provision.getAnyType().getKey(), 
workingDelta.getUid().getUidValue(), e);
                         output = e;
                         resultStatus = Result.FAILURE;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), workingDelta, 
result, e);
-                        }
                     } catch (Exception e) {
+                        throwIgnoreProvisionException(delta, e);
+
                         result.setStatus(ProvisioningReport.Status.FAILURE);
                         
result.setMessage(ExceptionUtils.getRootCauseMessage(e));
                         LOG.error("Could not update {} {}",
                                 provision.getAnyType().getKey(), 
workingDelta.getUid().getUidValue(), e);
                         output = e;
                         resultStatus = Result.FAILURE;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), workingDelta, 
result, e);
-                        }
                     }
                 }
-                audit(MatchingRule.toEventName(MatchingRule.UPDATE), 
resultStatus, before, output, workingDelta);
+                finalize(MatchingRule.toEventName(MatchingRule.UPDATE), 
resultStatus, before, output, workingDelta);
             }
             results.add(result);
         }
@@ -399,11 +434,11 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                     try {
                         if (unlink) {
                             for (PullActions action : profile.getActions()) {
-                                action.beforeUnassign(this.getProfile(), 
delta, before);
+                                action.beforeUnassign(profile, delta, before);
                             }
                         } else {
                             for (PullActions action : profile.getActions()) {
-                                action.beforeDeprovision(this.getProfile(), 
delta, before);
+                                action.beforeDeprovision(profile, delta, 
before);
                             }
                         }
 
@@ -411,13 +446,12 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                         output = getAnyTO(key);
 
                         for (PullActions action : profile.getActions()) {
-                            action.after(this.getProfile(), delta, 
AnyTO.class.cast(output), result);
+                            action.after(profile, delta, 
AnyTO.class.cast(output), result);
                         }
 
                         resultStatus = Result.SUCCESS;
+
                         LOG.debug("{} {} successfully updated", 
provision.getAnyType().getKey(), key);
-                    } catch (IgnoreProvisionException e) {
-                        throw e;
                     } catch (PropagationException e) {
                         // A propagation failure doesn't imply a pull failure.
                         // The propagation exception status will be reported 
into the propagation task execution.
@@ -425,24 +459,18 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                                 provision.getAnyType().getKey(), 
delta.getUid().getUidValue(), e);
                         output = e;
                         resultStatus = Result.FAILURE;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), delta, result, 
e);
-                        }
                     } catch (Exception e) {
+                        throwIgnoreProvisionException(delta, e);
+
                         result.setStatus(ProvisioningReport.Status.FAILURE);
                         
result.setMessage(ExceptionUtils.getRootCauseMessage(e));
                         LOG.error("Could not update {} {}",
                                 provision.getAnyType().getKey(), 
delta.getUid().getUidValue(), e);
                         output = e;
                         resultStatus = Result.FAILURE;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), delta, result, 
e);
-                        }
                     }
                 }
-                audit(unlink
+                finalize(unlink
                         ? MatchingRule.toEventName(MatchingRule.UNASSIGN)
                         : MatchingRule.toEventName(MatchingRule.DEPROVISION), 
resultStatus, before, output, delta);
             }
@@ -497,24 +525,23 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                     try {
                         if (unlink) {
                             for (PullActions action : profile.getActions()) {
-                                action.beforeUnlink(this.getProfile(), delta, 
before);
+                                action.beforeUnlink(profile, delta, before);
                             }
                         } else {
                             for (PullActions action : profile.getActions()) {
-                                action.beforeLink(this.getProfile(), delta, 
before);
+                                action.beforeLink(profile, delta, before);
                             }
                         }
 
                         output = doLink(before, unlink);
 
                         for (PullActions action : profile.getActions()) {
-                            action.after(this.getProfile(), delta, 
AnyTO.class.cast(output), result);
+                            action.after(profile, delta, 
AnyTO.class.cast(output), result);
                         }
 
                         resultStatus = Result.SUCCESS;
+
                         LOG.debug("{} {} successfully updated", 
provision.getAnyType().getKey(), key);
-                    } catch (IgnoreProvisionException e) {
-                        throw e;
                     } catch (PropagationException e) {
                         // A propagation failure doesn't imply a pull failure.
                         // The propagation exception status will be reported 
into the propagation task execution.
@@ -522,24 +549,18 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                                 provision.getAnyType().getKey(), 
delta.getUid().getUidValue(), e);
                         output = e;
                         resultStatus = Result.FAILURE;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), delta, result, 
e);
-                        }
                     } catch (Exception e) {
+                        throwIgnoreProvisionException(delta, e);
+
                         result.setStatus(ProvisioningReport.Status.FAILURE);
                         
result.setMessage(ExceptionUtils.getRootCauseMessage(e));
                         LOG.error("Could not update {} {}",
                                 provision.getAnyType().getKey(), 
delta.getUid().getUidValue(), e);
                         output = e;
                         resultStatus = Result.FAILURE;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), delta, result, 
e);
-                        }
                     }
                 }
-                audit(unlink ? MatchingRule.toEventName(MatchingRule.UNLINK)
+                finalize(unlink ? MatchingRule.toEventName(MatchingRule.UNLINK)
                         : MatchingRule.toEventName(MatchingRule.LINK), 
resultStatus, before, output, delta);
             }
             updResults.add(result);
@@ -581,7 +602,7 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
 
                 if (!profile.isDryRun()) {
                     for (PullActions action : profile.getActions()) {
-                        workingDelta = action.beforeDelete(this.getProfile(), 
workingDelta, before);
+                        workingDelta = action.beforeDelete(profile, 
workingDelta, before);
                     }
 
                     try {
@@ -590,22 +611,18 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                         resultStatus = Result.SUCCESS;
 
                         for (PullActions action : profile.getActions()) {
-                            action.after(this.getProfile(), workingDelta, 
before, result);
+                            action.after(profile, workingDelta, before, 
result);
                         }
-                    } catch (IgnoreProvisionException e) {
-                        throw e;
                     } catch (Exception e) {
+                        throwIgnoreProvisionException(delta, e);
+
                         result.setStatus(ProvisioningReport.Status.FAILURE);
                         
result.setMessage(ExceptionUtils.getRootCauseMessage(e));
                         LOG.error("Could not delete {} {}", 
provision.getAnyType().getKey(), key, e);
                         output = e;
-
-                        for (PullActions action : profile.getActions()) {
-                            action.onError(this.getProfile(), workingDelta, 
result, e);
-                        }
                     }
 
-                    audit(ResourceOperation.DELETE.name().toLowerCase(), 
resultStatus, before, output, workingDelta);
+                    finalize(ResourceOperation.DELETE.name().toLowerCase(), 
resultStatus, before, output, workingDelta);
                 }
 
                 delResults.add(result);
@@ -621,7 +638,7 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
         return delResults;
     }
 
-    private List<ProvisioningReport> ignore(
+    protected List<ProvisioningReport> ignore(
             final SyncDelta delta,
             final Provision provision,
             final boolean matching)
@@ -640,7 +657,7 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
         ignoreResults.add(result);
 
         if (!profile.isDryRun()) {
-            audit(matching
+            finalize(matching
                     ? MatchingRule.toEventName(MatchingRule.IGNORE)
                     : UnmatchingRule.toEventName(UnmatchingRule.IGNORE), 
Result.SUCCESS, null, null, delta);
         }
@@ -769,12 +786,16 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
         }
     }
 
-    private void audit(
+    protected void finalize(
             final String event,
             final Result result,
             final Object before,
             final Object output,
-            final Object... input) {
+            final SyncDelta delta) {
+
+        synchronized (this) {
+            this.latestResult = result;
+        }
 
         notificationManager.createTasks(AuditElements.EventCategoryType.PULL,
                 getAnyUtils().getAnyTypeKind().name().toLowerCase(),
@@ -783,7 +804,7 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                 result,
                 before,
                 output,
-                input);
+                delta);
 
         auditManager.audit(AuditElements.EventCategoryType.PULL,
                 getAnyUtils().getAnyTypeKind().name().toLowerCase(),
@@ -792,6 +813,6 @@ public abstract class AbstractPullResultHandler extends 
AbstractSyncopeResultHan
                 result,
                 before,
                 output,
-                input);
+                delta);
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultPullActions.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultPullActions.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultPullActions.java
index 7a4cbe0..a1d5878 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultPullActions.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultPullActions.java
@@ -20,6 +20,7 @@ package org.apache.syncope.core.provisioning.java.pushpull;
 
 import org.apache.syncope.common.lib.patch.AnyPatch;
 import org.apache.syncope.common.lib.to.AnyTO;
+import 
org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException;
 import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile;
 import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport;
 import org.identityconnectors.framework.common.objects.SyncDelta;
@@ -102,12 +103,6 @@ public abstract class DefaultPullActions implements 
PullActions {
     }
 
     @Override
-    public void onError(
-            final ProvisioningProfile<?, ?> profile, final SyncDelta delta, 
final ProvisioningReport result,
-            final Exception error) throws JobExecutionException {
-    }
-
-    @Override
     public <A extends AnyTO> void after(
             final ProvisioningProfile<?, ?> profile, final SyncDelta delta, 
final A any,
             final ProvisioningReport result)
@@ -115,6 +110,15 @@ public abstract class DefaultPullActions implements 
PullActions {
     }
 
     @Override
+    public IgnoreProvisionException onError(
+            final ProvisioningProfile<?, ?> profile,
+            final SyncDelta delta,
+            final Exception e) throws JobExecutionException {
+
+        return null;
+    }
+
+    @Override
     public void afterAll(final ProvisioningProfile<?, ?> profile)
             throws JobExecutionException {
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullJobDelegate.java
----------------------------------------------------------------------
diff --git 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullJobDelegate.java
 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullJobDelegate.java
index 6bfc55b..4c1b3cb 100644
--- 
a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullJobDelegate.java
+++ 
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullJobDelegate.java
@@ -19,6 +19,7 @@
 package org.apache.syncope.core.provisioning.java.pushpull;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -40,8 +41,6 @@ import 
org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
 import org.apache.syncope.core.provisioning.api.Connector;
 import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile;
-import org.identityconnectors.framework.common.objects.SyncResultsHandler;
-import org.identityconnectors.framework.common.objects.SyncToken;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
@@ -50,9 +49,13 @@ import 
org.apache.syncope.core.persistence.api.entity.task.PullTask;
 import 
org.apache.syncope.core.provisioning.api.pushpull.AnyObjectPullResultHandler;
 import org.apache.syncope.core.provisioning.api.pushpull.PullActions;
 import 
org.apache.syncope.core.provisioning.api.pushpull.GroupPullResultHandler;
+import org.apache.syncope.core.provisioning.api.pushpull.SyncopePullExecutor;
+import 
org.apache.syncope.core.provisioning.api.pushpull.SyncopePullResultHandler;
 import org.apache.syncope.core.provisioning.api.pushpull.UserPullResultHandler;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.SyncToken;
 
-public class PullJobDelegate extends AbstractProvisioningJobDelegate<PullTask> 
{
+public class PullJobDelegate extends AbstractProvisioningJobDelegate<PullTask> 
implements SyncopePullExecutor {
 
     @Autowired
     private UserDAO userDAO;
@@ -64,7 +67,14 @@ public class PullJobDelegate extends 
AbstractProvisioningJobDelegate<PullTask> {
     private VirSchemaDAO virSchemaDAO;
 
     @Autowired
-    protected PullUtils pullUtils;
+    private PullUtils pullUtils;
+
+    private final Map<ObjectClass, SyncToken> latestSyncTokens = new 
HashMap<>();
+
+    @Override
+    public void setLatestSyncToken(final ObjectClass objectClass, final 
SyncToken latestSyncToken) {
+        latestSyncTokens.put(objectClass, latestSyncToken);
+    }
 
     protected void setGroupOwners(final GroupPullResultHandler ghandler) {
         for (Map.Entry<String, String> entry : 
ghandler.getGroupOwnerMap().entrySet()) {
@@ -132,17 +142,22 @@ public class PullJobDelegate extends 
AbstractProvisioningJobDelegate<PullTask> {
         AnyObjectPullResultHandler ahandler = (AnyObjectPullResultHandler) 
ApplicationContextProvider.getBeanFactory().
                 createBean(AnyObjectPullResultHandlerImpl.class, 
AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
         ahandler.setProfile(profile);
+        ahandler.setPullExecutor(this);
 
         // Prepare handler for SyncDelta objects (users)
         UserPullResultHandler uhandler = (UserPullResultHandler) 
ApplicationContextProvider.getBeanFactory().
                 createBean(UserPullResultHandlerImpl.class, 
AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
         uhandler.setProfile(profile);
+        uhandler.setPullExecutor(this);
 
         // Prepare handler for SyncDelta objects (groups)
         GroupPullResultHandler ghandler = (GroupPullResultHandler) 
ApplicationContextProvider.getBeanFactory().
                 createBean(GroupPullResultHandlerImpl.class, 
AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
         ghandler.setProfile(profile);
+        ghandler.setPullExecutor(this);
 
+        latestSyncTokens.clear();
+        
         if (!profile.isDryRun()) {
             for (PullActions action : actions) {
                 action.beforeAll(profile);
@@ -151,7 +166,7 @@ public class PullJobDelegate extends 
AbstractProvisioningJobDelegate<PullTask> {
 
         for (Provision provision : pullTask.getResource().getProvisions()) {
             if (provision.getMapping() != null) {
-                SyncResultsHandler handler;
+                SyncopePullResultHandler handler;
                 switch (provision.getAnyType().getKind()) {
                     case USER:
                         handler = uhandler;
@@ -177,13 +192,13 @@ public class PullJobDelegate extends 
AbstractProvisioningJobDelegate<PullTask> {
 
                     switch (pullTask.getPullMode()) {
                         case INCREMENTAL:
-                            SyncToken latestSyncToken = 
connector.getLatestSyncToken(provision.getObjectClass());
-                            connector.sync(provision.getObjectClass(),
+                            connector.sync(
+                                    provision.getObjectClass(),
                                     provision.getSyncToken(),
                                     handler,
                                     
MappingManagerImpl.buildOperationOptions(mapItems));
                             if (!dryRun) {
-                                provision.setSyncToken(latestSyncToken);
+                                
provision.setSyncToken(latestSyncTokens.get(provision.getObjectClass()));
                                 resourceDAO.save(provision.getResource());
                             }
                             break;

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
index d8ee45f..2bfba5a 100644
--- 
a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
+++ 
b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/ResourceServiceImpl.java
@@ -78,6 +78,16 @@ public class ResourceServiceImpl extends AbstractServiceImpl 
implements Resource
     }
 
     @Override
+    public void setLatestSyncToken(final String key, final String anyTypeKey) {
+        logic.setLatestSyncToken(key, anyTypeKey);
+    }
+
+    @Override
+    public void removeSyncToken(final String key, final String anyTypeKey) {
+        logic.removeSyncToken(key, anyTypeKey);
+    }
+
+    @Override
     public void delete(final String key) {
         logic.delete(key);
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/fit/build-tools/src/main/resources/testdb.sql
----------------------------------------------------------------------
diff --git a/fit/build-tools/src/main/resources/testdb.sql 
b/fit/build-tools/src/main/resources/testdb.sql
index 706c760..df929da 100644
--- a/fit/build-tools/src/main/resources/testdb.sql
+++ b/fit/build-tools/src/main/resources/testdb.sql
@@ -24,7 +24,6 @@ status VARCHAR(5));
 
 INSERT INTO test VALUES ('testuser1', 'password', 'false');
 
--- this table must be created in order to provide a specific test for 
issueSYNCOPE68
 DROP TABLE test2 IF EXISTS;
 CREATE TABLE test2 (
 id VARCHAR(50) PRIMARY KEY,
@@ -35,15 +34,13 @@ INSERT INTO test2 VALUES ('testuser2', 'password321', 
'false');
 INSERT INTO test2 VALUES ('rossini', 'password321', 'true');
 INSERT INTO test2 VALUES ('verdi', 'password321', 'true');
 
--- this table is for issueSYNCOPE230
 DROP TABLE testpull IF EXISTS;
 CREATE TABLE testpull (
 id CHAR(36) PRIMARY KEY,
 username VARCHAR(80),
 surname VARCHAR(80),
-email VARCHAR(80));
-
-INSERT INTO testpull VALUES ('a54b3794-b231-47be-b24a-11e1a42949f6', 
'issuesyncope230', 'Surname', '[email protected]');
+email VARCHAR(80),
+lastModification TIMESTAMP);
 
 DROP TABLE testPRINTER IF EXISTS;
 CREATE TABLE testPRINTER (

http://git-wip-us.apache.org/repos/asf/syncope/blob/6a0a6ffb/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
----------------------------------------------------------------------
diff --git 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
index 12bf74f..2a7cf78 100644
--- 
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
@@ -61,12 +61,14 @@ import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.CipherAlgorithm;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.ConnConfProperty;
+import org.apache.syncope.common.lib.types.ConnectorCapability;
 import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
 import org.apache.syncope.common.lib.types.PullMode;
 import org.apache.syncope.common.lib.types.TaskType;
 import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
 import org.apache.syncope.common.rest.api.beans.TaskQuery;
+import org.apache.syncope.common.rest.api.service.ConnectorService;
 import org.apache.syncope.common.rest.api.service.TaskService;
 import org.apache.syncope.core.spring.security.Encryptor;
 import 
org.apache.syncope.core.provisioning.java.pushpull.DBPasswordPullActions;
@@ -208,8 +210,8 @@ public class PullTaskITCase extends AbstractTaskITCase {
             assertEquals(1, IterableUtils.countMatches(userTO.getDerAttrs(), 
new Predicate<AttrTO>() {
 
                 @Override
-                public boolean evaluate(final AttrTO attributeTO) {
-                    return "csvuserid".equals(attributeTO.getSchema());
+                public boolean evaluate(final AttrTO attrTO) {
+                    return "csvuserid".equals(attrTO.getSchema());
                 }
             }));
 
@@ -271,7 +273,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
         try {
             ExecTO execution = execProvisioningTask(
                     taskService, "83f7e85d-9774-43fe-adba-ccd856312994", 50, 
false);
-            assertNotNull(execution.getStatus());
             assertEquals(PropagationTaskExecStatus.SUCCESS, 
PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             userTO = userService.read("testuser1");
@@ -285,7 +286,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
             // re-execute the same PullTask: now user must be active
             execution = execProvisioningTask(
                     taskService, "83f7e85d-9774-43fe-adba-ccd856312994", 50, 
false);
-            assertNotNull(execution.getStatus());
             assertEquals(PropagationTaskExecStatus.SUCCESS, 
PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             userTO = userService.read("testuser1");
@@ -339,8 +339,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
         ldapCleanup();
 
         // 0. pull
-        ExecTO execution = execProvisioningTask(
-                taskService, "1e419ca4-ea81-4493-a14f-28b90113686d", 50, 
false);
+        ExecTO execution = execProvisioningTask(taskService, 
"1e419ca4-ea81-4493-a14f-28b90113686d", 50, false);
 
         // 1. verify execution status
         assertEquals(PropagationTaskExecStatus.SUCCESS, 
PropagationTaskExecStatus.valueOf(execution.getStatus()));
@@ -396,8 +395,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
         ProvisionTO provision = resource.getProvision("PRINTER");
         assertNotNull(provision);
 
-        provision.setSyncToken(null);
-
         MappingItemTO mappingItem = IterableUtils.find(
                 provision.getMapping().getItems(), new 
Predicate<MappingItemTO>() {
 
@@ -412,6 +409,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
         try {
             resourceService.update(resource);
+            resourceService.removeSyncToken(resource.getKey(), 
provision.getAnyType());
 
             // 1. create printer on external resource
             AnyObjectTO anyObjectTO = AnyObjectITCase.getSampleTO("pull");
@@ -475,9 +473,9 @@ public class PullTaskITCase extends AbstractTaskITCase {
         try {
             // 1. create 2 users on testpull
             jdbcTemplate.execute("INSERT INTO testpull VALUES ("
-                    + "'" + user1OnTestPull + "', 'user1', 'Doe', 
'[email protected]')");
+                    + "'" + user1OnTestPull + "', 'user1', 'Doe', 
'[email protected]', NULL)");
             jdbcTemplate.execute("INSERT INTO testpull VALUES ("
-                    + "'" + user2OnTestPull + "', 'user2', 'Rossi', 
'[email protected]')");
+                    + "'" + user2OnTestPull + "', 'user2', 'Rossi', 
'[email protected]', NULL)");
 
             // 2. create new pull task for test-db, with reconciliation filter 
(surname 'Rossi') 
             task = taskService.read("7c2242f4-14af-4ab5-af31-cdae23783655", 
true);
@@ -492,7 +490,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
             // 3. exec task
             ExecTO execution = execProvisioningTask(taskService, 
task.getKey(), 50, false);
-            assertNotNull(execution.getStatus());
             assertEquals(PropagationTaskExecStatus.SUCCESS, 
PropagationTaskExecStatus.valueOf(execution.getStatus()));
 
             // 4. verify that only enabled user was pulled
@@ -518,6 +515,89 @@ public class PullTaskITCase extends AbstractTaskITCase {
     }
 
     @Test
+    public void syncTokenWithErrors() {
+        ResourceTO origResource = resourceService.read(RESOURCE_NAME_DBPULL);
+        ConnInstanceTO origConnector = 
connectorService.read(origResource.getConnector(), null);
+
+        ResourceTO resForTest = SerializationUtils.clone(origResource);
+        resForTest.setKey("syncTokenWithErrors");
+        resForTest.setConnector(null);
+        ConnInstanceTO connForTest = SerializationUtils.clone(origConnector);
+        connForTest.setKey(null);
+        connForTest.setDisplayName("For syncTokenWithErrors");
+
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
+        try {
+            connForTest.getCapabilities().add(ConnectorCapability.SYNC);
+
+            ConnConfProperty changeLogColumn = 
connForTest.getConfMap().get("changeLogColumn");
+            assertNotNull(changeLogColumn);
+            assertTrue(changeLogColumn.getValues().isEmpty());
+            changeLogColumn.getValues().add("lastModification");
+
+            Response response = connectorService.create(connForTest);
+            if (response.getStatusInfo().getStatusCode() != 
Response.Status.CREATED.getStatusCode()) {
+                throw (RuntimeException) 
clientFactory.getExceptionMapper().fromResponse(response);
+            }
+            connForTest = getObject(response.getLocation(), 
ConnectorService.class, ConnInstanceTO.class);
+            assertNotNull(connForTest);
+
+            resForTest.setConnector(connForTest.getKey());
+            resForTest = createResource(resForTest);
+            assertNotNull(resForTest);
+
+            PullTaskTO pullTask = new PullTaskTO();
+            pullTask.setActive(true);
+            pullTask.setName("For syncTokenWithErrors");
+            pullTask.setResource(resForTest.getKey());
+            pullTask.setDestinationRealm(SyncopeConstants.ROOT_REALM);
+            pullTask.setPullMode(PullMode.INCREMENTAL);
+            pullTask.setPerformCreate(true);
+            pullTask.setPerformUpdate(true);
+            pullTask.setPerformDelete(true);
+
+            response = taskService.create(pullTask);
+            if (response.getStatusInfo().getStatusCode() != 
Response.Status.CREATED.getStatusCode()) {
+                throw (RuntimeException) 
clientFactory.getExceptionMapper().fromResponse(response);
+            }
+            pullTask = getObject(response.getLocation(), TaskService.class, 
PullTaskTO.class);
+            assertNotNull(pullTask);
+
+            jdbcTemplate.execute("DELETE FROM testpull");
+            jdbcTemplate.execute("INSERT INTO testpull VALUES "
+                    + "(1040, 'syncTokenWithErrors1', 'Surname1', "
+                    + "'[email protected]', '2014-05-23 
13:53:24.293')");
+            jdbcTemplate.execute("INSERT INTO testpull VALUES "
+                    + "(1041, 'syncTokenWithErrors2', 'Surname2', "
+                    + "'[email protected]', '2015-05-23 
13:53:24.293')");
+
+            ExecTO exec = execProvisioningTask(taskService, pullTask.getKey(), 
50, false);
+            assertEquals(PropagationTaskExecStatus.SUCCESS, 
PropagationTaskExecStatus.valueOf(exec.getStatus()));
+
+            resForTest = resourceService.read(resForTest.getKey());
+            
assertTrue(resForTest.getProvision(AnyTypeKind.USER.name()).getSyncToken().contains("2014-05-23"));
+
+            jdbcTemplate.execute("UPDATE testpull "
+                    + "SET email='[email protected]', 
lastModification='2016-05-23 13:53:24.293' "
+                    + "WHERE ID=1041");
+
+            exec = execProvisioningTask(taskService, pullTask.getKey(), 50, 
false);
+            assertEquals(PropagationTaskExecStatus.SUCCESS, 
PropagationTaskExecStatus.valueOf(exec.getStatus()));
+
+            resForTest = resourceService.read(resForTest.getKey());
+            
assertTrue(resForTest.getProvision(AnyTypeKind.USER.name()).getSyncToken().contains("2016-05-23"));
+        } finally {
+            if (resForTest.getConnector() != null) {
+                resourceService.delete(resForTest.getKey());
+                connectorService.delete(connForTest.getKey());
+            }
+
+            jdbcTemplate.execute("DELETE FROM testpull WHERE ID=1040");
+            jdbcTemplate.execute("DELETE FROM testpull WHERE ID=1041");
+        }
+    }
+
+    @Test
     public void issueSYNCOPE68() {
         //-----------------------------
         // Create a new user ... it should be updated applying pull policy
@@ -588,7 +668,13 @@ public class PullTaskITCase extends AbstractTaskITCase {
 
     @Test
     public void issueSYNCOPE230() {
-        // 1. read PullTask for resource-db-pull (table TESTPULL on external 
H2)
+        JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
+
+        // 1. populate the external table
+        jdbcTemplate.execute("INSERT INTO testpull VALUES"
+                + "('a54b3794-b231-47be-b24a-11e1a42949f6', 'issuesyncope230', 
'Surname', '[email protected]', NULL)");
+
+        // 2. execute PullTask for resource-db-pull (table TESTPULL on 
external H2)
         execProvisioningTask(taskService, 
"7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
 
         // 3. read e-mail address for user created by the PullTask first 
execution
@@ -598,7 +684,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
         assertNotNull(email);
 
         // 4. update TESTPULL on external H2 by changing e-mail address
-        JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
         jdbcTemplate.execute("UPDATE TESTPULL SET 
email='[email protected]'");
 
         // 5. re-execute the PullTask

Reply via email to