@@ -268,10 +268,12 @@ class ObjectMerger : public BaseObjectDispatcher {
268268 // ----------------------------------------------------------------------
269269 public:
270270 ObjectMerger (Communication::Connection *connection,
271- DatabaseReader *db, bool test)
271+ DatabaseReader *db, bool test, bool allowRemove )
272272 : BaseObjectDispatcher(Visitor::TM_TOPDOWN, connection, test)
273273 , _db(db)
274- , _msgCount(0 ) {}
274+ , _msgCount(0 )
275+ , _allowRemove(allowRemove)
276+ {}
275277
276278
277279 // ----------------------------------------------------------------------
@@ -350,6 +352,11 @@ class ObjectMerger : public BaseObjectDispatcher {
350352
351353 for ( size_t i = 0 ; i < diffs.size (); ++i ) {
352354 Notifier *n = diffs[i].get ();
355+
356+ if ( !_allowRemove && (n->operation () == OP_REMOVE) )
357+ // Block removes if requested
358+ continue ;
359+
353360 po = PublicObject::Cast (n->object ());
354361 if ( po != NULL ) flush ();
355362 write (n->object ()->parent (), n->object (), n->operation ());
@@ -439,6 +446,7 @@ class ObjectMerger : public BaseObjectDispatcher {
439446 int _msgCount;
440447 string _targetGroup;
441448 string _inputIndent;
449+ bool _allowRemove;
442450};
443451// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
444452
@@ -504,7 +512,7 @@ class DispatchTool : public Seiscomp::Client::Application {
504512 void createCommandLineDescription () {
505513 commandline ().addGroup (" Dispatch" );
506514 commandline ().addOption (" Dispatch" , " input,i" , " File to dispatch to messaging" , &_inputFile, false );
507- commandline ().addOption (" Dispatch" , " operation,O" , " Notifier operation: add, update, remove or merge" ,
515+ commandline ().addOption (" Dispatch" , " operation,O" , " Notifier operation: add, update, remove, merge or merge-without-remove " ,
508516 &_notifierOperation, true );
509517 commandline ().addOption (" Dispatch" , " routingtable" ,
510518 " Specify routing table as list of object:group pairs" ,
@@ -529,14 +537,13 @@ class DispatchTool : public Seiscomp::Client::Application {
529537 if ( entry.size () == 2 )
530538 _routingTable.insert (make_pair (entry[0 ], entry[1 ]));
531539 }
532-
533540 }
534541
535- if ( _notifierOperation != " merge" )
542+ if ( _notifierOperation != " merge" && _notifierOperation != " merge-without-remove " )
536543 setDatabaseEnabled (false , false );
537544
538545 if ( commandline ().hasOption (" operation" ) ) {
539- if ( _notifierOperation != " merge" ) {
546+ if ( _notifierOperation != " merge" && _notifierOperation != " merge-without-remove " ) {
540547 if ( !_operation.fromString (_notifierOperation) ) {
541548 cout << " Notifier operation " << _notifierOperation << " is not valid" << endl;
542549 cout << " Operations are add, update, remove or merge" << endl;
@@ -613,7 +620,9 @@ class DispatchTool : public Seiscomp::Client::Application {
613620
614621 BaseObjectDispatcher *dispatcher = NULL ;
615622 if ( _notifierOperation == " merge" )
616- dispatcher = new ObjectMerger (connection (), query (), commandline ().hasOption (" test" ));
623+ dispatcher = new ObjectMerger (connection (), query (), commandline ().hasOption (" test" ), true );
624+ else if ( _notifierOperation == " merge-without-remove" )
625+ dispatcher = new ObjectMerger (connection (), query (), commandline ().hasOption (" test" ), false );
617626 else
618627 dispatcher = new ObjectDispatcher (connection (), _operation, commandline ().hasOption (" test" ));
619628
0 commit comments