Logo 
Search:

MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Issue Updating MOSS through the API - Has anyone come across

  Asked By: Alvin    Date: Feb 16    Category: MOSS    Views: 2431

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

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Jennifer Jones     Answered On: Feb 16

A starting point might be to go to default.aspx and
bring up the web part maintenance screen by adding the
querystring default.aspx?contents=1

You can remove web parts one at a time and try to
narrow down where the error might be thrown.

It's not exactly an answer, but it might help you find
one.

 
Answer #2    Answered By: Annie Norris     Answered On: Feb 16

Would it be acceptable to just reset those 8 default.aspx pages back to
the site definition and recreate them? If so, you can do that under
Site Settings > Reset to Site Definition (Under Look and Feel).

 
Answer #3    Answered By: Chadd Hahn     Answered On: Feb 16

We've been investigating further and found that the pages that are "broken"
are now pointing to a page layout on the "in place upgrade" machine. They
are hard-coded with the FQDN instead of a relative path to the masterpage
gallery. They were pointed to the right place before we ran our code.

What we did with our upgrade was:

1) Backup 2003 production
2) Restore to the in place upgrade machine
3) Run the in place upgrade
4) Backup the upgraded site, grab the content database and restore to the
new MOSS farm.

Now that we've identified what value is out of range, we just need to figure
out how to reset the page layout. We can't do it through the page settings
admin page because it throws an exception. Trying to set it through the API
also throws an exception.

We tried to reset back to the site definition, but it doesn't seem to change
anything. The page settings admin page still throws that exception.

We might just have to recreate these pages manually by creating brand new
pages and then deleting the old ones. Hopefully there won't be too many when
we do the upgrade "for real" next week.

 
Answer #4    Answered By: Cheryl Kelley     Answered On: Feb 16

Another "trick" is you can open the site up in Explorer view and drag a
default.aspx in from another site (also opened in Explorer view). I've
had to do that a couple of times to fix broken default.aspx files.

 
Answer #5    Answered By: Titus Sweet     Answered On: Feb 16

I'll try that trick in the morning.

 
Answer #6    Answered By: Jagdish Joshi     Answered On: Feb 16

We still don't know why
this is happening, but here is the code we are using to reset the
page layout. Maybe it will help someone else.

We adapted it from a custom stsadm command from this site:
stsadm.blogspot.com/.../fix-publishing-pages-page-layout-
url.html



Sub updatePageLayout(ByVal web As SPWeb)
Try

'make sure this web is a publishing web
If Not PublishingWeb.IsPublishingWeb(web) Then
Exit Sub
End If


Dim pweb As PublishingWeb = PublishingWeb.GetPublishingWeb
(web)
Dim ppages As PublishingPageCollection
Dim ppage As PublishingPage
Dim url As SPFieldUrlValue
Dim nlname As String
= "/_catalogs/masterpage/inetmasterpage.aspx"

ppages = pweb.GetPublishingPages()


For Each ppage In ppages


oWrite.Write("Processing page: " &
ppage.ListItem.File.ServerRelativeUrl)
oWrite.Write(" " & "Current layout set to: " &
ppage.ListItem(FieldId.PageLayout))

' if the page is checked out we cannot change it's
layout
If ppage.ListItem.File.CheckOutStatus =
SPFile.SPCheckOutStatus.None Then
url = New SPFieldUrlValue(nlname)
ppage.CheckOut()
ppage.ListItem(FieldId.PageLayout) = url
ppage.ListItem.UpdateOverwriteVersion()
ppage.ListItem.File.CheckIn("Set Page Layout",
SPCheckinType.MajorCheckIn)
oWrite.Write(" " & "Layout set to: " & nlname)

End If
Next


Catch ex As Exception

oWrite.Write(ex.Message & ex.StackTrace)
Finally

web.Dispose()
End Try
End Sub

 




Tagged: