Changeset 7725


Ignore:
Timestamp:
Jun 11, 2019, 4:10:52 PM (2 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2184: Marking a job as ended fails with PermissionDeniedException?

The internal code should now work with data-layer objects directly to avoid permission problems.

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

Legend:

Unmodified
Added
Removed
  • branches/3.15-stable/src/core/net/sf/basedb/core/Job.java

    r7605 r7725  
    18511851  {
    18521852    DbControl dc = getDbControl();
    1853     Message m = Message.getNewSystemMessage(dc, getOwner(), "SYSTEM", null, this);
     1853    Message m = Message.getNewSystemMessage(dc, getData().getOwner(), "SYSTEM", null, getData());
    18541854    m.setDescription(getStatusMessage());
    18551855    String jobName = net.sf.basedb.util.Values.trim(getName(), Message.MAX_NAME_LENGTH - 20);
  • branches/3.15-stable/src/core/net/sf/basedb/core/Message.java

    r7452 r7725  
    2323package net.sf.basedb.core;
    2424
     25import net.sf.basedb.core.data.JobData;
    2526import net.sf.basedb.core.data.MessageData;
    2627import net.sf.basedb.core.data.UserData;
     
    7374    Message m = dc.newItem(Message.class);
    7475    m.setName("New message");
    75     m.setTo(to);
     76    m.setTo(to == null ? null : to.getData());
    7677    m.setFrom(fromName);
    77     m.setSender(fromUser);
     78    m.setSender(fromUser == null ? null : fromUser.getData());
    7879    m.getData().setTimeSent(new Date());
    79     m.setJob(job);
     80    m.setJob(job == null ? null : job.getData());
    8081    return m;
    8182  }
     
    9495    @throws BaseException If there is an error
    9596  */
    96   static Message getNewSystemMessage(DbControl dc, User to, String fromName, User fromUser, Job job)
     97  static Message getNewSystemMessage(DbControl dc, UserData to, String fromName, UserData fromUser, JobData job)
    9798  {
    9899    Message m = dc.newItem(Message.class);
     
    325326    @throws InvalidDataException If the user is null
    326327  */
    327   private void setTo(User to)
     328  private void setTo(UserData to)
    328329    throws InvalidDataException
    329330  {
    330331    if (to == null) throw new InvalidUseOfNullException("to");
    331     getData().setTo(to.getData());
    332     sendAsEmail = EmailUtil.isEnabled(to);
     332    getData().setTo(to);
     333    sendAsEmail = EmailUtil.isEnabled() && to.getSendMessagesAsEmail() && EmailUtil.isValidEmail(to.getEmail());
    333334  }
    334335 
     
    385386  }
    386387 
    387   private void setSender(User sender)
     388  private void setSender(UserData sender)
    388389  {
    389390    getData().setFromId(sender == null ? 0 : sender.getId());
     
    402403    return getDbControl().getItem(Job.class, getData().getJob());
    403404  }
    404   private void setJob(Job job)
     405  private void setJob(JobData job)
    405406    throws PermissionDeniedException
    406407  {
    407     if (job != null) job.checkPermission(Permission.READ);
    408     getData().setJob(job == null ? null : job.getData());
     408    getData().setJob(job == null ? null : job);
    409409  }
    410410 
Note: See TracChangeset for help on using the changeset viewer.