Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
* 'master' of github.com:Evolveum/midpoint:
  introduced searchReferencesIterative(), but still WIP
  • Loading branch information
katkav committed Feb 1, 2023
2 parents 2f15a6d + 835b27a commit 00b0e29
Show file tree
Hide file tree
Showing 26 changed files with 998 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
/*
* Copyright (c) 2010-2013 Evolveum and contributors
* Copyright (C) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.schema;

import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.schema.result.OperationResult;

/**
* Handles iterative processes that concern containerables.
*/
@FunctionalInterface
public interface ContainerableResultHandler<C extends Containerable> {
public interface ContainerableResultHandler<C extends Containerable> extends ObjectHandler<C> {

/**
* Handle a single value.
* @param value Value to process.
* @return true if the operation should proceed, false if it should stop
*/
boolean handle(C value, OperationResult parentResult);
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(
return null;
}

@Override
public SearchResultMetadata searchReferencesIterative(
@Nullable ObjectQuery query,
@NotNull ObjectHandler<ObjectReferenceType> handler,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
@NotNull OperationResult parentResult) {
return null;
}

@Override
public <O extends ObjectType> boolean isDescendant(
PrismObject<O> object, String ancestorOrgOid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public interface RepositoryService {
String OP_SEARCH_CONTAINERS = "searchContainers";
String OP_COUNT_CONTAINERS = "countContainers";
String OP_SEARCH_REFERENCES = "searchReferences";
String OP_SEARCH_REFERENCES_ITERATIVE = "searchReferencesIterative";
String OP_SEARCH_REFERENCES_ITERATIVE_PAGE = "searchReferencesIterativePage";
String OP_COUNT_REFERENCES = "countReferences";
String OP_FETCH_EXT_ITEMS = "fetchExtItems";
String OP_ADD_DIAGNOSTIC_INFORMATION = "addDiagnosticInformation";
Expand Down Expand Up @@ -207,7 +209,7 @@ <T extends ObjectType> String getVersion(Class<T> type, String oid, OperationRes
*
* This operation should fail if such object already exists (if object with
* the provided OID already exists).
* Overwrite is possible if {@link RepoAddOptions#overwrite} is true, but only
* Overwrite is possible if {@link RepoAddOptions#isOverwrite()} is true, but only
* for the object of the same type.
*
* The operation may fail if provided OID is in an unusable format for the storage.
Expand Down Expand Up @@ -488,6 +490,22 @@ <T extends ObjectType> SearchResultMetadata searchObjectsIterative(Class<T> type
OperationResult parentResult)
throws SchemaException;

/**
* Executes iterative reference search using the provided `handler` to process each references.
*
* @param query search query
* @param handler result handler
* @param options get options to use for the search
* @param parentResult parent OperationResult (in/out)
* @return summary information about the search result
*/
@Experimental
SearchResultMetadata searchReferencesIterative(
@Nullable ObjectQuery query,
@NotNull ObjectHandler<ObjectReferenceType> handler,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
@NotNull OperationResult parentResult) throws SchemaException;

/**
* Returns `true` if the `object` is under the organization identified with `ancestorOrgOid`.
* The `object` can either be an Org or any other object in which case all the targets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2021 Evolveum and contributors
* Copyright (C) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -120,6 +120,15 @@ public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(Class<
return searchOpHandler.searchObjectsIterative(type, query, handler, options, strictlySequential, parentResult);
}

@Override
public SearchResultMetadata searchReferencesIterative(
@Nullable ObjectQuery query,
@NotNull ObjectHandler<ObjectReferenceType> handler,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
@NotNull OperationResult parentResult) throws SchemaException {
return searchOpHandler.searchReferencesIterative(query, handler, options, parentResult);
}

@Override
public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*
* Copyright (c) 2020 Evolveum and contributors
* Copyright (C) 2020-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.repo.cache.handlers;

import static com.evolveum.midpoint.repo.api.RepositoryService.OP_COUNT_REFERENCES;
import static com.evolveum.midpoint.repo.api.RepositoryService.OP_SEARCH_REFERENCES;
import static com.evolveum.midpoint.repo.cache.RepositoryCache.CLASS_NAME_WITH_DOT;
import static com.evolveum.midpoint.repo.cache.other.MonitoringUtil.repoOpEnd;
import static com.evolveum.midpoint.repo.cache.other.MonitoringUtil.repoOpStart;
Expand All @@ -19,6 +17,7 @@
import java.util.Collection;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.prism.Containerable;
Expand All @@ -45,6 +44,9 @@ public class SearchOpHandler extends CachedOpHandler {
private static final String OP_SEARCH_SHADOW_OWNER = CLASS_NAME_WITH_DOT + "searchShadowOwner";
private static final String OP_COUNT_CONTAINERS = CLASS_NAME_WITH_DOT + "countContainers";
private static final String OP_COUNT_OBJECTS = CLASS_NAME_WITH_DOT + "countObjects";
private static final String OP_SEARCH_REFERENCES = CLASS_NAME_WITH_DOT + "searchReferences";
private static final String OP_COUNT_REFERENCES = CLASS_NAME_WITH_DOT + "countReferences";
private static final String OP_SEARCH_REFERENCES_ITERATIVE = CLASS_NAME_WITH_DOT + "searchReferencesIterative";

/**
* Queries resulting in more objects will not be cached "as such" - although individual objects/versions can be cached.
Expand Down Expand Up @@ -378,7 +380,8 @@ public <T extends Containerable> int countContainers(Class<T> type, ObjectQuery
}
}

public SearchResultList<ObjectReferenceType> searchReferences(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException {
public SearchResultList<ObjectReferenceType> searchReferences(ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException {
OperationResult result = parentResult.subresult(OP_SEARCH_REFERENCES)
.addParam("query", query)
.addArbitraryObjectAsParam("options", options)
Expand Down Expand Up @@ -414,6 +417,27 @@ public int countReferences(ObjectQuery query,
}
}

public SearchResultMetadata searchReferencesIterative(
@Nullable ObjectQuery query,
@NotNull ObjectHandler<ObjectReferenceType> handler,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
@NotNull OperationResult parentResult) throws SchemaException {
OperationResult result = parentResult.subresult(OP_SEARCH_REFERENCES_ITERATIVE)
.addParam("query", query)
.addArbitraryObjectAsParam("options", options)
.build();
Long startTime = repoOpStart();
try {
return repositoryService.searchReferencesIterative(query, handler, options, result);
} catch (Throwable t) {
result.recordFatalError(t);
throw t;
} finally {
repoOpEnd(startTime);
result.computeStatusIfUnknown();
}
}

public <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
throws SchemaException {
Expand Down

0 comments on commit 00b0e29

Please sign in to comment.