fix #2818 Enable fess-crawler plugin in Fess plugin system

This commit is contained in:
Shinsuke Sugaya 2024-06-17 21:38:38 +09:00
parent 146f52e299
commit 95354c5400
2 changed files with 51 additions and 2 deletions

View file

@ -120,6 +120,9 @@ public class PluginHelper {
final Matcher matcher = Pattern.compile("href=\"[^\"]*(" + artifactType.getId() + "[a-zA-Z0-9\\-]+)/?\"").matcher(repoContent);
while (matcher.find()) {
final String name = matcher.group(1);
if (isExcludedName(artifactType, name)) {
continue;
}
final String pluginUrl = url + (url.endsWith("/") ? name + "/" : "/" + name + "/");
try {
final String pluginMetaContent = getRepositoryContent(pluginUrl + "maven-metadata.xml");
@ -160,6 +163,26 @@ public class PluginHelper {
return list;
}
protected boolean isExcludedName(final ArtifactType artifactType, final String name) {
if (artifactType != ArtifactType.CRAWLER) {
return false;
}
if ("fess-crawler".equals(name)//
|| "fess-crawler-db".equals(name)//
|| "fess-crawler-db-h2".equals(name)//
|| "fess-crawler-db-mysql".equals(name)//
|| "fess-crawler-es".equals(name)//
|| "fess-crawler-lasta".equals(name)//
|| "fess-crawler-parent".equals(name)//
|| "fess-crawler-playwright".equals(name)//
|| "fess-crawler-webdriver".equals(name)) {
return true;
}
return false;
}
protected boolean isTargetPluginVersion(final String version) {
return ComponentUtil.getFessConfig().isTargetPluginVersion(version);
}
@ -378,8 +401,14 @@ public class PluginHelper {
}
public enum ArtifactType {
DATA_STORE("fess-ds"), THEME("fess-theme"), INGEST("fess-ingest"), SCRIPT("fess-script"), WEBAPP("fess-webapp"), THUMBNAIL(
"fess-thumbnail"), UNKNOWN("jar");
DATA_STORE("fess-ds"), //
THEME("fess-theme"), //
INGEST("fess-ingest"), //
SCRIPT("fess-script"), //
WEBAPP("fess-webapp"), //
THUMBNAIL("fess-thumbnail"), //
CRAWLER("fess-crawler"), //
UNKNOWN("jar");
private final String id;
@ -410,6 +439,9 @@ public class PluginHelper {
if (name.startsWith(THUMBNAIL.getId())) {
return THUMBNAIL;
}
if (name.startsWith(CRAWLER.getId())) {
return CRAWLER;
}
return UNKNOWN;
}
}

View file

@ -55,6 +55,12 @@ public class PluginHelperTest extends UnitFessTestCase {
} catch (IOException e) {
throw new IORuntimeException(e);
}
} else if (url.contains("plugin/repo3")) {
try (InputStream is = ResourceUtil.getResourceAsStream(url)) {
return new String(InputStreamUtil.getBytes(is), Constants.UTF_8);
} catch (IOException e) {
throw new IORuntimeException(e);
}
} else if (url.contains("plugin/repo.yaml")) {
try (InputStream is = ResourceUtil.getResourceAsStream(url)) {
return new String(InputStreamUtil.getBytes(is), Constants.UTF_8);
@ -88,6 +94,17 @@ public class PluginHelperTest extends UnitFessTestCase {
list.get(0).getUrl());
}
public void test_processRepository3() {
List<Artifact> list = pluginHelper.processRepository(ArtifactType.CRAWLER, "plugin/repo3/");
assertEquals(2, list.size());
assertEquals("fess-crawler-smbj", list.get(0).getName());
assertEquals("14.14.0", list.get(0).getVersion());
assertEquals("plugin/repo3/fess-crawler-smbj/14.14.0/fess-crawler-smbj-14.14.0.jar", list.get(0).getUrl());
assertEquals("fess-crawler-smbj", list.get(1).getName());
assertEquals("14.15.0", list.get(1).getVersion());
assertEquals("plugin/repo3/fess-crawler-smbj/14.15.0/fess-crawler-smbj-14.15.0.jar", list.get(1).getUrl());
}
public void test_getArtifactFromFileName1() {
Artifact artifact = pluginHelper.getArtifactFromFileName(ArtifactType.DATA_STORE, "fess-ds-atlassian-13.2.0.jar");
assertEquals("fess-ds-atlassian", artifact.getName());