Skip to content

Liberty starter validation - #677

Open
malavikaharikumar23 wants to merge 10 commits into
OpenLiberty:devfrom
malavikaharikumar23:liberty-starter-validation
Open

Liberty starter validation#677
malavikaharikumar23 wants to merge 10 commits into
OpenLiberty:devfrom
malavikaharikumar23:liberty-starter-validation

Conversation

@malavikaharikumar23

Copy link
Copy Markdown

No description provided.

// Validate Group
String groupRaw = groupText.getText();
String group = groupRaw.trim();
String groupErrorMsg = "Valid characters for package names include a-z, A-Z, '_' and 0-9. Packages must be separated by '.'";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This and other messages in this class also need to be translated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

}

// Should not start or end with hyphen
if (artifact.startsWith("-") || artifact.endsWith("-")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this and the following check can be done more efficient with a regular expression. For example, what if the user enters --- or ----

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

return false;
}

// Check for leading/trailing dots or consecutive dots

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as previous comment. A regular expression would be better here to validate ending starting with ... or ...., etc.

Similarly with _ or -: here and in the previous case. do we allow users entering multiple _ or -?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

* @param mpVersion The MicroProfile version
* @return The highest compatible Jakarta EE version, or null if none found
*/
private String getFirstCompatibleEEVersion(String mpVersion) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might want to rename this method to getHighestCompatibleEEVersion. I was a bit confused about it until i read the content.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done


// Add listeners to combo boxes.
SelectionListener comboListener = new SelectionAdapter() {
// javaSECombo validates page and also checks compatibility with current EE/MP selections.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this is still needed here? I am asking because a listener was already added and are doing the validation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, this is needed. Unlike javaEECombo and microProfileCombo which have their own SelectionAdapters added in createVersionsSection(), javaSECombo(Called when user manually changes Java SE) only has this one listener. It calls checkAndUpdateJavaSE() to validate Java SE compatibility with current EE/MP selections and validatePage() for page completion tracking.

* @param eeVersion The Jakarta EE version
* @param mpVersion The MicroProfile version
*/
private void checkAndUpdateJavaSE(String eeVersion, String mpVersion) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we not getting the java SE validation data from the starter ... that is why you are manually verifying this?
If not, we need to take a different approach; otherwise, we will need to update this code every time a new compatibilities/versions are created.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The Liberty Starter API (/api/start/info) does not provide Java SE compatibility constraints for Jakarta EE or MicroProfile versions ie it only provides EE↔MP compatibility via the constraints field under "e". Therefore, the Java SE validation rules are hardcoded based on the same logic used by the Liberty Starter website's frontend (builds.js). We are aware of this and will need to be updated when new versions are released, but there is no API-driven alternative currently available.

Comment thread bundles/io.openliberty.tools.eclipse.ui/pom.xml Outdated

@mezarin mezarin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi Malavika, i got around to trying the code. Here are a few of things i saw:

  • When opening the package/project explorer, i do not see the link to create a Liberty starter.
  • When i change the Java SE Version to an invalid version and it auto corrects, the error message does not go away even after subsequent correct selections.
  • If i have a version of SE=8, EE=9.1, MP=5.0, and i change EE=10, The SE version changes to 11, and the MP version changes 7.1. These two changes are reflected in the site message, but not ours. We say just this: "Java SE Version has been automatically updated from 8 to 11. Jakarta EE 10.0 requires a minimum of Java SE 11." The site says this: "MicroProfile Version has been automatically updated from 5.0 to 7.1 for compatibility with Java EE / Jakarta EE Version.
    MicroProfile Version 7.1 and Java EE/Jakarta EE Version 10.0 require a minimum of Java SE Version 11."
    Please double check the combinations. We also need to make sure that the warning/error messages on the wizard are cleared as soon as the user starts selecting a new option.
  • The site messages say "with Java EE / Jakarta EE Version.", you are just using Jakarta EE. Let's match the messages.
  • You also deleted a few .project files. Was that by accident?

Aside from this.

  • Can you please add a trace for each of the Logger warning/error messages we issue.

After this PR is merged:

  • We need to add some integration tests.

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