From f67988f236c21b86c08fc02e864c42a49689ef95 Mon Sep 17 00:00:00 2001 From: cnathe Date: Wed, 30 Jul 2025 15:15:04 -0500 Subject: [PATCH 1/2] ValidateDomainAndFieldNamesAction to use domainKind generateDomainURI() when applicable --- .../controllers/property/PropertyController.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java index 1b0324ecbbd..35f7f1b282f 100644 --- a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java +++ b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java @@ -521,8 +521,13 @@ public Object execute(DomainApiForm form, BindException errors) DomainKind kind = PropertyService.get().getDomainKindByName(kindName); if (kind == null) throw new IllegalArgumentException("No domain kind matches name '" + kindName + "'"); - String typeURI = "urn:lsid:labkey.com:" + kindName + ".Folder-1000.1001:1002"; // note using a fake lsid here, since not all domain kinds override generateDomainURI - Domain domain = PropertyService.get().createDomain(getContainer(), typeURI, "test"); + + // try using the DomainKind to generate a domain URI, if it supports it. default to using a fake / representative URI + String typeURI = kind.generateDomainURI("schemaName", "queryName", getContainer(), getUser()); + if (typeURI == null) + typeURI = "urn:lsid:labkey.com:" + kindName + ".Folder-21085:Test+Domain+Name-115c61b7-4faa-103e-8e7f-a47ad552213c"; + + Domain domain = PropertyService.get().createDomain(getContainer(), typeURI, "queryName"); boolean checkFieldNames = !domainDesign.getFields().isEmpty(); boolean checkDomainName = domainDesign.getName() != null; From 364227f7e5fda3c3b0f57430fab0db25b9add59c Mon Sep 17 00:00:00 2001 From: cnathe Date: Wed, 30 Jul 2025 16:37:21 -0500 Subject: [PATCH 2/2] add try/catch --- .../controllers/property/PropertyController.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java index 35f7f1b282f..d318dd83d83 100644 --- a/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java +++ b/experiment/src/org/labkey/experiment/controllers/property/PropertyController.java @@ -523,7 +523,12 @@ public Object execute(DomainApiForm form, BindException errors) throw new IllegalArgumentException("No domain kind matches name '" + kindName + "'"); // try using the DomainKind to generate a domain URI, if it supports it. default to using a fake / representative URI - String typeURI = kind.generateDomainURI("schemaName", "queryName", getContainer(), getUser()); + String typeURI = null; + try + { + typeURI = kind.generateDomainURI("schemaName", "queryName", getContainer(), getUser()); + } + catch (AssertionError ignored) {} // no-op if the DomainKind does not support generateDomainURI() if (typeURI == null) typeURI = "urn:lsid:labkey.com:" + kindName + ".Folder-21085:Test+Domain+Name-115c61b7-4faa-103e-8e7f-a47ad552213c";