@Test public void pushToCSV() throws IOException { Pair<Integer, List<UserTO>> search = AuthContextUtils.callAsAdmin(SyncopeConstants.MASTER_DOMAIN, () -> userLogic.search(null, 1, 100, List.of(), SyncopeConstants.ROOT_REALM, false)); assertNotNull(search); CSVPushSpec spec = new CSVPushSpec.Builder(AnyTypeKind.USER.name()).ignorePaging(true). field("username"). field("status"). plainAttr("firstname"). plainAttr("surname"). plainAttr("email"). plainAttr("loginDate"). build(); PipedInputStream in = new PipedInputStream(); PipedOutputStream os = new PipedOutputStream(in); List<ProvisioningReport> results = AuthContextUtils.callAsAdmin(SyncopeConstants.MASTER_DOMAIN, () -> { return reconciliationLogic.push(null, 1, 1, List.of(), SyncopeConstants.ROOT_REALM, spec, os); }); assertEquals(search.getLeft(), results.size()); MappingIterator<Map<String, String>> reader = new CsvMapper().readerFor(Map.class).with(CsvSchema.emptySchema().withHeader()).readValues(in); for (int i = 0; i < results.size() && reader.hasNext(); i++) { Map<String, String> row = reader.next(); assertEquals(results.get(i).getName(), row.get("username")); assertEquals(search.getRight().stream().filter(user -> row.get("username").equals(user.getUsername())). findFirst().get().getStatus(), row.get("status")); switch (row.get("username")) { case "rossini": assertEquals(spec.getNullValue(), row.get("email")); assertTrue(row.get("loginDate").contains(spec.getArrayElementSeparator())); break; case "verdi": assertEquals("verdi@syncope.org", row.get("email")); assertEquals(spec.getNullValue(), row.get("loginDate")); break; case "bellini": assertEquals(spec.getNullValue(), row.get("email")); assertFalse(row.get("loginDate").contains(spec.getArrayElementSeparator())); break; default: break; } } }
@PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") public void push(final ReconQuery query, final PushTaskTO pushTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision). orElseThrow(() -> new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'")); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); List<ProvisioningReport> results = new ArrayList<>(); if (query.getConnObjectKeyValue() != null) { inboundMatcher.matchByConnObjectKeyValue(connObjectKeyItem, query.getConnObjectKeyValue(), provision). stream().findFirst().ifPresent(match -> { try { if (match.getMatchTarget() == MatchType.ANY) { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getAny(), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } else { ProvisioningReport result = singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getLinkedAccount(), pushTask); if (result.getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(result.getMessage()); } else { results.add(result); } } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } }); } if (sce.isEmpty() && results.isEmpty() && query.getAnyKey() != null) { try { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), getAny(provision, query.getAnyKey()), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } } if (!sce.isEmpty()) { throw sce; } }
ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> { @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") public void push(final ReconQuery query, final PushTaskTO pushTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision). orElseThrow(() -> new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'")); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); List<ProvisioningReport> results = new ArrayList<>(); if (query.getConnObjectKeyValue() != null) { inboundMatcher.matchByConnObjectKeyValue(connObjectKeyItem, query.getConnObjectKeyValue(), provision). stream().findFirst().ifPresent(match -> { try { if (match.getMatchTarget() == MatchType.ANY) { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getAny(), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } else { ProvisioningReport result = singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getLinkedAccount(), pushTask); if (result.getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(result.getMessage()); } else { results.add(result); } } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } }); } if (sce.isEmpty() && results.isEmpty() && query.getAnyKey() != null) { try { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), getAny(provision, query.getAnyKey()), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } } if (!sce.isEmpty()) { throw sce; } } }
ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> { @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") public void push(final ReconQuery query, final PushTaskTO pushTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision). orElseThrow(() -> new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'")); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); List<ProvisioningReport> results = new ArrayList<>(); if (query.getConnObjectKeyValue() != null) { inboundMatcher.matchByConnObjectKeyValue(connObjectKeyItem, query.getConnObjectKeyValue(), provision). stream().findFirst().ifPresent(match -> { try { if (match.getMatchTarget() == MatchType.ANY) { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getAny(), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } else { ProvisioningReport result = singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getLinkedAccount(), pushTask); if (result.getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(result.getMessage()); } else { results.add(result); } } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } }); } if (sce.isEmpty() && results.isEmpty() && query.getAnyKey() != null) { try { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), getAny(provision, query.getAnyKey()), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } } if (!sce.isEmpty()) { throw sce; } }  }
ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> { @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") public void push(final ReconQuery query, final PushTaskTO pushTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision). orElseThrow(() -> new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'")); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); List<ProvisioningReport> results = new ArrayList<>(); if (query.getConnObjectKeyValue() != null) { inboundMatcher.matchByConnObjectKeyValue(connObjectKeyItem, query.getConnObjectKeyValue(), provision). stream().findFirst().ifPresent(match -> { try { if (match.getMatchTarget() == MatchType.ANY) { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getAny(), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } else { ProvisioningReport result = singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getLinkedAccount(), pushTask); if (result.getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(result.getMessage()); } else { results.add(result); } } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } }); } if (sce.isEmpty() && results.isEmpty() && query.getAnyKey() != null) { try { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), getAny(provision, query.getAnyKey()), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } } if (!sce.isEmpty()) { throw sce; } }  @PreAuthorize("hasRole('" + IdMEntitlement.RESOURCE_GET_CONNOBJECT + "')") ReconStatus status(final ReconQuery query); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") void push(final ReconQuery query, final PushTaskTO pushTask); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") void pull(final ReconQuery query, final PullTaskTO pullTask); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") List<ProvisioningReport> push(
            final SearchCond searchCond,
            final int page,
            final int size,
            final List<OrderByClause> orderBy,
            final String realm,
            final CSVPushSpec spec,
            final OutputStream os); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") List<ProvisioningReport> pull(final CSVPullSpec spec, final InputStream csv); }
ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> { @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") public void push(final ReconQuery query, final PushTaskTO pushTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision). orElseThrow(() -> new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'")); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); List<ProvisioningReport> results = new ArrayList<>(); if (query.getConnObjectKeyValue() != null) { inboundMatcher.matchByConnObjectKeyValue(connObjectKeyItem, query.getConnObjectKeyValue(), provision). stream().findFirst().ifPresent(match -> { try { if (match.getMatchTarget() == MatchType.ANY) { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getAny(), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } else { ProvisioningReport result = singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), match.getLinkedAccount(), pushTask); if (result.getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(result.getMessage()); } else { results.add(result); } } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } }); } if (sce.isEmpty() && results.isEmpty() && query.getAnyKey() != null) { try { results.addAll(singlePushExecutor.push( provision, connFactory.getConnector(provision.getResource()), getAny(provision, query.getAnyKey()), pushTask)); if (!results.isEmpty() && results.get(0).getStatus() == ProvisioningReport.Status.FAILURE) { sce.getElements().add(results.get(0).getMessage()); } } catch (JobExecutionException e) { sce.getElements().add(e.getMessage()); } } if (!sce.isEmpty()) { throw sce; } }  @PreAuthorize("hasRole('" + IdMEntitlement.RESOURCE_GET_CONNOBJECT + "')") ReconStatus status(final ReconQuery query); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") void push(final ReconQuery query, final PushTaskTO pushTask); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") void pull(final ReconQuery query, final PullTaskTO pullTask); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") List<ProvisioningReport> push(
            final SearchCond searchCond,
            final int page,
            final int size,
            final List<OrderByClause> orderBy,
            final String realm,
            final CSVPushSpec spec,
            final OutputStream os); @PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") List<ProvisioningReport> pull(final CSVPullSpec spec, final InputStream csv);  }