Changeset 357:85fc65cb2520


Ignore:
Timestamp:
09/21/11 16:46:58 (5 months ago)
Author:
delmitz
Branch:
default
Convert:
svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2791
Message:
  • modified script name timestamps to timestamp.
  • modified bundle update.
Location:
kraken-core
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kraken-core/pom.xml

    r265 r357  
    99        </parent> 
    1010        <artifactId>kraken-core</artifactId> 
    11         <version>1.8.0</version> 
     11        <version>1.8.1</version> 
    1212        <name>Kraken Core</name> 
    1313        <packaging>jar</packaging> 
  • kraken-core/src/main/java/org/krakenapps/bundle/BundleManagerService.java

    r215 r357  
    6262 */ 
    6363public class BundleManagerService implements SynchronousBundleListener, BundleManager { 
    64         final Logger logger = LoggerFactory.getLogger(BundleManagerService.class.getName()); 
     64        private Logger logger = LoggerFactory.getLogger(BundleManagerService.class); 
    6565 
    6666        private BundleContext context; 
     
    312312                        bundle.stop(); 
    313313                } catch (BundleException e) { 
    314                         e.printStackTrace(); 
     314                        logger.error("kraken core: stopping bundle failed.", e); 
    315315                } 
    316316        } 
     
    330330 
    331331                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                        } 
    332353                        bundle.update(); 
    333354                } 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); 
    336396        } 
    337397 
  • kraken-core/src/main/java/org/krakenapps/bundle/BundleScript.java

    r210 r357  
    119119                        @ScriptArgument(name = "url", type = "string", description = "the url of bundle repository"), 
    120120                        @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) }) 
    122124        public void addSecureRepository(String[] args) { 
    123125                try { 
     
    139141        } 
    140142 
    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") }) 
    142145        public void removeRepository(String[] args) { 
    143146                try { 
     
    166169        } 
    167170 
    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") }) 
    169173        public void resetHttpAuth(String[] args) { 
    170174                Preferences prefs = getRepositoryPreferences(Kraken.getContext()); 
     
    293297        } 
    294298 
    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") }) 
    296303        public void updateAll(String[] args) { 
    297304                if (args.length < 1 || !args[0].equals("force")) { 
     
    329336        } 
    330337 
    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) }) 
    332340        public void list(String[] args) { 
    333341                String filterText = null; 
     
    357365        } 
    358366 
    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") }) 
    360369        public void location(String[] args) { 
    361370                try { 
     
    432441        } 
    433442 
    434         public void timestamps(String[] args) { 
     443        public void timestamp(String[] args) { 
    435444                int bundleId = -1; 
    436445                String filterText = null; 
  • kraken-core/src/main/java/org/krakenapps/logger/LoggerScriptFactory.java

    r229 r357  
    1818import org.krakenapps.api.Script; 
    1919import org.krakenapps.api.ScriptFactory; 
    20 import org.slf4j.ILoggerFactory; 
    2120import org.slf4j.impl.KrakenLoggerFactory; 
    2221import org.slf4j.impl.StaticLoggerBinder; 
  • kraken-core/src/main/java/org/krakenapps/pkg/MavenResolver.java

    r100 r357  
    141141                                        String metadataUrl = normalize(repo.getUrl()) 
    142142                                                        + String.format("%s/%s/maven-metadata.xml", artifact.getGroupId().replace(".", "/"), 
    143                                                         artifact.getArtifactId()); 
     143                                                                        artifact.getArtifactId()); 
    144144                                        logger.info("maven resolver: failed to get {} {}", metadataUrl, e.getMessage()); 
    145145                                } 
     
    182182 
    183183                        // download jar 
    184                         if (localJar.exists() == false) { 
     184//                      if (localJar.exists() == false) { 
    185185                                try { 
    186186                                        byte[] binary = download(repo, jarUrl); 
     
    191191                                        return null; 
    192192                                } 
    193                         } 
     193//                      } 
    194194 
    195195                        return localJar; 
  • kraken-core/src/main/java/org/krakenapps/script/Editor.java

    r239 r357  
    354354        } 
    355355 
     356        @SuppressWarnings("unused") 
    356357        private void drawText(int x, int y, String s) { 
    357358                context.print(new MoveToCode(x, y)); 
     
    359360        } 
    360361 
     362        @SuppressWarnings("unused") 
    361363        private void drawBox(int x1, int y1, int x2, int y2) { 
    362364                // first line 
     
    387389        } 
    388390 
     391        @SuppressWarnings("unused") 
    389392        private void drawHorizontalLine(int x1, int x2, int y) { 
    390393                context.print(new MoveToCode(x1, y)); 
     
    395398        } 
    396399 
     400        @SuppressWarnings("unused") 
    397401        private void drawVerticalLine(int x1, int y1, int y2) { 
    398402                context.print(new MoveToCode(x1, y1)); 
Note: See TracChangeset for help on using the changeset viewer.