Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restrictions on names of domains #6140

Merged
merged 20 commits into from
Dec 16, 2024
Merged

Add restrictions on names of domains #6140

merged 20 commits into from
Dec 16, 2024

Conversation

XingY
Copy link
Contributor

@XingY XingY commented Dec 10, 2024

Rationale

This set of PRs implement a set of rules what characters / patterns can be used as domain (sample, data class, list, etc) names for new domains as well as existing domains when they are re-named.

Related Pull Requests

Changes

  • Add DomainUtil.validateDomainName and wire up domain name validation during creation and update
  • Validate parentAlias to avoid conflict with naming pattern syntax
  • Support parent and ancestor naming pattern for parent type that contains /, in the form of $S
  • fix detailed audit with special names
  • Add jest integration test for validating domain names
  • Update / Add selenium tests for domain names with special characters

inputs.get(inputsCategory).addAll(parents);
// TODO, parents broken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -671,4 +671,10 @@ public boolean supportsPhiLevel()
{
return ComplianceService.get().isComplianceSupported();
}

@Override
public boolean supportNamingPattern()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public boolean supportNamingPattern()
public boolean supportsNamingPattern()

String prefix = "Invalid " + kindName + " name. ";

if (StringUtils.isBlank(domainName))
return "Domain name must not be blank";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "Domain name must not be blank";
return "Domain name must not be blank.";


char start = domainName.charAt(0);
if (!Character.isLetterOrDigit(start))
return prefix + "Domain name must start with a letter or a number character.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return prefix + "Domain name must start with a letter or a number character.";
return prefix + "Domain name must start with a letter or a number.";

(or it could be "must not start with a letter or a digit")

if (!Character.isLetterOrDigit(start))
return prefix + "Domain name must start with a letter or a number character.";

//final String legalChars = " -_()&/.:";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

@@ -917,6 +935,32 @@ public static ValidationException updateDomainDescriptor(GWTDomain<? extends GWT
return validationException;
}

public static @Nullable String validateDomainName(@NotNull String domainName, String kindName, boolean supportNamingPattern)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static @Nullable String validateDomainName(@NotNull String domainName, String kindName, boolean supportNamingPattern)
public static @Nullable String validateDomainName(@NotNull String domainName, String kindName, boolean supportsNamingPattern)

@@ -917,6 +935,32 @@ public static ValidationException updateDomainDescriptor(GWTDomain<? extends GWT
return validationException;
}

public static @Nullable String validateDomainName(@NotNull String domainName, String kindName, boolean supportNamingPattern)
{
String prefix = "Invalid " + kindName + " name. ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String prefix = "Invalid " + kindName + " name. ";
String prefix = "Invalid " + kindName + " name '" + domainName + "'.";

}

@LogMethod
protected void renameDataset(String orgName, String newName, String orgLabel, String newLabel, String... fieldNames)
protected void renameDataset(String error, String orgName, String newName, String orgLabel, String newLabel, String... fieldNames)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected void renameDataset(String error, String orgName, String newName, String orgLabel, String newLabel, String... fieldNames)
protected void renameDataset(@Nullable String error, String orgName, String newName, String orgLabel, String newLabel, String... fieldNames)

@XingY XingY requested a review from labkey-susanh December 13, 2024 00:46
@XingY XingY merged commit 5bda2b7 into develop Dec 16, 2024
2 of 9 checks passed
@XingY XingY deleted the fb_domainNameValidation branch December 16, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants