Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Aug 26, 2021
2 parents 8fc1537 + cb83d54 commit 6ced04d
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
@SpringBean(name = "taskManager")
private TaskManager taskManager;

@SpringBean(name = "auditService")
private AuditService auditService;
@SpringBean(name = "modelAuditService")
private ModelAuditService modelAuditService;

@SpringBean(name = "modelController")
private WorkflowService workflowService;
Expand Down Expand Up @@ -449,8 +449,8 @@ public ReportManager getReportManager() {
return reportManager;
}

public AuditService getAuditService() {
return auditService;
public ModelAuditService getModelAuditService() {
return modelAuditService;
}

public AccessCertificationService getCertificationService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,7 @@ public static <C extends Containerable> List<C> searchContainers(Class<C> type,
Task task = page.createSimpleTask(subResult.getOperation());
List<C> list;
if (AuditEventRecordType.class.equals(type)) {
// TODO: This goes around any authorization, is it what we want? If yes, delete this TODO, please. :-)
list = (List<C>) page.getAuditService().searchObjects(query, options, subResult);
list = (List<C>) page.getModelAuditService().searchObjects(query, options, task, subResult);
} else {
list = page.getModelService().searchContainers(type, query, options, task, subResult);
}
Expand Down Expand Up @@ -515,8 +514,7 @@ public static <C extends Containerable> int countContainers(Class<C> type, Objec
int count = 0;
try {
if (AuditEventRecordType.class.equals(type)) {
// TODO: This goes around any authorization, is it what we want? If yes, delete this TODO, please. :-)
count = page.getAuditService().countObjects(query, options, parentResult);
count = page.getModelAuditService().countObjects(query, options, task, parentResult);
} else {
count = page.getModelService().countContainers(type, query, options, task, parentResult);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ public Iterator<SelectableBean<C>> internalIterator(long offset, long pageSize)
LOGGER.trace("end::iterator() {}", result);
return getAvailableData().iterator();
}
public List<SelectableBean<C>> createDataObjectWrappers(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result)
throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
public List<SelectableBean<C>> createDataObjectWrappers(Class<? extends C> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result)
throws CommonException {
List<C> list = searchObjects(type, query, options, task, result);

if (LOGGER.isTraceEnabled()) {
Expand All @@ -197,7 +198,9 @@ public List<SelectableBean<C>> createDataObjectWrappers(Class<? extends C> type,
return data;
}

protected List<C> searchObjects(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
protected List<C> searchObjects(Class<? extends C> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result)
throws CommonException {
return (List) getModel().searchContainers(type, query, options, task, result);
}

Expand Down Expand Up @@ -255,7 +258,9 @@ protected int internalSize() {
return count;
}

protected Integer countObjects(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
protected Integer countObjects(Class<? extends C> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result)
throws CommonException {
return getModel().countContainers(type, getQuery(), currentOptions, task, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import java.util.*;

import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.web.application.Url;

import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -157,12 +157,13 @@ protected AuditEventRecordType load() {
.item(AuditEventRecordType.F_REPO_ID)
.eq(eventIdentifier);
ObjectQuery query = filter.build();
OperationResult result = new OperationResult(OPERATION_LOAD_AUDIT_RECORD);
Task task = createSimpleTask(OPERATION_LOAD_AUDIT_RECORD);
OperationResult result = task.getResult();
SearchResultList<AuditEventRecordType> records = null;
try {
records = getAuditService().searchObjects(query, null, result);
records = getModelAuditService().searchObjects(query, null, task, result);
result.computeStatusIfUnknown();
} catch (SchemaException e) {
} catch (CommonException e) {
LOGGER.error("Cannot get audit record, reason: {}", e.getMessage(), e);
result.recordFatalError("Cannot get audit record, reason: " + e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import java.util.*;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.audit.api.AuditEventRecord;

import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectColumnType;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -54,7 +53,6 @@
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.ISelectableDataProvider;
Expand Down Expand Up @@ -164,15 +162,16 @@ protected PageStorage getPageStorage() {

@Override
protected Integer countObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) {
return getPageBase().getAuditService().countObjects(query, currentOptions, result);
Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result)
throws CommonException {
return getPageBase().getModelAuditService().countObjects(query, currentOptions, task, result);
}

@Override
protected List<AuditEventRecordType> searchObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query,
Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result)
throws SchemaException {
return getPageBase().getAuditService().searchObjects(query, options, result);
throws CommonException {
return getPageBase().getModelAuditService().searchObjects(query, options, task, result);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void cleanupAudit(CleanupPolicyType policy, Task task, OperationResult parentRes
/**
* @throws UnsupportedOperationException if object retrieval is not supported
*/
long countObjects(
int countObjects(
@Nullable ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
Task task,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import javax.xml.namespace.QName;
Expand All @@ -35,15 +30,14 @@
public interface DashboardService {

DashboardWidget createWidgetData(DashboardWidgetType widget, boolean useDisplaySource, Task task, OperationResult result)
throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException,
ExpressionEvaluationException, ObjectNotFoundException;
throws CommonException;

ObjectCollectionType getObjectCollectionType(DashboardWidgetType widget, Task task, OperationResult result) throws ObjectNotFoundException,
SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException;

CollectionRefSpecificationType getCollectionRefSpecificationType(DashboardWidgetType widget, Task task, OperationResult result);

Integer countAuditEvents(CollectionRefSpecificationType collectionRef, ObjectCollectionType collection, Task task, OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException;
throws CommonException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void audit(AuditEventRecord record, Task task, OperationResult result)
}

@Override
public long countObjects(
public int countObjects(
@Nullable ObjectQuery query,
@Nullable Collection<SelectorOptions<GetOperationOptions>> options,
Task task,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import java.util.*;

import com.evolveum.midpoint.model.api.ModelAuditService;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -62,7 +64,7 @@ public class DashboardServiceImpl implements DashboardService {
private static final String VAR_POLICY_SITUATIONS = "policySituations";

@Autowired private TaskManager taskManager;
@Autowired private AuditService auditService;
@Autowired private ModelAuditService modelAuditService;
@Autowired private PrismContext prismContext;
@Autowired private Clock clock;
@Autowired private ModelInteractionService modelInteractionService;
Expand All @@ -74,7 +76,7 @@ public class DashboardServiceImpl implements DashboardService {

@Override
public DashboardWidget createWidgetData(DashboardWidgetType widget, boolean useDisplaySource, Task task, OperationResult result)
throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, ObjectNotFoundException {
throws CommonException {

Validate.notNull(widget, "Widget is null");

Expand Down Expand Up @@ -172,7 +174,7 @@ private DashboardWidgetSourceTypeType getSourceTypeForNumberMessage(DashboardWid
}

private String getNumberMessage(DashboardWidgetType widget, DashboardWidget data, boolean useDisplaySource, Task task, OperationResult result)
throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException, ObjectNotFoundException {
throws CommonException {
DashboardWidgetSourceTypeType sourceType = getSourceTypeForNumberMessage(widget, useDisplaySource);
DashboardWidgetPresentationType presentation = widget.getPresentation();
switch (sourceType) {
Expand Down Expand Up @@ -225,7 +227,7 @@ private String generateNumberMessageForObject(DashboardWidgetType widget, Dashbo
}

private String generateNumberMessageForAuditSearch(DashboardWidgetType widget, DashboardWidget data, Task task, OperationResult result)
throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
throws CommonException {
ObjectCollectionType collection = getObjectCollectionType(widget, task, result);
CollectionRefSpecificationType collectionRef = getCollectionRefSpecificationType(widget, task, result);
if (collection == null && collectionRef.getFilter() == null) {
Expand All @@ -249,8 +251,8 @@ private String generateNumberMessageForAuditSearch(DashboardWidgetType widget, D
return generateNumberMessage(widget, createVariables(null, statType, null, null), data);
}

public Integer countAuditEvents(CollectionRefSpecificationType collectionRef, ObjectCollectionType collection, Task task, OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
public Integer countAuditEvents(CollectionRefSpecificationType collectionRef, ObjectCollectionType collection,
Task task, OperationResult result) throws CommonException {

if (collectionRef == null ||
((collectionRef.getCollectionRef() == null || collectionRef.getCollectionRef().getOid() == null)
Expand Down Expand Up @@ -281,7 +283,7 @@ public Integer countAuditEvents(CollectionRefSpecificationType collectionRef, Ob
}
@NotNull Collection<SelectorOptions<GetOperationOptions>> option = combineAuditOption(collectionRef, collection, task, result);

return auditService.countObjects(query, option, result);
return modelAuditService.countObjects(query, option, task, result);
}

private @NotNull Collection<SelectorOptions<GetOperationOptions>> combineAuditOption(CollectionRefSpecificationType collectionRef, ObjectCollectionType collection, Task task, OperationResult result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public class ModelInteractionServiceImpl implements ModelInteractionService {
@Autowired private CacheConfigurationManager cacheConfigurationManager;
@Autowired private ClusterwideUserSessionManager clusterwideUserSessionManager;
@Autowired private ContextLoader contextLoader;
@Autowired private AuditService auditService;
@Autowired private ModelAuditService modelAuditService;

private static final String OPERATION_GENERATE_VALUE = ModelInteractionService.class.getName() + ".generateValue";
private static final String OPERATION_VALIDATE_VALUE = ModelInteractionService.class.getName() + ".validateValue";
Expand Down Expand Up @@ -1976,15 +1976,18 @@ public void processObjectsFromCollection(CollectionRefSpecificationType collecti
task.setExpectedTotal(count);
}
if (AuditEventRecordType.class.equals(type)) {
checkOrdering(query, ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), AuditEventRecordType.F_TIMESTAMP.getLocalPart())));
@NotNull SearchResultList<AuditEventRecordType> auditRecords = auditService.searchObjects(query, options, result);
checkOrdering(query, ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(),
AuditEventRecordType.F_TIMESTAMP.getLocalPart())));
@NotNull SearchResultList<AuditEventRecordType> auditRecords = modelAuditService.searchObjects(
query, options, task, result);
processContainerByHandler(auditRecords, handler);
} else if (ObjectType.class.isAssignableFrom(type)) {
ResultHandler<ObjectType> resultHandler = (value, operationResult) -> handler.test((PrismContainer)value);
checkOrdering(query, ObjectType.F_NAME);
modelService.searchObjectsIterative((Class<ObjectType>) type, query, resultHandler, options, task, result);
} else {
SearchResultList<? extends Containerable> containers = modelService.searchContainers(type, query, options, task, result);
SearchResultList<? extends Containerable> containers = modelService.searchContainers(
type, query, options, task, result);
processContainerByHandler(containers, handler);
}
}
Expand Down Expand Up @@ -2069,15 +2072,18 @@ public List<? extends Containerable> searchObjectsFromCollection(CollectionRefSp
Collection<SelectorOptions<GetOperationOptions>> options = determineOptionsForSearch(compiledCollection, defaultOptions);

if (AuditEventRecordType.class.equals(type)) {
@NotNull SearchResultList<AuditEventRecordType> auditRecords = auditService.searchObjects(query, options, result);
@NotNull SearchResultList<AuditEventRecordType> auditRecords = modelAuditService.searchObjects(
query, options, task, result);
return auditRecords.getList();
} else if (ObjectType.class.isAssignableFrom(type)) {
SearchResultList<PrismObject<ObjectType>> results = modelService.searchObjects((Class<ObjectType>) type, query, options, task, result);
SearchResultList<PrismObject<ObjectType>> results = modelService.searchObjects(
(Class<ObjectType>) type, query, options, task, result);
List list = new ArrayList<Containerable>();
results.forEach(object -> list.add(object.asObjectable()));
return list;
} else {
SearchResultList<? extends Containerable> containers = modelService.searchContainers(type, query, options, task, result);
SearchResultList<? extends Containerable> containers = modelService.searchContainers(
type, query, options, task, result);
return containers.getList();
}
}
Expand Down Expand Up @@ -2105,7 +2111,7 @@ public Integer countObjectsFromCollection(CollectionRefSpecificationType collect
private Integer countObjectsFromCollectionByType(Class<? extends Containerable> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result)
throws SchemaException, ExpressionEvaluationException, SecurityViolationException, CommunicationException, ConfigurationException, ObjectNotFoundException {
if (AuditEventRecordType.class.equals(type)) {
return auditService.countObjects(query, options, result);
return modelAuditService.countObjects(query, options, task, result);
} else if (ObjectType.class.isAssignableFrom(type)) {
return modelService.countObjects((Class<ObjectType>) type, query, options, task, result);
}
Expand Down

0 comments on commit 6ced04d

Please sign in to comment.