On 03/15/2010 12:36 PM, vmassol (SVN) wrote:
> Author: vmassol
> Date: 2010-03-15 12:36:08 +0100 (Mon, 15 Mar 2010)
> New Revision: 27636
>
> Modified:
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
> Log:
> XWIKI-4902: Introduce new APIs based on Entity Reference (public APIs)
>
> * Better implementation
>
> Modified:
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
> 2010-03-15 11:04:29 UTC (rev 27635)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
> 2010-03-15 11:36:08 UTC (rev 27636)
> @@ -1493,8 +1493,11 @@
> public DocumentReference getDocumentReferenceFromPath(String path,
> XWikiContext context)
> {
> // TODO: Remove this and use XWikiURLFactory instead in XWikiAction
> and all entry points.
> +
> + // Make sure the path is URL-decoded
> + String decodedPath = Util.decodeURI(path, context);
No, this breaks encoded / (%2B) in document names.
> List<String> segments = new ArrayList<String>();
> - for (String segment : path.split("/", -1)) {
> + for (String segment : decodedPath.split("/", -1)) {
> segments.add(segment);
> }
> // Remove the first segment if it's empty to cater for cases when
> the path starts with "/"
> @@ -1505,18 +1508,7 @@
> XWikiEntityURL entityURL = (XWikiEntityURL)
> this.entityXWikiURLBuilder.build(
> new WikiReference(context.getDatabase()), segments);
>
> - // URL-unencode the parsed document reference parts since the path
> we get as input can contain URL-encoded
> - // path segments.
> - // TODO: When we move to using XWikiURLFactory this won't be needed
> anymore.
> - DocumentReference documentReference =
> - new
> DocumentReference(entityURL.getEntityReference().extractReference(EntityType.DOCUMENT));
> -
> documentReference.setName(Util.decodeURI(documentReference.getName(),
> context));
> - documentReference.getLastSpaceReference().setName(
> -
> Util.decodeURI(documentReference.getLastSpaceReference().getName(), context));
> - documentReference.getWikiReference().setName(
> - Util.decodeURI(documentReference.getWikiReference().getName(),
> context));
> -
> - return documentReference;
> + return new
> DocumentReference(entityURL.getEntityReference().extractReference(EntityType.DOCUMENT));
> }
>
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs