1 21 package com.jaspersoft.jasperserver.api.engine.jasperreports.util.repo; 22 23 import java.io.IOException ; 24 import java.net.URL ; 25 import java.net.URLConnection ; 26 import java.net.URLStreamHandler ; 27 28 import com.jaspersoft.jasperserver.api.engine.jasperreports.util.RepositoryUtil; 29 30 31 35 public class Handler extends URLStreamHandler 36 { 37 public final static String REPOSITORY_PROTOCOL = "repo"; 38 public final static String URL_PROTOCOL_PREFIX = REPOSITORY_PROTOCOL + ':'; 39 40 public Handler() 41 { 42 super(); 43 } 44 45 protected void parseURL(URL u, String spec, int start, int limit) 46 { 47 spec = spec.trim(); 48 49 String protocol = null; 50 String path; 51 if (spec.startsWith(URL_PROTOCOL_PREFIX)) 52 { 53 protocol = REPOSITORY_PROTOCOL; 54 path = spec.substring(URL_PROTOCOL_PREFIX.length()); 55 } 56 else 57 { 58 path = spec; 59 } 60 61 setURL(u, protocol, null, -1, null, null, path, null, null); 62 } 63 64 protected URLConnection openConnection(URL url) throws IOException 65 { 66 return new RepositoryConnection(RepositoryUtil.getThreadRepositoryContext(), url); 67 } 68 } 69 | Popular Tags |