Skip to content

Commit

Permalink
removal of AuditReindexTaskHandler and AuditService#reindexEntry
Browse files Browse the repository at this point in the history
This is non-functional for a year now, and in general causes more harm
than good - audit should be insert only even in DB, helps performance.
  • Loading branch information
virgo47 committed Aug 24, 2021
1 parent 532a809 commit 8261002
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 274 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2020 Evolveum and contributors
* Copyright (C) 2010-2021 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 @@ -135,10 +135,6 @@ public boolean isVisible() {
}

private ItemVisibility getBasicTabVisibility(ItemPath path) {
// if (ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_CLEANUP_POLICIES).equivalent(path)) {
// return ItemVisibility.HIDDEN;
// }

if (TaskType.F_SUBTASK_REF.equivalent(path)) {
return ItemVisibility.HIDDEN;
}
Expand Down Expand Up @@ -207,8 +203,6 @@ private ItemVisibility getBasicTabVisibility(ItemPath path) {
ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.JDBC_PING_JDBC_USERNAME_QNAME),
ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.JDBC_PING_JDBC_PASSWORD_QNAME),
ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.JDBC_PING_LOG_ON_INFO_LEVEL_QNAME));
} else if (taskHandler.endsWith("model/auditReindex/handler-3")) {
//no extension attributes
} else if (taskHandler.endsWith("task/lightweight-partitioning/handler-3")
|| taskHandler.endsWith("model/partitioned-focus-validity-scanner/handler-3")
|| taskHandler.endsWith("model/synchronization/task/partitioned-reconciliation/handler-3")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2015 Evolveum and contributors
* Copyright (C) 2010-2021 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 @@ -17,12 +17,11 @@
*/
public class ModelPublicConstants {

private static final String NS_SYNCHRONIZATION_PREFIX = SchemaConstants.NS_MODEL +"/synchronization";
private static final String NS_SYNCHRONIZATION_PREFIX = SchemaConstants.NS_MODEL + "/synchronization";
public static final String NS_SYNCHRONIZATION_TASK_PREFIX = NS_SYNCHRONIZATION_PREFIX + "/task";

public static final String DELETE_TASK_HANDLER_URI = NS_SYNCHRONIZATION_TASK_PREFIX + "/delete/handler-3"; // TODO why "synchronization"?
public static final String REINDEX_TASK_HANDLER_URI = SchemaConstants.NS_MODEL + "/reindex/handler-3";
public static final String AUDIT_REINDEX_TASK_HANDLER_URI = SchemaConstants.NS_MODEL + "/auditReindex/handler-3";
public static final String CLEANUP_TASK_HANDLER_URI = SchemaConstants.NS_MODEL + "/cleanup/handler-3";
public static final String SHADOW_INTEGRITY_CHECK_TASK_HANDLER_URI = SchemaConstants.NS_MODEL + "/shadow-integrity-check/handler-3";
public static final String OBJECT_INTEGRITY_CHECK_TASK_HANDLER_URI = SchemaConstants.NS_MODEL + "/object-integrity-check/handler-3";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ public interface AuditService {
*/
List<AuditEventRecord> listRecords(String query, Map<String, Object> params, OperationResult result);

/**
* Reindex audit record - <b>currently does nothing</b>.
* Previously it effectively created missing changed items detail entities,
* which is less and less useful nowadays.
* TODO: In the future we may consider reindexing of new columns, but the functionality
* is currently not fully specified.
*/
void reindexEntry(AuditEventRecord record);

/**
* @throws UnsupportedOperationException if object retrieval is not supported
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2020 Evolveum and contributors
* Copyright (C) 2010-2021 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 @@ -165,11 +165,6 @@ public boolean supportsRetrieval() {
return false;
}

@Override
public void reindexEntry(AuditEventRecord record) {
throw new UnsupportedOperationException("Reindex entry not supported");
}

@Override
public int countObjects(
@Nullable ObjectQuery query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,52 +673,6 @@ private AuditReferenceValue createAuditReferenceValue(ResultSet resultSet) throw
RUtil.stringToQName(resultSet.getString(QAuditRefValue.TYPE.getName())), targetName);
}

@Override
public void reindexEntry(AuditEventRecord record) {
LOGGER.warn("Audit reindex does nothing now and probably should not be used.");
/* TODO: disabled in 2020 during MID-6318, see Javadoc from interface.
* Consider removal if it doesn't get proper meaning in some not so distant time.
final String operation = "reindexEntry";
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
long opHandle = pm.registerOperationStart(operation, AuditEventRecord.class);
int attempt = 1;
while (true) {
try {
reindexEntryAttempt(record);
return;
} catch (RuntimeException ex) {
attempt = baseHelper.logOperationAttempt(null, operation, attempt, ex, null);
pm.registerOperationNewAttempt(opHandle, attempt);
} finally {
pm.registerOperationFinish(opHandle, attempt);
}
}
}
private void reindexEntryAttempt(AuditEventRecord record) {
Session session = baseHelper.beginTransaction();
try {
RAuditEventRecord reindexed = RAuditEventRecord.toRepo(record, prismContext, null, auditConfiguration);
//TODO FIXME temporary hack, merge will eventually load the object to the session if there isn't one,
// but in this case we force loading object because of "objectDeltaOperation". There is some problem probably
// during serializing/deserializing which causes constraint violation on primary key..
RAuditEventRecord rRecord = session.load(RAuditEventRecord.class, record.getRepoId());
rRecord.getChangedItems().clear();
rRecord.getChangedItems().addAll(reindexed.getChangedItems());
session.merge(rRecord);
session.getTransaction().commit();
} catch (DtoTranslationException ex) {
baseHelper.handleGeneralCheckedException(ex, session, null);
} catch (RuntimeException ex) {
baseHelper.handleGeneralRuntimeException(ex, session, null);
} finally {
baseHelper.cleanupSessionAndResult(session, null);
}
*/
}

private RObjectType repoObjectType(ResultSet resultList, String columnName)
throws SQLException {
// Yes, to detect null, you have to check again after reading int. No getInteger there.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,6 @@ public boolean supportsRetrieval() {
return false;
}

@Override
public void reindexEntry(AuditEventRecord record) {
// not needed in dummy
}

public boolean isEnabled() {
return enabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import java.util.List;
import java.util.Map;

import com.evolveum.midpoint.task.api.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;

import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -36,11 +33,13 @@
import com.evolveum.midpoint.security.api.HttpConnectionInformation;
import com.evolveum.midpoint.security.api.SecurityContextManager;
import com.evolveum.midpoint.security.api.SecurityUtil;
import com.evolveum.midpoint.task.api.*;
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.xml.ns._public.common.audit_3.AuditEventRecordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType;
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.SystemConfigurationAuditType;

Expand Down Expand Up @@ -219,15 +218,6 @@ public List<AuditEventRecord> listRecords(String query, Map<String, Object> para
return result;
}

@Override
public void reindexEntry(AuditEventRecord record) {
for (AuditService service : services) {
if (service.supportsRetrieval()) {
service.reindexEntry(record);
}
}
}

@Override
public long countObjects(String query, Map<String, Object> params) {
long count = 0;
Expand Down

0 comments on commit 8261002

Please sign in to comment.