Well my quest concerning the content organizer architecture has come to an end.
Got my solution to work without any problems. For those who don’t know what I’m talking about, please read my previous 2 blog posts and all will become clear.
The main issue that I had was how the content organizer structure does not automatically create a connection, so that the rootweb could send files from the drop-off library to a drop-off library on a subsite.
Instead Microsoft expects that the user must contact a farm administrator so that he can create a connection (in “General application settings” -> “Configure send to connections”).
It is a nightmare when sites can be created on the fly (even if a well defined governance document is created) and every time he/she must add the connection to the Web Application.
Now if a site template is used and the content organizer feature is activated in the template, a connection will be made automatically. I’ve put the logic in the WebEventReceiver at the webprovisioned event.
I’ll have to rewrite some code, clean up a lot of commented code lines and I’ll post the solution on codeplex, link will be provided later.
Basically it comes down to this:
SPOfficialFileHost tempFile = new SPOfficialFileHost(true); // the boolean condition gives an indication if a unique ID must be created or not, this happens on constructor level
tempFile.Explanation = “string value” ;
tempFile.OfficialFileName = Web.Title; (or string value)
tempFile.OfficialFileUrl = new Uri( url of the site + “/_vti_bin/officialfile.asmx”); // I’ve added the _vti_bin part because in central admin this is requested as well, but don’t know if it works without
tempFile.Action = SOfficialFileAction (.move, .link, .copy) //choose what you want to do when the file leaves the drop folder
tempFile.ShowOnSendToMenu = boolean value
As you can see the image below, this is familiar 🙂
To add this SPOfficialFileHost object to the web app, you’ll need to add it to (spsite)site.WebApplication.OfficialFileHosts.Add(tempFile);
and now you need to use site.WebApplication.Update() , if you don’t do this, all your connections will be gone when a application pool recycle happens.
If you use the update , all the changes are being serialized and propagating the changes throughout the farm.
Now if you go to the cental admin page, you’ll see the added connection listed in the listbox. If you didn’t use the webapplication update, the connection will not be listed.
Now there could be a catch, if you use the .update() an error must be shown (even in elevation mode) that you have been denied access to push the changes.
A small SP PowerShell command set must be done before this is solved. But it’s probably not the correct way to bypass this error. Got it from here
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$contentService.RemoteAdministratorAccessDenied = $false
Hope it helps someone because I didn’t found one blog about this subject.