Get xwiki document from URL

How to get document from URL like a http://xwiki.site.com/xwiki/bin/edit/HardwareInventory/Item1 ?
Or Space / Page?

Thanks.

You mean how do you get a reference to a page?

See https://www.xwiki.org/xwiki/bin/view/FAQ/How%20can%20I%20get%20the%20reference%20of%20a%20page

I continue to be struggling to save the selected checkboxes in LiveTable into db :slight_smile:

In the ServiceDocument, where they are transmitted, I want to write the processing, that receives the url using $request.getHeader ("referer"), then get a document from URL and manipulate the fields of this document.

I need a reverse operation: having a URL, get a document and process him

That’s more difficult. You should read the reference from the returned HTML. We have metadata for that.

For example:

!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"
        data-xwiki-reference="xwiki:Main.WebHome"
    data-xwiki-document="Main.WebHome"
    data-xwiki-wiki="xwiki"
    data-xwiki-space="Main"
    data-xwiki-page="WebHome"
    data-xwiki-version="51.1"
    data-xwiki-rest-url="/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome"
    data-xwiki-form-token="ADUeB3OwVZ8lyDFqND8Qxw"
    data-xwiki-user-reference="xwiki:XWiki.VincentMassol"
    data-xwiki-locale=""
>

I’m sorry for my primitiveness, hint me some more :slight_smile:
$request.getPropertyNames() returns the correct link: http://xwiki.site.com/xwiki/bin/edit/HardwareInventory/Item1
where space=‘HardwareInventory’, doc.Title=‘Item1’

public class URLTool
{
    /**
     * Parse a query string into a map of key-value pairs.
     * 
     * @param query query string to be parsed
     * @return a mapping of parameter names to values suitable e.g. to pass into {@link EscapeTool#url(Map)}
     */
    public Map<String, List<String>> parseQuery(String query)
    {
        Map<String, List<String>> queryParams = new LinkedHashMap<>();
        if (query != null) {
            for (NameValuePair params : URLEncodedUtils.parse(query, StandardCharsets.UTF_8)) {
                String name = params.getName();
                List<String> values = queryParams.get(name);
                if (values == null) {
                    values = new ArrayList<>();
                    queryParams.put(name, values);
                }
                values.add(params.getValue());
            }
        }
        return queryParams;
    }
}

But when i try this simply code:

{{velocity}}
#set ($refStr = 'http://xwiki.test.com/xwiki/bin/edit/Sandbox/WebHome')
#set ($mapp = {})
#set ($mapp = $urltool.parseQuery($refStr))
Map: $mapp
Size: $mapp.size()
{{/velocity}}

I see:

Map: {http://xwiki.test.com/xwiki/bin/edit/Sandbox/WebHome=[null]}
Size: 1

Where my mistake?

Thanks…