From 2bc19f8bc6cbf654713278bc50cd9c3cb7201215 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 8 Jul 2010 16:08:07 +0000 Subject: Improve default uri calculation git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@961826 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/shell/Shell.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'sca-java-2.x/trunk/modules/shell/src/main') 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; } -- cgit v1.2.3