Converts internal links (eznode:// and ezobject://) to URLs.

Overridden to add option to download files by using Netgen Site specific route.
14841
public function convert(DOMDocument $xmlDoc): void
    {
        foreach ($xmlDoc->getElementsByTagName('link') as $link) {
            /** @var \DOMElement $link */
            if (!$link->hasAttribute('custom:file')) {
                continue;
            }

            $content = null;
            $location = null;

            if ($link->hasAttribute('object_id')) {
                try {
                    $content = $this->loadService->loadContent($link->getAttribute('object_id'));
                    $location = $content->mainLocation;
                } catch (NotFoundException $e) {
                    $this->logger->warning(
                        'While generating links for xmltext, could not locate ' .
                        'Content object with ID ' . $link->getAttribute('object_id')
                    );
                } catch (UnauthorizedException $e) {
                    $this->logger->notice(
                        'While generating links for xmltext, unauthorized to load ' .
                        'Content object with ID ' . $link->getAttribute('object_id')
                    );
                }
            }

            if ($link->hasAttribute('node_id')) {
                try {
                    $location = $this->loadService->loadLocation($link->getAttribute('node_id'));
                    $content = $location->content;
                } catch (NotFoundException $e) {
                    $this->logger->warning(
                        'While generating links for xmltext, could not locate ' .
                        'Location with ID ' . $link->getAttribute('node_id')
                    );
                } catch (UnauthorizedException $e) {
                    $this->logger->notice(
                        'While generating links for xmltext, unauthorized to load ' .
                        'Location with ID ' . $link->getAttribute('node_id')
                    );
                }
            }

            if ($content !== null && $content->hasField('file')) {
                $field = $content->getField('file');
                if (!$field->isEmpty()) {
                    $url = $this->router->generate('ngsite_download', ['contentId' => $content->id, 'fieldId' => $field->id, 'isInline' => $link->hasAttribute('custom:inline')]);
                }
            }

            if (empty($url) && $location !== null) {
                $link->setAttribute('url', $this->router->generate($location));
            } elseif (!empty($url)) {
                $link->setAttribute('url', $url);
            } else {
                $link->setAttribute('url', '');
            }

            if ($link->hasAttribute('anchor_name')) {
                $link->setAttribute('url', $link->getAttribute('url') . '#' . $link->getAttribute('anchor_name'));
            }

            // With this we disable the original pre-converter
            // (and hopefully all other that touch link element)
            $link->removeAttribute('object_id');
            $link->removeAttribute('node_id');
            $link->removeAttribute('anchor_name');
        }
    }
1243566
function (baseUrl) {
    var fullUrl = url.parse(String(baseUrl || '/'));
    fullUrl.pathname = normalizePath(this.path, fullUrl.pathname);
    fullUrl = url.format(fullUrl);

    var routes = {};
    Object.keys(this.children).forEach(function (child) {
      routes[child.replace(/^\//, '')] = nodepath.join(fullUrl, child);
    });
    return routes;
  }
205378
def fill_urls(self):
        

        protocol = self.dcnm_protocol
        self._org_url = '%s://%s/rest/auto-config/organizations' % (
            (protocol, self._ip))
        self._create_network_url = ('%s://%s/' % (protocol, self._ip) +
                                    'rest/auto-config/organizations'
                                    '/%s/partitions/%s/networks')
        self.host_protocol_url = '%s://%s/' % (protocol, self._ip)
        self._create_network_url = self._build_url(
            'rest/auto-config/organizations'
            '/%s/partitions/%s/networks')
        self._cfg_profile_list_url = '%s://%s/rest/auto-config/profiles' % (
            (protocol, self._ip))
        self._cfg_profile_get_url = self._cfg_profile_list_url + '/%s'
        self._global_settings_url = self._build_url(
            'rest/auto-config/settings')
        self._create_part_url = self._build_url(
            'rest/auto-config/organizations/%s/partitions')
        self._update_part_url = self._build_url(
            'rest/auto-config/organizations/%s/partitions/%s')
        self._del_org_url = self._build_url(
            'rest/auto-config/organizations/%s')
        self._del_part = self._build_url(
            'rest/auto-config/organizations/%s/partitions/%s')
        self._network_url = self._build_url(
            'rest/auto-config/organizations/%s/partitions/'
            '%s/networks/segment/%s')
        self._network_mob_url = self._build_url(
            'rest/auto-config/organizations/%s/partitions/'
            '%s/networks/vlan/%s/mobility-domain/%s')
        self._segmentid_ranges_url = self._build_url(
            'rest/settings/segmentid-ranges')
        self._login_url = self._build_url('rest/logon')
        self._logout_url = self._build_url('rest/logout')
482210
def makeCNBaseURL(url):
    """"""
    o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_CN_PROTOCOL)
    if o.netloc and o.path:
        netloc = o.netloc
        path = o.path
    elif o.netloc:
        netloc = o.netloc
        path = d1_common.const.DEFAULT_CN_PATH
    elif o.path:
        s = o.path.split('/', 1)
        netloc = s[0]
        if len(s) == 1:
            path = d1_common.const.DEFAULT_CN_PATH
        else:
            path = s[1]
    else:
        netloc = d1_common.const.DEFAULT_CN_HOST
        path = d1_common.const.DEFAULT_CN_PATH
    return urllib.parse.urlunparse(
        (o.scheme, netloc, path, o.params, o.query, o.fragment)
    )
931222
def custom_url_for(object_type, action)
      path = @paths.find do |path|
        path[:object_type] == object_type &&
        path[:action] == action
      end
      if path
        ServiceUrl.new(generate_url(path[:path]), path[:method])
      end
    end
1020234
def build_url (self):
        
        # norm base url - can raise UnicodeError from url.idna_encode()
        base_url, is_idn = url_norm(self.base_url, self.encoding)
        # make url absolute
        if self.base_ref:
            # use base reference as parent url
            if ":" not in self.base_ref:
                # some websites have a relative base reference
                self.base_ref = urljoin(self.parent_url, self.base_ref)
            self.url = urljoin(self.base_ref, base_url)
        elif self.parent_url:
            # strip the parent url query and anchor
            urlparts = list(urlparse.urlsplit(self.parent_url))
            urlparts[4] = ""
            parent_url = urlutil.urlunsplit(urlparts)
            self.url = urljoin(parent_url, base_url)
        else:
            self.url = base_url
        # urljoin can unnorm the url path, so norm it again
        urlparts = list(urlparse.urlsplit(self.url))
        if urlparts[2]:
            urlparts[2] = urlutil.collapse_segments(urlparts[2])
        self.url = urlutil.urlunsplit(urlparts)
        # split into (modifiable) list
        self.urlparts = strformat.url_unicode_split(self.url)
        self.build_url_parts()
        # and unsplit again
        self.url = urlutil.urlunsplit(self.urlparts)
280399
def generate_links(self, nodes):
        
        new_links = []

        for link in self.links:
            # Expand port name if required
            if INTERFACE_RE.search(link['dest_port'])\
                    or VBQ_INT_RE.search(link['dest_port']):
                int_type = link['dest_port'][0]
                dest_port = link['dest_port'].replace(
                    int_type, PORT_TYPES[int_type.upper()])
            else:
                dest_port = link['dest_port']

            # Convert dest_dev and port to id's
            dest_details = self.convert_destination_to_id(
                link['dest_dev'], dest_port, nodes)

            desc = 'Link from %s port %s to %s port %s' % \
                   (link['source_dev'], link['source_port_name'],
                    dest_details['name'], dest_port)

            new_links.append({'description': desc,
                              'destination_node_id': dest_details['id'],
                              'destination_port_id': dest_details['pid'],
                              'source_port_id': link['source_port_id'],
                              'source_node_id': link['source_node_id']})

        # Remove duplicate links and add link_id
        link_id = 1
        for link in new_links:
            t_link = str(link['source_node_id']) + ':' + \
                str(link['source_port_id'])
            for link2 in new_links:
                d_link = str(link2['destination_node_id']) + ':' + \
                    str(link2['destination_port_id'])
                if t_link == d_link:
                    new_links.remove(link2)
                    break
            link['id'] = link_id
            link_id += 1

            self.add_node_connection(link, nodes)

        return new_links
1104521
function toPathIfFileURL(fileURLOrPath) {
  if (!(fileURLOrPath &&
    fileURLOrPath.protocol &&
    fileURLOrPath.pathname)) {
    return fileURLOrPath;
  }

  if (fileURLOrPath.protocol !== 'file:') {
    throw new Errors.EINVAL('only file: URLs are supported for paths', fileURLOrPath);
  }

  const pathname = fileURLOrPath.pathname;
  for (let n = 0; n < pathname.length; n++) {
    if (pathname[n] === '%') {
      const third = pathname.codePointAt(n + 2) | 0x20;
      if (pathname[n + 1] === '2' && third === 102) {
        throw new Errors.EINVAL('file: URLs must not include encoded / characters', fileURLOrPath);
      }
    }
  }

  return decodeURIComponent(pathname);
}
891997
def add_url (self, url, line=0, column=0, page=0, name=u"", base=None):
        """"""
        webroot = self.aggregate.config["localwebroot"]
        if webroot and url and url.startswith(u"/"):
            url = webroot + url[1:]
            log.debug(LOG_CHECK, "Applied local webroot `%s' to `%s'.", webroot, url)
        super(FileUrl, self).add_url(url, line=line, column=column, page=page, name=name, base=base)
851194
def as_raw_link(self):
        
        if self.link_type == "raw":
            return self # Can be discussed if we need an hard copy, or fail
        if self.link_type != "blob":
            raise ValueError("Cannot get a download link from a tree link")
        return self.__class__(
            self.gitid,
            "raw",
            self.branch_or_commit,
            self.path,
            self.token
        )
888180
def url_for(self, operation, _external=True, **kwargs):
        
        return url_for(self.endpoint_for(operation), _external=_external, **kwargs)
1111746
def addInternalLink(self, link):
        '''
        
        '''
        if isinstance(link, InternalLink):
            self.internalLinks.append(link)
        else:
            raise InternalLinkError( 
                'link Type should be InternalLink, not %s' % type(link))
1013116
def get_links(self, request=None):
        
        links = LinkNode()

        # Generate (path, method, view) given (path, method, callback).
        paths = []
        view_endpoints = []
        for path, method, callback in self.endpoints:
            view = self.create_view(callback, method, request)
            if getattr(view, 'exclude_from_schema', False):
                continue
            path = self.coerce_path(path, method, view)
            paths.append(path)
            view_endpoints.append((path, method, view))

        # Only generate the path prefix for paths that will be included
        if not paths:
            return None
        prefix = self.determine_path_prefix(paths)

        for path, method, view in view_endpoints:
            if not self.has_view_permissions(path, method, view):
                continue
            link = self.get_link(path, method, view, version=getattr(request, 'version', None))
            subpath = path[len(prefix):]
            keys = self.get_keys(subpath, method, view)
            try:
                insert_into(links, keys, link)
            except Exception:
                continue
        return links
245044
def enqueue_conversion_path(url_string, to_type, enqueue_convert):
    '''
    
    '''
    target_ts = TypeString(to_type)
    foreign_res = ForeignResource(url_string)

    # Determine the file type of the foreign resource
    typed_foreign_res = foreign_res.guess_typed()

    if not typed_foreign_res.cache_exists():
        # Symlink to new location that includes typed extension
        typed_foreign_res.symlink_from(foreign_res)

    # Now find path between types
    original_ts = typed_foreign_res.typestring
    path = singletons.converter_graph.find_path(original_ts, target_ts)

    # Loop through each step in graph path and convert
    is_first = True
    for converter_class, from_ts, to_ts in path:
        converter = converter_class()
        in_resource = TypedResource(url_string, from_ts)
        if is_first:  # Ensure first resource is just the source one
            in_resource = TypedForeignResource(url_string, from_ts)
        out_resource = TypedResource(url_string, to_ts)
        enqueue_convert(converter, in_resource, out_resource)
        is_first = False
1241184
public static MozuUrl convertToProductReservationUrl()
	{
		UrlFormatter formatter = new UrlFormatter("/api/commerce/catalog/admin/softallocations/convert");
		return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
	}
518207
def base_url(klass, space_id, resource_id=None, public=False, environment_id=None, **kwargs):
        

        if public:
            environment_slug = ""
            if environment_id is not None:
                environment_slug = "/environments/{0}".format(environment_id)
            return "spaces/{0}{1}/public/content_types".format(space_id, environment_slug)
        return super(ContentType, klass).base_url(
            space_id,
            resource_id=resource_id,
            environment_id=environment_id,
            **kwargs
        )
562451
def url(self):
        
        path = None
        nodes = self.parents()
        while not nodes.empty():
            path = urljoin(path, nodes.get().path())
        return path