Eli Mesika has uploaded a new change for review. Change subject: core: moving AuditLog message length check to DB ......................................................................
core: moving AuditLog message length check to DB The check in the setMessage breaks API tests since the created mock has no access to configuration. Since this check is relevant only for External Events, it was moved to the stored procedure. Change-Id: Ib2805ee22301d75a7d6a2c852a3acfe3fc0f5f59 Signed-off-by: Eli Mesika <[email protected]> --- M backend/manager/dbscripts/audit_log_sp.sql M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java 2 files changed, 9 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/10522/1 diff --git a/backend/manager/dbscripts/audit_log_sp.sql b/backend/manager/dbscripts/audit_log_sp.sql index 731a6bd..9f8876c 100644 --- a/backend/manager/dbscripts/audit_log_sp.sql +++ b/backend/manager/dbscripts/audit_log_sp.sql @@ -86,8 +86,17 @@ v_event_flood_in_sec INTEGER, v_custom_data text) AS $procedure$ +DECLARE + v_max_message_length INTEGER; BEGIN + -- truncate message if exceeds configured max length. truncated messages will be ended + -- with "..." to indicate that message is incomplete due to size limits. + + v_max_message_length := cast(option_value as int) FROM vdc_options WHERE option_name = 'MaxAuditLogMessageLength' and version = 'general'; + IF (v_max_message_length IS NOT NULL and length(v_message) > v_max_message_length) THEN + v_message := substr(v_message, 1, v_max_message_length -3) || '...'; + END IF; INSERT INTO audit_log(LOG_TIME, log_type, log_type_name, severity,message, user_id, USER_NAME, vds_id, VDS_NAME, vm_id, VM_NAME,vm_template_id,VM_TEMPLATE_NAME,storage_pool_id,STORAGE_POOL_NAME,storage_domain_id,STORAGE_DOMAIN_NAME,vds_group_id,vds_group_name, correlation_id, job_id, quota_id, quota_name, gluster_volume_id, gluster_volume_name,origin, custom_event_id, event_flood_in_sec, custom_data ) VALUES(v_log_time, v_log_type, v_log_type_name, v_severity, v_message, v_user_id, v_user_name, v_vds_id, v_vds_name, v_vm_id, v_vm_name,v_vm_template_id,v_vm_template_name,v_storage_pool_id,v_storage_pool_name,v_storage_domain_id,v_storage_domain_name,v_vds_group_id,v_vds_group_name, v_correlation_id, v_job_id, v_quota_id, v_quota_name, v_gluster_volume_id, v_gluster_volume_name,v_origin, v_custom_event_id, v_event_flood_in_sec, v_custom_data); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java index 0e9ad46..ef7a5fe 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java @@ -7,8 +7,6 @@ import org.ovirt.engine.core.common.AuditLogSeverity; import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.businessentities.mapping.GuidType; -import org.ovirt.engine.core.common.config.Config; -import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.compat.INotifyPropertyChanged; import org.ovirt.engine.core.compat.NGuid; @@ -122,14 +120,6 @@ } public void setmessage(String value) { - final String INCOMPLETE_SIGN = "..."; - int maxAuditLogMessageLength = Config.<Integer> GetValue(ConfigValues.MaxAuditLogMessageLength); - // truncate message if exceeds configured max length. - // truncated messages will be ended with "..." to indicate that message - // is incomplete due to size limits. - if (value.length() > maxAuditLogMessageLength) { - value = value.substring(0, maxAuditLogMessageLength - (INCOMPLETE_SIGN.length() + 1)) + INCOMPLETE_SIGN; - } this.message = value; } -- To view, visit http://gerrit.ovirt.org/10522 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib2805ee22301d75a7d6a2c852a3acfe3fc0f5f59 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
