Any insights or suggestions would be very much appreciated.
We are upgrading a 544 site SharePoint 2003 farm to MOSS. We have a
ton of list items, content editor web parts and custom web parts that
contain links that did not get updated in the upgrade.
For example: /C11/library in 2003 is now /admin/library.
So we wrote code to update web part properties through the API and
built a link translation map in a SQL table. Everything seems to work
okay, the web part properites are updated, but on about 8 sites out
of 544, the default.aspx page settings get messed up. We've run this
a couple of times and the pages that get messed up are different. No
exceptions are thrown when we run the code.
Here's the code we are using to update our custom web part:
~~~~~~~~~~~~~
Sub UpdateWP(ByVal web As SPWeb)
Dim lst As SPList
Dim li As SPListItem
Dim pp As PublishingPage
Dim fl As SPFile
Dim wpm As SPLimitedWebPartManager
Dim wp As System.Web.UI.WebControls.WebParts.WebPart
Dim ql As QuickLinksWebPart
Dim holder As String
Dim numchanges As Int16 = 0
Dim re As Regex = New Regex(txtRegex.Text)
Try
'get the pages document collection list
Try
lst = web.Lists("Pages")
Catch ex As System.ArgumentException
Exit Sub
End Try
'each list item references a file
For Each li In lst.Items
numchanges = 0
pp = PublishingPage.GetPublishingPage(li)
If pp.ListItem.File.CheckOutStatus =
SPFile.SPCheckOutStatus.None Then
pp.CheckOut()
wpm = pp.ListItem.File.GetLimitedWebPartManager
(PersonalizationScope.Shared)
If wpm.WebParts.Count > 0 Then
For Each wp In wpm.WebParts
If wp.GetType.Name = "QuickLinksWebPart"
Then
ql = CType(wp, QuickLinksWebPart)
holder = CheckForTranslation(ql.Text)
'if holder does not equal ql.text, a
change was made
If ql.Text <> holder Then
numchanges += 1
ql.Text = holder
wpm.SaveChanges(ql)
End If
End If
Next
End If
wpm.Dispose()
'undo the checkout if we have not made changes.
If numchanges > 0 Then
pp.ListItem.File.CheckIn("Updating Quick
Links List Areas", SPCheckinType.MajorCheckIn)
Else
pp.ListItem.File.UndoCheckOut()
End If
Else
oWrite.Write(pp.ListItem.File.ServerRelativeUrl
& " is already checked out by " &
pp.ListItem.File.CheckedOutBy.LoginName & " and is not being
checked." & vbNewLine)
End If
Next
Catch ex As Exception
oWrite.Write(vbNewLine + ex.Message + ex.StackTrace +
vbNewLine)
Finally
wpm = Nothing
lst = Nothing
li = Nothing
wp = Nothing
End Try
End Sub
~~~~~~~~~~~~
After the code is run, if you go into Site Actions -> Manage Content
and Stucture -> Navigate to the Pages list and then choose Edit Page
Settings on default.aspx, we get this error:
Value does not fall within the expected range
We tried to copy this page through the API and the operation failed,
but the log did give us this call stack:
<error><message>Value does not fall within the expected
range.</message><full>System.ArgumentException: Value does not fall
within the expected range. at
Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl
(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32&
plItemId, Int32& plType, Object& pvarFileOrFolder) at
Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String
bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32&
plItemId, Int32& plType, Object& pvarFileOrFolder) at
Microsoft.SharePoint.SPWeb.GetMetadataForUrl(String relUrl, Int32
mondoProcHint, Guid& listId, Int32& itemId, Int32&
typeOfObject, Object& fileOrFolder) at
Microsoft.SharePoint.SPWeb.GetFileOrFolderObject(String strUrl) at
Microsoft.SharePoint.Publishing.CommonUtilities.GetFileFromUrl(String
url, SPWeb web) at
Microsoft.SharePoint.Publishing.PublishingPage.get_Layout() at
Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.cachePageIn
foForXmlFiltering(PublishingPage publishingPage) at
Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.configureEx
portCopyOrMove(String[] sourceSmtObjectIds, SPExportSettings&
exportSettings, SPIncludeVersions versionsToInclude) at
Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.Copy(String
[] sourceSmtObjectIds, String destSmtObjectId) at
Microsoft.SharePoint.Publishing.Internal.WebControls.CopyObjects.Copy
() at
Microsoft.SharePoint.Publishing.Internal.WebControls.CopyObjects.DoWor
k() at
Microsoft.SharePoint.Publishing.Internal.LongRunningOperationJob.<T
hreadEntryPoint>b__11() at
Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter
(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter,
CatchBlock catchBlock, FinallyBlock finallyBlock)
</full><customData></customData></error><error><message>Value does
not fall within the expected
range.</message><full>System.ArgumentException: Value does not fall
within the expected range. at
Microsoft.SharePoint.Library.SPRequestInternalClass.GetMetadataForUrl
(String bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32&
plItemId, Int32& plType, Object& pvarFileOrFolder) at
Microsoft.SharePoint.Library.SPRequest.GetMetadataForUrl(String
bstrUrl, Int32 METADATAFLAGS, Guid& pgListId, Int32&
plItemId, Int32& plType, Object& pvarFileOrFolder) at
Microsoft.SharePoint.SPWeb.GetMetadataForUrl(String relUrl, Int32
mondoProcHint, Guid& listId, Int32& itemId, Int32&
typeOfObject, Object& fileOrFolder) at
Microsoft.SharePoint.SPWeb.GetFileOrFolderObject(String strUrl) at
Microsoft.SharePoint.Publishing.CommonUtilities.GetFileFromUrl(String
url, SPWeb web) at
Microsoft.SharePoint.Publishing.PublishingPage.get_Layout() at
Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.cachePageIn
foForXmlFiltering(PublishingPage publishingPage) at
Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.configureEx
portCopyOrMove(String[] sourceSmtObjectIds, SPExportSettings&
exportSettings, SPIncludeVersions versionsToInclude) at
Microsoft.SharePoint.Publishing.Internal.DeploymentWrapper.Copy(String
[] sourceSmtObjectIds, String destSmtObjectId) at
Microsoft.SharePoint.Publishing.Internal.WebControls.CopyObjects.Copy
() at
Microsoft.SharePoint.Publishing.Internal.WebControls.CopyObjects.DoWor
k() at
Microsoft.SharePoint.Publishing.Internal.LongRunningOperationJob.<T
hreadEntryPoint>b__11() at
Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter
(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter,
CatchBlock catchBlock, FinallyBlock finallyBlock) at
Microsoft.Office.Server.Diagnostics.ULS.SendWatsonOnExceptionTag
(ULSTagID tagID, ULSCat categoryID, String output, Boolean
fRethrowException, TryBlock tryBlock, CatchBlock catchBlock,
FinallyBlock finallyBlock) at
Microsoft.SharePoint.Publishing.Internal.LongRunningOperationJob.<T
hreadEntryPoint>b__f() at
Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter
(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter,
CatchBlock catchBlock, FinallyBlock finallyBlock)
</full><customData></customData></error