@Deprecated public static String fixLocation(String locationId) { if (locationId.startsWith("/v1/locations/")) { log.warn("REST API using legacy URI syntax for location: "+locationId); locationId = Strings.removeFromStart(locationId, "/v1/locations/"); } return locationId; }
@Deprecated public static String fixLocation(String locationId) { if (locationId.startsWith("/v1/locations/")) { log.warn("REST API using legacy URI syntax for location: "+locationId); locationId = Strings.removeFromStart(locationId, "/v1/locations/"); } return locationId; }
public static String tidyFilePath(String path) { String pathRelativeToHome = Strings.removeFromStart(path, "~/"); if (path.equals(pathRelativeToHome)) { return path; } // allow ~ syntax for home dir String result = mergeFilePaths(System.getProperty("user.home"), pathRelativeToHome); if (log.isDebugEnabled()) log.debug("quietly changing to "+path+" to "+result); return result; }
public static String tidyFileUrl(String url) { if (url.matches("file://[A-Za-z]:[/\\\\].*")) { // file://c:/path/to/x is sometimes mistakenly supplied // where file:///c:/path/to/x is the correct syntax. // treat the former as the latter since the former doesn't have any other interpretation if (log.isDebugEnabled()) log.debug("quietly changing "+url+" to file:/// prefix"); url = "file:///"+url.substring(7); } String urlRelativeToHome = Strings.removeFromStart(url, "file://~/", "file:~/"); if (!url.equals(urlRelativeToHome)) { // allow ~ syntax for home dir url = "file://"+System.getProperty("user.home")+"/"+urlRelativeToHome; if (log.isDebugEnabled()) log.debug("quietly changing to "+url+" from file://~/ URL"); } return url; }
public String getClassLoaderDir(String resourceInThatDir) { resourceInThatDir = Strings.removeFromStart(resourceInThatDir, "/"); URL url = getLoader().getResource(resourceInThatDir); if (url==null) throw new NoSuchElementException("Resource ("+resourceInThatDir+") not found"); String urls = url.toString(); boolean isJar = urls.startsWith("jar:"); urls = Strings.removeFromStart(urls, "jar:"); if (!urls.startsWith("file:")) throw new IllegalStateException("Resource ("+resourceInThatDir+") not on file system (at "+urls+")"); urls = Strings.removeFromStart(urls, "file:"); urls = Strings.removeFromStart(urls, "//"); int i = urls.indexOf(resourceInThatDir); if (i==-1) throw new IllegalStateException("Resource path ("+resourceInThatDir+") not in url substring ("+urls+")"); urls = urls.substring(0, i); if (isJar) { urls = Strings.removeFromEnd(urls, "/"); if (!urls.endsWith("!")) throw new IllegalStateException("Context class url mismatch, is jar but does not have ! separator ("+urls+")"); urls = Strings.removeFromEnd(urls, "!"); if (!new File(urls).exists()) throw new IllegalStateException("Context class url substring ("+urls+") not found on filesystem"); } return urls; }
String OLD_PACKAGE = "brooklyn.web.console.security."; if (className.startsWith(OLD_PACKAGE)) { className = Strings.removeFromStart(className, OLD_PACKAGE); className = DelegatingSecurityProvider.class.getPackage().getName()+"."+className; clazz = (Class<? extends SecurityProvider>)Class.forName(className);
String OLD_PACKAGE = "brooklyn.web.console.security."; if (className.startsWith(OLD_PACKAGE)) { className = Strings.removeFromStart(className, OLD_PACKAGE); className = DelegatingSecurityProvider.class.getPackage().getName()+"."+className; clazz = (Class<? extends SecurityProvider>)Class.forName(className);
url = Strings.removeFromStart(tidyFileUrl("file:"+url), "file://", "file:");
String key = entry.getKey(); if (key.startsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX)) { key = Strings.removeFromStart(key, SshTool.BROOKLYN_CONFIG_KEY_PREFIX); } else if (key.startsWith(SSHCONFIG_PREFIX)) { key = Strings.removeFromStart(key, SSHCONFIG_PREFIX); } else if (ALL_SSH_CONFIG_KEY_NAMES.contains(entry.getKey())) {