Esempio n. 1
0
 /**
  * @see
  *     org.telscenter.sail.webapp.service.offering.RunService#getSharedTeacherRole(org.telscenter.sail.webapp.domain.Run,
  *     net.sf.sail.webapp.domain.User)
  */
 public String getSharedTeacherRole(Run run, User user) {
   List<Permission> permissions = this.aclService.getPermissions(run, user);
   // for runs, a user can have at most one permission per run
   if (!permissions.isEmpty()) {
     Permission permission = permissions.get(0);
     if (permission.equals(BasePermission.READ)) {
       return UserDetailsService.RUN_READ_ROLE;
     } else if (permission.equals(BasePermission.WRITE)) {
       return UserDetailsService.RUN_GRADE_ROLE;
     }
   }
   return null;
 }
 /**
  * @param permission the permission to convert
  * @return a string
  */
 public final String convert(final Permission permission) {
   if (permission == null) {
     return null;
   } else if (permission.equals(BasePermission.CREATE)) {
     return "CREATE";
   } else if (permission.equals(BasePermission.READ)) {
     return "READ";
   } else if (permission.equals(BasePermission.WRITE)) {
     return "WRITE";
   } else if (permission.equals(BasePermission.DELETE)) {
     return "DELETE";
   } else if (permission.equals(BasePermission.ADMINISTRATION)) {
     return "ADMINISTRATION";
   } else {
     throw new IllegalArgumentException(permission + " cannot be converted into a string");
   }
 }