[java-idp-plugin-scripting] 03/03: IDP-1595 Revert version information to being URL based
Rod Widdowson
rdw at steadingsoftware.com
Sun Jul 5 13:46:27 UTC 2020
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-idp-plugin-scripting.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-scripting.git;a=commit;h=99ab7c027e0777b107588775cf61838fecdc454b
commit 99ab7c027e0777b107588775cf61838fecdc454b
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sun Jul 5 14:43:11 2020 +0100
IDP-1595 Revert version information to being URL based
https://issues.shibboleth.net/jira/browse/IDP-1595
---
.../plugin/scripting/nashorn/NashornDescription.java | 18 ++++++------------
.../idp/plugin/scripting/nashorn/PluginTest.java | 16 ++++++++--------
.../idp/plugin/scripting/rhino/RhinoDescription.java | 9 ++++-----
3 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/nashorn-impl/src/main/java/net/shibboleth/idp/plugin/scripting/nashorn/NashornDescription.java b/nashorn-impl/src/main/java/net/shibboleth/idp/plugin/scripting/nashorn/NashornDescription.java
index 32c9c01..4800320 100644
--- a/nashorn-impl/src/main/java/net/shibboleth/idp/plugin/scripting/nashorn/NashornDescription.java
+++ b/nashorn-impl/src/main/java/net/shibboleth/idp/plugin/scripting/nashorn/NashornDescription.java
@@ -18,19 +18,15 @@
package net.shibboleth.idp.plugin.scripting.nashorn;
import java.io.IOException;
+import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.client.HttpClient;
import org.springframework.core.io.ClassPathResource;
-import net.shibboleth.ext.spring.resource.HTTPResource;
-import net.shibboleth.ext.spring.resource.ResourceHelper;
import net.shibboleth.utilities.java.support.collection.Pair;
-import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
import net.shibboleth.utilities.java.support.plugin.AbstractPluginDescription;
-import net.shibboleth.utilities.java.support.resource.Resource;
/**
* Details about the nashorn scripting plugin
@@ -52,21 +48,19 @@ public class NashornDescription extends AbstractPluginDescription {
}
@Override
- public List<Resource> getUpdateResources() {
- return List.of(ResourceHelper.of(new ClassPathResource("META-INF/plugins/")));
+ public List<URL> getUpdateURLs() throws IOException {
+ return List.of(new ClassPathResource("META-INF/plugins/").getURL());
}
@Override
- public List<Pair<Resource, Path>> getExternalFilePathsToCopy() throws IOException {
+ public List<Pair<URL, Path>> getExternalFilePathsToCopy() throws IOException {
- final HttpClientBuilder builder = new HttpClientBuilder();
final Path to = Path.of("dist", "edit-webapp-" + getPluginId(), "WEB-INF", "lib");
try {
- final HttpClient client = builder.buildClient();
- List<Pair<Resource, Path>> result = new ArrayList<>(jars.size());
+ List<Pair<URL, Path>> result = new ArrayList<>(jars.size());
for (String url : jars) {
// cannot use stream because the constructor throws and pipes hate that
- result.add( new Pair<>((Resource) new HTTPResource(client, url), to));
+ result.add( new Pair<>(new URL(url), to));
}
return List.copyOf(result);
} catch (Exception e) {
diff --git a/nashorn-impl/src/test/java/net/shibboleth/idp/plugin/scripting/nashorn/PluginTest.java b/nashorn-impl/src/test/java/net/shibboleth/idp/plugin/scripting/nashorn/PluginTest.java
index ae6c133..e22831e 100644
--- a/nashorn-impl/src/test/java/net/shibboleth/idp/plugin/scripting/nashorn/PluginTest.java
+++ b/nashorn-impl/src/test/java/net/shibboleth/idp/plugin/scripting/nashorn/PluginTest.java
@@ -20,19 +20,18 @@ package net.shibboleth.idp.plugin.scripting.nashorn;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import java.io.IOException;
import java.io.InputStream;
-import java.nio.file.Path;
+import java.net.URL;
import java.util.ServiceLoader;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import net.shibboleth.ext.spring.resource.HTTPResource;
import net.shibboleth.idp.installer.plugin.impl.PluginState;
-import net.shibboleth.utilities.java.support.collection.Pair;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.httpclient.HttpClientBuilder;
import net.shibboleth.utilities.java.support.plugin.PluginDescription;
-import net.shibboleth.utilities.java.support.resource.Resource;
/** basic sanity tests */
@SuppressWarnings("javadoc")
@@ -61,12 +60,13 @@ public class PluginTest {
}
@Test
- public void testDownload() throws IOException {
+ public void testDownload() throws Exception {
//
- // Abuse: We 'know' that the first dowload is the sdk
+ // Abuse: We 'know' that the first download is the sdk
//
- final Pair<Resource, Path> p = nashorn.getExternalFilePathsToCopy().get(0);
- final InputStream stream = p.getFirst().getInputStream();
+ final URL url = nashorn.getExternalFilePathsToCopy().get(0).getFirst();
+ final HTTPResource resource = new HTTPResource(new HttpClientBuilder().buildClient(), url);
+ final InputStream stream = resource.getInputStream();
byte[] buffer;
int count = 0;
do {
diff --git a/rhino-impl/src/main/java/net/shibboleth/idp/plugin/scripting/rhino/RhinoDescription.java b/rhino-impl/src/main/java/net/shibboleth/idp/plugin/scripting/rhino/RhinoDescription.java
index b9e5d1e..1f76179 100644
--- a/rhino-impl/src/main/java/net/shibboleth/idp/plugin/scripting/rhino/RhinoDescription.java
+++ b/rhino-impl/src/main/java/net/shibboleth/idp/plugin/scripting/rhino/RhinoDescription.java
@@ -18,16 +18,15 @@
package net.shibboleth.idp.plugin.scripting.rhino;
import java.io.IOException;
+import java.net.URL;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import org.springframework.core.io.ClassPathResource;
-import net.shibboleth.ext.spring.resource.ResourceHelper;
import net.shibboleth.utilities.java.support.collection.Pair;
import net.shibboleth.utilities.java.support.plugin.AbstractPluginDescription;
-import net.shibboleth.utilities.java.support.resource.Resource;
/**
* Details about the nashorn scripting plugin
@@ -41,12 +40,12 @@ public class RhinoDescription extends AbstractPluginDescription {
}
@Override
- public List<Resource> getUpdateResources() {
- return List.of(ResourceHelper.of(new ClassPathResource("META-INF/plugins/")));
+ public List<URL> getUpdateURLs() throws IOException {
+ return List.of(new ClassPathResource("META-INF/plugins/").getURL());
}
@Override
- public List<Pair<Resource, Path>> getExternalFilePathsToCopy() throws IOException {
+ public List<Pair<URL, Path>> getExternalFilePathsToCopy() throws IOException {
return Collections.emptyList();
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list