1 17 18 package org.apache.avalon.repository ; 19 20 import java.io.IOException ; 21 import java.net.URL ; 22 23 26 public class ArtifactURLConnection extends AbstractURLConnection 27 { 28 34 ArtifactURLConnection( URL url ) 35 throws NullPointerException , IOException 36 { 37 super( url ); 38 } 39 40 44 public Object getContent() throws IOException 45 { 46 return getContent( "jar" ); 47 } 48 49 53 protected Object getContent( String defaultType ) throws IOException 54 { 55 try 56 { 57 final String path = getURL().getPath(); 58 final int i = path.lastIndexOf( "/" ); 59 final String group = path.substring( 0, i ); 60 final String name = path.substring( i+1 ); 61 final String version = getVersion( url ); 62 final String type = getType( getURL(), defaultType ); 63 return Artifact.createArtifact( group, name, version, type ); 64 } 65 catch( Throwable e ) 66 { 67 final String error = 68 "Unexpected exception while resolving url [" + getURL() + "]."; 69 throw new CascadingIOException( error ); 70 } 71 } 72 73 private String getType( URL url, String type ) 74 { 75 return getQueryField( url, "type", type ); 76 } 77 78 79 80 } 81 | Popular Tags |