[jira] [Comment Edited] (SLING-9660) Add RequestPathInfoBuilder for easily constructing Sling URLs
[ https://issues.apache.org/jira/browse/SLING-9660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17177545#comment-17177545 ] Georg Henzler edited comment on SLING-9660 at 8/14/20, 7:14 AM: [~kwin] I think this is now already covered by SLING-9662, also constructing URLs works with it [~joerghoh], see https://github.com/apache/sling-org-apache-sling-api/tree/feature/SLING-9662-Introduce-Resource-Mapping-SPI/src/main/java/org/apache/sling/api/resource/uri and: {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); // this works because ResourceUri implements RequestPathInfo RequestPathInfo requestPathInfo = requestPathInfoBuilder.build(); {code} if you want to change this in a URL you can just use {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); resourceUriBuilder.useSchemeAndAuthority(new URI("https://example.com:8443;)) ResourceUri resourceUri = requestPathInfoBuilder.build(); String resourceUriStr = resourceUri.toString(); URI resourceRealURI = resourceUri.toUri(); {code} or you can create a full URI to start with {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.parse("https://example.com/path/to/resouce.sel.html/suffix?test=1#frag;) // and e.g. add a selector and change the suffix .addSelector("sel2") // methods are chainable .setSuffix("/anotherSuffix"); ResourceUri resourceUri = requestPathInfoBuilder.build(); // resourceUri.toString() will contain // https://example.com/path/to/resouce.sel.sel2.html/anotherSuffix?test=1#frag {code} was (Author: henzlerg): [~kwin] I think this is now already covered by SLING-9662, also constructing URLs works with it [~joerghoh], see https://github.com/apache/sling-org-apache-sling-api/tree/feature/SLING-9662-Introduce-Resource-Mapping-SPI/src/main/java/org/apache/sling/api/resource/uri and: {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); // this works because ResourceUri implements RequestPathInfo RequestPathInfo requestPathInfo = requestPathInfoBuilder.build(); {code} if you want to change this in a URL you can just use {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); resourceUriBuilder.useSchemeAndAuthority(new URI("https://example.com:8443;)) ResourceUri resourceUri = requestPathInfoBuilder.build(); String resourceUriStr = resourceUri.toString(); URI resourceRealURI = resourceUri.toUri(); {code} or you can create a full URI to start with {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.parse("https://example.com/path/to/resouce.sel.html/suffix?test=1#frag;); // and e.g. add a selector and change the suffix resourceUriBuilder.addSelector("sel2") resourceUriBuilder.setSuffix("/anotherSuffix") ResourceUri resourceUri = requestPathInfoBuilder.build(); // resourceUri.toString() will contain // https://example.com/path/to/resouce.sel.sel2.html/anotherSuffix?test=1#frag {code} > Add RequestPathInfoBuilder for easily constructing Sling URLs > - > > Key: SLING-9660 > URL: https://issues.apache.org/jira/browse/SLING-9660 > Project: Sling > Issue Type: Improvement > Components: API >Reporter: Konrad Windszus >Assignee: Konrad Windszus >Priority: Major > Fix For: API 2.22.2 > > > Currently Sling URLs with their parts outlined in > https://sling.apache.org/documentation/the-sling-engine/url-decomposition.html > must be constructed manually (i.e. by String operations). > To ease constructing such URLs a {{RequestPathInfoBuilder}} should be > provided which allows to create a URL out of the individual parts easily. > Such a Builder should be either constructed from an existing URL or > RequestPathInfo and should allow to modify/extend each of the given parts. > The Builder should work similarly to > https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URIBuilder.html. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Comment Edited] (SLING-9660) Add RequestPathInfoBuilder for easily constructing Sling URLs
[ https://issues.apache.org/jira/browse/SLING-9660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17177545#comment-17177545 ] Georg Henzler edited comment on SLING-9660 at 8/14/20, 7:13 AM: [~kwin] I think this is now already covered by SLING-9662, also constructing URLs works with it [~joerghoh], see https://github.com/apache/sling-org-apache-sling-api/tree/feature/SLING-9662-Introduce-Resource-Mapping-SPI/src/main/java/org/apache/sling/api/resource/uri and: {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); // this works because ResourceUri implements RequestPathInfo RequestPathInfo requestPathInfo = requestPathInfoBuilder.build(); {code} if you want to change this in a URL you can just use {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); resourceUriBuilder.useSchemeAndAuthority(new URI("https://example.com:8443;)) ResourceUri resourceUri = requestPathInfoBuilder.build(); String resourceUriStr = resourceUri.toString(); URI resourceRealURI = resourceUri.toUri(); {code} or you can create a full URI to start with {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.parse("https://example.com/path/to/resouce.sel.html/suffix?test=1#frag;); // and e.g. add a selector and change the suffix resourceUriBuilder.addSelector("sel2") resourceUriBuilder.setSuffix("/anotherSuffix") ResourceUri resourceUri = requestPathInfoBuilder.build(); // resourceUri.toString() will contain // https://example.com/path/to/resouce.sel.sel2.html/anotherSuffix?test=1#frag {code} was (Author: henzlerg): [~kwin] I think this is now already covered by SLING-9662, also constructing URLs works with it [~joerghoh], see https://github.com/apache/sling-org-apache-sling-api/tree/feature/SLING-9662-Introduce-Resource-Mapping-SPI/src/main/java/org/apache/sling/api/resource/uri and: {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); // this works because ResourceUri implements RequestPathInfo RequestPathInfo requestPathInfo = requestPathInfoBuilder.build(); {code} if you want to change this in a URL you can just use {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("/path/to/resouce.sel.html/suffix"); resourceUriBuilder.useSchemeAndAuthority(new URI("https://example.com:8443;)) ResourceUri resourceUri = requestPathInfoBuilder.build(); String resourceUriStr = resourceUri.toString(); URI resourceRealURI = resourceUri.toUri(); {code} or you can create a full URI to start with {code} ResourceUriBuilder resourceUriBuilder = ResourceUriBuilder.forPath("https://example.com/path/to/resouce.sel.html/suffix?test=1#frag;); // and e.g. add a selector and change the suffix resourceUriBuilder.addSelector("sel2") resourceUriBuilder.setSuffix("/anotherSuffix") ResourceUri resourceUri = requestPathInfoBuilder.build(); // resourceUri.toString() will contain // https://example.com/path/to/resouce.sel.sel2.html/anotherSuffix?test=1#frag {code} > Add RequestPathInfoBuilder for easily constructing Sling URLs > - > > Key: SLING-9660 > URL: https://issues.apache.org/jira/browse/SLING-9660 > Project: Sling > Issue Type: Improvement > Components: API >Reporter: Konrad Windszus >Assignee: Konrad Windszus >Priority: Major > Fix For: API 2.22.2 > > > Currently Sling URLs with their parts outlined in > https://sling.apache.org/documentation/the-sling-engine/url-decomposition.html > must be constructed manually (i.e. by String operations). > To ease constructing such URLs a {{RequestPathInfoBuilder}} should be > provided which allows to create a URL out of the individual parts easily. > Such a Builder should be either constructed from an existing URL or > RequestPathInfo and should allow to modify/extend each of the given parts. > The Builder should work similarly to > https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URIBuilder.html. -- This message was sent by Atlassian Jira (v8.3.4#803005)