Changeset 4706


Ignore:
Timestamp:
Dec 17, 2008, 8:35:30 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1219: Deleting the active project results in ItemNotFoundException? in subsequent operations

Location:
branches/2.9-stable/src/core/net/sf/basedb/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.9-stable/src/core/net/sf/basedb/core/DbControl.java

    r4527 r4706  
    328328    sc.updateLastAccess();
    329329
    330     Project activeProject = sc.getActiveProjectId() == 0 ?
    331       null : Project.getById(this, sc.getActiveProjectId());
     330    Project activeProject = null;
     331    if (sc.getActiveProjectId() != 0)
     332    {
     333      try
     334      {
     335        activeProject = Project.getById(this, sc.getActiveProjectId());
     336      }
     337      catch (ItemNotFoundException ex)
     338      {
     339        // The project was deleted
     340        sc.setActiveProject(null);
     341      }
     342    }
    332343   
    333344    Map<BasicItem, Transactional.Action> tempQueue = null;
  • branches/2.9-stable/src/core/net/sf/basedb/core/Project.java

    r4649 r4706  
    2424package net.sf.basedb.core;
    2525
     26import net.sf.basedb.core.Transactional.Action;
    2627import net.sf.basedb.core.data.AnyToAnyData;
    2728import net.sf.basedb.core.data.BasicData;
     
    209210    -------------------------------------------
    210211  */
     212  @Override
     213  void onBeforeCommit(Action action)
     214    throws NotLoggedInException, BaseException
     215  {
     216    super.onBeforeCommit(action);
     217    if (action == Action.DELETE)
     218    {
     219      SessionControl sc = getSessionControl();
     220      if (sc.getActiveProjectId() == getId())
     221      {
     222        sc.setActiveProject(null);
     223      }
     224    }
     225  }
    211226  /**
    212227    If the logged in user is a member of this project, read or use
Note: See TracChangeset for help on using the changeset viewer.