Search in sources :

Example 36 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class AbstractLdapConnTest method test174SeachFirst222AccountsOffset20.

/**
	 * Blocksize is 100, so this gets more than two blocks.
	 * There is offset, so VLV should be used.
	 * No explicit sorting.
	 */
@Test
public void test174SeachFirst222AccountsOffset20() throws Exception {
    final String TEST_NAME = "test174SeachFirst222AccountsOffset20";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(20, 222);
    query.setPaging(paging);
    SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 222, task, result);
    assertConnectorOperationIncrement(1, 223);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = searchResultList.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(1, 2);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 37 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class ResourceObjectConverter method searchResourceObjects.

public SearchResultMetadata searchResourceObjects(final ProvisioningContext ctx, final ResultHandler<ShadowType> resultHandler, ObjectQuery query, final boolean fetchAssociations, final OperationResult parentResult) throws SchemaException, CommunicationException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    LOGGER.trace("Searching resource objects, query: {}", query);
    RefinedObjectClassDefinition objectClassDef = ctx.getObjectClassDefinition();
    AttributesToReturn attributesToReturn = ProvisioningUtil.createAttributesToReturn(ctx);
    SearchHierarchyConstraints searchHierarchyConstraints = null;
    ResourceObjectReferenceType baseContextRef = objectClassDef.getBaseContext();
    if (baseContextRef != null) {
        PrismObject<ShadowType> baseContextShadow = resourceObjectReferenceResolver.resolve(ctx, baseContextRef, null, "base context specification in " + objectClassDef, parentResult);
        if (baseContextShadow == null) {
            throw new ObjectNotFoundException("No base context defined by " + baseContextRef + " in base context specification in " + objectClassDef);
        }
        RefinedObjectClassDefinition baseContextObjectClassDefinition = ctx.getRefinedSchema().determineCompositeObjectClassDefinition(baseContextShadow);
        ResourceObjectIdentification baseContextIdentification = ShadowUtil.getResourceObjectIdentification(baseContextShadow, baseContextObjectClassDefinition);
        searchHierarchyConstraints = new SearchHierarchyConstraints(baseContextIdentification, null);
    }
    if (InternalsConfig.consistencyChecks && query != null && query.getFilter() != null) {
        query.getFilter().checkConsistence(true);
    }
    ConnectorInstance connector = ctx.getConnector(ReadCapabilityType.class, parentResult);
    SearchResultMetadata metadata = null;
    try {
        metadata = connector.search(objectClassDef, query, (shadow) -> {
            // in order to utilize the cache right from the beginning...
            RepositoryCache.enter();
            try {
                try {
                    shadow = postProcessResourceObjectRead(ctx, shadow, fetchAssociations, parentResult);
                } catch (SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ObjectNotFoundException | ExpressionEvaluationException e) {
                    throw new TunnelException(e);
                }
                return resultHandler.handle(shadow);
            } finally {
                RepositoryCache.exit();
            }
        }, attributesToReturn, objectClassDef.getPagedSearches(), searchHierarchyConstraints, ctx, parentResult);
    } catch (GenericFrameworkException e) {
        parentResult.recordFatalError("Generic error in the connector: " + e.getMessage(), e);
        throw new SystemException("Generic error in the connector: " + e.getMessage(), e);
    } catch (CommunicationException ex) {
        parentResult.recordFatalError("Error communicating with the connector " + connector + ": " + ex.getMessage(), ex);
        throw new CommunicationException("Error communicating with the connector " + connector + ": " + ex.getMessage(), ex);
    } catch (SecurityViolationException ex) {
        parentResult.recordFatalError("Security violation communicating with the connector " + connector + ": " + ex.getMessage(), ex);
        throw new SecurityViolationException("Security violation communicating with the connector " + connector + ": " + ex.getMessage(), ex);
    } catch (TunnelException e) {
        Throwable cause = e.getCause();
        if (cause instanceof SchemaException) {
            throw (SchemaException) cause;
        } else if (cause instanceof CommunicationException) {
            throw (CommunicationException) cause;
        } else if (cause instanceof ObjectNotFoundException) {
            throw (ObjectNotFoundException) cause;
        } else if (cause instanceof ConfigurationException) {
            throw (ConfigurationException) cause;
        } else if (cause instanceof SecurityViolationException) {
            throw (SecurityViolationException) cause;
        } else if (cause instanceof ExpressionEvaluationException) {
            throw (ExpressionEvaluationException) cause;
        } else if (cause instanceof GenericFrameworkException) {
            throw new GenericConnectorException(cause.getMessage(), cause);
        } else {
            throw new SystemException(cause.getMessage(), cause);
        }
    }
    computeResultStatus(parentResult);
    LOGGER.trace("Searching resource objects done: {}", parentResult.getStatus());
    return metadata;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) Autowired(org.springframework.beans.factory.annotation.Autowired) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) com.evolveum.midpoint.common.refinery(com.evolveum.midpoint.common.refinery) AsynchronousOperationReturnValue(com.evolveum.midpoint.schema.result.AsynchronousOperationReturnValue) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ResourceTypeUtil(com.evolveum.midpoint.schema.util.ResourceTypeUtil) MatchingRuleRegistry(com.evolveum.midpoint.prism.match.MatchingRuleRegistry) AsynchronousOperationQueryable(com.evolveum.midpoint.schema.result.AsynchronousOperationQueryable) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) DeleteCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.DeleteCapabilityType) ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) UpdateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.UpdateCapabilityType) Entry(java.util.Map.Entry) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) Clock(com.evolveum.midpoint.common.Clock) Validate(org.apache.commons.lang.Validate) CreateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType) java.util(java.util) com.evolveum.midpoint.util(com.evolveum.midpoint.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Trace(com.evolveum.midpoint.util.logging.Trace) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) RepositoryCache(com.evolveum.midpoint.repo.cache.RepositoryCache) JavaTypeConverter(com.evolveum.midpoint.prism.util.JavaTypeConverter) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) SchemaDebugUtil(com.evolveum.midpoint.schema.util.SchemaDebugUtil) CapabilityUtil(com.evolveum.midpoint.schema.CapabilityUtil) AddRemoveAttributeValuesCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AddRemoveAttributeValuesCapabilityType) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) PrismUtil(com.evolveum.midpoint.prism.util.PrismUtil) LiveSyncCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.LiveSyncCapabilityType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) QueryBuilder(com.evolveum.midpoint.prism.query.builder.QueryBuilder) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) Component(org.springframework.stereotype.Component) com.evolveum.midpoint.provisioning.ucf.api(com.evolveum.midpoint.provisioning.ucf.api) com.evolveum.midpoint.schema.processor(com.evolveum.midpoint.schema.processor) AsynchronousOperationResult(com.evolveum.midpoint.schema.result.AsynchronousOperationResult) ActivationStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType) ProvisioningUtil(com.evolveum.midpoint.provisioning.util.ProvisioningUtil) ShadowUtil(com.evolveum.midpoint.schema.util.ShadowUtil) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ActivationLockoutStatusCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException)

Example 38 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class ProvisioningServiceImpl method searchObjectsIterative.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(final Class<T> type, ObjectQuery query, final Collection<SelectorOptions<GetOperationOptions>> options, final ResultHandler<T> handler, Task task, final OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    Validate.notNull(parentResult, "Operation result must not be null.");
    Validate.notNull(handler, "Handler must not be null.");
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Start to search object. Query {}", query != null ? query.debugDump() : "(null)");
    }
    final OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".searchObjectsIterative");
    result.setSummarizeSuccesses(true);
    result.setSummarizeErrors(true);
    result.setSummarizePartialErrors(true);
    result.addParam("query", query);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
    ObjectFilter filter = null;
    if (query != null) {
        filter = ObjectQueryUtil.simplify(query.getFilter());
        query = query.cloneEmpty();
        query.setFilter(filter);
    }
    if (InternalsConfig.consistencyChecks && filter != null) {
        // We may not have all the definitions here. We will apply the definitions later
        filter.checkConsistence(false);
    }
    if (filter != null && filter instanceof NoneFilter) {
        result.recordSuccessIfUnknown();
        result.cleanupResult();
        LOGGER.trace("Finished searching. Nothing to do. Filter is NONE");
        SearchResultMetadata metadata = new SearchResultMetadata();
        metadata.setApproxNumberOfAllResults(0);
        return metadata;
    }
    final GetOperationOptions rootOptions = SelectorOptions.findRootOptions(options);
    if (!ShadowType.class.isAssignableFrom(type)) {
        ResultHandler<T> internalHandler = (object, objResult) -> handleRepoObject(type, object, options, handler, task, objResult);
        Collection<SelectorOptions<GetOperationOptions>> repoOptions = null;
        if (GetOperationOptions.isReadOnly(rootOptions)) {
            repoOptions = SelectorOptions.createCollection(GetOperationOptions.createReadOnly());
        }
        SearchResultMetadata metadata = null;
        try {
            // TODO think about strictSequential flag
            metadata = getCacheRepositoryService().searchObjectsIterative(type, query, internalHandler, repoOptions, false, result);
            result.computeStatus();
            result.recordSuccessIfUnknown();
        } catch (SchemaException | RuntimeException | Error e) {
            ProvisioningUtil.recordFatalError(LOGGER, result, null, e);
        }
        result.cleanupResult();
        return metadata;
    }
    final boolean shouldDoRepoSearch = ProvisioningUtil.shouldDoRepoSearch(rootOptions);
    final ShadowHandler shadowHandler = new ShadowHandler() {

        @Override
        public boolean handle(ShadowType shadowType) {
            OperationResult handleResult = result.createSubresult(ProvisioningService.class.getName() + ".searchObjectsIterative.handle");
            if (shouldDoRepoSearch) {
                return handleRepoObject(type, (PrismObject<T>) shadowType.asPrismObject(), options, handler, task, handleResult);
            }
            if (shadowType == null) {
                throw new IllegalArgumentException("Null shadow in call to handler");
            }
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("searchObjectsIterative: processing shadow: {}", SchemaDebugUtil.prettyPrint(shadowType));
            }
            boolean doContinue;
            try {
                PrismObject shadow = shadowType.asPrismObject();
                validateObject(shadow);
                doContinue = handler.handle(shadow, handleResult);
                handleResult.computeStatus();
                handleResult.recordSuccessIfUnknown();
                if (!handleResult.isSuccess() && !handleResult.isHandledError()) {
                    Collection<? extends ItemDelta> shadowModificationType = PropertyDelta.createModificationReplacePropertyCollection(ShadowType.F_RESULT, getResourceObjectShadowDefinition(), handleResult.createOperationResultType());
                    try {
                        ConstraintsChecker.onShadowModifyOperation(shadowModificationType);
                        cacheRepositoryService.modifyObject(ShadowType.class, shadowType.getOid(), shadowModificationType, result);
                    } catch (ObjectNotFoundException ex) {
                        result.recordFatalError("Saving of result to " + shadow + " shadow failed: Not found: " + ex.getMessage(), ex);
                    } catch (ObjectAlreadyExistsException ex) {
                        result.recordFatalError("Saving of result to " + shadow + " shadow failed: Already exists: " + ex.getMessage(), ex);
                    } catch (SchemaException ex) {
                        result.recordFatalError("Saving of result to " + shadow + " shadow failed: Schema error: " + ex.getMessage(), ex);
                    } catch (RuntimeException e) {
                        result.recordFatalError("Saving of result to " + shadow + " shadow failed: " + e.getMessage(), e);
                        throw e;
                    }
                }
            } catch (RuntimeException e) {
                result.recordFatalError(e);
                throw e;
            } finally {
                handleResult.computeStatus();
                handleResult.recordSuccessIfUnknown();
                // AbstractSummarizingResultHandler [lazyman]
                if (result.isSuccess()) {
                    result.getSubresults().clear();
                }
                result.summarize();
            }
            return doContinue;
        }
    };
    SearchResultMetadata metadata;
    try {
        metadata = getShadowCache(Mode.STANDARD).searchObjectsIterative(query, options, shadowHandler, true, task, result);
        result.computeStatus();
    } catch (ConfigurationException | CommunicationException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, null, e);
        throw e;
    } finally {
        result.cleanupResult();
    }
    return metadata;
}
Also used : Primary(org.springframework.context.annotation.Primary) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ConnectorTestOperation(com.evolveum.midpoint.schema.constants.ConnectorTestOperation) PreDestroy(javax.annotation.PreDestroy) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) ObjectQueryUtil(com.evolveum.midpoint.schema.util.ObjectQueryUtil) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) Objectable(com.evolveum.midpoint.prism.Objectable) Set(java.util.Set) ProvisioningDiag(com.evolveum.midpoint.schema.ProvisioningDiag) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) NoneFilter(com.evolveum.midpoint.prism.query.NoneFilter) Task(com.evolveum.midpoint.task.api.Task) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) List(java.util.List) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConstraintViolationConfirmer(com.evolveum.midpoint.provisioning.api.ConstraintViolationConfirmer) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) QName(javax.xml.namespace.QName) Validate(org.apache.commons.lang.Validate) LabeledString(com.evolveum.midpoint.schema.LabeledString) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) CryptoUtil(com.evolveum.midpoint.common.crypto.CryptoUtil) Mode(com.evolveum.midpoint.provisioning.impl.ShadowCacheFactory.Mode) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Trace(com.evolveum.midpoint.util.logging.Trace) DebugUtil(com.evolveum.midpoint.util.DebugUtil) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ArrayList(java.util.ArrayList) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) SchemaDebugUtil(com.evolveum.midpoint.schema.util.SchemaDebugUtil) Service(org.springframework.stereotype.Service) PrismContext(com.evolveum.midpoint.prism.PrismContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType) ConstraintsCheckingResult(com.evolveum.midpoint.provisioning.api.ConstraintsCheckingResult) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) PrismObject(com.evolveum.midpoint.prism.PrismObject) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) RepoAddOptions(com.evolveum.midpoint.repo.api.RepoAddOptions) ProvisioningUtil(com.evolveum.midpoint.provisioning.util.ProvisioningUtil) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ProvisioningScriptType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptType) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) NoneFilter(com.evolveum.midpoint.prism.query.NoneFilter) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 39 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class ProvisioningServiceImpl method searchObjects.

@Override
public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".searchObjects");
    result.addParam("objectType", type);
    result.addParam("query", query);
    result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
    final SearchResultList<PrismObject<T>> objListType = new SearchResultList<>(new ArrayList<PrismObject<T>>());
    SearchResultMetadata metadata;
    try {
        if (!ShadowType.class.isAssignableFrom(type)) {
            SearchResultList<PrismObject<T>> objects = searchRepoObjects(type, query, options, task, result);
            result.computeStatus();
            result.recordSuccessIfUnknown();
            result.cleanupResult();
            //				validateObjects(objects);
            return objects;
        }
        final ResultHandler<T> handler = (object, parentResult1) -> objListType.add(object);
        metadata = searchObjectsIterative(type, query, options, handler, task, result);
    } catch (ConfigurationException | SecurityViolationException | CommunicationException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
        ProvisioningUtil.recordFatalError(LOGGER, result, "Could not search objects: " + e.getMessage(), e);
        throw e;
    }
    result.computeStatus();
    result.cleanupResult();
    //		validateObjects(objListType);
    objListType.setMetadata(metadata);
    return objListType;
}
Also used : Primary(org.springframework.context.annotation.Primary) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ConnectorTestOperation(com.evolveum.midpoint.schema.constants.ConnectorTestOperation) PreDestroy(javax.annotation.PreDestroy) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) ObjectQueryUtil(com.evolveum.midpoint.schema.util.ObjectQueryUtil) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) Objectable(com.evolveum.midpoint.prism.Objectable) Set(java.util.Set) ProvisioningDiag(com.evolveum.midpoint.schema.ProvisioningDiag) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) NoneFilter(com.evolveum.midpoint.prism.query.NoneFilter) Task(com.evolveum.midpoint.task.api.Task) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) List(java.util.List) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConstraintViolationConfirmer(com.evolveum.midpoint.provisioning.api.ConstraintViolationConfirmer) ProvisioningService(com.evolveum.midpoint.provisioning.api.ProvisioningService) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) QName(javax.xml.namespace.QName) Validate(org.apache.commons.lang.Validate) LabeledString(com.evolveum.midpoint.schema.LabeledString) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) CryptoUtil(com.evolveum.midpoint.common.crypto.CryptoUtil) Mode(com.evolveum.midpoint.provisioning.impl.ShadowCacheFactory.Mode) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Trace(com.evolveum.midpoint.util.logging.Trace) DebugUtil(com.evolveum.midpoint.util.DebugUtil) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ArrayList(java.util.ArrayList) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) SchemaDebugUtil(com.evolveum.midpoint.schema.util.SchemaDebugUtil) Service(org.springframework.stereotype.Service) PrismContext(com.evolveum.midpoint.prism.PrismContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType) ConstraintsCheckingResult(com.evolveum.midpoint.provisioning.api.ConstraintsCheckingResult) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationProvisioningScriptsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType) PrismObject(com.evolveum.midpoint.prism.PrismObject) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) RepoAddOptions(com.evolveum.midpoint.repo.api.RepoAddOptions) ProvisioningUtil(com.evolveum.midpoint.provisioning.util.ProvisioningUtil) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ProvisioningScriptType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProvisioningScriptType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)39 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)39 PrismObject (com.evolveum.midpoint.prism.PrismObject)37 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)37 Task (com.evolveum.midpoint.task.api.Task)36 Test (org.testng.annotations.Test)34 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)19 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)9 QName (javax.xml.namespace.QName)4 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)3 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 GenericConnectorException (com.evolveum.midpoint.provisioning.api.GenericConnectorException)3 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)3 ProvisioningUtil (com.evolveum.midpoint.provisioning.util.ProvisioningUtil)3 ResourceShadowDiscriminator (com.evolveum.midpoint.schema.ResourceShadowDiscriminator)3 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)3 InternalsConfig (com.evolveum.midpoint.schema.internals.InternalsConfig)3