1 26 package org.objectweb.openccm.descriptor.softpkg.ccm; 27 28 29 36 public class LinkDeployer 37 extends LinkDeployerContext 38 { 39 private java.io.File tmpFile; 46 52 private String 58 getValeur() 59 { 60 if(getLink().getHref()!=null) 61 return getLink().getHref().trim(); 62 else return getLink().getValue().trim(); 63 } 64 65 private java.io.InputStream 66 getInputStreamInternal() 67 throws java.io.IOException 68 { 69 70 71 java.net.URL url=new java.net.URL (getValeur()); 72 73 if(getValeur().startsWith("file:")) 75 return url.openStream(); 76 77 78 if(tmpFile!=null) 80 return new java.io.FileInputStream (tmpFile); 81 82 if(getRootDeployerContext().isAlreadyDownloaded(getValeur())) 84 { 85 tmpFile=getRootDeployerContext().getTemporaryFile(getValeur()); 86 return new java.io.FileInputStream (tmpFile); 87 } 88 89 tmpFile = java.io.File.createTempFile( 91 98 "OpenCCM_tmp_" 99 +url.getPath().substring( 100 url.getPath().lastIndexOf('/')+1) 101 +"_" 102 ,System.currentTimeMillis()+""); 103 104 java.io.FileOutputStream fos=new java.io.FileOutputStream (tmpFile); 105 java.io.InputStream is=url.openStream(); 106 byte [] buff=new byte[32000]; 107 int readed=is.read(buff,0,32000); 108 while(readed>0) 109 { 110 fos.write(buff,0,readed); 111 readed=is.read(buff,0,32000); 112 } 113 fos.close(); 114 getRootDeployerContext().connectTemporaryFile(tmpFile,getValeur()); 115 return new java.io.FileInputStream (tmpFile); 116 } 117 125 public String 126 getReference() 127 { 128 return getValeur(); 129 } 130 131 132 133 public java.io.InputStream 134 getInputStream() 135 throws java.io.IOException 136 { 137 java.io.InputStream is=getInputStreamInternal(); 138 getRootDeployerContext().connectOpenInputStream(is); 139 return is; 140 } 141 142 } 143 | Popular Tags |