<commit_before>package aaf.fr.export

import grails.converters.*
import aaf.fr.foundation.*

import groovy.json.JsonSlurper

class ExportController {
    def organization(long id) {
      def o = Organization.get(id)

      if(o) {
        def builder = new groovy.json.JsonBuilder()
        builder { organization o.structureAsJson() }

        render text: builder.toPrettyString(), contentType: "text/json"
      } else {
        response.status = 404
        render([error: 'organization is unknown'] as JSON)
      }
    }

    def organizations() {
      def builder = new groovy.json.JsonBuilder()
      builder { organizations  Organization.list().collect { o ->
                              o.structureAsJson()
                            }
      }
      render text: builder.toPrettyString(), contentType: "text/json"
    }

    def serviceprovider(long id) {
      def sp = SPSSODescriptor.get(id)

      if(sp){
        def builder = new groovy.json.JsonBuilder()
        builder { serviceprovider sp.structureAsJson() }
        render text: builder.toPrettyString(), contentType: "text/json"
      } else {
        response.status = 400
        render([error: 'serviceprovider is unknown'] as JSON)
      }
    }
}<commit_msg>Allow export of all SPSSODescriptor data<commit_after>package aaf.fr.export

import grails.converters.*
import aaf.fr.foundation.*

import groovy.json.JsonSlurper

class ExportController {
    def organization(long id) {
      def o = Organization.get(id)

      if(o) {
        def builder = new groovy.json.JsonBuilder()
        builder { organization o.structureAsJson() }

        render text: builder.toPrettyString(), contentType: "text/json"
      } else {
        response.status = 404
        render([error: 'organization is unknown'] as JSON)
      }
    }

    def organizations() {
      def builder = new groovy.json.JsonBuilder()
      builder { organizations  Organization.list().collect { o ->
                              o.structureAsJson()
                            }
      }
      render text: builder.toPrettyString(), contentType: "text/json"
    }

    def serviceprovider(long id) {
      def sp = SPSSODescriptor.get(id)

      if(sp){
        def builder = new groovy.json.JsonBuilder()
        builder { serviceprovider sp.structureAsJson() }
        render text: builder.toPrettyString(), contentType: "text/json"
      } else {
        response.status = 400
        render([error: 'serviceprovider is unknown'] as JSON)
      }
  }

  def serviceproviders() {
    def builder = new groovy.json.JsonBuilder()
    builder { serviceproviders  SPSSODescriptor.list().collect { sp ->
                            sp.structureAsJson()
                          }
    }
    render text: builder.toPrettyString(), contentType: "text/json"
  }
}
{'fraction_non_alphanumeric': 0.10438190238688992, 'fraction_numerical': 0.004275026718916993, 'mean_word_length': 2.176470588235294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3439603', 'n_tokens_mistral': 811, 'n_tokens_neox': 769, 'n_words': 185}