<commit_before>package fedreg.api.v1

import groovy.xml.MarkupBuilder
import grails.converters.*
import fedreg.core.*

/**
 * Provides metadata exports.
 *
 * @author <NAME>
 */
class MetadataAPIv1Controller {
	def metadataGenerationService
	def grailsApplication
	
	def list = {
		def metadata = []
		metadata.add([minimal:[description:"Minimal set of SAML metadata compliant with Shibboleth 2.x clients", format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPI', params:[type:"minimal"], absolute: true)]])
		metadata.add([minimalnoext:[description:"Minimal set of SAML metadata compliant with Shibboleth 1.x clients", format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPI', params:[type:"minimalnoext"], absolute: true)]])
		metadata.add([current:[description:"Extended SAML 2 metadata compatible with Shibboleth 2.x clients and other SAML 2 compliant implementations", format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPI', params:[type:"current"], absolute: true)]])
		metadata.add([all:[description:"Extended SAML 2 metadata includes all federation components including those unapproved, non-functioning and archived", format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPI', params:[type:"all"], absolute: true)]])
		metadata.add([entity:[description:"SAML 2 compliant metadata snippet for specific entity descriptor ID", format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPI', params:[type:"entity"], absolute: true)]])
		
		render metadata as JSON
	}
	
	def show = {
		def xml
		switch(params.type) {
			case "minimal": 		xml = currentPublishedMetadata(true, true)
									break
			case "minimalnoext":  	xml = currentPublishedMetadata(true, false)
									break
			case "current": 		xml = currentPublishedMetadata(false, true)
									break
			case "all": 			xml = allMetadata(false)
									break
			case "entity": 			xml = entityMetadata()
									break
		}
		
		if(xml)
			render(text:xml, contentType:"text/xml", encoding:"UTF-8")
		else {
			response.sendError(400)<commit_msg>reformed list JSON for API<commit_after>package fedreg.api.v1

import groovy.xml.MarkupBuilder
import grails.converters.*
import fedreg.core.*

/**
 * Provides metadata exports.
 *
 * @author <NAME>
 */
class MetadataAPIv1Controller {
	def metadataGenerationService
	def grailsApplication
	
	def list = {
		def metadata = []
		metadata.add([name:'minimal',description:"Minimal set of SAML metadata compliant with Shibboleth 1.x clients", format:"xml", type:"federation", functioning:true, link:g.createLink(controller: 'metadataAPIv1', params:[type:"minimal"], absolute: true)])
		metadata.add([name:'minimal-noext',description:"Minimal set of SAML metadata compliant with Shibboleth 1.x clients using MAMS tools", format:"xml", type:"federation", functioning:true,  link:g.createLink(controller: 'metadataAPIv1', params:[type:"minimalnoext"], absolute: true)])
		metadata.add([name:'complete',description:"Extended SAML 2 metadata compatible with Shibboleth 2.x clients and other SAML 2 compliant implementations", functioning:true,  format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPIv1', params:[type:"current"], absolute: true)])
		metadata.add([name:'all', description:"Extended SAML 2 metadata includes all federation components including those unapproved, non-functioning and archived", functioning:false,  format:"xml", type:"federation", link:g.createLink(controller: 'metadataAPIv1', params:[type:"all"], absolute: true)])
		metadata.add([name:'entity', description:"SAML 2 compliant metadata snippet for specific entity descriptor ID", format:"xml", type:"entity", functioning:true, link:g.createLink(controller: 'metadataAPIv1', params:[type:"entity"], absolute: true)])
		
		def result = ['metadatadocuments':metadata]
		render result as JSON
	}
	
	def show = {
		def xml
		switch(params.type) {
			case "minimal": 		xml = currentPublishedMetadata(true, true)
									break
			case "minimalnoext":  	xml = currentPublishedMetadata(true, false)
									break
			case "current": 		xml = currentPublishedMetadata(false, true)
									break
			case "all": 			xml = allMetadata(false)
									break
			case "entity": 			xml = entityMetadata()
									break
		}
		
		if(xml)
			render(text:xml, contentType:"text/xml", encoding:"UTF-8")
		else {
			response.sendError(400)
{'fraction_non_alphanumeric': 0.13007024699750735, 'fraction_numerical': 0.0070246997507364605, 'mean_word_length': 5.406386066763425, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 30}, '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': '1570450', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1235, 'n_words': 336}