<commit_before>module AuthpdsNyu
  module Session
    module Aleph
      require 'exlibris-aleph'
      def aleph_bor_auth_permissions(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
        bor_auth = aleph_bor_auth(bor_id, verification, adm, sublibrary)
        return (bor_auth.nil? or bor_auth.error) ? {} : bor_auth.permissions
      end

      def aleph_bor_auth(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
        if bor_id.nil? and pds_user
          bor_id = pds_user.id
          verification = pds_user.verification
        end
        raise ArgumentError.new("Argument Error in #{self.class}. bor_id not specified.") if bor_id.nil?;
        raise ArgumentError.new("Argument Error in #{self.class}. verification not specified.") if verification.nil?;
        adm = aleph_default_adm if adm.nil?
        sublibrary = aleph_default_sublibrary if sublibrary.nil?
        # Call X-Service
        bor_auth = Exlibris::Aleph::Xservice::BorAuth.new(aleph_url, adm, sublibrary, "N", bor_id, verification)
        log_error(bor_id, verification, bor_auth) and return nil if bor_auth.nil? or bor_auth.error
        return bor_auth
      end

      def log_error bor_id, verification, bor_auth
        controller.logger.error "Error in #{self.class}. "+
          "No permissions returned from Aleph bor-auth for user with bor_id #{bor_id} and verification #{verification}.\n"+
            "Error: #{(bor_auth.nil?) ? "bor_auth is nil." : bor_auth.error.inspect}\n"+
              "Response: #{bor_auth.response.inspect}"
      end
      private :log_error
    end
  end
end<commit_msg>Don't log response. It's not useful.<commit_after>module AuthpdsNyu
  module Session
    module Aleph
      require 'exlibris-aleph'
      def aleph_bor_auth_permissions(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
        bor_auth = aleph_bor_auth(bor_id, verification, adm, sublibrary)
        return (bor_auth.nil? or bor_auth.error) ? {} : bor_auth.permissions
      end

      def aleph_bor_auth(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
        if bor_id.nil? and pds_user
          bor_id = pds_user.id
          verification = pds_user.verification
        end
        raise ArgumentError.new("Argument Error in #{self.class}. bor_id not specified.") if bor_id.nil?;
        raise ArgumentError.new("Argument Error in #{self.class}. verification not specified.") if verification.nil?;
        adm = aleph_default_adm if adm.nil?
        sublibrary = aleph_default_sublibrary if sublibrary.nil?
        # Call X-Service
        bor_auth = Exlibris::Aleph::Xservice::BorAuth.new(aleph_url, adm, sublibrary, "N", bor_id, verification)
        log_error(bor_id, verification, bor_auth) and return nil if bor_auth.nil? or bor_auth.error
        return bor_auth
      end

      def log_error bor_id, verification, bor_auth
        controller.logger.error "Error in #{self.class}. "+
          "No permissions returned from Aleph bor-auth for user with bor_id #{bor_id} and verification #{verification}.\n"+
            "Error: #{(bor_auth.nil?) ? "bor_auth is nil." : bor_auth.error.inspect}"
      end
      private :log_error
    end
  end
end
{'fraction_non_alphanumeric': 0.09757632987094743, 'fraction_numerical': 0.0, 'mean_word_length': 3.0691421254801536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '341869', 'n_tokens_mistral': 994, 'n_tokens_neox': 987, 'n_words': 252}