1 26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.util; 27 28 29 36 public class LinkDeployer 37 extends LinkDeployerContext 38 { 39 private java.io.File tmpFile; 46 private String 57 getValeur() 58 { 59 if(getLink().getHref()!=null) 60 return getLink().getHref().trim(); 61 else return getLink().getValue().trim(); 62 } 63 64 private java.io.InputStream 65 getInputStreamInternal() 66 throws java.io.IOException 67 { 68 if(getValeur().indexOf(":")==-1) 70 return 71 getRootDeployerContext() 72 .getZipEntryRetriever() 73 .getZipEntryISIgnoringDelimiterType(getLink().getHref()); 74 75 java.net.URL url=new java.net.URL (getValeur()); 76 77 78 79 if(getValeur().startsWith("file:")) 81 return url.openStream(); 82 83 84 if(tmpFile!=null) 86 return new java.io.FileInputStream (tmpFile); 87 88 if(getRootDeployerContext().isAlreadyDownloaded(getValeur())) 90 { 91 tmpFile=getRootDeployerContext().getTemporaryFile(getValeur()); 92 return new java.io.FileInputStream (tmpFile); 93 } 94 95 tmpFile = java.io.File.createTempFile( 97 104 "OpenCCM_tmp_" 105 +url.getPath().substring( 106 url.getPath().lastIndexOf('/')+1) 107 +"_" 108 ,System.currentTimeMillis()+""); 109 110 java.io.FileOutputStream fos=new java.io.FileOutputStream (tmpFile); 111 java.io.InputStream is=url.openStream(); 112 byte [] buff=new byte[32000]; 113 int readed=is.read(buff,0,32000); 114 while(readed>0) 115 { 116 fos.write(buff,0,readed); 117 readed=is.read(buff,0,32000); 118 } 119 fos.close(); 120 getRootDeployerContext().connectTemporaryFile(tmpFile,getValeur()); 121 return new java.io.FileInputStream (tmpFile); 122 } 123 131 public String 132 getReference() 133 { 134 return getValeur(); 135 } 136 137 138 139 public java.io.InputStream 140 getInputStream() 141 throws java.io.IOException 142 { 143 java.io.InputStream is=getInputStreamInternal(); 144 getRootDeployerContext().connectOpenInputStream(is); 145 return is; 146 } 147 148 149 150 151 } 152 | Popular Tags |