-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
478 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...nternet2/tier/shibboleth/admin/ui/controller/MetadataSourcesUiDefinitionController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.