Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[KARAF-2134] Deployers do not support mvn urls well

git-svn-id: https://svn.apache.org/repos/asf/karaf/trunk@1436339 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit b118d10152ff528c2365067f3801997b12c2d4e5 1 parent 4f14b61
@gnodet gnodet authored
View
24 deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/BlueprintTransformer.java
@@ -64,7 +64,7 @@ public static void transform(URL url, OutputStream os) throws Exception {
// Build dom document
Document doc = parse(url);
// Heuristicly retrieve name and version
- String name = url.getPath();
+ String name = getPath(url);
int idx = name.lastIndexOf('/');
if (idx >= 0) {
name = name.substring(idx + 1);
@@ -185,6 +185,28 @@ protected static Document parse(URL url) throws Exception {
return db.parse(url.toString());
}
+ protected static String getPath(URL url) {
+ if (url.getProtocol().equals("mvn")) {
+ String[] parts = url.toExternalForm().substring(4).split("/");
+ String groupId;
+ String artifactId;
+ String version;
+ String type;
+ String qualifier;
+ if (parts.length < 3 || parts.length > 5) {
+ return url.getPath();
+ }
+ groupId = parts[0];
+ artifactId = parts[1];
+ version = parts[2];
+ type = (parts.length >= 4) ? "." + parts[3] : ".jar";
+ qualifier = (parts.length >= 5) ? "-" + parts[4] : "";
+ return groupId.replace('.', '/') + "/" + artifactId + "/"
+ + version + "/" + artifactId + "-" + version + qualifier + type;
+ }
+ return url.getPath();
+ }
+
protected static void copyInputStream(InputStream in, OutputStream out) throws Exception {
byte[] buffer = new byte[4096];
int len = in.read(buffer);
View
24 deployer/features/src/main/java/org/apache/karaf/deployer/features/FeatureTransformer.java
@@ -36,7 +36,7 @@
public static void transform(URL url, OutputStream os) throws Exception {
// Heuristicly retrieve name and version
- String name = url.getPath();
+ String name = getPath(url);
int idx = name.lastIndexOf('/');
if (idx >= 0) {
name = name.substring(idx + 1);
@@ -72,6 +72,28 @@ public static void transform(URL url, OutputStream os) throws Exception {
os.close();
}
+ private static String getPath(URL url) {
+ if (url.getProtocol().equals("mvn")) {
+ String[] parts = url.toExternalForm().substring(4).split("/");
+ String groupId;
+ String artifactId;
+ String version;
+ String type;
+ String qualifier;
+ if (parts.length < 3 || parts.length > 5) {
+ return url.getPath();
+ }
+ groupId = parts[0];
+ artifactId = parts[1];
+ version = parts[2];
+ type = (parts.length >= 4) ? "." + parts[3] : ".jar";
+ qualifier = (parts.length >= 5) ? "-" + parts[4] : "";
+ return groupId.replace('.', '/') + "/" + artifactId + "/"
+ + version + "/" + artifactId + "-" + version + qualifier + type;
+ }
+ return url.getPath();
+ }
+
private static void copyInputStream(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[8192];
int len = in.read(buffer);
View
24 deployer/spring/src/main/java/org/apache/karaf/deployer/spring/SpringTransformer.java
@@ -64,7 +64,7 @@ public static void transform(URL url, OutputStream os) throws Exception {
// Build dom document
Document doc = parse(url);
// Heuristicly retrieve name and version
- String name = url.getPath();
+ String name = getPath(url);
int idx = name.lastIndexOf('/');
if (idx >= 0) {
name = name.substring(idx + 1);
@@ -182,6 +182,28 @@ protected static Document parse(URL url) throws Exception {
return db.parse(url.toString());
}
+ protected static String getPath(URL url) {
+ if (url.getProtocol().equals("mvn")) {
+ String[] parts = url.toExternalForm().substring(4).split("/");
+ String groupId;
+ String artifactId;
+ String version;
+ String type;
+ String qualifier;
+ if (parts.length < 3 || parts.length > 5) {
+ return url.getPath();
+ }
+ groupId = parts[0];
+ artifactId = parts[1];
+ version = parts[2];
+ type = (parts.length >= 4) ? "." + parts[3] : ".jar";
+ qualifier = (parts.length >= 5) ? "-" + parts[4] : "";
+ return groupId.replace('.', '/') + "/" + artifactId + "/"
+ + version + "/" + artifactId + "-" + version + qualifier + type;
+ }
+ return url.getPath();
+ }
+
protected static void copyInputStream(InputStream in, OutputStream out) throws Exception {
byte[] buffer = new byte[4096];
int len = in.read(buffer);
Please sign in to comment.
Something went wrong with that request. Please try again.