Changeset 832:bc7154271a98
Legend:
- Unmodified
- Added
- Removed
-
kraken-core/src/main/java/org/krakenapps/bundle/BundleScript.java
r732 r832 18 18 import java.io.File; 19 19 import java.io.FileNotFoundException; 20 import java.io.FileOutputStream; 20 21 import java.io.IOException; 21 22 import java.net.MalformedURLException; … … 41 42 import org.krakenapps.api.ScriptUsage; 42 43 import org.krakenapps.main.Kraken; 44 import org.krakenapps.pkg.HttpWagon; 43 45 import org.krakenapps.pkg.MavenMetadata; 44 46 import org.krakenapps.pkg.ProgressMonitorImpl; … … 218 220 String path = args[0].replace('\\', '/'); 219 221 bundleId = manager.installBundle(path); 222 } else if (args[0].startsWith("http://")) { 223 URL url = new URL(args[0]); 224 String dir = System.getProperty("kraken.download.dir"); 225 String[] pathTokens = url.getPath().split("/"); 226 File f = new File(dir, pathTokens[pathTokens.length - 1]); 227 f.getParentFile().mkdirs(); 228 context.println("trying download to " + f.getAbsolutePath()); 229 230 if (f.createNewFile()) { 231 byte[] b = HttpWagon.download(url); 232 FileOutputStream os = new FileOutputStream(f); 233 try { 234 os.write(b); 235 } finally { 236 os.close(); 237 } 238 239 bundleId = manager.installBundle("file:///" + f.getAbsolutePath()); 240 } else { 241 context.println("cannot download file, file already exists"); 242 return; 243 } 220 244 } else { 221 245 context.println("local path should starts with file:// or file:\\\\"); … … 244 268 context.println(" bundle.install groupId artifactId version"); 245 269 context.println(" bundlePath example: file:///C:\\bundle\\sample.jar or file:///root/kraken/sample.jar"); 270 } catch (MalformedURLException e) { 271 context.println("Invalid bundle download URL"); 272 } catch (IOException e) { 273 context.println(e.getMessage()); 246 274 } 247 275 }
Note: See TracChangeset
for help on using the changeset viewer.
