@Test public void pullFromCSV() { CSVPullSpec spec = new CSVPullSpec.Builder(AnyTypeKind.USER.name(), "username").build(); InputStream csv = getClass().getResourceAsStream("/test1.csv"); List<ProvisioningReport> results = AuthContextUtils.callAsAdmin(SyncopeConstants.MASTER_DOMAIN, () -> { return reconciliationLogic.pull(spec, csv); }); assertEquals(2, results.size()); assertEquals(AnyTypeKind.USER.name(), results.get(0).getAnyType()); assertNotNull(results.get(0).getKey()); assertEquals("donizetti", results.get(0).getName()); assertEquals("donizetti", results.get(0).getUidValue()); assertEquals(ResourceOperation.CREATE, results.get(0).getOperation()); assertEquals(ProvisioningReport.Status.SUCCESS, results.get(0).getStatus()); AuthContextUtils.callAsAdmin(SyncopeConstants.MASTER_DOMAIN, () -> { UserTO donizetti = userLogic.read(results.get(0).getKey()); assertNotNull(donizetti); assertEquals("Gaetano", donizetti.getPlainAttr("firstname").get().getValues().get(0)); assertEquals(1, donizetti.getPlainAttr("loginDate").get().getValues().size()); UserTO cimarosa = userLogic.read(results.get(1).getKey()); assertNotNull(cimarosa); assertEquals("Domenico Cimarosa", cimarosa.getPlainAttr("fullname").get().getValues().get(0)); assertEquals(2, cimarosa.getPlainAttr("loginDate").get().getValues().size()); return null; }); }
@PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')") public void pull(final ReconQuery query, final PullTaskTO pullTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); Optional<String> connObjectKeyValue = Optional.ofNullable(query.getConnObjectKeyValue()); if (query.getAnyKey() != null) { Any<?> any = getAny(provision, query.getAnyKey()); connObjectKeyValue = mappingManager.getConnObjectKeyValue(any, provision); } if (connObjectKeyValue.isEmpty()) { throw new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'"); } if (pullTask.getDestinationRealm() == null || realmDAO.findByFullPath(pullTask.getDestinationRealm()) == null) { throw new NotFoundException("Realm " + pullTask.getDestinationRealm()); } if (provision.getMapping().getConnObjectKeyItem().isEmpty()) { throw new NotFoundException( "ConnObjectKey cannot be determined for mapping " + provision.getMapping().getKey()); } SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); try { List<ProvisioningReport> results = singlePullExecutor.pull( provision, connFactory.getConnector(provision.getResource()), provision.getMapping().getConnObjectKeyItem().get().getExtAttrName(), connObjectKeyValue.get(), pullTask); 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 pull(final ReconQuery query, final PullTaskTO pullTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); Optional<String> connObjectKeyValue = Optional.ofNullable(query.getConnObjectKeyValue()); if (query.getAnyKey() != null) { Any<?> any = getAny(provision, query.getAnyKey()); connObjectKeyValue = mappingManager.getConnObjectKeyValue(any, provision); } if (connObjectKeyValue.isEmpty()) { throw new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'"); } if (pullTask.getDestinationRealm() == null || realmDAO.findByFullPath(pullTask.getDestinationRealm()) == null) { throw new NotFoundException("Realm " + pullTask.getDestinationRealm()); } if (provision.getMapping().getConnObjectKeyItem().isEmpty()) { throw new NotFoundException( "ConnObjectKey cannot be determined for mapping " + provision.getMapping().getKey()); } SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); try { List<ProvisioningReport> results = singlePullExecutor.pull( provision, connFactory.getConnector(provision.getResource()), provision.getMapping().getConnObjectKeyItem().get().getExtAttrName(), connObjectKeyValue.get(), pullTask); 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 pull(final ReconQuery query, final PullTaskTO pullTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); Optional<String> connObjectKeyValue = Optional.ofNullable(query.getConnObjectKeyValue()); if (query.getAnyKey() != null) { Any<?> any = getAny(provision, query.getAnyKey()); connObjectKeyValue = mappingManager.getConnObjectKeyValue(any, provision); } if (connObjectKeyValue.isEmpty()) { throw new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'"); } if (pullTask.getDestinationRealm() == null || realmDAO.findByFullPath(pullTask.getDestinationRealm()) == null) { throw new NotFoundException("Realm " + pullTask.getDestinationRealm()); } if (provision.getMapping().getConnObjectKeyItem().isEmpty()) { throw new NotFoundException( "ConnObjectKey cannot be determined for mapping " + provision.getMapping().getKey()); } SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); try { List<ProvisioningReport> results = singlePullExecutor.pull( provision, connFactory.getConnector(provision.getResource()), provision.getMapping().getConnObjectKeyItem().get().getExtAttrName(), connObjectKeyValue.get(), pullTask); 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 pull(final ReconQuery query, final PullTaskTO pullTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); Optional<String> connObjectKeyValue = Optional.ofNullable(query.getConnObjectKeyValue()); if (query.getAnyKey() != null) { Any<?> any = getAny(provision, query.getAnyKey()); connObjectKeyValue = mappingManager.getConnObjectKeyValue(any, provision); } if (connObjectKeyValue.isEmpty()) { throw new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'"); } if (pullTask.getDestinationRealm() == null || realmDAO.findByFullPath(pullTask.getDestinationRealm()) == null) { throw new NotFoundException("Realm " + pullTask.getDestinationRealm()); } if (provision.getMapping().getConnObjectKeyItem().isEmpty()) { throw new NotFoundException( "ConnObjectKey cannot be determined for mapping " + provision.getMapping().getKey()); } SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); try { List<ProvisioningReport> results = singlePullExecutor.pull( provision, connFactory.getConnector(provision.getResource()), provision.getMapping().getConnObjectKeyItem().get().getExtAttrName(), connObjectKeyValue.get(), pullTask); 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 pull(final ReconQuery query, final PullTaskTO pullTask) { Provision provision = getProvision(query.getAnyTypeKey(), query.getResourceKey()); Optional<String> connObjectKeyValue = Optional.ofNullable(query.getConnObjectKeyValue()); if (query.getAnyKey() != null) { Any<?> any = getAny(provision, query.getAnyKey()); connObjectKeyValue = mappingManager.getConnObjectKeyValue(any, provision); } if (connObjectKeyValue.isEmpty()) { throw new NotFoundException( "ConnObjectKey for " + provision.getAnyType().getKey() + " on resource '" + provision.getResource().getKey() + "'"); } if (pullTask.getDestinationRealm() == null || realmDAO.findByFullPath(pullTask.getDestinationRealm()) == null) { throw new NotFoundException("Realm " + pullTask.getDestinationRealm()); } if (provision.getMapping().getConnObjectKeyItem().isEmpty()) { throw new NotFoundException( "ConnObjectKey cannot be determined for mapping " + provision.getMapping().getKey()); } SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation); try { List<ProvisioningReport> results = singlePullExecutor.pull( provision, connFactory.getConnector(provision.getResource()), provision.getMapping().getConnObjectKeyItem().get().getExtAttrName(), connObjectKeyValue.get(), pullTask); 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);  }