コード例 #1
0
 @Override
 protected boolean isAccessAllowed(Ticket ticket) {
   UserDetails currentUser = this.getCurrentUser();
   boolean allowed = false;
   int status = ticket.getStatus();
   if (this.getAuthorizationManager()
           .isAuthOnPermission(currentUser, JpWttSystemConstants.WTT_ADMIN_PERMISSION)
       || (Ticket.STATES_ASSIGNABLE == status && this.userHasRole(ticket.getWttRole()))
       || Ticket.STATES_ASSIGNED == status
           && currentUser.getUsername().equals(ticket.getWttOperator())) {
     allowed = true;
   }
   return allowed;
 }
コード例 #2
0
 public boolean isOperationAllowed(Ticket ticket, int operationCode) {
   boolean allowed = false;
   int status = ticket.getStatus();
   String operator = ticket.getWttOperator();
   UserDetails currentUser = this.getCurrentUser();
   boolean isAdmin =
       this.getAuthorizationManager()
           .isAuthOnPermission(currentUser, JpWttSystemConstants.WTT_ADMIN_PERMISSION);
   switch (operationCode) {
     case TicketOperation.OPERATIONS_SETASSIGNABLE:
       if (isAdmin && (Ticket.STATES_OPENED == status || Ticket.STATES_WORKING == status)) {
         allowed = true;
       }
       break;
     case TicketOperation.OPERATIONS_TAKEINCHARGE:
       if ((isAdmin && (Ticket.STATES_OPENED == status || Ticket.STATES_WORKING == status))
           || (Ticket.STATES_ASSIGNABLE == status && this.userHasRole(ticket.getWttRole()))) {
         allowed = true;
       }
       break;
     case TicketOperation.OPERATIONS_ANSWER:
     case TicketOperation.OPERATIONS_UPDATE:
     case TicketOperation.OPERATIONS_CLOSE:
       if (Ticket.STATES_ASSIGNED == status && currentUser.getUsername().equals(operator)) {
         allowed = true;
       }
       break;
     case TicketOperation.OPERATIONS_RELEASE:
       if ((isAdmin && (Ticket.STATES_ASSIGNABLE == status || Ticket.STATES_ASSIGNED == status))
           || (Ticket.STATES_ASSIGNED == status && currentUser.getUsername().equals(operator))) {
         allowed = true;
       }
       break;
   }
   return allowed;
 }