diff --git a/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/MetadataProviderUiDefinitionController.groovy b/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/MetadataResolverUiDefinitionController.groovy similarity index 66% rename from backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/MetadataProviderUiDefinitionController.groovy rename to backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/MetadataResolverUiDefinitionController.groovy index c68f1eedb..e8c383aeb 100644 --- a/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/MetadataProviderUiDefinitionController.groovy +++ b/backend/src/main/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/MetadataResolverUiDefinitionController.groovy @@ -3,7 +3,6 @@ package edu.internet2.tier.shibboleth.admin.ui.controller import com.fasterxml.jackson.databind.ObjectMapper import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocationRegistry -import edu.internet2.tier.shibboleth.admin.ui.service.JsonSchemaBuilderService import org.springframework.beans.factory.annotation.Autowired import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping @@ -11,25 +10,22 @@ import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController -import javax.annotation.PostConstruct - -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.dynamicHttpMetadataProviderSchema import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.filesystemMetadataProviderSchema -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.localDynamicMetadataProviderSchema -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.metadataSourcesSchema +//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.localDynamicMetadataProviderSchema +//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.dynamicHttpMetadataProviderSchema import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType /** - * Controller implementing REST resource responsible for exposing structure definition for metadata sources user + * Controller implementing REST resource responsible for exposing structure definition for metadata resolvers user * interface in terms of JSON schema. * * @author Dmitriy Kopylenko * @author Bill Smith (wsmith@unicon.net) */ @RestController -@RequestMapping('/api/ui/MetadataProvider') -class MetadataProviderUiDefinitionController { +@RequestMapping('/api/ui/MetadataResolver') +class MetadataResolverUiDefinitionController { @Autowired JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry @@ -39,20 +35,20 @@ class MetadataProviderUiDefinitionController { @Autowired ObjectMapper jacksonObjectMapper - @GetMapping(value = "/{providerType}") - ResponseEntity getUiDefinitionJsonSchema(@PathVariable String providerType) { - switch (JsonSchemaResourceLocation.SchemaType.valueOf(providerType)) { - case SchemaType.LOCAL_DYNAMIC_METADATA_PROVIDER: - jsonSchemaLocation = localDynamicMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry) - break - case SchemaType.FILESYSTEM_METADATA_PROVIDER: + @GetMapping(value = "/{resolverType}") + ResponseEntity getUiDefinitionJsonSchema(@PathVariable String resolverType) { + switch (SchemaType.valueOf(resolverType)) { + case SchemaType.FILESYSTEM_METADATA_RESOLVER: jsonSchemaLocation = filesystemMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry) break - case SchemaType.DYNAMIC_HTTP_METADATA_PROVIDER: +/* case SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER: + jsonSchemaLocation = localDynamicMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry) + break*/ +/* case SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER: jsonSchemaLocation = dynamicHttpMetadataProviderSchema(this.jsonSchemaResourceLocationRegistry) - break + break*/ default: - throw new UnsupportedOperationException("Json schema for an unsupported metadata provider (" + providerType + ") was requested") + throw new UnsupportedOperationException("Json schema for an unsupported metadata resolver (" + resolverType + ") was requested") } try { def parsedJson = jacksonObjectMapper.readValue(this.jsonSchemaLocation.url, Map) @@ -66,8 +62,8 @@ class MetadataProviderUiDefinitionController { } } - @PostConstruct - void init() { - this.jsonSchemaLocation = metadataSourcesSchema(this.jsonSchemaResourceLocationRegistry) + @GetMapping(value = "/types") + ResponseEntity getResolverTypes() { + return ResponseEntity.ok(SchemaType.getResolverTypes()) } } diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/JsonSchemaComponentsConfiguration.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/JsonSchemaComponentsConfiguration.java index 326e6e4b5..4c4ad86db 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/JsonSchemaComponentsConfiguration.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/configuration/JsonSchemaComponentsConfiguration.java @@ -11,8 +11,10 @@ import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.*; import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS; -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_PROVIDER; import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES; +import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER; +//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER; +//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER; /** * @author Dmitriy Kopylenko @@ -31,8 +33,20 @@ public class JsonSchemaComponentsConfiguration { @Setter private String entityAttributesFiltersUiSchemaLocation = "classpath:entity-attributes-filters-ui-schema.json"; + //Configured via @ConfigurationProperties (using setter method) with 'shibui.filesystem-metadata-provider-ui-schema-location' property and + // default value set here if that property is not explicitly set in application.properties + @Setter + private String filesystemMetadataResolverUiSchemaLocation = "classpath:file-system-metadata-provider.schema.json"; + +/* TODO: Will be added as part of SHIBUI-703 @Setter - private String filesystemMetadtaProviderUiSchemaLocation = "classpath:file-system-metadata-provider.schema.json"; + private String localDynamicMetadataResolverUiSchemaLocation = "classpath:local-dynamic-metadata-provider.schema.json"; +*/ + +/* TODO: Will be added as part of SHIBUI-704 + @Setter + private String dynamicHttpMetadataResolverUiSchemaLocation = "classpath:dynamic-http-metadata-provider.schema.json"; +*/ @Bean public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(ResourceLoader resourceLoader, ObjectMapper jacksonMapper) { @@ -49,12 +63,24 @@ public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(Res .jacksonMapper(jacksonMapper) .detectMalformedJson(true) .build()) - .register(FILESYSTEM_METADATA_PROVIDER, JsonSchemaLocationBuilder.with() - .jsonSchemaLocation(filesystemMetadtaProviderUiSchemaLocation) + .register(FILESYSTEM_METADATA_RESOLVER, JsonSchemaLocationBuilder.with() + .jsonSchemaLocation(filesystemMetadataResolverUiSchemaLocation) .resourceLoader(resourceLoader) .jacksonMapper(jacksonMapper) .detectMalformedJson(true) .build()); + /*.register(DYNAMIC_HTTP_METADATA_RESOLVER, JsonSchemaLocationBuilder.with() + .jsonSchemaLocation(dynamicHttpMetadataResolverUiSchemaLocation) + .resourceLoader(resourceLoader) + .jacksonMapper(jacksonMapper) + .detectMalformedJson(true) + .build()) + .register(LOCAL_DYNAMIC_METADATA_RESOLVER, JsonSchemaLocationBuilder.with() + .jsonSchemaLocation(localDynamicMetadataResolverUiSchemaLocation) + .resourceLoader(resourceLoader) + .jacksonMapper(jacksonMapper) + .detectMalformedJson(true) + .build());*/ } diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaLocationLookup.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaLocationLookup.java index 1a055984c..62f46969e 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaLocationLookup.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaLocationLookup.java @@ -2,9 +2,9 @@ import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS; import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES; -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_PROVIDER; -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_PROVIDER; -import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_PROVIDER; +import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER; +//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER; +//import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER; /** * Utility methods for common JSON schema types lookups. @@ -30,7 +30,7 @@ public static JsonSchemaResourceLocation metadataSourcesSchema(JsonSchemaResourc * Searches entity attributes filters JSON schema resource location object in the given location registry. * * @param resourceLocationRegistry - * @returnentity attributes filters JSON schema resource location object + * @return entity attributes filters JSON schema resource location object * @throws IllegalStateException if schema is not found in the given registry */ public static JsonSchemaResourceLocation entityAttributesFiltersSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { @@ -39,21 +39,28 @@ public static JsonSchemaResourceLocation entityAttributesFiltersSchema(JsonSchem .orElseThrow(() -> new IllegalStateException("JSON schema resource location for metadata sources is not registered.")); } + /** + * Searches filesystem metadata resolver JSON schema resource location object in the given location registry. + * + * @param resourceLocationRegistry + * @return filesystem metadata resolver JSON schema resource location object + * @throws IllegalStateException if schema is not found in the given registry + */ public static JsonSchemaResourceLocation filesystemMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { return resourceLocationRegistry - .lookup(FILESYSTEM_METADATA_PROVIDER) - .orElseThrow(() -> new IllegalStateException("JSON schema resource location for metadata sources is not registered.")); + .lookup(FILESYSTEM_METADATA_RESOLVER) + .orElseThrow(() -> new IllegalStateException("JSON schema resource location for filesystem metadata resolver is not registered.")); } - public static JsonSchemaResourceLocation localDynamicMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { +/* public static JsonSchemaResourceLocation localDynamicMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { return resourceLocationRegistry - .lookup(LOCAL_DYNAMIC_METADATA_PROVIDER) - .orElseThrow(() -> new IllegalStateException("JSON schema resource location for metadata sources is not registered.")); - } + .lookup(LOCAL_DYNAMIC_METADATA_RESOLVER) + .orElseThrow(() -> new IllegalStateException("JSON schema resource location for local dynamic metadata resolver is not registered.")); + }*/ - public static JsonSchemaResourceLocation dynamicHttpMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { +/* public static JsonSchemaResourceLocation dynamicHttpMetadataProviderSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { return resourceLocationRegistry - .lookup(DYNAMIC_HTTP_METADATA_PROVIDER) - .orElseThrow(() -> new IllegalStateException("JSON schema resource location for metadata sources is not registered.")); - } + .lookup(DYNAMIC_HTTP_METADATA_RESOLVER) + .orElseThrow(() -> new IllegalStateException("JSON schema resource location for dynamic http metadata resolver is not registered.")); + }*/ } diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaResourceLocation.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaResourceLocation.java index e84d512d3..61f6bbeff 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaResourceLocation.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaResourceLocation.java @@ -9,7 +9,10 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Encapsulates arbitrary JSON schema location. @@ -91,7 +94,19 @@ public static JsonSchemaResourceLocation newSchemaLocation(String jsonSchemaLoca } public enum SchemaType { - METADATA_SOURCES, ENTITY_ATTRIBUTES_FILTERS, - FILESYSTEM_METADATA_PROVIDER, LOCAL_DYNAMIC_METADATA_PROVIDER, DYNAMIC_HTTP_METADATA_PROVIDER + // common types + METADATA_SOURCES, + + // filter types + ENTITY_ATTRIBUTES_FILTERS, + + // resolver types + FILESYSTEM_METADATA_RESOLVER; +// LOCAL_DYNAMIC_METADATA_RESOLVER, +// DYNAMIC_HTTP_METADATA_RESOLVER; + + public static List getResolverTypes() { + return Stream.of(SchemaType.values()).map(SchemaType::name).filter(it -> it.endsWith("RESOLVER")).collect(Collectors.toList()); + } } } \ No newline at end of file