mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2026-09-16 18:13:17 +00:00
ACS-10772 Fix for cm:modifiedAt property not in sync between ACS & ElasticSearch (#3748)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2026 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -316,7 +316,7 @@ public class NodeEventConsolidator extends EventConsolidator<NodeRef, NodeResour
|
||||
resourceBeforeAllFieldsNull = false;
|
||||
}
|
||||
|
||||
Map<String, Map<String, String>> localizedProps = helper.getLocalizedPropertiesBefore(changedPropsBefore, after);
|
||||
Map<String, Map<String, String>> localizedProps = helper.getLocalizedPropertiesBefore(propertiesBefore, after);
|
||||
if (!localizedProps.isEmpty())
|
||||
{
|
||||
builder.setLocalizedProperties(localizedProps);
|
||||
@@ -378,10 +378,14 @@ public class NodeEventConsolidator extends EventConsolidator<NodeRef, NodeResour
|
||||
resourceBeforeAllFieldsNull = false;
|
||||
}
|
||||
|
||||
// Only set modifiedAt if one of the other fields is also not null
|
||||
if (modifiedAt != null && !resourceBeforeAllFieldsNull)
|
||||
// If modifiedAt is changed, set it
|
||||
if (modifiedAt != null)
|
||||
{
|
||||
builder.setModifiedAt(modifiedAt);
|
||||
if (resourceBeforeAllFieldsNull)
|
||||
{
|
||||
resourceBeforeAllFieldsNull = false;
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2026 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -26,12 +26,6 @@
|
||||
|
||||
package org.alfresco.repo.event2;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.alfresco.model.ContentModel.PROP_DESCRIPTION;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -1093,6 +1087,9 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
assertTrue(aspectsBefore.contains("cm:auditable"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that verifies update event is generated when only cm:modifiedAt property is changed. In a transaction userName property is added and removed, resulting in no net change to properties but cm:modifiedAt should be updated
|
||||
*/
|
||||
@Test
|
||||
public void testAddAndRemovePropertyInTheSameTransaction()
|
||||
{
|
||||
@@ -1112,12 +1109,12 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
|
||||
return null;
|
||||
});
|
||||
|
||||
// There should only be a create event
|
||||
resource = getNodeResource(1);
|
||||
// No change to properties expected
|
||||
resource = getNodeResource(2);
|
||||
assertTrue(resource.getProperties().isEmpty());
|
||||
|
||||
// Check there isn't a node update event
|
||||
// There should be one update event as modifiedAt is updated
|
||||
List<RepoEvent<EventData<NodeResource>>> nodeUpdatedEvents = getFilteredEvents(EventType.NODE_UPDATED);
|
||||
assertEquals(0, nodeUpdatedEvents.size());
|
||||
assertEquals(1, nodeUpdatedEvents.size());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user