Skip to content

Commit

Permalink
WIP1
Browse files Browse the repository at this point in the history
  • Loading branch information
dima767 committed Oct 4, 2018
1 parent 6ca0465 commit 853c1bd
Show file tree
Hide file tree
Showing 3 changed files with 478 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package edu.internet2.tier.shibboleth.admin.ui.controller

import groovy.json.JsonSlurper
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.core.io.ResourceLoader
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

/**
* Controller implementing REST resource responsible for exposing structure definition for metadata sources user
* interface in terms of JSON schema.
*
* @author Dmitriy Kopylenko
*/
@RestController('/api/ui/metadataSources')
@ConfigurationProperties('shibui')
class MetadataSourcesUiDefinitionController {

//Configured via @ConfigurationProperties with 'shibui.metadata-sources-ui-schema-location' property and default
//value set here if that property is not set
String metadataSourcesUiSchemaLocation = 'classpath:metadata-sources-ui-schema.json'

URL jsonSchemaUrl

MetadataSourcesUiDefinitionController(ResourceLoader resourceLoader) {
jsonSchemaUrl = resourceLoader.getResource(metadataSourcesUiSchemaLocation).getURL()
}

@GetMapping
ResponseEntity<?> getUiDefinitionJsonSchema() {
//JsonSlurper is not threadsafe, but cheap to init. New instance per-thread is the canonical usage
def json = new JsonSlurper().parse(this.jsonSchemaUrl)
ResponseEntity.ok(json)
}
}
3 changes: 3 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ spring.profiles.active=default

#shibui.default-password=

shibui.metadata-sources-ui-schema-location=classpath:metadata-sources-ui-schema-location.json

#Actuator endpoints (info)
# Un-comment to get full git details exposed like author, abbreviated SHA-1, commit message
#management.info.git.mode=full

Loading

0 comments on commit 853c1bd

Please sign in to comment.