/** * Gets a shorter name for this deployable. * @return a shorter name based on the URL. */ public String getShortName() { IDeployable<?> deployable = this; // Gets the root deployable while (deployable.getOriginalDeployable() != null) { deployable = deployable.getOriginalDeployable(); } // Get URL String urlExternalForm; try { urlExternalForm = deployable.getArchive().getURL().toExternalForm(); } catch (ArchiveException e) { throw new IllegalStateException("Cannot get URL of the deployable '" + this + "'.", e); } // if it ends by a /, remove this last one if (urlExternalForm.charAt(urlExternalForm.length() - 1) == '/') { urlExternalForm = urlExternalForm.substring(0, urlExternalForm.length() - 1); } // get string after the last / (all URL have this, no need to test if // there is a / character) int slashPos = urlExternalForm.lastIndexOf('/'); // Return the shorter name return urlExternalForm.substring(slashPos + 1, urlExternalForm.length()); }
IDeployable<?> originalDeployable = deployable.getOriginalDeployable(); if (originalDeployable != null) { deployableURL = originalDeployable.getArchive().getURL();