@@ -199,13 +199,21 @@ public void consume(Context ctx, Event event) throws Exception {
199199
200200 // make sure we are supposed to process this Collection
201201 if (acceptId (id , event , ctx )) {
202+ // --- NEW CHECK: Fetch and verify the item using event.getDetail() ---
203+ String addedItemIdentifier = event .getDetail ();
204+ Item addedItem = itemService .findByIdOrLegacyId (ctx , addedItemIdentifier );
205+
206+ if (addedItem == null || !addedItem .isArchived ()) {
207+ // Skip replication if the item isn't archived yet
208+ break ;
209+ }
202210 // add Collection to the master lists of modified objects
203211 // for which we need to perform tasks
204212 mapId (taskQMap , modQTasks , id );
205213 mapId (taskPMap , modPTasks , id );
206214
207215 //now, get Handle of Item that was mapped/added
208- id = event . getDetail () ;
216+ id = addedItemIdentifier ;
209217
210218 // add Item to the master lists of modified objects
211219 // for which we need to perform tasks
@@ -252,16 +260,23 @@ public void consume(Context ctx, Event event) throws Exception {
252260 break ;
253261 case MODIFY : // MODIFY = modify an object
254262 case MODIFY_METADATA : // MODIFY_METADATA = just modify an object's metadata
263+ DSpaceObject subjectObj = event .getSubject (ctx );
255264 // If subject of event is null, this means the object was likely deleted
256- if (event . getSubject ( ctx ) == null ) {
265+ if (subjectObj == null ) {
257266 log .warn ("{} event, could not get object for {} id={}, perhaps it has been deleted." ,
258267 event .getEventTypeAsString (), event .getSubjectTypeAsString (),
259268 String .valueOf (event .getSubjectID ()));
260269 break ;
261270 }
262271
272+ // --- NEW CHECK: Skip unarchived items ---
273+ if (subjType == Constants .ITEM && !((Item ) subjectObj ).isArchived ()) {
274+ break ;
275+ }
276+ // ----------------------------------------
277+
263278 // For MODIFY events, the Handle of modified object needs to be obtained from the Subject
264- id = event . getSubject ( ctx ) .getHandle ();
279+ id = subjectObj .getHandle ();
265280
266281 // make sure handle resolves - these could be events
267282 // for a newly created item that hasn't been assigned a handle
0 commit comments