Some apparent bugs in the sp2010 code

Nov 25, 2013 at 7:48 PM
I discovered a few significant bugs in the parsing of Urls that led to webs being opened in what looks like an indeterminate state. I think I've fixed those, and I'll send them along if you like.

More importantly, however, I need to know if there's a way to add a "Link to Document" content type back into the mix (we used to have this when "New Document" led to a list of content types.
The template hub is significantly better, except for this.

Thanks
Josh
Dec 2, 2013 at 9:26 AM
Hello. I would like to know more about these problems. Do they exist in current version? I am particularly worried about the disposing problem. If possible I did like to receive the fixed version.
Coordinator
Dec 2, 2013 at 1:17 PM
Sorry about the late answer.

There is no plan to get "Link to Document" added to the mix. We use the standard "New document" button for that here, but it's a good idea I can pitch for our next update.

We also know there are issues With the url parsing, but had no time to fix it, so if you have something we can incorporate, I'd be happy if you could send me the changes.

I'm glad you like our little Project :)

Tolppa: There should be no dispose issues as far as I know, but if you have found issues please let me know.
Dec 2, 2013 at 1:39 PM
Kjetil:
URL Parsing
I've got a change to just one function, and it seems to do the trick. Please let me know how you want me to send this to you.
Coordinator
Dec 2, 2013 at 1:41 PM
If it is just one function you can post it here along with the filename, and I'll integrate it into the Source :)
Dec 2, 2013 at 2:03 PM
Kjetil:
URL Parsing
I've got a change to just one function, and it seems to do the trick. Please let me know how you want me to send this to you.
Dec 2, 2013 at 2:07 PM
Kjetil:

It's the TemplateLibraryUtility.GetDocumentLibraryWeb() method. I suspect that the immediately following method - GetDocumentLibraryWebFromUrl() - needs the same modification, but I haven't tried it yet.

The replacement code looks like this:
        internal static SPWeb GetDocumentLibraryWeb(string doclibAbsoluteUrl, SPSite site)
        {
            SPWeb web = null;
            string[] webNames = site.AllWebs.Names;
            string libraryWeb = site.Url;
            string remainder = doclibAbsoluteUrl.Replace(libraryWeb, "").TrimStart('/');
            string relativeSubWebUrl = String.Empty;

            foreach (string subWeb in webNames)
            {
                if (remainder.StartsWith(subWeb))
                {
                    if (! String.IsNullOrEmpty(subWeb))
                    {
                        relativeSubWebUrl = subWeb;
                        break;
                    }
                }
            }

            web = site.OpenWeb(relativeSubWebUrl);
            return web;
        }
Dec 2, 2013 at 3:00 PM
Kjetil:

It's the TemplateLibraryUtility.GetDocumentLibraryWeb() method. I suspect that the immediately following method - GetDocumentLibraryWebFromUrl() - needs the same modification, but I haven't tried it yet.

The replacement code looks like this:
        internal static SPWeb GetDocumentLibraryWeb(string doclibAbsoluteUrl, SPSite site)
        {
            SPWeb web = null;
            string[] webNames = site.AllWebs.Names;
            string libraryWeb = site.Url;
            string remainder = doclibAbsoluteUrl.Replace(libraryWeb, "").TrimStart('/');
            string relativeSubWebUrl = String.Empty;

            foreach (string subWeb in webNames)
            {
                if (remainder.StartsWith(subWeb))
                {
                    if (! String.IsNullOrEmpty(subWeb))
                    {
                        relativeSubWebUrl = subWeb;
                        break;
                    }
                }
            }

            web = site.OpenWeb(relativeSubWebUrl);
            return web;
        }