Returns a copy of a given URL truncated to its service component.
Characteristic and field components will be null.
@return a copy of a given URL truncated to the service component
484550
public URL getServiceURL() {
        return new URL(this.protocol, this.adapterAddress, this.deviceAddress, this.deviceAttributes,
                this.serviceUUID, null, null);
    }
352978
@Nullable
  public static String getUnifiedURL (@Nullable final String sURL)
  {
    return sURL == null ? null : sURL.trim ().toLowerCase (Locale.US);
  }
928525
public static Element getContentElementByUrl(String url) throws Exception {
//        HttpRequest request = new HttpRequest(url);
        String html = okHttpRequester.getResponse(url).html();
        return getContentElementByHtml(html, url);
    }
828759
public static JsonRtn shortUrl(License license, String url) {
        if (StringUtils.isEmpty(url)) {
            return JsonRtnUtil.buildFailureJsonRtn(JsonRtn.class, "missing url");
        }

        Map<String, String> paramMap = ImmutableMap.of("action", "long2short", "long_url", url);
        return HttpUtil.postBodyRequest(WechatRequest.SHORT_URL, license, paramMap, JsonRtn.class);
    }
893093
@Restricted(DoNotUse.class)
    public static String getFrom() {
        String from = null, returnValue = null;
        final StaplerRequest request = Stapler.getCurrentRequest();

        // Try to obtain a return point either from the Session
        // or from the QueryParameter in this order
        if (request != null
                && request.getSession(false) != null) {
            from = (String) request.getSession().getAttribute("from");
        } else if (request != null) {
            from = request.getParameter("from");
        }

        // If entry point was not found, try to deduce it from the request URI
        // except pages related to login process
        if (from == null
                && request != null
                && request.getRequestURI() != null
                && !request.getRequestURI().equals("/loginError")
                && !request.getRequestURI().equals("/login")) {

                from = request.getRequestURI();
        }

        // If deduced entry point isn't deduced yet or the content is a blank value
        // use the root web point "/" as a fallback
        from = StringUtils.defaultIfBlank(from, "/").trim();
        
        // Encode the return value
        try {
            returnValue = java.net.URLEncoder.encode(from, "UTF-8");
        } catch (UnsupportedEncodingException e) { }

        // Return encoded value or at least "/" in the case exception occurred during encode()
        // or if the encoded content is blank value
        return StringUtils.isBlank(returnValue) ? "/" : returnValue;
    }
383385
protected static String cleanupUrl(final String url) {
        if (url == null) {
            return null;
        }
        val jsessionPosition = url.indexOf(";jsession");
        if (jsessionPosition == -1) {
            return url;
        }
        val questionMarkPosition = url.indexOf('?');
        if (questionMarkPosition < jsessionPosition) {
            return url.substring(0, url.indexOf(";jsession"));
        }
        return url.substring(0, jsessionPosition) + url.substring(questionMarkPosition);
    }
365438
@Nullable
  public static String getURLValue (@Nullable final String sValue)
  {
    if (isURLValue (sValue))
    {
      return CSSParseHelper.trimUrl (sValue);
    }
    return null;
  }
759594
private static URL getPersistenceRootUrl(URL url)
    {
        String f = url.getFile();
        f = parseFilePath(f);

        URL jarUrl = url;
        try
        {
            if (AllowedProtocol.isJarProtocol(url.getProtocol()))
            {
                jarUrl = new URL(f);
                if (jarUrl.getProtocol() != null
                        && AllowedProtocol.FILE.name().equals(jarUrl.getProtocol().toUpperCase())
                        && StringUtils.contains(f, " "))
                {
                    jarUrl = new File(f).toURI().toURL();
                }
            }
            else if (AllowedProtocol.isValidProtocol(url.getProtocol()))
            {
                if (StringUtils.contains(f, " "))
                {
                    jarUrl = new File(f).toURI().toURL();
                }
                else
                {
                    jarUrl = new File(f).toURL();
                }
            }
        }
        catch (MalformedURLException mex)
        {
            log.error("Error during getPersistenceRootUrl(), Caused by: {}.", mex);
            throw new IllegalArgumentException("Invalid jar URL[] provided!" + url);
        }

        return jarUrl;
    }
777692
public static MozuUrl deleteExtendedPropertiesUrl()
	{
		UrlFormatter formatter = new UrlFormatter("/api/commerce/carts/current/extendedproperties");
		return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
	}
351754
@Override
    public String url() {
        String url = "";
        if (!StringUtils.isEmpty(baseUrl())) {
            url = baseUrl() + path();
        } else {
            if (!StringUtils.isEmpty(properties.getProperty(Constants.DEFAULT_PROPERTY_URL))) {
                url = properties.getProperty(Constants.DEFAULT_PROPERTY_URL);
            }
            if (testConfig != null && (!StringUtils.isEmpty(testConfig.url()))) {
                url = testConfig.url();
            }
            if (!StringUtils.isEmpty(JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL))) {
                url = JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL);
            }
        }
        return url;
    }
1273959
@Nullable
  public IURLProtocol getProtocol (@Nullable final ISimpleURL aURL)
  {
    return aURL == null ? null : getProtocol (aURL.getPath ());
  }
217370
public static File getCanonicalFileFromFileUrl(final URL url) {
        File file = null;
        if (url == null) {
            throw new NullPointerException("The URL cannot be null.");
        }
        if ("file".equals(url.getProtocol())) {
            final String fileName = url.getFile();
            final String path = URLUtils.uncorrect(fileName);
            file = new File(path);

            try {
                file = file.getCanonicalFile();
            } catch (final IOException e) {
                // Does not exist.
                file = file.getAbsoluteFile();
            }

        }
        return file;
    }
1093242
private ResponseWrapper fetchContentFromCacheIfAvailable(
            final RenderRequest req, final String serviceUrl) {

        ResponseWrapper rslt = null; // default

        final List<CacheTuple> cacheKeysToTry = new ArrayList<>();
        // Don't use private-scope caching for anonymous users
        if (req.getRemoteUser() != null) {
            cacheKeysToTry.add(
                    // Private-scope cache key
                    new CacheTuple(
                            serviceUrl,
                            req.getPortletMode().toString(),
                            req.getWindowState().toString(),
                            req.getRemoteUser()));
        }
        cacheKeysToTry.add(
                // Public-scope cache key
                new CacheTuple(
                        serviceUrl,
                        req.getPortletMode().toString(),
                        req.getWindowState().toString()));

        for (CacheTuple key : cacheKeysToTry) {
            final Element cacheElement = this.responseCache.get(key);
            if (cacheElement != null) {
                rslt = (ResponseWrapper) cacheElement.getObjectValue();
                break;
            }
        }

        return rslt;
    }
1083521
public AmazonWebServiceRequest getCloneRoot() {
        AmazonWebServiceRequest cloneRoot = cloneSource;
        if (cloneRoot != null) {
            while (cloneRoot.getCloneSource() != null) {
                cloneRoot = cloneRoot.getCloneSource();
            }
        }
        return cloneRoot;
    }
749730
public static CompletionStage<Void> copy(final ServiceBundler services, final Session session,
            final Resource resource, final IRI destination, final String baseUrl) {

        final Metadata.Builder builder = Metadata.builder(destination)
            .interactionModel(resource.getInteractionModel());
        resource.getContainer().ifPresent(builder::container);
        resource.getBinaryMetadata().ifPresent(builder::binary);
        resource.getInsertedContentRelation().ifPresent(builder::insertedContentRelation);
        resource.getMemberOfRelation().ifPresent(builder::memberOfRelation);
        resource.getMemberRelation().ifPresent(builder::memberRelation);
        resource.getMembershipResource().ifPresent(builder::membershipResource);

        try (final Stream<Quad> stream = resource.stream(Trellis.PreferUserManaged)) {
            LOGGER.debug("Copying {} to {}", resource.getIdentifier(), destination);
            final TrellisDataset mutable = new TrellisDataset(stream.collect(toDataset()));

            return services.getResourceService().create(builder.build(), mutable.asDataset())
                .whenComplete((a, b) -> mutable.close())
                .thenCompose(future -> {
                        final TrellisDataset immutable = TrellisDataset.createDataset();
                        services.getAuditService().creation(resource.getIdentifier(), session).stream()
                            .map(skolemizeQuads(services.getResourceService(), baseUrl)).forEachOrdered(immutable::add);

                        return services.getResourceService().add(resource.getIdentifier(), immutable.asDataset())
                            .whenComplete((a, b) -> immutable.close());
                    })
                .thenCompose(future -> services.getMementoService().put(services.getResourceService(),
                            resource.getIdentifier()))
                .thenAccept(future -> services.getEventService().emit(new SimpleEvent(externalUrl(destination, baseUrl),
                            session.getAgent(), asList(PROV.Activity, AS.Create),
                            singletonList(resource.getInteractionModel()))));
        }
    }
1079129
public TLSARecord getTLSARecord(URL url) {

        String recordValue;

        int port = url.getPort();
        if (port == -1) {
            port = url.getDefaultPort();
        }
        String tlsaRecordName = String.format("_%s._tcp.%s", port, DNSUtil.ensureDot(url.getHost()));
        try {
            recordValue = this.dnssecResolver.resolve(tlsaRecordName, Type.TLSA);
        } catch (DNSSECException e) {
            return null;
        }

        if (recordValue.equals("")) return null;

        // Process TLSA Record
        String[] tlsaValues = recordValue.split(" ");
        if (tlsaValues.length != 4) return null;
        try {
            return new TLSARecord(
                    new Name(tlsaRecordName),
                    DClass.IN,
                    0,
                    Integer.parseInt(tlsaValues[0]),
                    Integer.parseInt(tlsaValues[1]),
                    Integer.parseInt(tlsaValues[2]),
                    BaseEncoding.base16().decode(tlsaValues[3])
            );
        } catch (TextParseException e) {
            return null;
        }
    }
906003
protected URL extractURL(Object url)
    throws IOException {
    if (!(url instanceof String)) {
      return null;
    }
    return (null == url || "".equals(url)) ? null : new URL( (String) url);
  }