MOSS 2007 : CMS 2002 Migration Issue : How to rename a resource Gallery Item?
Unfortunately MCMS 2002 Site Manager doesnt allow you to rename the resource gallery item. In some situation you may end up duplicate entries in the resource gallery item names. MCMS 2002 allows you to have multiple resource items with same name. The items will be differentiated by using their guids. But this will endup a problem when you are migrating to MOSS 2007, and you will get "Leaf names are not unique." error message. And the suggestion is you have to rename the resource gallery item. Here is the sample code to rename the resource gallery item.
// Get the MCMS application context.
CmsApplicationContext cmsContext = new CmsApplicationContext();
// Logon to MCMS:
// Assumes that you have Windows Authentication turned on.
WindowsIdentity ident = WindowsIdentity.GetCurrent();
// Make sure to set the context to Update mode (which means you can write
// back to MCMS using PAPI).
ResourceGallery rsg = cmsContext.Searches.GetByPath("/Resources ") as ResourceGallery;
Resource res = rsg.Resources[“Content Development”];
res.Name = "EMP1.gif";
res.DisplayName = "EMP1.gif";
// Commit changes back to MCMS.
Keep coding :)