code: public static NamespaceDto transformToDto(Namespace namespace) {
          if (namespace == null) {
              throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
          }
  
          NamespaceDto result = createDtoObject(NamespaceDto.class, namespace);
  
          for (PrincipalUser user : namespace.getUsers()) {
              result.addUsername(user.getUserName());
          }
          return result;
      }
docs: Converts a namespace entity to a DTO.
  
  @param   namespace  The entity to convert.
  
  @return  The namespace DTO.
  
  @throws  WebApplicationException  If an error occurs.