public ServerExplorerItem CreateResourceItem(IResource resource) { Guid resourceId = resource.ResourceID; var childNode = new ServerExplorerItem(resource.ResourceName, resourceId, resource.ResourceType == ResourceType.Server ? ResourceType.ServerSource : resource.ResourceType, null, _authService.GetResourcePermissions(resourceId), resource.ResourcePath); return(childNode); }
public IExplorerItem BuildRoot() { ServerExplorerItem serverExplorerItem = new ServerExplorerItem(RootName, Guid.Empty, ResourceType.Server, new List <IExplorerItem>(), _authService.GetResourcePermissions(Guid.Empty), "") { ServerId = HostSecurityProvider.Instance.ServerID, WebserverUri = EnvironmentVariables.WebServerUri }; return(serverExplorerItem); }
public void AddResouceItem(IContextualResourceModel resourceModel) { var explorerItemModel = new ServerExplorerItem { ResourcePath = resourceModel.Category, DisplayName = resourceModel.DisplayName, ResourceId = resourceModel.ID, Permissions = resourceModel.UserPermissions, ServerId = resourceModel.Environment.ID }; ResourceType resourceType; Enum.TryParse(resourceModel.ServerResourceType, out resourceType); explorerItemModel.ResourceType = resourceType; ItemAddedMessageHandler(explorerItemModel); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { IExplorerRepositoryResult item = null; var serializer = new Dev2JsonSerializer(); try { if (values == null) { throw new ArgumentNullException(nameof(values)); } StringBuilder itemToBeRenamed; StringBuilder newName; StringBuilder folderToBeRenamed = null; if (!values.TryGetValue("itemToRename", out itemToBeRenamed)) { if (!values.TryGetValue("folderToRename", out folderToBeRenamed)) { throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "itemToRename")); } } if (!values.TryGetValue("newName", out newName)) { throw new ArgumentException(string.Format(ErrorResource.ValueNotSupplied, "newName")); } IExplorerItem explorerItem; if (itemToBeRenamed != null) { explorerItem = ServerExplorerRepo.Find(Guid.Parse(itemToBeRenamed.ToString())); if (explorerItem == null) { throw new ArgumentException(string.Format(ErrorResource.FailedToFindResource, "newName")); } Dev2Logger.Info($"Rename Item. Path:{explorerItem.ResourcePath} NewPath:{newName}"); item = ServerExplorerRepo.RenameItem(explorerItem, newName.ToString(), GlobalConstants.ServerWorkspaceID); } else if (folderToBeRenamed != null) { explorerItem = new ServerExplorerItem() { ResourceType = "Folder", ResourcePath = folderToBeRenamed.ToString() }; item = ServerExplorerRepo.RenameItem(explorerItem, newName.ToString(), GlobalConstants.ServerWorkspaceID); } } catch (Exception e) { Dev2Logger.Error(e); item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message); } return(serializer.SerializeToBuilder(item)); }
public IExplorerItem CreateResourceItem(IResource resource, Guid workSpaceId) { var resourceId = resource.ResourceID; var childNode = new ServerExplorerItem(resource.ResourceName, resourceId, resource.ResourceType, null, _authService.GetResourcePermissions(resourceId), resource.GetResourcePath(workSpaceId)) { IsService = resource.IsService, IsSource = resource.IsSource, IsFolder = resource.IsFolder, IsServer = resource.IsServer, IsResourceVersion = resource.IsResourceVersion, }; return(childNode); }
public void ServerExplorerItem_GetHashCode_ExpectHashCodeSameAsID() { //------------Setup for test-------------------------- var guid = Guid.NewGuid(); const string name = "a"; var children = new List <IExplorerItem>(); const Permissions permissions = Permissions.DeployFrom; //------------Execute Test--------------------------- var serverExplorerItem = new ServerExplorerItem(name, guid, "PluginService", children, permissions, ""); //------------Assert Results------------------------- Assert.AreEqual(guid.GetHashCode(), serverExplorerItem.GetHashCode()); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { IExplorerRepositoryResult item = null; var serializer = new Dev2JsonSerializer(); try { if (values == null) { throw new ArgumentNullException(nameof(values)); } StringBuilder itemBeingDeleted; StringBuilder pathBeingDeleted = null; if (!values.TryGetValue("itemToDelete", out itemBeingDeleted)) { if (!values.TryGetValue("folderToDelete", out pathBeingDeleted)) { throw new ArgumentException(string.Format(ErrorResource.IsBlank, "itemToDelete")); } } IExplorerItem itemToDelete; if (itemBeingDeleted != null) { itemToDelete = ServerExplorerRepo.Find(a => a.ResourceId.ToString() == itemBeingDeleted.ToString()); Dev2Logger.Info("Delete Item Service." + itemToDelete); item = ServerExplorerRepo.DeleteItem(itemToDelete, GlobalConstants.ServerWorkspaceID); } else if (pathBeingDeleted != null) { itemToDelete = new ServerExplorerItem { ResourceType = "Folder", ResourcePath = pathBeingDeleted.ToString() }; item = ServerExplorerRepo.DeleteItem(itemToDelete, GlobalConstants.ServerWorkspaceID); } } catch (Exception e) { Dev2Logger.Error("Delete Item Error", e); item = new ExplorerRepositoryResult(ExecStatus.Fail, e.Message); } return(serializer.SerializeToBuilder(item)); }
private IList <IExplorerItem> BuildStructureFromFilePath(IDirectory directory, string path, string rootPath) { var firstGen = directory.GetDirectories(path) .Where(a => !a.EndsWith("VersionControl")); IList <IExplorerItem> children = new List <IExplorerItem>(); foreach (var resource in firstGen) { var resourcePath = resource.Replace(rootPath, "").Substring(1); var node = new ServerExplorerItem(new DirectoryInfo(resource).Name, Guid.NewGuid(), ResourceType.Folder, null, _authService.GetResourcePermissions(Guid.Empty), resourcePath); children.Add(node); node.Children = BuildStructureFromFilePath(directory, resource, rootPath); } return(children); }
public void FetchResourceDuplicates_Execute_ExpectName() { //------------Setup for test-------------------------- var FetchResourceDuplicates = new FetchResourceDuplicates(); var serverExplorerItem = new ServerExplorerItem("a", Guid.NewGuid(), "Folder", null, Permissions.DeployFrom, ""); Assert.IsNotNull(serverExplorerItem); var repo = new Mock <IExplorerServerResourceRepository>(); var ws = new Mock <IWorkspace>(); repo.Setup(a => a.LoadDuplicate()); ws.Setup(a => a.ID).Returns(Guid.Empty); FetchResourceDuplicates.ServerExplorerRepo = repo.Object; //------------Execute Test--------------------------- FetchResourceDuplicates.Execute(new Dictionary <string, StringBuilder>(), ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.LoadDuplicate()); }
public void ServerExplorerItem_Constructor_Construct_ExpectAllFieldsAreSetup() { //------------Setup for test-------------------------- var guid = Guid.NewGuid(); const string name = "a"; const string explorerItemType = "Folder"; var children = new List <IExplorerItem>(); const Permissions permissions = Permissions.DeployFrom; //------------Execute Test--------------------------- var serverExplorerItem = new ServerExplorerItem(name, guid, "Folder", children, permissions, "/"); //------------Assert Results------------------------- Assert.AreEqual(children, serverExplorerItem.Children); Assert.AreEqual(name, serverExplorerItem.DisplayName); Assert.AreEqual(serverExplorerItem.ResourceType, explorerItemType); Assert.AreEqual(permissions, serverExplorerItem.Permissions); Assert.AreEqual(guid, serverExplorerItem.ResourceId); }
public void ClientExplorerRepository_CreateFolder_ExpectCreateServiceCalled() { //------------Setup for test-------------------------- var env = new Mock <IEnvironmentConnection>(); var comFactory = new Mock <ICommunicationControllerFactory>(); var rep = new ServerExplorerClientProxy(env.Object, comFactory.Object); var com = new Mock <ICommunicationController>(); var item = new ServerExplorerItem("", Guid.Empty, ResourceType.DbService, null, Permissions.Contribute, "f"); comFactory.Setup(a => a.CreateController("AddFolderService")).Returns(com.Object).Verifiable(); com.Setup(a => a.ExecuteCommand <IExplorerItem>(env.Object, Guid.Empty)).Returns(item).Verifiable(); //------------Execute Test--------------------------- rep.AddItem(item, Guid.Empty); //------------Assert Results------------------------- comFactory.Verify(a => a.CreateController("AddFolderService")); com.Verify(a => a.ExecuteCommand <IExplorerRepositoryResult>(env.Object, Guid.Empty)); com.Verify(a => a.AddPayloadArgument("itemToAdd", It.IsAny <string>())); com.Verify(a => a.ExecuteCommand <IExplorerRepositoryResult>(env.Object, Guid.Empty)); }
public void deleteItem_Execute_ExpectName() { //------------Setup for test-------------------------- var deleteFolder = new DeleteFolderService(); ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, ""); var repo = new Mock<IExplorerResourceRepository>(); var ws = new Mock<IWorkspace>(); repo.Setup(a => a.DeleteItem(item, It.IsAny<Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable(); var inputs = new Dictionary<string, StringBuilder>(); inputs.Add("folderToDelete", new StringBuilder( "folderToDelete")); inputs.Add("deleteContents", new StringBuilder(true.ToString())); ws.Setup(a => a.ID).Returns(Guid.Empty); deleteFolder.ServerExplorerRepository = repo.Object; //------------Execute Test--------------------------- var ax = deleteFolder.Execute(inputs, ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.DeleteItem(item, It.IsAny<Guid>())); }
/// <summary> /// Add a folder to a warewolf server /// </summary> /// <param name="path"></param> /// <param name="name"></param> /// <param name="id"></param> public void AddFolder(string path, string name, Guid id) { var controller = CommunicationControllerFactory.CreateController("AddFolderService"); string resourcePath = String.IsNullOrEmpty(path) ? name : $"{path}\\{name}"; Dev2JsonSerializer serialiser = new Dev2JsonSerializer(); ServerExplorerItem explorerItemModel = new ServerExplorerItem { DisplayName = name, ResourceType = "Folder", ResourcePath = resourcePath, ResourceId = id }; controller.AddPayloadArgument("itemToAdd", serialiser.SerializeToBuilder(explorerItemModel)); var result = controller.ExecuteCommand <IExplorerRepositoryResult>(Connection, GlobalConstants.ServerWorkspaceID); if (result.Status != ExecStatus.Success) { throw new WarewolfSaveException(result.Message, null); } }
public void FetchExplorerItems_Execute_ExpectName() { //------------Setup for test-------------------------- var fetchExplorerItems = new FetchExplorerItems(); ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, ""); var repo = new Mock <IExplorerServerResourceRepository>(); var ws = new Mock <IWorkspace>(); repo.Setup(a => a.Load(It.IsAny <Guid>())).Returns(item).Verifiable(); var serializer = new Dev2JsonSerializer(); ws.Setup(a => a.ID).Returns(Guid.Empty); fetchExplorerItems.ServerExplorerRepo = repo.Object; //------------Execute Test--------------------------- var ax = fetchExplorerItems.Execute(new Dictionary <string, StringBuilder>(), ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.Load(It.IsAny <Guid>())); Assert.AreEqual(serializer.Deserialize <IExplorerItem>(ax.ToString()).ResourceId, item.ResourceId); }
public void CreateFolder_Execute_ExpectCreateCalled() { //------------Setup for test-------------------------- var createFolderService = new AddFolderService(); ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, ""); var repo = new Mock <IExplorerServerResourceRepository>(); var ws = new Mock <IWorkspace>(); repo.Setup(a => a.AddItem(item, It.IsAny <Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Fail, "noddy")); var serializer = new Dev2JsonSerializer(); var inputs = new Dictionary <string, StringBuilder>(); inputs.Add("itemToAdd", serializer.SerializeToBuilder(item)); ws.Setup(a => a.ID).Returns(Guid.Empty); createFolderService.ServerExplorerRepo = repo.Object; //------------Execute Test--------------------------- createFolderService.Execute(inputs, ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.AddItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>())); }
public void DeleteItem_Execute_ExpectName() { //------------Setup for test-------------------------- var deleteItem = new DeleteItemService(); ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), ResourceType.Folder, null, Permissions.DeployFrom, ""); var repo = new Mock <IExplorerServerResourceRepository>(); var ws = new Mock <IWorkspace>(); repo.Setup(a => a.DeleteItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable(); var serializer = new Dev2JsonSerializer(); var inputs = new Dictionary <string, StringBuilder>(); inputs.Add("itemToDelete", serializer.SerializeToBuilder(item)); ws.Setup(a => a.ID).Returns(Guid.Empty); deleteItem.ServerExplorerRepo = repo.Object; //------------Execute Test--------------------------- deleteItem.Execute(inputs, ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.DeleteItem(It.IsAny <IExplorerItem>(), It.IsAny <Guid>())); }
public void ServerExplorerItem_Equals_ExpectEqualityOnGuidOnly() { //------------Setup for test-------------------------- var guid = Guid.NewGuid(); const string name = "a"; const string explorerItemType = "PluginService"; var children = new List <IExplorerItem>(); const Permissions permissions = Permissions.DeployFrom; //------------Execute Test--------------------------- var serverExplorerItem = new ServerExplorerItem(name, guid, explorerItemType, children, permissions, ""); var serverExplorerItem2 = new ServerExplorerItem(name, guid, explorerItemType, children, Permissions.Administrator, ""); var serverExplorerItem3 = new ServerExplorerItem(name, Guid.NewGuid(), explorerItemType, children, permissions, ""); //------------Assert Results------------------------- Assert.AreEqual(serverExplorerItem, serverExplorerItem2); Assert.AreNotEqual(serverExplorerItem, null); Assert.AreEqual(serverExplorerItem, serverExplorerItem); Assert.AreNotEqual(serverExplorerItem, guid); Assert.AreNotEqual(serverExplorerItem, serverExplorerItem3); }
private IExplorerItem GetTestData(string workFlowId = "DF279411-F678-4FCC-BE88-A1B613EE51E3", string dbServiceId = "DF279411-F678-4FCC-BE88-A1B613EE51E3", Guid?folderID = null) { var workflow1 = new ServerExplorerItem { ResourceType = ResourceType.WorkflowService, DisplayName = "workflow1", ResourceId = string.IsNullOrEmpty(workFlowId) ? Guid.NewGuid() : Guid.Parse(workFlowId), Permissions = Permissions.Administrator }; var dbService1 = new ServerExplorerItem { ResourceType = ResourceType.DbService, DisplayName = "dbService1", ResourceId = string.IsNullOrEmpty(dbServiceId) ? Guid.NewGuid() : Guid.Parse(dbServiceId), Permissions = Permissions.Contribute }; var webService1 = new ServerExplorerItem { ResourceType = ResourceType.WebService, DisplayName = "webService1", ResourceId = Guid.NewGuid(), Permissions = Permissions.View }; var pluginService1 = new ServerExplorerItem { ResourceType = ResourceType.PluginService, DisplayName = "pluginService1", ResourceId = Guid.NewGuid(), Permissions = Permissions.View }; var dbSource1 = new ServerExplorerItem { ResourceType = ResourceType.DbSource, DisplayName = "dbSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var webSource1 = new ServerExplorerItem { ResourceType = ResourceType.WebSource, DisplayName = "webSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var pluginSource1 = new ServerExplorerItem { ResourceType = ResourceType.PluginSource, DisplayName = "pluginSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var emailSource1 = new ServerExplorerItem { ResourceType = ResourceType.EmailSource, DisplayName = "emailSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var serverSource1 = new ServerExplorerItem { ResourceType = ResourceType.ServerSource, DisplayName = "serverSource1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var folder1 = new ServerExplorerItem { ResourceType = ResourceType.Folder, DisplayName = "folder1", ResourceId = folderID ?? Guid.NewGuid(), Permissions = Permissions.Administrator }; var folder2 = new ServerExplorerItem { ResourceType = ResourceType.Folder, DisplayName = "folder2", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var subfolder1 = new ServerExplorerItem { ResourceType = ResourceType.Folder, DisplayName = "subfolder1", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; var localhost = new ServerExplorerItem { ResourceType = ResourceType.Server, DisplayName = "localhost", ResourceId = Guid.NewGuid(), Permissions = Permissions.Administrator }; dbService1.Parent = webService1.Parent = pluginService1.Parent = subfolder1.Parent = folder1; dbSource1.Parent = webSource1.Parent = pluginSource1.Parent = emailSource1.Parent = serverSource1.Parent = folder2; folder2.Children = new List <IExplorerItem> { dbSource1, webSource1, pluginSource1, emailSource1, serverSource1 }; folder1.Children = new List <IExplorerItem> { dbService1, webService1, pluginService1, subfolder1 }; localhost.Children = new List <IExplorerItem> { folder1, workflow1 }; workflow1.Parent = localhost; folder1.Parent = localhost; return(localhost); }
public void GetDirectoriesRelativeToServer_UnitTest_ExecuteWithDirectory_ExpectDirectoryStructure() { //----------------Setup--------------------------------------------- var esb = new GetDirectoriesRelativeToServer(); Mock <IExplorerServerResourceRepository> mockRepo = new Mock <IExplorerServerResourceRepository>(); ServerExplorerItem serverExplorerItem = new ServerExplorerItem(); serverExplorerItem.ResourceType = ResourceType.Server; ServerExplorerItem levelOneFolder = new ServerExplorerItem(); levelOneFolder.ResourceType = ResourceType.Folder; levelOneFolder.DisplayName = "Test1"; levelOneFolder.ResourcePath = "Test1"; serverExplorerItem.Children.Add(levelOneFolder); IExplorerItem levelOneFolderTwo = new ServerExplorerItem(); levelOneFolderTwo.ResourceType = ResourceType.Folder; levelOneFolderTwo.DisplayName = "Test2"; levelOneFolderTwo.ResourcePath = "Test2"; ServerExplorerItem levelTwoFolderInFolderTwo = new ServerExplorerItem(); levelTwoFolderInFolderTwo.ResourceType = ResourceType.Folder; levelTwoFolderInFolderTwo.DisplayName = "InnerTest2"; levelTwoFolderInFolderTwo.ResourcePath = levelOneFolderTwo.ResourcePath + "\\InnerTest2"; levelOneFolderTwo.Children.Add(levelTwoFolderInFolderTwo); serverExplorerItem.Children.Add(levelOneFolderTwo); mockRepo.Setup(repository => repository.Load(ResourceType.Folder, It.IsAny <string>())).Returns(serverExplorerItem); esb.ServerExplorerRepo = mockRepo.Object; //----------------Execute------------------------------------------------ var actual = esb.Execute(new Dictionary <string, StringBuilder> { { "Directory", new StringBuilder("Resources") } }, null); //----------------Assert Results----------------------------------------- Assert.AreNotEqual(string.Empty, actual); const string expected = @"<JSON>{ ""$type"": ""Dev2.Runtime.ESB.Management.Services.JsonTreeNode, Dev2.Runtime.Services"", ""title"": ""Root"", ""isFolder"": true, ""key"": ""root"", ""isLazy"": false, ""children"": [ { ""$type"": ""Dev2.Runtime.ESB.Management.Services.JsonTreeNode, Dev2.Runtime.Services"", ""title"": ""Test1"", ""isFolder"": true, ""key"": ""Test1"", ""isLazy"": false, ""children"": [] }, { ""$type"": ""Dev2.Runtime.ESB.Management.Services.JsonTreeNode, Dev2.Runtime.Services"", ""title"": ""Test2"", ""isFolder"": true, ""key"": ""Test2"", ""isLazy"": false, ""children"": [ { ""$type"": ""Dev2.Runtime.ESB.Management.Services.JsonTreeNode, Dev2.Runtime.Services"", ""title"": ""InnerTest2"", ""isFolder"": true, ""key"": ""Test2\\\\InnerTest2"", ""isLazy"": false, ""children"": [] } ] } ] }</JSON> "; var actuals = actual.ToString().Trim(); Assert.AreEqual(expected.Trim(), actuals); }
IEnumerable <IExplorerItem> SaveFolders(string sourceLocation, string destination, string newName, bool fixRefences) { var resourcesToUpdate = new List <IResource>(); var resourceUpdateMap = new Dictionary <Guid, Guid>(); var resourceList = _resourceCatalog.GetResourceList(GlobalConstants.ServerWorkspaceID); var items = new List <IExplorerItem>(); var resourceToMove = resourceList.Where(resource => { var upper = resource.GetResourcePath(GlobalConstants.ServerWorkspaceID).ToUpper(); return(upper.StartsWith(sourceLocation.ToUpper())); }).Where(resource => !(resource is ManagementServiceResource)).ToList(); var destPath = destination + "\\" + newName; var actualPath = destPath.TrimStart('\\'); var trimEnd = destination.TrimStart('\\').TrimEnd('\\'); var parentItem = ServerExplorerRepository.Instance.Find(item => item.ResourcePath.ToLowerInvariant().TrimEnd('\\').Equals(trimEnd)); if (parentItem == null) { var itemToAdd = new ServerExplorerItem(newName, Guid.NewGuid(), "Folder", new List <IExplorerItem>(), Permissions.Contribute, actualPath) { IsFolder = true }; ServerExplorerRepository.Instance.AddItem(itemToAdd, GlobalConstants.ServerWorkspaceID); items.Add(itemToAdd); } else { var itemToAdd = new ServerExplorerItem(newName, Guid.NewGuid(), "Folder", new List <IExplorerItem>(), Permissions.Contribute, actualPath) { IsFolder = true, Parent = parentItem }; parentItem.Children.Add(itemToAdd); items.Add(itemToAdd); } foreach (var resource in resourceToMove) { try { var result = _resourceCatalog.GetResourceContents(GlobalConstants.ServerWorkspaceID, resource.ResourceID); var xElement = result.ToXElement(); var newResource = new Resource(xElement) { IsUpgraded = true }; var newResourceId = Guid.NewGuid(); var oldResourceId = resource.ResourceID; newResource.ResourceID = newResourceId; var fixedResource = xElement.ToStringBuilder(); var resourcePath = resource.GetResourcePath(GlobalConstants.ServerWorkspaceID); var savePath = resourcePath; var resourceNameIndex = resourcePath.LastIndexOf(resource.ResourceName, StringComparison.InvariantCultureIgnoreCase); if (resourceNameIndex >= 0) { savePath = resourcePath.Substring(0, resourceNameIndex); } savePath = savePath.ReplaceFirst(sourceLocation, destPath); var subActualPath = savePath.TrimStart('\\'); var subTrimEnd = subActualPath.TrimStart('\\').TrimEnd('\\'); var idx = subTrimEnd.LastIndexOf("\\", StringComparison.InvariantCultureIgnoreCase); var name = subTrimEnd.Substring(idx + 1); var subItem = ServerExplorerRepository.Instance.Find(item => item.ResourcePath.ToLowerInvariant().TrimEnd('\\').Equals(subTrimEnd)); var itemToAdd = new ServerExplorerItem(name, Guid.NewGuid(), "Folder", new List <IExplorerItem>(), Permissions.Contribute, subTrimEnd) { IsFolder = true, Parent = subItem }; ServerExplorerRepository.Instance.AddItem(itemToAdd, GlobalConstants.ServerWorkspaceID); _resourceCatalog.SaveResource(GlobalConstants.ServerWorkspaceID, newResource, fixedResource, savePath); resourcesToUpdate.Add(newResource); resourceUpdateMap.Add(oldResourceId, newResourceId); SaveTests(oldResourceId, newResourceId); ServerExplorerRepository.Instance.UpdateItem(newResource); } catch (Exception e) { Dev2Logger.Error(e.Message, e, GlobalConstants.WarewolfError); } } if (fixRefences) { try { using (var tx = new TransactionScope()) { FixReferences(resourcesToUpdate, resourceUpdateMap); tx.Complete(); } } catch (Exception e) { Transaction.Current.Rollback(); throw new Exception("Failure Fixing references", e); } } return(items); }