diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-08 16:08:07 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-08 16:08:07 +0000 |
commit | 2bc19f8bc6cbf654713278bc50cd9c3cb7201215 (patch) | |
tree | caa4a8ae43ca9eb0409b5dc00febf20266ae9be1 /sca-java-2.x/trunk/modules/shell/src/main | |
parent | 7d60695aaaf715e9e79ac8c7aa0107573c164870 (diff) |
Improve default uri calculation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@961826 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/shell/src/main')
-rw-r--r-- | sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java index c340572b2a..2987b1fb6c 100644 --- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java +++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java @@ -160,20 +160,23 @@ public class Shell { private String getDefaultURI(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()) && "target".equals(f.getParentFile().getName())) {
- uri = f.getParentFile().getParentFile().getName();
- }
- } catch (Exception e) {
- // ignore
+ String uri = null;
+ try {
+ File f = new File(contributionURL);
+ if ("classes".equals(f.getName()) && "target".equals(f.getParentFile().getName())) {
+ uri = f.getParentFile().getParentFile().getName();
+ } else {
+ uri = f.getName();
}
+ } catch (Exception e) {
+ // ignore
+ }
+ if (uri == null) {
+ uri = contributionURL;
+ }
+ int lastDot = uri.lastIndexOf('.');
+ if (lastDot > -1) {
+ uri = uri.substring(0, lastDot);
}
return uri;
}
|