@@ -552,19 +552,21 @@ public void addMapAnnotation(Client client, MapAnnotationWrapper mapAnnotation)
552552 */
553553 public void addTable (Client client , TableWrapper table )
554554 throws ServiceException , AccessException , ExecutionException {
555+ String error = "Cannot add table to " + this ;
556+
555557 TablesFacility tablesFacility = client .getTablesFacility ();
556558 TableData tableData = ExceptionHandler .of (tablesFacility ,
557559 tf -> tf .addTable (client .getCtx (),
558560 data ,
559561 table .getName (),
560562 table .createTable ()))
561- .handleOMEROException ("Cannot add table to " + this )
563+ .handleOMEROException (error )
562564 .get ();
563565
564566 Collection <FileAnnotationData > tables = ExceptionHandler .of (tablesFacility ,
565567 tf -> tf .getAvailableTables (client .getCtx (),
566568 data ))
567- .handleOMEROException ("Cannot add table to " + this )
569+ .handleOMEROException (error )
568570 .get ();
569571 long fileId = tableData .getOriginalFileId ();
570572
@@ -590,17 +592,18 @@ public void addTable(Client client, TableWrapper table)
590592 */
591593 public void addAndReplaceTable (Client client , TableWrapper table , ReplacePolicy policy )
592594 throws ServiceException , AccessException , ExecutionException , OMEROServerError , InterruptedException {
595+ String error = "Cannot add table to " + this ;
596+
593597 Collection <FileAnnotationWrapper > tables = wrap (ExceptionHandler .of (client .getTablesFacility (),
594598 t -> t .getAvailableTables (
595599 client .getCtx (), data ))
596- .handleOMEROException ("Cannot get tables from "
597- + this )
600+ .handleOMEROException (error )
598601 .get (),
599602 FileAnnotationWrapper ::new );
600603 addTable (client , table );
601604 tables .removeIf (t -> !t .getDescription ().equals (table .getName ()));
605+ this .unlink (client , tables );
602606 for (FileAnnotationWrapper fileAnnotation : tables ) {
603- this .unlink (client , fileAnnotation );
604607 if (policy == ReplacePolicy .DELETE ||
605608 policy == ReplacePolicy .DELETE_ORPHANED && fileAnnotation .countAnnotationLinks (client ) == 0 ) {
606609 client .deleteFile (fileAnnotation .getId ());
0 commit comments