code: @GET
      @Produces(MediaType.APPLICATION_JSON)
      @Path("/username/{username}")
      @Description("Returns the user having the given username.")
      public PrincipalUserDto getUserByUsername(@Context HttpServletRequest req,
          @PathParam("username") final String userName) {
  
          Enumeration<String> headerNames = req.getHeaderNames();
          while(headerNames.hasMoreElements()) {
              String headerName = headerNames.nextElement();
              String headerValue = req.getHeader(headerName);
              System.out.println(headerName + ": " + headerValue);
          }
  
          if (userName == null || userName.isEmpty()) {
              throw new WebApplicationException("Username cannot be null or empty.", Status.BAD_REQUEST);
          }
  
          PrincipalUser remoteUser = validateAndGetOwner(req, null);
          PrincipalUser user = _uService.findUserByUsername(userName);
  
          if (user != null) {
              super.validateResourceAuthorization(req, user, remoteUser);
              return PrincipalUserDto.transformToDto(user);
          } else if (!remoteUser.isPrivileged()) {
              throw new WebApplicationException(Response.Status.FORBIDDEN.getReasonPhrase(), Response.Status.FORBIDDEN);
          } else {
              throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
          }
      }
docs: Returns the user having the given username.
  
  @param   req       The HTTP request.
  @param   userName  The username to retrieve.
  
  @return  The user DTO.
  
  @throws  WebApplicationException  If an error occurs.