use of org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile in project syncope by apache.
the class PullJobDelegate method doExecuteProvisioning.
@Override
protected String doExecuteProvisioning(final PullTask pullTask, final Connector connector, final boolean dryRun) throws JobExecutionException {
LOG.debug("Executing pull on {}", pullTask.getResource());
List<PullActions> actions = new ArrayList<>();
pullTask.getActions().forEach(impl -> {
try {
actions.add(ImplementationManager.build(impl));
} catch (Exception e) {
LOG.warn("While building {}", impl, e);
}
});
profile = new ProvisioningProfile<>(connector, pullTask);
profile.getActions().addAll(actions);
profile.setDryRun(dryRun);
profile.setResAct(pullTask.getResource().getPullPolicy() == null ? ConflictResolutionAction.IGNORE : pullTask.getResource().getPullPolicy().getConflictResolutionAction());
latestSyncTokens.clear();
if (!profile.isDryRun()) {
for (PullActions action : actions) {
action.beforeAll(profile);
}
}
status.set("Initialization completed");
// First realms...
if (pullTask.getResource().getOrgUnit() != null) {
status.set("Pulling " + pullTask.getResource().getOrgUnit().getObjectClass().getObjectClassValue());
OrgUnit orgUnit = pullTask.getResource().getOrgUnit();
OperationOptions options = MappingUtils.buildOperationOptions(MappingUtils.getPullItems(orgUnit.getItems()).iterator());
rhandler = buildRealmHandler();
try {
switch(pullTask.getPullMode()) {
case INCREMENTAL:
if (!dryRun) {
latestSyncTokens.put(orgUnit.getObjectClass(), orgUnit.getSyncToken());
}
connector.sync(orgUnit.getObjectClass(), orgUnit.getSyncToken(), rhandler, options);
if (!dryRun) {
orgUnit.setSyncToken(latestSyncTokens.get(orgUnit.getObjectClass()));
resourceDAO.save(orgUnit.getResource());
}
break;
case FILTERED_RECONCILIATION:
ReconFilterBuilder filterBuilder = ImplementationManager.build(pullTask.getReconFilterBuilder());
connector.filteredReconciliation(orgUnit.getObjectClass(), filterBuilder, rhandler, options);
break;
case FULL_RECONCILIATION:
default:
connector.fullReconciliation(orgUnit.getObjectClass(), rhandler, options);
break;
}
} catch (Throwable t) {
throw new JobExecutionException("While pulling from connector", t);
}
}
// ...then provisions for any types
ahandler = buildAnyObjectHandler();
uhandler = buildUserHandler();
ghandler = buildGroupHandler();
for (Provision provision : pullTask.getResource().getProvisions()) {
if (provision.getMapping() != null) {
status.set("Pulling " + provision.getObjectClass().getObjectClassValue());
SyncopePullResultHandler handler;
switch(provision.getAnyType().getKind()) {
case USER:
handler = uhandler;
break;
case GROUP:
handler = ghandler;
break;
case ANY_OBJECT:
default:
handler = ahandler;
}
try {
Set<MappingItem> linkingMappingItems = virSchemaDAO.findByProvision(provision).stream().map(schema -> schema.asLinkingMappingItem()).collect(Collectors.toSet());
Iterator<MappingItem> mapItems = new IteratorChain<>(provision.getMapping().getItems().iterator(), linkingMappingItems.iterator());
OperationOptions options = MappingUtils.buildOperationOptions(mapItems);
switch(pullTask.getPullMode()) {
case INCREMENTAL:
if (!dryRun) {
latestSyncTokens.put(provision.getObjectClass(), provision.getSyncToken());
}
connector.sync(provision.getObjectClass(), provision.getSyncToken(), handler, options);
if (!dryRun) {
provision.setSyncToken(latestSyncTokens.get(provision.getObjectClass()));
resourceDAO.save(provision.getResource());
}
break;
case FILTERED_RECONCILIATION:
ReconFilterBuilder filterBuilder = ImplementationManager.build(pullTask.getReconFilterBuilder());
connector.filteredReconciliation(provision.getObjectClass(), filterBuilder, handler, options);
break;
case FULL_RECONCILIATION:
default:
connector.fullReconciliation(provision.getObjectClass(), handler, options);
break;
}
} catch (Throwable t) {
throw new JobExecutionException("While pulling from connector", t);
}
}
}
try {
setGroupOwners(ghandler);
} catch (Exception e) {
LOG.error("While setting group owners", e);
}
if (!profile.isDryRun()) {
for (PullActions action : actions) {
action.afterAll(profile);
}
}
status.set("Pull done");
String result = createReport(profile.getResults(), pullTask.getResource(), dryRun);
LOG.debug("Pull result: {}", result);
return result;
}
use of org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile in project syncope by apache.
the class LDAPMembershipPullActions method populateMemberships.
/**
* Pull Syncope memberships with the situation read on the external resource's group.
*
* @param profile pull profile
* @param delta representing the pullong group
* @param groupTO group after modification performed by the handler
* @throws JobExecutionException if anything goes wrong
*/
protected void populateMemberships(final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final GroupTO groupTO) throws JobExecutionException {
Connector connector = profile.getConnector();
getMembAttrValues(delta, connector).stream().map(membValue -> {
Set<String> memb = memberships.get(membValue.toString());
if (memb == null) {
memb = new HashSet<>();
memberships.put(membValue.toString(), memb);
}
return memb;
}).forEachOrdered(memb -> {
memb.add(groupTO.getKey());
});
}
Aggregations