tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r960321 - /tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
Date Sun, 04 Jul 2010 11:25:24 GMT
Author: antelder
Date: Sun Jul  4 11:25:24 2010
New Revision: 960321

URL: http://svn.apache.org/viewvc?rev=960321&view=rev
Log:
Use a nicer default contribution uri

Modified:
    tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java

Modified: tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java?rev=960321&r1=960320&r2=960321&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
Sun Jul  4 11:25:24 2010
@@ -23,6 +23,7 @@ import static java.lang.System.in;
 import static java.lang.System.out;
 
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.StringReader;
@@ -69,13 +70,35 @@ public class Shell {
     }
 
     boolean install(final String cloc) throws ContributionReadException, ActivationException,
ValidationException {
-        node.installContribution(cloc, cloc, null, null, true);
+        String uri = getURI(cloc);
+        node.installContribution(getURI(cloc), cloc, null, null, true);
+        out.println("installed: " + uri);
         return true;
     }
 
+    private String getURI(String contributionURL) {
+        int lastDot = contributionURL.lastIndexOf('.');
+        int lastSep = contributionURL.lastIndexOf("/");
+        String uri = contributionURL;
+        if (lastDot > -1 && lastSep > -1 && lastDot > lastSep) {
+            uri = contributionURL.substring(lastSep+1, lastDot);
+        } else {
+            try {
+                File f = new File(contributionURL);
+                if ("classes".equals(f.getName())) {
+                    uri = f.getParentFile().getParentFile().getName();                  

+                }
+            } catch (Exception e) {
+                // ignore
+            }
+        }
+        return uri;
+    }
+
     boolean listDeployedCompostes(String curi) throws ContributionReadException, ActivationException,
ValidationException {
         for (String uri : node.getDeployedCompostes(curi)) {
-            out.println(uri.substring(curi.length()+1));
+//            out.println(uri.substring(curi.length()+1));
+            out.println(uri);
         }
         return true;
     }



Mime
View raw message