diff --git a/perun-base/src/main/java/cz/metacentrum/perun/core/api/NamespaceRules.java b/perun-base/src/main/java/cz/metacentrum/perun/core/api/NamespaceRules.java index 9f435c1f5f..988255c911 100644 --- a/perun-base/src/main/java/cz/metacentrum/perun/core/api/NamespaceRules.java +++ b/perun-base/src/main/java/cz/metacentrum/perun/core/api/NamespaceRules.java @@ -7,15 +7,12 @@ public class NamespaceRules { private String namespaceName; private String defaultEmail; + private String csvGenHeader; + private String csvGenPlaceholder; private Set requiredAttributes; private Set optionalAttributes; - public NamespaceRules(String namespaceName, String defaultEmail, Set requiredAttributes, Set optionalAttributes) { - this.namespaceName = namespaceName; - this.defaultEmail = defaultEmail; - this.requiredAttributes = requiredAttributes; - this.optionalAttributes = optionalAttributes; - } + public NamespaceRules() {} public String getNamespaceName() { return namespaceName; @@ -70,4 +67,20 @@ public String getDefaultEmail() { public void setDefaultEmail(String defaultEmail) { this.defaultEmail = defaultEmail; } + + public String getCsvGenHeader() { + return csvGenHeader; + } + + public void setCsvGenHeader(String csvGenHeader) { + this.csvGenHeader = csvGenHeader; + } + + public String getCsvGenPlaceholder() { + return csvGenPlaceholder; + } + + public void setCsvGenPlaceholder(String csvGenPlaceholder) { + this.csvGenPlaceholder = csvGenPlaceholder; + } } diff --git a/perun-base/src/test/resources/sponsored-accounts-config.yml b/perun-base/src/test/resources/sponsored-accounts-config.yml index 7b875d4c67..2817fe51b4 100644 --- a/perun-base/src/test/resources/sponsored-accounts-config.yml +++ b/perun-base/src/test/resources/sponsored-accounts-config.yml @@ -6,6 +6,8 @@ # # default_email - this field determines, which email will be set as a preferred attribute, for the generated sponsored # user. If this value is not specified, it fallbacks to 'no-reply@perun-aai.org' +# csv_gen_header - this field defines the csv format used for parsing data. +# csv_gen_placeholder - this field contains placeholder for the used csv format. # required_attributes - fields from the SponsoredUserData class, which are required for the given namespace during the # creation of a sponsorship. Allowed values are fields of the SponsoredUserData class. This # should be mainly used in GUI to determine, which items should be visible in the dialog. But, it @@ -39,12 +41,16 @@ namespaces: dummy: default_email: "no-reply@dummy.com" + csv_gen_header: "" + csv_gen_placeholder: "" required_attributes: [] optional_attributes: - password dummy_with_login: default_email: "no-reply@dummy.com" + csv_gen_header: "" + csv_gen_placeholder: "" required_attributes: - login optional_attributes: diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/impl/SponsoredAccountsConfigLoader.java b/perun-core/src/main/java/cz/metacentrum/perun/core/impl/SponsoredAccountsConfigLoader.java index e4e1cc9e06..4b1ca89547 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/impl/SponsoredAccountsConfigLoader.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/impl/SponsoredAccountsConfigLoader.java @@ -57,12 +57,24 @@ private Set loadNamespacesRulesFromJsonNode(JsonNode rootNode) { String namespaceName = namespacesNames.next(); JsonNode namespaceNode = namespacesNodes.get(namespaceName); JsonNode defaultEmail = namespaceNode.get("default_email"); + JsonNode csvGenHeader = namespaceNode.get("csv_gen_header"); + JsonNode csvGenPlaceholder = namespaceNode.get("csv_gen_placeholder"); JsonNode requiredAttributesNode = namespaceNode.get("required_attributes"); JsonNode optionalAttributesNode = namespaceNode.get("optional_attributes"); Set requiredAttributes = objectMapper.convertValue(requiredAttributesNode, new TypeReference<>() {}); Set optionalAttributes = objectMapper.convertValue(optionalAttributesNode, new TypeReference<>() {}); - rules.add(new NamespaceRules(namespaceName, defaultEmail.asText(), requiredAttributes, optionalAttributes)); + NamespaceRules namespaceRules = new NamespaceRules(); + namespaceRules.setNamespaceName(namespaceName); + namespaceRules.setDefaultEmail(defaultEmail.asText()); + namespaceRules.setRequiredAttributes(requiredAttributes); + namespaceRules.setOptionalAttributes(optionalAttributes); + if (!csvGenHeader.isNull()) + namespaceRules.setCsvGenHeader(csvGenHeader.asText()); + if (!csvGenPlaceholder.isNull()) + namespaceRules.setCsvGenPlaceholder(csvGenPlaceholder.asText()); + + rules.add(namespaceRules); } return rules; diff --git a/perun-openapi/openapi.yml b/perun-openapi/openapi.yml index 3c8a42fb4a..329fccd09b 100644 --- a/perun-openapi/openapi.yml +++ b/perun-openapi/openapi.yml @@ -503,6 +503,8 @@ components: type: object properties: defaultEmail: { type: string } + csvGenHeader: { type: string } + csvGenPlaceholder: { type: string } namespaceName: { type: string } requiredAttributes: type: array