Changeset 3792


Ignore:
Timestamp:
Sep 27, 2007, 9:58:47 AM (16 years ago)
Author:
Martin Svensson
Message:

Fixes #560 Deleting reporters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/views/reporters/index.jsp

    r3679 r3792  
    4141  import="net.sf.basedb.core.DataQuery"
    4242  import="net.sf.basedb.core.PermissionDeniedException"
     43  import="net.sf.basedb.core.BaseException"
    4344  import="net.sf.basedb.util.RemovableUtil"
    4445  import="net.sf.basedb.util.ShareableUtil"
     
    175176    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    176177    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
    177     batcher.delete(cc.getId());
    178     batcher.close();
    179     dc.commit();
    180     redirect = listPage;
     178    try
     179    {
     180      batcher.delete(cc.getId());
     181      batcher.close();
     182      dc.commit();   
     183      redirect = listPage;
     184    }
     185    catch (BaseException bex)
     186    {
     187      message = "The reporter can not be deleted. " +
     188        "Probably because it is used by other items";
     189      redirect = viewPage + "&popmessage="+HTML.urlEncode(message);
     190    }
    181191  }
    182192  else if ("DeleteItems".equals(cmd))
     
    186196    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
    187197    ReporterBatcher batcher = ReporterBatcher.getNew(dc);
     198    batcher.setBatchSize(1);
     199    int notDeleted = 0;
    188200    for (int reporterId : cc.getSelected())
    189201    {
    190       batcher.delete(reporterId);
    191     }
    192     batcher.close();
     202      try
     203      {
     204        batcher.delete(reporterId);
     205      }
     206      catch (BaseException bex)
     207      {
     208        notDeleted++;
     209      }     
     210    }   
    193211    dc.commit();
    194     redirect = listPage;
     212    message = notDeleted > 0 ? notDeleted + " reporters can not be deleted. " +
     213        "Probably because they are used by other items" : null;
     214    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
    195215  }
    196216  else if ("ExportItems".equals(cmd))
Note: See TracChangeset for help on using the changeset viewer.