public ResourceCatalogResult RenameCategory(Guid workspaceID, string oldCategory, string newCategory, List <IResource> resourcesToUpdate)
 {
     if (resourcesToUpdate.Count == 0)
     {
         return(ResourceCatalogResultBuilder.CreateNoMatchResult($"<CompilerMessage>No Resources found in '{oldCategory}'</CompilerMessage>"));
     }
     return(PerformUpdate(workspaceID, oldCategory, newCategory, resourcesToUpdate));
 }
Esempio n. 2
0
        Dictionary <int, ResourceCatalogResult> GetDeleteCommands(Guid workspaceID, Guid resourceID, string type, bool deleteVersions, IEnumerable <IResource> resources, List <IResource> workspaceResources)
        {
            var commands = new Dictionary <int, ResourceCatalogResult>()
            {
                {
                    0,
                    ResourceCatalogResultBuilder.CreateNoMatchResult($"<Result>{type} '{resourceID}' was not found.</Result>")
                },
                { 1, DeleteImpl(workspaceID, resources, workspaceResources, deleteVersions) },
            };

            return(commands);
        }
Esempio n. 3
0
        public ResourceCatalogResult DeleteResource(Guid workspaceID, string resourceName, string type, bool deleteVersions)
        {
            var @lock = Common.GetWorkspaceLock(workspaceID);

            lock (@lock)
            {
                if (resourceName == "*")
                {
                    var noWildcardsAllowedhResult = ResourceCatalogResultBuilder.CreateNoWildcardsAllowedhResult("<Result>Delete resources does not accept wildcards.</Result>.");
                    return(noWildcardsAllowedhResult);
                }

                if (string.IsNullOrEmpty(resourceName) || string.IsNullOrEmpty(type))
                {
                    throw new InvalidDataContractException(ErrorResource.ResourceNameAndTypeMissing);
                }

                var workspaceResources = _resourceCatalog.GetResources(workspaceID);
                var resources          = _resourceCatalog.GetResourcesBasedOnType(type, workspaceResources, r => string.Equals(r.ResourceName, resourceName, StringComparison.InvariantCultureIgnoreCase));
                var commands           = new Dictionary <int, ResourceCatalogResult>()
                {
                    {
                        0, ResourceCatalogResultBuilder.CreateNoMatchResult($"<Result>{type} '{resourceName}' was not found.</Result>")
                    },
                    {
                        1, DeleteImpl(workspaceID, resources, workspaceResources, deleteVersions)
                    },
                };
                if (commands.ContainsKey(resources.Count))
                {
                    var resourceCatalogResult = commands[resources.Count];
                    return(resourceCatalogResult);
                }

                return(ResourceCatalogResultBuilder.CreateDuplicateMatchResult($"<Result>Multiple matches found for {type} '{resourceName}'.</Result>"));
            }
        }