/** * Get the default shortened server name given the server's path. * * @param path * @return */ public static String getDefaultShortServerName(final String path) { try { String name = new File(path).getName().replaceFirst("[.][^.]+$", ""); return name; } catch (Exception e) {} if (URLTools.checkURL(path)) return URLTools.getNameFromBaseURL(path); return path; }
public ProjectImageEntry(final Project<T> project, final String serverPath, final String imageName, final Map<String, String> metadataMap) { this.project = project; this.serverPath = serverPath; // TODO: Check if this is a remotely acceptable way to achieve relative pathnames! I suspect it is not really... String projectPath = project.getBaseDirectory().getAbsolutePath(); if (this.serverPath.startsWith(projectPath)) this.serverPath = "{$PROJECT_DIR}" + this.serverPath.substring(projectPath.length()); if (imageName == null) { if (URLTools.checkURL(serverPath)) this.imageName = URLTools.getNameFromBaseURL(serverPath); else this.imageName = new File(serverPath).getName(); } else this.imageName = imageName; if (metadataMap != null) metadata.putAll(metadataMap); }