private bool CloneFolder(List <InventoryFolderBase> avatarInventory, UUID avID, UUID parentFolder, AvatarAppearance appearance, InventoryFolderBase templateFolder, List <InventoryFolderBase> templateFolders, bool modifyPermissions) { bool success = false; UUID templateFolderId = templateFolder.ID; if (templateFolderId != UUID.Zero) { InventoryFolderBase toFolder = FindFolder(templateFolder.Name, parentFolder.Guid, avatarInventory); if (toFolder == null) { //create new folder toFolder = new InventoryFolderBase(); toFolder.ID = UUID.Random(); toFolder.Name = templateFolder.Name; toFolder.Owner = avID; toFolder.Type = templateFolder.Type; toFolder.Version = 1; toFolder.ParentID = parentFolder; if (!SynchronousRestObjectRequester.MakeRequest <InventoryFolderBase, bool>( "POST", m_inventoryServerUrl + "CreateFolder/", toFolder)) { m_log.InfoFormat("[AvatarApperance] Couldn't make new folder {0} in users inventory", toFolder.Name); return(false); } else { // m_log.InfoFormat("made new folder {0} in users inventory", toFolder.Name); } } List <InventoryItemBase> templateItems = SynchronousRestObjectRequester.MakeRequest <Guid, List <InventoryItemBase> >( "POST", m_inventoryServerUrl + "GetItems/", templateFolderId.Guid); if ((templateItems != null) && (templateItems.Count > 0)) { List <ClothesAttachment> wornClothes = new List <ClothesAttachment>(); List <ClothesAttachment> attachedItems = new List <ClothesAttachment>(); foreach (InventoryItemBase item in templateItems) { UUID clonedItemId = CloneInventoryItem(avID, toFolder.ID, item, modifyPermissions); if (clonedItemId != UUID.Zero) { int appearanceType = ItemIsPartOfAppearance(item, appearance); if (appearanceType >= 0) { // UpdateAvatarAppearance(avID, appearanceType, clonedItemId, item.AssetID); wornClothes.Add(new ClothesAttachment(appearanceType, clonedItemId, item.AssetID)); } if (appearance != null) { int attachment = appearance.GetAttachpoint(item.ID); if (attachment > 0) { //UpdateAvatarAttachment(avID, attachment, clonedItemId, item.AssetID); attachedItems.Add(new ClothesAttachment(attachment, clonedItemId, item.AssetID)); } } success = true; } } if ((wornClothes.Count > 0) || (attachedItems.Count > 0)) { //Update the worn clothes and attachments AvatarAppearance targetAppearance = GetAppearance(avID); if (targetAppearance != null) { foreach (ClothesAttachment wornItem in wornClothes) { targetAppearance.Wearables[wornItem.Type].AssetID = wornItem.AssetID; targetAppearance.Wearables[wornItem.Type].ItemID = wornItem.ItemID; } foreach (ClothesAttachment wornItem in attachedItems) { targetAppearance.SetAttachment(wornItem.Type, wornItem.ItemID, wornItem.AssetID); } m_userDataBaseService.UpdateUserAppearance(avID, targetAppearance); wornClothes.Clear(); attachedItems.Clear(); } } } List <InventoryFolderBase> subFolders = FindSubFolders(templateFolder.ID.Guid, templateFolders); foreach (InventoryFolderBase subFolder in subFolders) { if (subFolder.Name.ToLower() != "trash") { success = CloneFolder(avatarInventory, avID, toFolder.ID, appearance, subFolder, templateFolders, modifyPermissions); } } } else { m_log.Info("[AvatarAppearance] Failed to find the template folder"); } return(success); }