Introducing the SharePoint Content Deployment Wizard

Regular readers might have spotted I’ve been slightly quieter than usual over the past few weeks – actually I’ve not been slacking, but working on a tool which you might find useful from time to time. As I’ve discussed in numerous posts, deployment of SharePoint artifacts is something that’s perhaps more complex than it should be, and the standard tools provided don’t always simplify this picture. Personally, over my past few MOSS projects, there have been several times when I’ve thought:

  • I just need to move this document library from A to B
  • I just need to move these selected files (e.g. master page, page layouts, CSS etc.) from A to B
  • I just need to move this web from A to B
  • I just need to move this site collection from A to B
  • I just need to move these 20 list items from A to B

If only there was an easy way! CMS 2002 users may remember the SDO export mechanism which allowed you to use a treeview to select exactly which content you wished to move, but unfortunately there’s no similar tool for MOSS. Sure, we have Content Deployment and STSADM export etc., but the lowest level of granularity is a web, and if you don’t want to overwrite the whole thing neither option can be used. The only other option is to write code which uses the Content Migration API. This is fine for projects which have the appropriate development skills and time, but otherwise things can be tricky.

Enter the SharePoint Content Deployment Wizard.

The tool provides a wizard-like approach to deploying content between SharePoint sites. The selected content is exported using the Content Migration API (PRIME), giving a .cmp file (Content Migration Package) which can be copied to other servers.

Since pictures are often more useful than words, let’s look at using the tool. Click to enlarge any of the images below:

EXPORTING CONTENT

Welcome screen (click any image to enlarge):


Select action (import or export) and provide site URL:

 

For export, use the treeview to select which content you wish to deploy. On container objects such as webs, there are options about whether descendent objects should be included:

 
Select options around security, dependencies, versions and name of the export file:
 
 
 
The details are shown back for confirmation, and when ‘Finish’ is clicked the export will begin:
 
 
 
IMPORTING CONTENT
 

Browse to the .cmp file we exported in the previous steps, and select options around security, versions and, importantly for some scenarios, whether object IDs should be retained:
 
 

The details are shown back for confirmation, and when ‘Finish’ is clicked the import will begin:
 
 
 

And that’s the gist of it. This is the first beta of the tool and I’m sure there will be issues. Regardless, when using any tool which makes this kind of change to your data you should always take a backup before performing the import. Depending on what you’re doing, it could be difficult to revert back to the previous state otherwise.

Some other notes:

  • the tool must be installed locally on the server which hosts the site
  • not all features of the Content Migration API are supported by the tool
  • the next beta (mid-December) will properly support large sites – currently the site bind operation can be slow for large sites since the treeview is built in one operation
  • it must be run under an account which has the appropriate permissions to the SharePoint site – use the Windows ‘Run as..’ feature to do this if necessary (shown below in the image below- right-click on the .exe and select ‘Run as..’)

 
In the next post, I’ll cover details on different usages of the tool and the effect of different options. The tool also supports reparenting (e.g. importing a web or list to a different parent on the target) and I’ll talk about this.

You can download the tool now from www.codeplex.com/SPDeploymentWizard. All feedback (particularly bug reports) welcome, either post here or on the Codeplex site.

Part 2 : Blending publishing/collaboration functionality in SharePoint

A couple of months ago I wrote an article on some of the issues around building sites which are not pure publishing or collaboration solutions, but which mix features of the two. I mentioned at the time that I would follow up on these issues and any others we came across at the end of the project, so here it is.

As a quick recap, we said that characteristics of a site which blends publishing/collab features could be:

  • site has completely bespoke look and feel/navigation
  • users will work with document libraries, discussions, calendars etc.
  • site templates or definitions are used to create several sites with the same content/functionality
  • custom workflow is used to support a business process (other than standard content publishing), perhaps with InfoPath forms

    So let’s cover some of the issues you may face in projects like this:

    Look and feel of system pages

    This refers to the fact that whilst pages you create will happily use your custom master page, any ‘system’ pages in the ‘_layouts’ directory will not share this look and feel by default since they reference a separate master page, ‘application.master’, which is also stored on the filesystem in ‘_layouts’. Such pages are often seen due to the use of collaboration functionality in our site, examples being when a user uploads or edits metadata for a file, starts a workflow etc.

    In fact this turned out to be less of an issue than I anticipated because:

    • a quick test showed that the use of a HTTP module to switch the master page of these pages works fine. Several people have documented this approach, and I note that Ted Pattison has provided a Codeplex feature for those who would prefer not to write their own code for this. (N.B. though not strictly supported, the idea behind the HTTP module approach is that it is better than modifying files installed with SharePoint such as ‘application.master’, and can be disabled with a switch if we need to fall back in line with official support.)
    • our client decided this was a low priority item, that we may or may not deal with further down the line

    On this subject, I see that Microsoft have themselves released KB article How to customize application pages in the Layouts folder in SharePoint Server 2007 and in Windows SharePoint Services 3.0. Bizarrely, the proposed solutions are modifying the standard files but taking backups of the originals, or duplicating the ‘layouts’ virtual directory in IIS – the HTTP module idea is not mentioned. Without dwelling on this too much, this seems crazy to me and I’m not the only one. I still much prefer the HTTP module solution and will use this on my projects where it is required, though will be sure to regression test thoroughly.


    Use of InfoPath with forms authentication

    This is an interesting illustration of blending the two types of functionality – collaboration solutions may well use InfoPath for forms, but publishing sites typically use forms auth for a customized/branded login experience. Straight away we ran into problems using InfoPath with forms auth – essentially the link to create a new instance of an InfoPath form in a forms library would disappear (example link shown below [Windows auth enabled here]):

  • It took a while for me to track down that this is related to the ‘Client Integration’ switch in Central Admin. For a forms auth site, this gets set to ‘off’ by default, but defaults to ‘on’ for windows auth sites. Unfortunately, resolving the problem isn’t as simple as flicking the switch back, since what the switch does is remove certain links and disable ActiveX controls which integrate with the browser for link-handling. With the switch enabled again, the InfoPath link reappears on the content type, but when a link to say, a Word document is followed, the browser now shows the basic prompt to download or save the file. This means the more sophisticated ‘do you want to check out or open as read-only’ prompt is lost and users must work with documents offline and upload to SharePoint at the end of editing, rather than being able to save back directly to the SharePoint repository. In other words, unacceptable to most for a SharePoint 2007 collaboration solution.

    In the end I found others in the same position, but didn’t find a solution in a short timeframe. Microsoft support tells me “they were unaware of any instances of of these two features working together in this way”, so the disappointing conclusion is that these two bits of functionality don’t play well together. Our client thus decided to accept windows authentication (our authentication store was always going to be AD rather than SQL anyhow). However, I’m actually convinced it would be possible to get this working given more time – I think the way forward would be to amend the site design to have a link to the InfoPath form in the standard content of a page rather than relying on SharePoint to supply the link. The information supplied in How to: Use Query Parameters to Invoke Browser-Enabled InfoPath Forms would be used here. I’m sure this must be possible and others have done it, I’d be interested to hear from anyone who has.


    Overidden control not appearing on standard collaboration pages

    Our client had requested some customizations to the search box, and going through our bug list towards the end of development, I realised that our customized version was present on pages we had created, but not existing list pages such as [MyList]/Forms/AllItems.aspx or similar. This seemed strange given that all pages were using our custom master and shared the same header! Digging deeper, this is caused by the fact that SharePoint uses a delegate control to load the search box .ascx file, and to properly override the control across the site, we needed to create a Feature to specify that our .ascx file should be used in preference to the standard control. If we had directly replaced the existing control on the filesystem this would not be required, but when adding custom files in order to avoid modifications to existing files, this extra piece is required. One to look out for when building sites of this nature.

    Summary

    I read some blogs/discussion threads earlier this week which suggest customizing SharePoint in this way is nigh on impossible, but our project (and surely many others) prove this isn’t the case. As is often the case with such a functional platform, there’s perhaps a greater chance of success if you understand the nuts and bolts of what SharePoint is doing, but extensive customizations to collaboration-focused sites are inherently possible!

    Change a SharePoint site’s URL

    Something you may find yourself tasked with at some point, is changing the URL of an existing SharePoint 2007 site. This is a fairly interesting scenario, and it’s fair to say the relationship between SharePoint and IIS makes this more complex than for a standard .Net site. However, there are several possible solutions. The first things many of us would think of as potential approaches would probably be:

    • extending the web application onto another URL
    • using Alternate Access Mappings somehow

    Depending on your site both could be valid methods, but as with anything SharePoint-related, there are different things to watch out for with the different approaches. As an example, extending the web application wasn’t the right approach for our scenario for the following reasons:

    • the site shouldn’t actually exist at the old URL, but a redirect was required
    • InfoPath forms don’t seem to deal well with the ‘extended web application’ configuration. (Problem detail – on one URL everything will be fine, but if the two web applications use separate site collections, on the other you’re likely to see security errors when opening forms. This is because the form templates are referenced in the other site collection – a document library can only have one URL to the document template, and publishing a form to a content type stores an absolute link in the content database.)

    Additionally some quick tests with Alternate Access Mappings didn’t seem to give the expected results for me, so I decided on another approach since I knew it would work and didn’t have much time for experimentation. So this was my process:

    Changing a site’s URL by recreating the site (downtime required)

    1. Stop old IIS site.
    2. Create new web application in SharePoint, bind to new IP address in IIS.
    3. Apply SSL certificate if appropriate.
    4. Create new site collection for this web application using the blank site template.
    5. Export content using the SharePoint’s content migration API (I have a tool which does this, which will shortly be on Codeplex) ensuring all security data is exported. Alternatives to this step include STSADM -O BACKUP and STSADM-O EXPORT. *
    6. Import content into the new site collection, ensuring to include security.
    7. Amend any absolute URLs in .udcx data connection files used by InfoPath.
    8. Republish any InfoPath forms to the new site.
    9. Configure search:
      1. Ensure new URL is a content source.
      2. Update any crawl rules which use absolute URLs.
      3. Update ‘authoritative pages’ as appropriate.
      4. Start full crawl.
      5. Update scopes.
      6. Go to Site Settings > Site collection administration > Search scopes, add any custom scopes to search dropdown (if using standard search web parts).
      7. Ensure search web parts use relative URLs/do not reference old site URLs.
    10. If a redirect from old URL is required, create new IIS site to implement this:
      1. Create new site in IIS and bind to old IP address.
      2. On ‘Home directory’ tab, specify content should come from ‘A redirection to a URL’ and enter the URL.
    11. Ensure DNS/firewalls are configured appropriately for new URL, remembering to allow appropriate time for DNS propagation.
    12. Perform testing.

    * N.B. Between the content migration API and STSADM export, I prefer the former since this allows control over whether object GUIDs are retained (more information in STSADM export, Content Deployment, Content Migration API, Features/Solutions – deployment options compared). STSADM backup/restore is discussed in next section.

    Considerations to this approach

    • When using the content migration API or STSADM backup/restore, the following items are not included – alerts, workflows, recycle bin state or site collection properties. These must be migrated/recreated separately.
    • Regression testing is absolutely required since the site is effectively recreated

    As a way to improve on the first consideration, another option would be STSADM backup/restore (though I’ve not tried this approach). Notably this method does collect data for the items which the other approaches exclude, however due to the nature of our site, none of these were significant problems.

    So this method was successful, and hopefully this information allows folks to see some of the pros and cons without having to spend the time going through it themselves. However, I also note an approach based on Alternate Access Mappings suggested by Faraz Khan. Since this was only published in the few days before this article it was too late for my scenario, though I’d encourage you to take a look. Note that Faraz also points out considerations such as certain links not being updated to new URL without fix-ups, though this doesn’t seem to be a major issue. It does echo my point about there being different things to watch out for with the different approaches, but both methods provide valid techniques for changing a SharePoint site’s URL.