Initializes the URL that will be used for web service access

@param url URL of the server instance
@return An URL that can be used for the web services
165365
protected String initializeURI(URL url, String servicePrefix) {
        if ( url == null ) {
            throw new IllegalArgumentException( "The url may not be empty or null." );
        }
        try {
            url.toURI();
        } catch ( URISyntaxException urise ) {
            throw new IllegalArgumentException(
                    "URL (" + url.toExternalForm() + ") is incorrectly formatted: " + urise.getMessage(), urise );
        }

        String urlString = url.toExternalForm();
        if ( !urlString.endsWith( "/" ) ) {
            urlString += "/";
        }
        urlString += "services/"+servicePrefix + "/server";

        URL serverPlusServicePrefixUrl;
        try {
            serverPlusServicePrefixUrl = new URL( urlString );
        } catch ( MalformedURLException murle ) {
            throw new IllegalArgumentException(
                    "URL (" + url.toExternalForm() + ") is incorrectly formatted: " + murle.getMessage(), murle );
        }

        return urlString;
    }
526010
public static ConsulService buildService(URL url) {
        ConsulService service = new ConsulService();
        service.setAddress(url.getHost());
        service.setId(ConsulUtils.convertConsulSerivceId(url));
        service.setName(url.getPath());
        service.setPort(url.getPort());
        List<String> tags = new ArrayList<String>();
        String env = url.getParameter(Constants.TAG_ENVIRONMENT);
        if(env != null) tags.add(env);
        service.setTags(tags);

        return service;
    }
73895
public String simpleGet(String url) throws IOException {
		final AtomicReference<String> str = new AtomicReference<>();
		simpleGetInternal(url, inputStream -> {
            try {
                str.set(IOUtils.toString(inputStream, "UTF-8"));
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }, null);

		return str.get();
	}
736497
public static String url(PMSession session, String url) {
        return url(session, url, false);
    }
690328
public static SeerClickableLabelAction createBrowseToUrlAction(final String url) {
        return () -> {
            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                try {
                    desktop.browse(URI.create(url));
                }
                catch (IOException | RuntimeException e) {
                    // ignored
                }
            }
        };
    }
1117601
public static URL correct(final URL url) throws MalformedURLException {
        if (url == null) {
            throw new MalformedURLException("The url is null");
        }
        return new URL(correct(url.toString(), false));
    }
197450
public static String getUrlParentDir(String url) {
		try {
			UsableURI uri = UsableURIFactory.getInstance(url);
			String path = uri.getPath();
			if(path.length() > 1) {
				int startIdx = path.length()-1;
				if(path.charAt(path.length()-1) == '/') {
					startIdx--;
				}
				int idx = path.lastIndexOf('/',startIdx);
				if(idx >= 0) {
					uri.setPath(path.substring(0,idx+1));
					uri.setQuery(null);
                    return uri.toUnicodeHostString();
				}
			}
		} catch (URIException e) {
			LOGGER.warning(e.getLocalizedMessage() + ": " + url);
		}
		return null;
	}
1219425
public String applyOnURL(String url) {
        if (StringUtils.isBlank(url)) {
            return url;
        }
        return StringUtils.substringBefore(url, "?") + toString();
    }
1350752
protected static Properties loadConfig(URL url) {
    InputStream is = null;
    try {
      URLConnection connection = url.openConnection();
      if(connection instanceof HttpURLConnection) {
        HttpURLConnection conn = (HttpURLConnection)connection;
        conn.setConnectTimeout(5000);
        conn.setReadTimeout(5000);        
      }
      is = connection.getInputStream();
      return loadConfig(url.toString(), is);     
    } catch (Exception ex) {
      ex.printStackTrace(System.err);
      throw new IllegalArgumentException("Failed to load configuration from [" + url + "]", ex);
    }finally {
      if(is!=null) try { is.close(); } catch (Exception ex) { /* No Op */ }
    }
  }
604793
public UrlChain hash(Object hashOnUrl) {
        final String argTitle = "hashOnUrl";
        assertArgumentNotNull(argTitle, hashOnUrl);
        checkWrongUrlChainUse(argTitle, hashOnUrl);
        this.hashOnUrl = hashOnUrl;
        return this;
    }
775931
private URL setURL(URL url) throws RepositoryIllegalArgumentException {
        int port = url.getPort();
        if (port == -1) {
            throw new RepositoryIllegalArgumentException("Bad proxy URL", new IllegalArgumentException("Proxy URL does not contain a port"));
        }
        String host = url.getHost();
        if (host.equals("")) {
            throw new RepositoryIllegalArgumentException("Bad proxy URL", new IllegalArgumentException("Proxy URL does not contain a host"));
        }
        return url;
    }
228074
public static Resource newResource(URL url)
        throws IOException
    {
        if (url==null)
            return null;

        String urls=url.toExternalForm();
        if( urls.startsWith( "file:"))
        {
            try
            {
                FileResource fileResource= new FileResource(url);
                return fileResource;
            }
            catch(Exception e)
            {
                log.debug(LogSupport.EXCEPTION,e);
                return new BadResource(url,e.toString());
            }
        }
        else if( urls.startsWith( "jar:file:"))
        {
            return new JarFileResource(url);
        }
        else if( urls.startsWith( "jar:"))
        {
            return new JarResource(url);
        }

        return new URLResource(url,null);
    }
911993
public static boolean validateUrl(String url) {
        String[] schemes = {"https"};
        UrlValidator urlValidator = new UrlValidator(schemes);
        return urlValidator.isValid(url);
    }
627064
public static String getURLPath(String url) {
		url = stripURLScheme(url);
		int pathIdx = url.indexOf(UrlOperations.PATH_START);
		if(pathIdx == -1) {
			return "/";
		}
		return url.substring(pathIdx);
	}
667772
public OrganizationMini getOrganizationByURL(String url) {
		return getResourceFactory().getApiResource("/org/url")
				.queryParam("url", url).get(OrganizationMini.class);
	}
392701
function (url) {
            if (this.$.width) {
                url += ",width=" + ImageService.normalizeImageSize(this.$.width);
            }

            if (this.$.height) {
                url += ",height=" + ImageService.normalizeImageSize(this.$.height);
            }

            return url;
        }
1005964
public URLConnection createURLConnection(URL url) throws IOException {
        URLConnection conn = url.openConnection();
		return conn;
	}