Changeset 357:85fc65cb2520
- Timestamp:
- 09/21/11 16:46:58 (5 months ago)
- Branch:
- default
- Convert:
- svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2791
- Location:
- kraken-core
- Files:
-
- 6 edited
-
pom.xml (modified) (1 diff)
-
src/main/java/org/krakenapps/bundle/BundleManagerService.java (modified) (3 diffs)
-
src/main/java/org/krakenapps/bundle/BundleScript.java (modified) (7 diffs)
-
src/main/java/org/krakenapps/logger/LoggerScriptFactory.java (modified) (1 diff)
-
src/main/java/org/krakenapps/pkg/MavenResolver.java (modified) (3 diffs)
-
src/main/java/org/krakenapps/script/Editor.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kraken-core/pom.xml
r265 r357 9 9 </parent> 10 10 <artifactId>kraken-core</artifactId> 11 <version>1.8. 0</version>11 <version>1.8.1</version> 12 12 <name>Kraken Core</name> 13 13 <packaging>jar</packaging> -
kraken-core/src/main/java/org/krakenapps/bundle/BundleManagerService.java
r215 r357 62 62 */ 63 63 public class BundleManagerService implements SynchronousBundleListener, BundleManager { 64 final Logger logger = LoggerFactory.getLogger(BundleManagerService.class.getName());64 private Logger logger = LoggerFactory.getLogger(BundleManagerService.class); 65 65 66 66 private BundleContext context; … … 312 312 bundle.stop(); 313 313 } catch (BundleException e) { 314 e.printStackTrace();314 logger.error("kraken core: stopping bundle failed.", e); 315 315 } 316 316 } … … 330 330 331 331 try { 332 if (!isLocalJar(bundle)) { 333 try { 334 File before = new File(bundle.getLocation().replace("file://", "")); 335 File temp = File.createTempFile(before.getName(), "", before.getParentFile()); 336 temp.delete(); 337 if (before.renameTo(temp)) { 338 MavenResolver resolver = new MavenResolver(getLocalRepository(), 339 config.getBundleRepositories(), null, getKeyStoreManager()); 340 MavenArtifact artifact = getArtifact(bundle); 341 File after = resolver.resolve(artifact); 342 if (after.exists()) 343 temp.delete(); 344 else 345 temp.renameTo(before); 346 } 347 } catch (MavenResolveException e) { 348 logger.error("kraken core: maven resolve failed.", e); 349 } catch (IOException e) { 350 logger.error("kraken core: create temp file failed.", e); 351 } 352 } 332 353 bundle.update(); 333 354 } catch (BundleException e) { 334 e.printStackTrace(); 335 } 355 logger.error("kraken core: updating bundle failed.", e); 356 } 357 } 358 359 private boolean isLocalJar(Bundle bundle) { 360 File location = new File(bundle.getLocation().replace("file://", "")); 361 File krakenDownload = new File(System.getProperty("kraken.download.dir")); 362 363 while (location.getParentFile() != null) { 364 if (location.equals(krakenDownload)) 365 return false; 366 location = location.getParentFile(); 367 } 368 369 return true; 370 } 371 372 private MavenArtifact getArtifact(Bundle bundle) { 373 File location = new File(bundle.getLocation().replace("file://", "")); 374 File krakenDownload = new File(System.getProperty("kraken.download.dir")); 375 376 String groupId = null; 377 String artifactId = null; 378 Version version = null; 379 while (location.getParentFile() != null) { 380 location = location.getParentFile(); 381 if (location.equals(krakenDownload)) 382 break; 383 384 String name = location.getName(); 385 if (version == null) 386 version = new Version(name); 387 else if (artifactId == null) 388 artifactId = name; 389 else if (groupId == null) 390 groupId = name; 391 else 392 groupId = name + "." + groupId; 393 } 394 395 return new MavenArtifact(groupId, artifactId, version); 336 396 } 337 397 -
kraken-core/src/main/java/org/krakenapps/bundle/BundleScript.java
r210 r357 119 119 @ScriptArgument(name = "url", type = "string", description = "the url of bundle repository"), 120 120 @ScriptArgument(name = "trust store alias", type = "string", description = "the alias of truststore"), 121 @ScriptArgument(name = "key store alias", type = "string", description = "the alias of keystore. if provided, client authentication will be used", optional = true) }) 121 @ScriptArgument(name = "key store alias", type = "string", 122 description = "the alias of keystore. if provided, client authentication will be used", 123 optional = true) }) 122 124 public void addSecureRepository(String[] args) { 123 125 try { … … 139 141 } 140 142 141 @ScriptUsage(description = "Remove maven repository", arguments = { @ScriptArgument(name = "alias", type = "string", description = "alias of the maven repository") }) 143 @ScriptUsage(description = "Remove maven repository", arguments = { @ScriptArgument(name = "alias", 144 type = "string", description = "alias of the maven repository") }) 142 145 public void removeRepository(String[] args) { 143 146 try { … … 166 169 } 167 170 168 @ScriptUsage(description = "Reset credential for repository http authentication", arguments = { @ScriptArgument(name = "alias", type = "string", description = "alias of the maven repository") }) 171 @ScriptUsage(description = "Reset credential for repository http authentication", arguments = { @ScriptArgument( 172 name = "alias", type = "string", description = "alias of the maven repository") }) 169 173 public void resetHttpAuth(String[] args) { 170 174 Preferences prefs = getRepositoryPreferences(Kraken.getContext()); … … 293 297 } 294 298 295 @ScriptUsage(description = "update all locally-installed bundle(s). before use this method, stop ipojo bundle first.", arguments = { @ScriptArgument(name = "isForced", description = "use 'force' to run this method.", optional = false, type = "force or not") }) 299 @ScriptUsage( 300 description = "update all locally-installed bundle(s). before use this method, stop ipojo bundle first.", 301 arguments = { @ScriptArgument(name = "isForced", description = "use 'force' to run this method.", 302 optional = false, type = "force or not") }) 296 303 public void updateAll(String[] args) { 297 304 if (args.length < 1 || !args[0].equals("force")) { … … 329 336 } 330 337 331 @ScriptUsage(description = "list all bundles", arguments = { @ScriptArgument(name = "filter", type = "string", description = "filter text for bundle symbolic name", optional = true) }) 338 @ScriptUsage(description = "list all bundles", arguments = { @ScriptArgument(name = "filter", type = "string", 339 description = "filter text for bundle symbolic name", optional = true) }) 332 340 public void list(String[] args) { 333 341 String filterText = null; … … 357 365 } 358 366 359 @ScriptUsage(description = "print bundle location", arguments = { @ScriptArgument(name = "bundle id", description = "the bundle id") }) 367 @ScriptUsage(description = "print bundle location", arguments = { @ScriptArgument(name = "bundle id", 368 description = "the bundle id") }) 360 369 public void location(String[] args) { 361 370 try { … … 432 441 } 433 442 434 public void timestamp s(String[] args) {443 public void timestamp(String[] args) { 435 444 int bundleId = -1; 436 445 String filterText = null; -
kraken-core/src/main/java/org/krakenapps/logger/LoggerScriptFactory.java
r229 r357 18 18 import org.krakenapps.api.Script; 19 19 import org.krakenapps.api.ScriptFactory; 20 import org.slf4j.ILoggerFactory;21 20 import org.slf4j.impl.KrakenLoggerFactory; 22 21 import org.slf4j.impl.StaticLoggerBinder; -
kraken-core/src/main/java/org/krakenapps/pkg/MavenResolver.java
r100 r357 141 141 String metadataUrl = normalize(repo.getUrl()) 142 142 + String.format("%s/%s/maven-metadata.xml", artifact.getGroupId().replace(".", "/"), 143 artifact.getArtifactId());143 artifact.getArtifactId()); 144 144 logger.info("maven resolver: failed to get {} {}", metadataUrl, e.getMessage()); 145 145 } … … 182 182 183 183 // download jar 184 if (localJar.exists() == false) {184 // if (localJar.exists() == false) { 185 185 try { 186 186 byte[] binary = download(repo, jarUrl); … … 191 191 return null; 192 192 } 193 }193 // } 194 194 195 195 return localJar; -
kraken-core/src/main/java/org/krakenapps/script/Editor.java
r239 r357 354 354 } 355 355 356 @SuppressWarnings("unused") 356 357 private void drawText(int x, int y, String s) { 357 358 context.print(new MoveToCode(x, y)); … … 359 360 } 360 361 362 @SuppressWarnings("unused") 361 363 private void drawBox(int x1, int y1, int x2, int y2) { 362 364 // first line … … 387 389 } 388 390 391 @SuppressWarnings("unused") 389 392 private void drawHorizontalLine(int x1, int x2, int y) { 390 393 context.print(new MoveToCode(x1, y)); … … 395 398 } 396 399 400 @SuppressWarnings("unused") 397 401 private void drawVerticalLine(int x1, int y1, int y2) { 398 402 context.print(new MoveToCode(x1, y1));
Note: See TracChangeset
for help on using the changeset viewer.
