Skip to content

Commit

Permalink
NOJIRA - expanding the values that can be used for att bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
chasegawa committed Sep 25, 2024
1 parent d739631 commit b8c9646
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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<String, Object> result = new HashMap<>();
result.put("type", "object");
result.put("required", new String[] { "name" });
HashMap<String, Object> props = new HashMap<>();
HashMap<String, Object> 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<String, Object> 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<String, Object> 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<String> getAttributeNames() {
List<String> resultNames = new ArrayList<>();
customPropertiesConfiguration.getAttributes().forEach(map -> resultNames.add(map.get("name")));
return resultNames;
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -28,4 +28,4 @@ export const CustomAttributeEditor = {
'ui:disabled': true
}
}, AttributeBundleDefinition.uiSchema)
};
};

0 comments on commit b8c9646

Please sign in to comment.