diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java index a1fc130dc..75f995d1c 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/AttributeBundleController.java @@ -1,5 +1,6 @@ package edu.internet2.tier.shibboleth.admin.ui.controller; +import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomPropertiesConfiguration; import edu.internet2.tier.shibboleth.admin.ui.domain.AttributeBundle; import edu.internet2.tier.shibboleth.admin.ui.exception.ObjectIdExistsException; import edu.internet2.tier.shibboleth.admin.ui.exception.PersistentEntityNotFound; @@ -21,13 +22,19 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + @RestController @RequestMapping("/api/custom/entity/bundles") @Slf4j -@Tags(value = {@Tag(name = "bundles")}) +@Tags(value = { @Tag(name = "bundles") }) public class AttributeBundleController { @Autowired AttributeBundleService attributeBundleService; + @Autowired CustomPropertiesConfiguration customPropertiesConfiguration; + @Secured("ROLE_ADMIN") @PostMapping @Transactional @@ -63,4 +70,37 @@ public ResponseEntity update(@RequestBody AttributeBundle bundle) throws Pers AttributeBundle result = attributeBundleService.updateBundle(bundle); return ResponseEntity.ok(result); } + + @GetMapping("/bundle_schema") + public ResponseEntity getBundleSchema() { + HashMap result = new HashMap<>(); + result.put("type", "object"); + result.put("required", new String[] { "name" }); + HashMap props = new HashMap<>(); + HashMap nameMap = new HashMap<>(); + nameMap.put("type", "string"); + nameMap.put("title", "label.bundle-name"); + nameMap.put("description", "tooltip.bundle-name"); + nameMap.put("minLength", 1); + nameMap.put("maxLength", 255); + props.put("name", nameMap); + HashMap attributesMap = new HashMap<>(); + attributesMap.put("type", "array"); + attributesMap.put("title", "label.attributes"); + attributesMap.put("description", "Attribute table - select the attributes you want to bundle (default unchecked)"); + attributesMap.put("uniqueItems", true); + HashMap itemsMap = new HashMap<>(); + itemsMap.put("type", "string"); + itemsMap.put("enum", getAttributeNames()); + attributesMap.put("items", itemsMap); + props.put("attributes", attributesMap); + result.put("properties", props); + return ResponseEntity.ok(result); + } + + private List getAttributeNames() { + List resultNames = new ArrayList<>(); + customPropertiesConfiguration.getAttributes().forEach(map -> resultNames.add(map.get("name"))); + return resultNames; + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7e1ca4702..b3ae433e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ name=shibui group=edu.internet2.tier.shibboleth.admin.ui -version=2.0.2 +version=2.1.0-SNAPSHOT ### library versions ### ## As of 2-23-23 diff --git a/ui/src/app/metadata/domain/attribute/AttributeBundleDefinition.js b/ui/src/app/metadata/domain/attribute/AttributeBundleDefinition.js index dd5416687..7c60db1cf 100644 --- a/ui/src/app/metadata/domain/attribute/AttributeBundleDefinition.js +++ b/ui/src/app/metadata/domain/attribute/AttributeBundleDefinition.js @@ -5,7 +5,7 @@ export const AttributeBundleDefinition = { label: 'Metadata Attribute Bundle', type: '@MetadataAttributeBundle', steps: [], - schema: `${BASE_PATH}assets/schema/attribute/bundle.schema.json`, + schema: `${BASE_PATH}api/custom/entity/bundles/bundle_schema`, uiSchema: { attributes: { 'ui:widget': 'AttributeReleaseWidget' @@ -28,4 +28,4 @@ export const CustomAttributeEditor = { 'ui:disabled': true } }, AttributeBundleDefinition.uiSchema) -}; \ No newline at end of file +};