TDSE.GetObject doesn't resolve a WebDAV URL with dots in it
Asked Answered
F

3

10

Anyone experienced exception using below function?

tdse.GetObject(tmpFolderWebDavURL, EnumOpenMode.OpenModeView, null,
                                          XMLReadFilter.XMLReadAll) as Folder;

Seems if the last segment of webdav contains a dot then the method throws and exception.

for example

tmpFolderWebDavURL = "/webdav/test_publication/2.2 folder name" - fails exception thrown

tmpFolderWebDavURL = "/webdav/test_publication/22 folder name" - works

tmpFolderWebDavURL = "/webdav/test_publication/2.2 folder name/sub_folder" - works

Exception

<?xml version="1.0"?>
<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0" ErrorCode="80040200" Category="4" Source="Kernel" Severity="2">
    <tcm:Line ErrorCode="80040200" Cause="false" MessageID="15301">
        <![CDATA[Unable to get TOM object for URI: /webdav/TPMG Medical Library Content/Building Blocks/Content Live/2.2 People Lists]]>
        <tcm:Token>/webdav/TPMG Medical Library Content/Building Blocks/Content Live/2.2 People Lists</tcm:Token>
    </tcm:Line>
    <tcm:Line ErrorCode="80040200" Cause="true" MessageID="15748">
        <![CDATA[Unable to map all paths to URIs.]]>
    </tcm:Line>
    <tcm:Details>
        <tcm:CallStack>
            <tcm:Location>SystemDAL.GetURIsFromPaths</tcm:Location>
            <tcm:Location>SystemDAL.GetURIsFromPaths</tcm:Location>
            <tcm:Location>URLConversion.ConvertURLToURI</tcm:Location>
            <tcm:Location>SystemBLST.IBLSystemST_ConvertURLToURI</tcm:Location>
            <tcm:Location>TDSE.GetObject</tcm:Location>
        </tcm:CallStack>
    </tcm:Details>
</tcm:Error>
Feltonfelts answered 10/4, 2012 at 20:43 Comment(0)
L
8

Just like with spaces, dots must be escaped in webdav URLs.

So a space becomes "%20", a dot becomes "%2E". Try doing tmpFolderWebDavURL.Replace(".", "%2E").

Leonorleonora answered 10/4, 2012 at 21:8 Comment(3)
Thanks Nuno! Works a treat! Weird works without encoding as long as the decimal point is not the last segment of the URL.Feltonfelts
Yeah, I find that weird too... I would expect it to fail always, wherever the . is in the path.Leonorleonora
I believe the dots before a slash are correctly interpreted. Those without a slash somewhere after them are considered the start of a file extension. So be carful when replacing the dot if it is actually a valid file extension indicator e.g. For Multimedia Components or Schemas etc.Haler
B
2

This is another reason to have the powershell open whenever you are doing this kind of development.

Assuming you know the tcm uri of the item, you can get the correct WebDAVURL very easily:

> $tdse = new-object -com TDS.TDSE
> $sch = $tdse.GetObject("tcm:3-92723-8",1)
> $sch.info.WebDAVURL
/webdav/00_Schemas_003/Building%20Blocks/Schemas/Component/ComponentStaffItem.xsd

A quick copy-paste and you're done!

Bessbessarabia answered 11/4, 2012 at 18:0 Comment(0)
O
1

Instead of replacing "." with "%2E" its better to use Url Encoding. Tridion will decode the url while resolving the item from the webdav url.

Its always safe to use url encoding before sending that to Tridion.

Oleary answered 17/4, 2012 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.