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

#316: fix Jasypt version #354

Merged
merged 8 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.devonfw.tools.ide.tool.jasypt;

import com.devonfw.tools.ide.url.updater.MavenBasedUrlUpdater;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
* {@link MavenBasedUrlUpdater} for jasypt
*/
public class JasyptUrlUpdater extends MavenBasedUrlUpdater {

public static final String MIN_VERSION = "1.9.3";
mvomiero marked this conversation as resolved.
Show resolved Hide resolved

@Override
protected String getTool() {

Expand All @@ -24,4 +28,14 @@ protected String getMavenArtifcatId() {
return "jasypt";
}

@Override
public boolean isValidVersion(String version) {

VersionIdentifier artifactVersion = VersionIdentifier.of(version);
if (artifactVersion != null) {
return artifactVersion.isGreaterOrEqual(VersionIdentifier.of(MIN_VERSION));
mvomiero marked this conversation as resolved.
Show resolved Hide resolved
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.devonfw.tools.ide.url.updater;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import com.devonfw.tools.ide.maven.MavenMetadata;
import com.devonfw.tools.ide.url.model.folder.UrlVersion;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
* The MvnCrawler class is an abstract class that provides functionality for crawling Maven repositories.
*/
Expand All @@ -23,8 +23,7 @@ public abstract class MavenBasedUrlUpdater extends AbstractUrlUpdater {
public MavenBasedUrlUpdater() {

super();
this.mavenBaseRepoUrl = "https://repo1.maven.org/maven2/" + getMavenGroupIdPath() + "/" + getMavenArtifcatId()
+ "/";
this.mavenBaseRepoUrl = "https://repo1.maven.org/maven2/" + getMavenGroupIdPath() + "/" + getMavenArtifcatId() + "/";

}

Expand Down Expand Up @@ -74,12 +73,25 @@ private Set<String> doGetVersionsFromMavenApi(String url) {
XmlMapper mapper = new XmlMapper();
MavenMetadata metaData = mapper.readValue(response, MavenMetadata.class);
for (String version : metaData.getVersioning().getVersions()) {
addVersion(version, versions);
if (isValidVersion(version)) {
addVersion(version, versions);
}
}
} catch (IOException e) {
throw new IllegalStateException("Failed to get version from " + url, e);
}
return versions;
}

/**
* Subclasses should override this method to enforce version validation.
*
* @param version the version of the artifact.
* @return true as default implementation.
*/
protected boolean isValidVersion(String version) {

return true;
}

}
Loading