Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jan 23, 2023
2 parents d149a1f + 7a9f832 commit 4f8f653
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

package com.evolveum.midpoint.gui.impl.page.admin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.poi.ss.formula.functions.T;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.FormComponent;
import org.apache.wicket.markup.html.form.validation.IFormValidator;
Expand Down Expand Up @@ -88,15 +88,15 @@ private void visitWrapper(ItemWrapper iw, List<ItemWrapper> iws) {
}

private void validateItemWrapperWithFormValidator(Form form, ItemWrapper iw, PrismValueWrapper value) {
Validatable<T> validatable = new Validatable<>() {
Validatable<Serializable> validatable = new Validatable<>() {

@Override
public T getValue() {
public Serializable getValue() {
return value.getNewValue().getRealValue();
}

@Override
public IModel<T> getModel() {
public IModel<Serializable> getModel() {
return () -> getValue();
}
};
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 All @@ -8,14 +8,6 @@

import java.util.*;

import com.evolveum.midpoint.schema.processor.ResourceSchema;

import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;

import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityCollectionType;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -32,11 +24,16 @@
import com.evolveum.midpoint.repo.api.query.ObjectFilterExpressionEvaluator;
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.processor.ResourceObjectDefinition;
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CapabilityCollectionType;

@SuppressWarnings({ "ConstantConditions" })
public class MockFactory {
Expand Down Expand Up @@ -169,7 +166,8 @@ public Object executeScript(
}

@Override
public @Nullable ResourceSchema fetchSchema(@NotNull PrismObject<ResourceType> resource, @NotNull OperationResult parentResult) {
public @Nullable ResourceSchema fetchSchema(
@NotNull PrismObject<ResourceType> resource, @NotNull OperationResult parentResult) {
return null;
}

Expand Down Expand Up @@ -308,7 +306,8 @@ public static RepositoryService createRepositoryService() {
return new RepositoryService() {
@Override
@NotNull
public <O extends ObjectType> PrismObject<O> getObject(Class<O> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
public <O extends ObjectType> PrismObject<O> getObject(Class<O> type,
String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
throw new UnsupportedOperationException();
}

Expand All @@ -318,36 +317,57 @@ public <T extends ObjectType> String getVersion(Class<T> type, String oid, Opera
}

@Override
public <T extends Containerable> int countContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
return 0;
public <T extends ObjectType> @NotNull String addObject(
@NotNull PrismObject<T> object, RepoAddOptions options, @NotNull OperationResult parentResult) {
return UUID.randomUUID().toString();
}

@Override
public <T extends ObjectType> @NotNull String addObject(@NotNull PrismObject<T> object, RepoAddOptions options, @NotNull OperationResult parentResult) {
return UUID.randomUUID().toString();
public <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
return 0;
}

@NotNull
@Override
public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(@NotNull Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult) {
return new SearchResultList<>(new ArrayList<>(0));
public <T extends ObjectType> SearchResultList<PrismObject<T>> searchObjects(
@NotNull Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult) {
return new SearchResultList<>(List.of());
}

@Override
public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
return new SearchResultList<>(new ArrayList<>(0));
public <T extends Containerable> int countContainers(Class<T> type,
ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
return 0;
}

@Override
public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(Class<T> type, ObjectQuery query, ResultHandler<T> handler, Collection<SelectorOptions<GetOperationOptions>> options, boolean strictlySequential, OperationResult parentResult) {
return null;
public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type,
ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
return new SearchResultList<>(List.of());
}

@Override
public <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
public int countReferences(@Nullable ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult) {
return 0;
}

@Override
public @NotNull SearchResultList<ObjectReferenceType> searchReferences(@NotNull ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult) {
return new SearchResultList<>(List.of());
}

@Override
public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(
Class<T> type, ObjectQuery query, ResultHandler<T> handler,
Collection<SelectorOptions<GetOperationOptions>> options,
boolean strictlySequential, OperationResult parentResult) {
return null;
}

@Override
public <O extends ObjectType> boolean isDescendant(
PrismObject<O> object, String ancestorOrgOid) {
Expand Down Expand Up @@ -389,7 +409,8 @@ public <T extends ObjectType> ModifyObjectResult<T> modifyObject(

@NotNull
@Override
public <T extends ObjectType> DeleteObjectResult deleteObject(Class<T> type, String oid, OperationResult parentResult) {
public <T extends ObjectType> DeleteObjectResult deleteObject(
Class<T> type, String oid, OperationResult parentResult) {
return null;
}

Expand All @@ -399,7 +420,8 @@ public long advanceSequence(String oid, OperationResult parentResult) {
}

@Override
public void returnUnusedValuesToSequence(String oid, Collection<Long> unusedValues, OperationResult parentResult) {
public void returnUnusedValuesToSequence(
String oid, Collection<Long> unusedValues, OperationResult parentResult) {

}

Expand Down Expand Up @@ -429,12 +451,15 @@ public void testOrgClosureConsistency(boolean repairIfNecessary, OperationResult
}

@Override
public RepositoryQueryDiagResponse executeQueryDiagnostics(RepositoryQueryDiagRequest request, OperationResult result) {
public RepositoryQueryDiagResponse executeQueryDiagnostics(
RepositoryQueryDiagRequest request, OperationResult result) {
return null;
}

@Override
public <O extends ObjectType> boolean selectorMatches(ObjectSelectorType objectSelector, PrismObject<O> object, ObjectFilterExpressionEvaluator filterEvaluator, Trace logger, String logMessagePrefix) {
public <O extends ObjectType> boolean selectorMatches(
ObjectSelectorType objectSelector, PrismObject<O> object,
ObjectFilterExpressionEvaluator filterEvaluator, Trace logger, String logMessagePrefix) {
return false;
}

Expand Down Expand Up @@ -469,7 +494,8 @@ public boolean hasConflict(ConflictWatcher watcher, OperationResult result) {
}

@Override
public <T extends ObjectType> void addDiagnosticInformation(Class<T> type, String oid, DiagnosticInformationType information, OperationResult parentResult) {
public <T extends ObjectType> void addDiagnosticInformation(Class<T> type,
String oid, DiagnosticInformationType information, OperationResult parentResult) {

}

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 All @@ -8,16 +8,12 @@

import java.util.Collection;

import com.evolveum.midpoint.prism.PrismConstants;

import com.evolveum.midpoint.prism.PrismContext;

import com.evolveum.midpoint.util.logging.TraceManager;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.PrismConstants;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.query.ObjectQuery;
Expand All @@ -28,6 +24,7 @@
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
Expand Down Expand Up @@ -135,6 +132,8 @@ public interface RepositoryService {
String OP_SEARCH_OBJECTS_ITERATIVE_PAGE = "searchObjectsIterativePage";
String OP_SEARCH_CONTAINERS = "searchContainers";
String OP_COUNT_CONTAINERS = "countContainers";
String OP_SEARCH_REFERENCES = "searchReferences";
String OP_COUNT_REFERENCES = "countReferences";
String OP_FETCH_EXT_ITEMS = "fetchExtItems";
String OP_ADD_DIAGNOSTIC_INFORMATION = "addDiagnosticInformation";
String OP_HAS_CONFLICT = "hasConflict";
Expand Down Expand Up @@ -345,11 +344,32 @@ <T extends Containerable> int countContainers(Class<T> type, ObjectQuery query,

/**
* Search for "sub-object" structures, i.e. containers.
* Currently, only one type of search is available: certification case search.
*/
<T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException;

/**
* Reference count - currently supporting roleMembershipRef and linkRef search.
*
* @param query mandatory query that has to have exactly one root OWNER-BY and additional REF filters
*/
int countReferences(
@Nullable ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
@NotNull OperationResult parentResult);

/**
* Reference search - currently supporting roleMembershipRef and linkRef search.
* This returns reference objects extracted from the actual object(s) that own them,
* but selection of which (and cardinality of the result list) is based on a repository search.
*
* @param query mandatory query that has to have exactly one root OWNER-BY and additional REF filters
*/
@NotNull SearchResultList<ObjectReferenceType> searchReferences(
@NotNull ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
@NotNull OperationResult parentResult) throws SchemaException;

/**
* <p>Search for objects in the repository.</p>
* <p>If no search criteria specified, list of all objects of specified type is returned.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> t
return searchOpHandler.searchContainers(type, query, options, parentResult);
}

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

@Override
public <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
Expand All @@ -138,6 +145,12 @@ public <T extends Containerable> int countContainers(Class<T> type, ObjectQuery
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
return searchOpHandler.countContainers(type, query, options, parentResult);
}

@Override
public int countReferences(@Nullable ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options, @NotNull OperationResult parentResult) {
return searchOpHandler.countReferences(query, options, parentResult);
}
//endregion

//region --- ADD, MODIFY, DELETE and other modifications -------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

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 @@ -28,10 +30,7 @@
import com.evolveum.midpoint.schema.*;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RepositorySearchObjectsTraceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TracingLevelType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

/**
* Handler for searchObjects/searchObjectsIterative operations.
Expand Down Expand Up @@ -337,7 +336,9 @@ public <F extends FocusType> PrismObject<F> searchShadowOwner(
}
}

public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException {
public <T extends Containerable> SearchResultList<T> searchContainers(Class<T> type,
ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult)
throws SchemaException {
OperationResult result = parentResult.subresult(OP_SEARCH_CONTAINERS)
.addQualifier(type.getSimpleName())
.addParam("type", type)
Expand Down Expand Up @@ -377,6 +378,42 @@ public <T extends Containerable> int countContainers(Class<T> type, ObjectQuery
}
}

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)
.build();
Long startTime = repoOpStart();
try {
return repositoryService.searchReferences(query, options, result);
} catch (Throwable t) {
result.recordFatalError(t);
throw t;
} finally {
repoOpEnd(startTime);
result.computeStatusIfUnknown();
}
}

public int countReferences(ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) {
OperationResult result = parentResult.subresult(OP_COUNT_REFERENCES)
.addParam("query", query)
.addArbitraryObjectCollectionAsParam("options", options)
.build();
MonitoringUtil.log("Cache: PASS countReferences ({})", false, ObjectReferenceType.class.getSimpleName());
Long startTime = repoOpStart();
try {
return repositoryService.countReferences(query, 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 4f8f653

Please sign in to comment.