/**
   * Transforms {@code User} object to {@code UserDTO} object
   *
   * @param user user object which will be transformed to DTO
   * @return user DTO object
   */
  public static UserDTO userToDTO(User user) {
    if (user == null) {
      throw new IllegalArgumentException("User is null");
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Converting User '" + user.getName() + " (" + user.getEmail() + ")' to UserDTO");
    }
    UserDTO result = new UserDTO();
    result.setUuid(user.getUuid());
    result.setName(user.getName());
    result.setProfession(user.getProfession());

    return result;
  }
  /**
   * Transforms JCR {@code Node} into {@code User} object
   *
   * @param node JCR {@code Node}
   * @return {@code User} object
   */
  public static User nodeToUser(Node node) {
    if (node == null) {
      throw new IllegalArgumentException("Node is null");
    }

    User user = null;
    try {
      user = new User();
      user.setUuid(node.getIdentifier());
      user.setPassword(node.getProperty(PROP_PASSWORD.toString()).getString());
      user.setEmail(node.getProperty(PROP_EMAIL.toString()).getString());
      user.setName(node.getProperty(PROP_NAME.toString()).getString());
      user.setPrivileged(node.getProperty(PROP_PRIVILEGED.toString()).getBoolean());
      user.setProfession(
          nodeToProfession(
              node.getSession()
                  .getNodeByIdentifier(node.getProperty(PROP_PROFESSION.toString()).getString())));
    } catch (RepositoryException ex) {
      logger.error("Failed to transform JCR Node to User. " + ex.getMessage());
    }

    return user;
  }