Changeset 7016


Ignore:
Timestamp:
Nov 18, 2015, 9:08:17 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #1966: The user that delete an item should see the item in the trashcan

Added getRemovedBy() method to the Removable interface and all implementing classes. Added two columns in the trashcan which display the owner and the user that removed the item.

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/BioAssaySet.java

    r7015 r7016  
    248248    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    249249    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     250  }
     251  @Override
     252  public User getRemovedBy()
     253    throws PermissionDeniedException, ItemNotFoundException
     254  {
     255    Integer userId = getData().getRemovedBy();
     256    return userId == null ? null : User.getById(getDbControl(), userId);
    250257  }
    251258  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/BioPlateEventType.java

    r7015 r7016  
    200200    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    201201    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     202  }
     203  @Override
     204  public User getRemovedBy()
     205    throws PermissionDeniedException, ItemNotFoundException
     206  {
     207    Integer userId = getData().getRemovedBy();
     208    return userId == null ? null : User.getById(getDbControl(), userId);
    202209  }
    203210  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/BioPlateType.java

    r7015 r7016  
    158158    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    159159    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     160  }
     161  @Override
     162  public User getRemovedBy()
     163    throws PermissionDeniedException, ItemNotFoundException
     164  {
     165    Integer userId = getData().getRemovedBy();
     166    return userId == null ? null : User.getById(getDbControl(), userId);
    160167  }
    161168  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/CommonItem.java

    r7015 r7016  
    9191    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    9292  }
     93  @Override
     94  public User getRemovedBy()
     95    throws PermissionDeniedException, ItemNotFoundException
     96  {
     97    Integer userId = getData().getRemovedBy();
     98    return userId == null ? null : User.getById(getDbControl(), userId);
     99  }
     100  // -------------------------------------------
    93101 
    94102}
  • trunk/src/core/net/sf/basedb/core/DataFileType.java

    r7015 r7016  
    411411    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    412412  }
     413  @Override
     414  public User getRemovedBy()
     415    throws PermissionDeniedException, ItemNotFoundException
     416  {
     417    Integer userId = getData().getRemovedBy();
     418    return userId == null ? null : User.getById(getDbControl(), userId);
     419  }
    413420  // -------------------------------------------
    414421  /*
  • trunk/src/core/net/sf/basedb/core/Directory.java

    r7015 r7016  
    515515    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    516516  }
     517  @Override
     518  public User getRemovedBy()
     519    throws PermissionDeniedException, ItemNotFoundException
     520  {
     521    Integer userId = getData().getRemovedBy();
     522    return userId == null ? null : User.getById(getDbControl(), userId);
     523  }
    517524  // -------------------------------------------
    518525  /*
  • trunk/src/core/net/sf/basedb/core/ExtraValueType.java

    r7015 r7016  
    213213    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    214214    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     215  }
     216  @Override
     217  public User getRemovedBy()
     218    throws PermissionDeniedException, ItemNotFoundException
     219  {
     220    Integer userId = getData().getRemovedBy();
     221    return userId == null ? null : User.getById(getDbControl(), userId);
    215222  }
    216223  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Group.java

    r7015 r7016  
    232232    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    233233    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     234  }
     235  @Override
     236  public User getRemovedBy()
     237    throws PermissionDeniedException, ItemNotFoundException
     238  {
     239    Integer userId = getData().getRemovedBy();
     240    return userId == null ? null : User.getById(getDbControl(), userId);
    234241  }
    235242  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/ItemSubtype.java

    r7015 r7016  
    325325    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    326326  }
     327  @Override
     328  public User getRemovedBy()
     329    throws PermissionDeniedException, ItemNotFoundException
     330  {
     331    Integer userId = getData().getRemovedBy();
     332    return userId == null ? null : User.getById(getDbControl(), userId);
     333  }
    327334  // -------------------------------------------
    328335  /*
  • trunk/src/core/net/sf/basedb/core/Message.java

    r7015 r7016  
    250250    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    251251    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     252  }
     253  @Override
     254  public User getRemovedBy()
     255    throws PermissionDeniedException, ItemNotFoundException
     256  {
     257    Integer userId = getData().getRemovedBy();
     258    return userId == null ? null : User.getById(getDbControl(), userId);
    252259  }
    253260  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/MimeType.java

    r7015 r7016  
    234234    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    235235  }
     236  @Override
     237  public User getRemovedBy()
     238    throws PermissionDeniedException, ItemNotFoundException
     239  {
     240    Integer userId = getData().getRemovedBy();
     241    return userId == null ? null : User.getById(getDbControl(), userId);
     242  }
    236243  // -------------------------------------------
    237244  /*
  • trunk/src/core/net/sf/basedb/core/News.java

    r7015 r7016  
    172172    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    173173    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     174  }
     175  @Override
     176  public User getRemovedBy()
     177    throws PermissionDeniedException, ItemNotFoundException
     178  {
     179    Integer userId = getData().getRemovedBy();
     180    return userId == null ? null : User.getById(getDbControl(), userId);
    174181  }
    175182  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PlateEventType.java

    r7015 r7016  
    198198    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    199199  }
     200  @Override
     201  public User getRemovedBy()
     202    throws PermissionDeniedException, ItemNotFoundException
     203  {
     204    Integer userId = getData().getRemovedBy();
     205    return userId == null ? null : User.getById(getDbControl(), userId);
     206  }
    200207  // -------------------------------------------
    201208
  • trunk/src/core/net/sf/basedb/core/PlateGeometry.java

    r7015 r7016  
    176176    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    177177    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     178  }
     179  @Override
     180  public User getRemovedBy()
     181    throws PermissionDeniedException, ItemNotFoundException
     182  {
     183    Integer userId = getData().getRemovedBy();
     184    return userId == null ? null : User.getById(getDbControl(), userId);
    178185  }
    179186  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Platform.java

    r7015 r7016  
    258258    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    259259    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     260  }
     261  @Override
     262  public User getRemovedBy()
     263    throws PermissionDeniedException, ItemNotFoundException
     264  {
     265    Integer userId = getData().getRemovedBy();
     266    return userId == null ? null : User.getById(getDbControl(), userId);
    260267  }
    261268  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PlatformVariant.java

    r7015 r7016  
    260260    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    261261    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     262  }
     263  @Override
     264  public User getRemovedBy()
     265    throws PermissionDeniedException, ItemNotFoundException
     266  {
     267    Integer userId = getData().getRemovedBy();
     268    return userId == null ? null : User.getById(getDbControl(), userId);
    262269  }
    263270  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PluginType.java

    r7015 r7016  
    233233    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    234234  }
     235  @Override
     236  public User getRemovedBy()
     237    throws PermissionDeniedException, ItemNotFoundException
     238  {
     239    Integer userId = getData().getRemovedBy();
     240    return userId == null ? null : User.getById(getDbControl(), userId);
     241  }
    235242  // -------------------------------------------
    236243  /*
  • trunk/src/core/net/sf/basedb/core/Project.java

    r7015 r7016  
    220220    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    221221  }
     222  @Override
     223  public User getRemovedBy()
     224    throws PermissionDeniedException, ItemNotFoundException
     225  {
     226    Integer userId = getData().getRemovedBy();
     227    return userId == null ? null : User.getById(getDbControl(), userId);
     228  }
    222229  // -------------------------------------------
    223230  /*
  • trunk/src/core/net/sf/basedb/core/Quantity.java

    r7015 r7016  
    428428    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
    429429  }
     430  @Override
     431  public User getRemovedBy()
     432    throws PermissionDeniedException, ItemNotFoundException
     433  {
     434    Integer userId = getData().getRemovedBy();
     435    return userId == null ? null : User.getById(getDbControl(), userId);
     436  }
    430437  // -------------------------------------------
    431438  /*
  • trunk/src/core/net/sf/basedb/core/Quota.java

    r7015 r7016  
    222222    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    223223    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     224  }
     225  @Override
     226  public User getRemovedBy()
     227    throws PermissionDeniedException, ItemNotFoundException
     228  {
     229    Integer userId = getData().getRemovedBy();
     230    return userId == null ? null : User.getById(getDbControl(), userId);
    224231  }
    225232  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Removable.java

    r4889 r7016  
    7474  public void setRemoved(boolean removed)
    7575    throws PermissionDeniedException;
     76 
     77  /**
     78    Get the user that flagged this item for removal.
     79   
     80    @return A User object, or null if this item has not been flagged
     81    @throws PermissionDeniedException If the logged in user doesn't have
     82      {@link Permission#READ} permission for the user
     83    @throws ItemNotFoundException If the user that removed this item
     84      can't be found
     85    @since 3.7
     86  */
     87  public User getRemovedBy()
     88    throws PermissionDeniedException, ItemNotFoundException;
    7689
    7790}
  • trunk/src/core/net/sf/basedb/core/ReporterType.java

    r7015 r7016  
    175175    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    176176    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     177  }
     178  @Override
     179  public User getRemovedBy()
     180    throws PermissionDeniedException, ItemNotFoundException
     181  {
     182    Integer userId = getData().getRemovedBy();
     183    return userId == null ? null : User.getById(getDbControl(), userId);
    177184  }
    178185  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Role.java

    r7015 r7016  
    227227    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    228228    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     229  }
     230  @Override
     231  public User getRemovedBy()
     232    throws PermissionDeniedException, ItemNotFoundException
     233  {
     234    Integer userId = getData().getRemovedBy();
     235    return userId == null ? null : User.getById(getDbControl(), userId);
    229236  }
    230237  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Transformation.java

    r7015 r7016  
    224224    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    225225    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     226  }
     227  @Override
     228  public User getRemovedBy()
     229    throws PermissionDeniedException, ItemNotFoundException
     230  {
     231    Integer userId = getData().getRemovedBy();
     232    return userId == null ? null : User.getById(getDbControl(), userId);
    226233  }
    227234  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Unit.java

    r7015 r7016  
    263263    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    264264    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     265  }
     266  @Override
     267  public User getRemovedBy()
     268    throws PermissionDeniedException, ItemNotFoundException
     269  {
     270    Integer userId = getData().getRemovedBy();
     271    return userId == null ? null : User.getById(getDbControl(), userId);
    265272  }
    266273  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/User.java

    r7015 r7016  
    344344    checkPermission(removed ? Permission.DELETE : Permission.WRITE);
    345345    getData().setRemovedBy(removed ? getSessionControl().getLoggedInUserId() : null);
     346  }
     347  @Override
     348  public User getRemovedBy()
     349    throws PermissionDeniedException, ItemNotFoundException
     350  {
     351    Integer userId = getData().getRemovedBy();
     352    return userId == null ? null : User.getById(getDbControl(), userId);
    346353  }
    347354  // -------------------------------------------
  • trunk/www/views/trashcan/list_trash.jsp

    r6834 r7016  
    3434  import="net.sf.basedb.core.Removable"
    3535  import="net.sf.basedb.core.Nameable"
     36  import="net.sf.basedb.core.Ownable"
    3637  import="net.sf.basedb.core.File"
    3738  import="net.sf.basedb.core.Directory"
     39  import="net.sf.basedb.core.User"
    3840  import="net.sf.basedb.core.Metadata"
     41  import="net.sf.basedb.core.ItemNotFoundException"
     42  import="net.sf.basedb.core.PermissionDeniedException"
    3943  import="net.sf.basedb.core.query.ResultList"
    4044  import="net.sf.basedb.util.Enumeration"
     
    144148      />
    145149      <tbl:columndef
     150        id="owner"
     151        title="Owner"
     152      />
     153      <tbl:columndef
     154        id="removedBy"
     155        title="Removed by"
     156      />
     157      <tbl:columndef
    146158        id="description"
    147159        title="Description"
     
    287299                <tbl:cell column="name"><%=link%></tbl:cell>
    288300                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
     301                <tbl:cell column="removedBy"><%
     302                    User removedBy = null;
     303                    boolean deniedRemovedBy = false;
     304                    try
     305                    {
     306                      removedBy = item.getRemovedBy();
     307                    }
     308                    catch (PermissionDeniedException ex)
     309                    {
     310                      deniedRemovedBy = true;
     311                    }
     312                    catch (ItemNotFoundException ex)
     313                    {}
     314                    out.write(Base.getLinkedName(ID, removedBy, deniedRemovedBy, true));
     315                  %></tbl:cell>
     316                <tbl:cell column="owner"><%
     317                  if (item instanceof Ownable)
     318                  {
     319                    User owner = null;
     320                    boolean deniedOwner = false;
     321                    try
     322                    {
     323                      owner = ((Ownable)item).getOwner();
     324                    }
     325                    catch (PermissionDeniedException ex)
     326                    {
     327                      deniedOwner = true;
     328                    }
     329                    out.write(Base.getLinkedName(ID, owner, deniedOwner, true));
     330                  }
     331                  %></tbl:cell>
    289332                <tbl:cell column="description"><%=HTML.encodeTags(description)%></tbl:cell>
    290333                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
Note: See TracChangeset for help on using the changeset viewer.