From d009516ddc9ab3a6bdfcaf1e794abc20c4fb1d98 Mon Sep 17 00:00:00 2001 From: Cody Rodgers Date: Tue, 16 May 2023 08:44:07 -0700 Subject: [PATCH] v10.2.X-0.4 (#19) * Update the videos/playlists pull pipelines to automatically refresh the search index to prevent a race condition (#14) Co-authored-by: Cody Rodgers * v10.1.X-3.6 (#18) * V10.2.0.3 (#16) * Fixed broken DXF configuration content for labels/folders * Add more error handling to the folder and labels property value readers * Fix bug preventing new labels from being synced * Remove automatic re-indexing from the videos/playlists pipeline --------- Co-authored-by: Cody Rodgers * Add missing embed media buttons * Reorganize DEF files * Update the DEF GET pipelines to have better error handling and removed broken SetFolderSettings code * Update the DEF resolve pipelines to have better error handling * Updated the UPDATE DEF pipelines to have better logging and error handling * Update playlist/video pipelines to accuratly reflect video name changes made outside of Sitecore * Fix bug preventing deleted Brightcove items from being deleted in Sitecore * Fix broken standard values for experience items * Update the Brightcove services to trim account ids/secrets * Update logging levels on video/player pipelines * Update all pipelines to handle name changes * Update sitecore package creation script to include patching instructions * Update the pull pipelines to support creating items in languages other an "en" * Update all template fields to be shared * Update the push pipelines to support creating items in languages other than "en" * Update the folder/labels value readers to have better error handling * Add support for embedding medai links again. It was removed as part of the upgrade but returned on client request * Update the resolve asset item pipeline step to rename resolved items if the name has been changed since creation * Fix the brightcove settings config so it loads both html editor scripts correctly * Update sitecore package creation script --------- Co-authored-by: Cody Rodgers --------- Co-authored-by: Cody Rodgers --- .../BrightcoveAuthenticationService.cs | 4 +- Brightcove.Core/Services/BrightcoveService.cs | 4 +- .../Brightcove.DataExchangeFramework.csproj | 61 ++-- .../PipelineStepWithEndpointFromConverter.cs | 0 .../ReadAssetItemsPipelineStepConverter.cs | 0 .../ResolveAssetItemPipelineStepConverter.cs | 0 ...OrUpdateAssetModelPipelineStepConverter.cs | 0 .../UpdatePipelineStepConverter.cs | 0 .../ChainedPropertyValueAccessorConverter.cs | 0 ...CsvStringPropertyValueAccessorConverter.cs | 0 .../FolderPropertyValueAccessorConverter.cs | 0 .../LabelsPropertyValueAccessorConverter.cs | 0 ...ictionaryPropertyValueAccessorConverter.cs | 0 .../VideoIdsPropertyValueAccessorConverter.cs | 0 .../Extensions/ItemModelExtensions.cs | 24 ++ .../Helpers/ResolveHelper.cs | 12 - .../Processors/BasePipelineStepProcessor.cs | 8 +- ...sePipelineStepWithEndpointFromProcessor.cs | 80 ----- ...PipelineStepWithWebApiEndpointProcessor.cs | 95 ++---- .../GetExperiencesPipelineStepProcessor.cs | 38 +++ .../Get/GetFoldersPipelineStepProcessor.cs | 50 +++ .../Get/GetLabelsPipelineStepProcessor.cs | 50 +++ .../GetPlayListsPipelineStepProcessor.cs | 28 +- .../Get/GetPlayersPipelineStepProcessor.cs | 44 +++ .../GetVideosPipelineStepProcessor.cs | 27 +- .../GetExperiencesPipelineStepProcessor.cs | 31 -- .../GetFoldersPipelineStepProcessor.cs | 43 --- .../GetLabelsPipelineStepProcessor.cs | 43 --- .../GetPlayersPipelineStepProcessor.cs | 31 -- .../ReadAssetItemsPipelineStepProcessor.cs | 9 +- .../ResolveAssetItemPipelineStepProcessor.cs | 237 ++++++++++++++ ...ResolveFolderModelPipelineStepProcessor.cs | 38 +-- .../ResolveLabelModelPipelineStepProcessor.cs | 40 +-- ...solvePlayListModelPipelineStepProcessor.cs | 38 +-- ...ResolvePlayerModelPipelineStepProcessor.cs | 38 +-- .../ResolveVideoModelPipelineStepProcessor.cs | 37 +-- .../ResolveAssetItemPipelineStepProcessor.cs | 90 ------ .../UpdateFolderModelPipelineStepProcessor.cs | 42 +-- .../UpdateLabelModelPipelineStepProcessor.cs | 36 +-- .../UpdatePlayerModelPipelineStepProcessor.cs | 60 +--- ...pdatePlaylistModelPipelineStepProcessor.cs | 38 +-- .../{ => Update}/UpdateVideoItemProcessor.cs | 40 ++- .../UpdateVideoModelPipelineStepProcessor.cs | 35 +- .../Settings/WebApiSettings.cs | 25 ++ .../ValueReaders/FolderPropertyValueReader.cs | 58 ++-- .../ValueReaders/LabelsPropertyValueReader.cs | 66 ++-- .../ValueWriters/LabelsPropertyValueWriter.cs | 30 +- .../Brightcove/Brightcove.Settings.CM.config | 4 +- .../Unicorn/Unicorn.Configs.Brightcove.config | 1 + Brightcove.Web/Brightcove.Web.csproj | 5 + Brightcove.Web/UI/Sublayouts/Player.aspx.cs | 110 ++++++- Brightcove.Web/UI/Wizards/BaseEmbedWizard.cs | 305 ++++++++++++++++++ Brightcove.Web/UI/Wizards/EmbedLinkWizard.cs | 107 ++++++ .../layouts/Brightcove/Sublayouts/Player.aspx | 6 +- .../EmbedLink/Brightcove RichText Commands.js | 24 ++ .../Rich Text Editor/EmbedLink/EmbedLink.js | 78 +++++ .../Rich Text Editor/EmbedLink/EmbedLink.xml | 82 +++++ Scripts/create_sitecore_package.ps1 | 10 +- .../Brightcove.yml | 8 +- .../Brightcove/Embed Media.yml | 12 +- .../Embed Media Link.yml | 38 +++ .../BrightcoveAccount/_name/Experiences.yml | 2 +- .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Asset Item Fields/__Display Name.yml | 22 ++ .../Pipeline Batches/Pull Pipeline Batch.yml | 10 +- .../Pipeline Batches/Push Pipeline Batch.yml | 7 +- .../Pipeline Batches/Sync Pipeline Batch.yml | 4 + .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Update Player Models.yml | 4 + .../Select Languages Pipeline Step.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../__Display Name.yml | 26 ++ .../__Display Name Mapping.yml | 26 ++ .../Select Languages Pipeline Step.yml | 26 ++ .../Brightcove/Brightcove Experience.yml | 6 +- .../Brightcove Experience Data/ID.yml | 2 +- .../Brightcove Experience Data/Url.yml | 2 +- .../__Standard Values.yml | 31 +- .../Synchronization Metadata/Delete.yml | 4 + .../Synchronization Metadata/LastSyncTime.yml | 4 + .../Analytics/PlaybackEventsRules.yml | 4 + .../BrightcoveFolder.yml | 4 + .../Video Variant Metadata/Description.yml | 4 + .../Video Variant Metadata/Language.yml | 4 + .../Video Variant Metadata/Name.yml | 4 + 91 files changed, 1950 insertions(+), 926 deletions(-) rename Brightcove.DataExchangeFramework/Converters/{ => PipelineStep}/PipelineStepWithEndpointFromConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => PipelineStep}/ReadAssetItemsPipelineStepConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => PipelineStep}/ResolveAssetItemPipelineStepConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => PipelineStep}/ResolveOrUpdateAssetModelPipelineStepConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => PipelineStep}/UpdatePipelineStepConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => ValueAccessor}/ChainedPropertyValueAccessorConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => ValueAccessor}/CsvStringPropertyValueAccessorConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => ValueAccessor}/FolderPropertyValueAccessorConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => ValueAccessor}/LabelsPropertyValueAccessorConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => ValueAccessor}/StringDictionaryPropertyValueAccessorConverter.cs (100%) rename Brightcove.DataExchangeFramework/Converters/{ => ValueAccessor}/VideoIdsPropertyValueAccessorConverter.cs (100%) create mode 100644 Brightcove.DataExchangeFramework/Extensions/ItemModelExtensions.cs delete mode 100644 Brightcove.DataExchangeFramework/Helpers/ResolveHelper.cs delete mode 100644 Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithEndpointFromProcessor.cs create mode 100644 Brightcove.DataExchangeFramework/Processors/Get/GetExperiencesPipelineStepProcessor.cs create mode 100644 Brightcove.DataExchangeFramework/Processors/Get/GetFoldersPipelineStepProcessor.cs create mode 100644 Brightcove.DataExchangeFramework/Processors/Get/GetLabelsPipelineStepProcessor.cs rename Brightcove.DataExchangeFramework/Processors/{ => Get}/GetPlayListsPipelineStepProcessor.cs (54%) create mode 100644 Brightcove.DataExchangeFramework/Processors/Get/GetPlayersPipelineStepProcessor.cs rename Brightcove.DataExchangeFramework/Processors/{ => Get}/GetVideosPipelineStepProcessor.cs (56%) delete mode 100644 Brightcove.DataExchangeFramework/Processors/GetExperiencesPipelineStepProcessor.cs delete mode 100644 Brightcove.DataExchangeFramework/Processors/GetFoldersPipelineStepProcessor.cs delete mode 100644 Brightcove.DataExchangeFramework/Processors/GetLabelsPipelineStepProcessor.cs delete mode 100644 Brightcove.DataExchangeFramework/Processors/GetPlayersPipelineStepProcessor.cs create mode 100644 Brightcove.DataExchangeFramework/Processors/Resolve/ResolveAssetItemPipelineStepProcessor.cs rename Brightcove.DataExchangeFramework/Processors/{ => Resolve}/ResolveFolderModelPipelineStepProcessor.cs (55%) rename Brightcove.DataExchangeFramework/Processors/{ => Resolve}/ResolveLabelModelPipelineStepProcessor.cs (57%) rename Brightcove.DataExchangeFramework/Processors/{ => Resolve}/ResolvePlayListModelPipelineStepProcessor.cs (56%) rename Brightcove.DataExchangeFramework/Processors/{ => Resolve}/ResolvePlayerModelPipelineStepProcessor.cs (55%) rename Brightcove.DataExchangeFramework/Processors/{ => Resolve}/ResolveVideoModelPipelineStepProcessor.cs (54%) delete mode 100644 Brightcove.DataExchangeFramework/Processors/ResolveAssetItemPipelineStepProcessor.cs rename Brightcove.DataExchangeFramework/Processors/{ => Update}/UpdateFolderModelPipelineStepProcessor.cs (54%) rename Brightcove.DataExchangeFramework/Processors/{ => Update}/UpdateLabelModelPipelineStepProcessor.cs (55%) rename Brightcove.DataExchangeFramework/Processors/{ => Update}/UpdatePlayerModelPipelineStepProcessor.cs (50%) rename Brightcove.DataExchangeFramework/Processors/{ => Update}/UpdatePlaylistModelPipelineStepProcessor.cs (60%) rename Brightcove.DataExchangeFramework/Processors/{ => Update}/UpdateVideoItemProcessor.cs (71%) rename Brightcove.DataExchangeFramework/Processors/{ => Update}/UpdateVideoModelPipelineStepProcessor.cs (86%) create mode 100644 Brightcove.Web/UI/Wizards/BaseEmbedWizard.cs create mode 100644 Brightcove.Web/UI/Wizards/EmbedLinkWizard.cs create mode 100644 Brightcove.Web/sitecore/shell/Controls/Rich Text Editor/EmbedLink/Brightcove RichText Commands.js create mode 100644 Brightcove.Web/sitecore/shell/Controls/Rich Text Editor/EmbedLink/EmbedLink.js create mode 100644 Brightcove.Web/sitecore/shell/Controls/Rich Text Editor/EmbedLink/EmbedLink.xml create mode 100644 Serialization/Brightcove.RichTextEditor.EmbedMediaLinkButton/Embed Media Link.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/062fa6d7-d5d5-424f-b677-900c2da935a6/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/2f977a04-220d-42b5-a313-9fe622f60bca/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/4e84572a-b578-46c1-a7f6-b09b543ba152/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/66c52e36-fb67-4007-9f8a-94b8a36f94f4/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/853ba6e4-363f-4e3e-b364-43138acfefca/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Data Access/Value Accessor Sets/Providers/Sitecore/Asset Item Fields/__Display Name.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Pipelines/Push Pipelines/Push Folders Pipeline/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Pipelines/Push Pipelines/Push Labels Pipeline/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Pipelines/Push Pipelines/Push Players Pipeline/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Pipelines/Push Pipelines/Push Playlists Pipeline/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Pipelines/Push Pipelines/Push Videos Pipeline/Select Languages Pipeline Step.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Value Mapping Sets/Model Source Mapping Sets/Asset Model Source Mapping Set/__Display Name.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/Brightcove Tenant/_name/Value Mapping Sets/Model Source Mapping Sets/Folder Model Source Mapping Se/__Display Name Mapping.yml create mode 100644 Serialization/Brightcove.Template.Branches.DataExchangeFramework.Framework.Branches/bcd318ab-a0b9-47e5-b4ae-ade05ed9504e/Select Languages Pipeline Step.yml diff --git a/Brightcove.Core/Services/BrightcoveAuthenticationService.cs b/Brightcove.Core/Services/BrightcoveAuthenticationService.cs index 12efcf88..57c07f63 100644 --- a/Brightcove.Core/Services/BrightcoveAuthenticationService.cs +++ b/Brightcove.Core/Services/BrightcoveAuthenticationService.cs @@ -29,8 +29,8 @@ public BrightcoveAuthenticationService(string clientId, string clientSecret) throw new ArgumentException("argument must not be null or empty", nameof(clientSecret)); } - this.clientId = clientId; - this.clientSecret = clientSecret; + this.clientId = clientId.Trim(); + this.clientSecret = clientSecret.Trim(); } AccessToken GetAccessToken() diff --git a/Brightcove.Core/Services/BrightcoveService.cs b/Brightcove.Core/Services/BrightcoveService.cs index 0e6c008e..ae40cc67 100644 --- a/Brightcove.Core/Services/BrightcoveService.cs +++ b/Brightcove.Core/Services/BrightcoveService.cs @@ -30,7 +30,7 @@ public BrightcoveService(string accountId, string clientId, string clientSecret) throw new ArgumentException("argument must not be null or empty", nameof(accountId)); } - this.accountId = accountId; + this.accountId = accountId.Trim(); authenticationService = new BrightcoveAuthenticationService(clientId, clientSecret); } @@ -513,8 +513,6 @@ public PlayerList GetPlayers() HttpResponseMessage response = SendRequest(request); PlayerList players = JsonConvert.DeserializeObject(response.Content.ReadAsString()); - foreach (var p in players.Items) - p.LastSyncTime = DateTime.UtcNow; return players; } diff --git a/Brightcove.DataExchangeFramework/Brightcove.DataExchangeFramework.csproj b/Brightcove.DataExchangeFramework/Brightcove.DataExchangeFramework.csproj index 24c320ca..28d8d7fa 100644 --- a/Brightcove.DataExchangeFramework/Brightcove.DataExchangeFramework.csproj +++ b/Brightcove.DataExchangeFramework/Brightcove.DataExchangeFramework.csproj @@ -420,44 +420,43 @@ - + - - - - + + + + - - - - - - + + + + + + + - - - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/Brightcove.DataExchangeFramework/Converters/PipelineStepWithEndpointFromConverter.cs b/Brightcove.DataExchangeFramework/Converters/PipelineStep/PipelineStepWithEndpointFromConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/PipelineStepWithEndpointFromConverter.cs rename to Brightcove.DataExchangeFramework/Converters/PipelineStep/PipelineStepWithEndpointFromConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/ReadAssetItemsPipelineStepConverter.cs b/Brightcove.DataExchangeFramework/Converters/PipelineStep/ReadAssetItemsPipelineStepConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/ReadAssetItemsPipelineStepConverter.cs rename to Brightcove.DataExchangeFramework/Converters/PipelineStep/ReadAssetItemsPipelineStepConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/ResolveAssetItemPipelineStepConverter.cs b/Brightcove.DataExchangeFramework/Converters/PipelineStep/ResolveAssetItemPipelineStepConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/ResolveAssetItemPipelineStepConverter.cs rename to Brightcove.DataExchangeFramework/Converters/PipelineStep/ResolveAssetItemPipelineStepConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/ResolveOrUpdateAssetModelPipelineStepConverter.cs b/Brightcove.DataExchangeFramework/Converters/PipelineStep/ResolveOrUpdateAssetModelPipelineStepConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/ResolveOrUpdateAssetModelPipelineStepConverter.cs rename to Brightcove.DataExchangeFramework/Converters/PipelineStep/ResolveOrUpdateAssetModelPipelineStepConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/UpdatePipelineStepConverter.cs b/Brightcove.DataExchangeFramework/Converters/PipelineStep/UpdatePipelineStepConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/UpdatePipelineStepConverter.cs rename to Brightcove.DataExchangeFramework/Converters/PipelineStep/UpdatePipelineStepConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/ChainedPropertyValueAccessorConverter.cs b/Brightcove.DataExchangeFramework/Converters/ValueAccessor/ChainedPropertyValueAccessorConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/ChainedPropertyValueAccessorConverter.cs rename to Brightcove.DataExchangeFramework/Converters/ValueAccessor/ChainedPropertyValueAccessorConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/CsvStringPropertyValueAccessorConverter.cs b/Brightcove.DataExchangeFramework/Converters/ValueAccessor/CsvStringPropertyValueAccessorConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/CsvStringPropertyValueAccessorConverter.cs rename to Brightcove.DataExchangeFramework/Converters/ValueAccessor/CsvStringPropertyValueAccessorConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/FolderPropertyValueAccessorConverter.cs b/Brightcove.DataExchangeFramework/Converters/ValueAccessor/FolderPropertyValueAccessorConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/FolderPropertyValueAccessorConverter.cs rename to Brightcove.DataExchangeFramework/Converters/ValueAccessor/FolderPropertyValueAccessorConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/LabelsPropertyValueAccessorConverter.cs b/Brightcove.DataExchangeFramework/Converters/ValueAccessor/LabelsPropertyValueAccessorConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/LabelsPropertyValueAccessorConverter.cs rename to Brightcove.DataExchangeFramework/Converters/ValueAccessor/LabelsPropertyValueAccessorConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/StringDictionaryPropertyValueAccessorConverter.cs b/Brightcove.DataExchangeFramework/Converters/ValueAccessor/StringDictionaryPropertyValueAccessorConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/StringDictionaryPropertyValueAccessorConverter.cs rename to Brightcove.DataExchangeFramework/Converters/ValueAccessor/StringDictionaryPropertyValueAccessorConverter.cs diff --git a/Brightcove.DataExchangeFramework/Converters/VideoIdsPropertyValueAccessorConverter.cs b/Brightcove.DataExchangeFramework/Converters/ValueAccessor/VideoIdsPropertyValueAccessorConverter.cs similarity index 100% rename from Brightcove.DataExchangeFramework/Converters/VideoIdsPropertyValueAccessorConverter.cs rename to Brightcove.DataExchangeFramework/Converters/ValueAccessor/VideoIdsPropertyValueAccessorConverter.cs diff --git a/Brightcove.DataExchangeFramework/Extensions/ItemModelExtensions.cs b/Brightcove.DataExchangeFramework/Extensions/ItemModelExtensions.cs new file mode 100644 index 00000000..3fe5884b --- /dev/null +++ b/Brightcove.DataExchangeFramework/Extensions/ItemModelExtensions.cs @@ -0,0 +1,24 @@ +using Sitecore.Services.Core.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Brightcove.DataExchangeFramework.Extensions +{ + public static class ItemModelExtensions + { + public static string GetLanguage(this ItemModel model) + { + object language = null; + + if(!model.TryGetValue(ItemModel.ItemLanguage, out language)) + { + language = "en"; + } + + return (string)language; + } + } +} diff --git a/Brightcove.DataExchangeFramework/Helpers/ResolveHelper.cs b/Brightcove.DataExchangeFramework/Helpers/ResolveHelper.cs deleted file mode 100644 index 2f9f8beb..00000000 --- a/Brightcove.DataExchangeFramework/Helpers/ResolveHelper.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Brightcove.DataExchangeFramework.Helpers -{ - class ResolveHelper - { - } -} diff --git a/Brightcove.DataExchangeFramework/Processors/BasePipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/BasePipelineStepProcessor.cs index 2eb04641..f08fffaa 100644 --- a/Brightcove.DataExchangeFramework/Processors/BasePipelineStepProcessor.cs +++ b/Brightcove.DataExchangeFramework/Processors/BasePipelineStepProcessor.cs @@ -43,15 +43,13 @@ protected override void ProcessPipelineStep(PipelineStep pipelineStep = null, Pi } catch(Exception ex) { - LogFatal("An unexpected error occured running the pipeline step", ex); - pipelineContext.CriticalError = true; + LogFatal("An unexpected error occured running the internal pipeline step", ex); + pipelineContext.CriticalError = false; } } protected virtual void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) { - LogFatal($"No processor has been defined for the pipeline step"); - pipelineContext.CriticalError = true; return; } @@ -119,7 +117,7 @@ private string GetErrorMessage(string message) private string GetExceptionMessage(Exception ex) { - return $"{ex.GetType()}: {ex.Message}\n{ex.StackTrace}"; + return ex.ToString(); } } } diff --git a/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithEndpointFromProcessor.cs b/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithEndpointFromProcessor.cs deleted file mode 100644 index d6ec9b6f..00000000 --- a/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithEndpointFromProcessor.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Brightcove.Core.Models; -using Brightcove.Core.Services; -using Brightcove.DataExchangeFramework.Settings; -using Sitecore.DataExchange.Attributes; -using Sitecore.DataExchange.Contexts; -using Sitecore.DataExchange.Converters.PipelineSteps; -using Sitecore.DataExchange.Extensions; -using Sitecore.DataExchange.Models; -using Sitecore.DataExchange.Plugins; -using Sitecore.DataExchange.Processors.PipelineSteps; -using Sitecore.DataExchange.Repositories; -using Sitecore.Services.Core.Diagnostics; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Brightcove.DataExchangeFramework.Processors -{ - public class BasePipelineStepWithEndpointFromProcessor : BasePipelineStepWithEndpointsProcessor - { - protected Endpoint EndpointFrom { get; set; } - - - protected override void ProcessPipelineStep(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) - { - if (pipelineStep == null) - { - throw new ArgumentNullException(nameof(pipelineStep)); - } - if (pipelineContext == null) - { - throw new ArgumentNullException(nameof(pipelineContext)); - } - if (logger == null) - { - throw new ArgumentNullException(nameof(logger)); - } - - EndpointSettings endpointSettings = pipelineStep.GetEndpointSettings(); - - if (endpointSettings == null) - { - this.Log(new Action(logger.Error), pipelineContext, "Pipeline step processing will abort because the pipeline step is missing a plugin.", new string[1] - { - "plugin: " + typeof (EndpointSettings).FullName - }); - - pipelineContext.CriticalError = true; - return; - } - - EndpointFrom = endpointSettings.EndpointFrom; - - if (EndpointFrom == null) - { - this.Log(new Action(logger.Error), pipelineContext, "Pipeline step processing will abort because the pipeline step is missing an endpoint to read from.", new string[2] - { - "plugin: " + typeof (EndpointSettings).FullName, - "property: EndpointFrom" - }); - - pipelineContext.CriticalError = true; - return; - } - else if (!this.IsEndpointValid(EndpointFrom, pipelineStep, pipelineContext, logger)) - { - this.Log(new Action(logger.Error), pipelineContext, "Pipeline step processing will abort because the endpoint to read from is not valid.", new string[1] - { - "endpoint: " + EndpointFrom.Name - }); - - pipelineContext.CriticalError = true; - return; - } - } - } -} diff --git a/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithWebApiEndpointProcessor.cs b/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithWebApiEndpointProcessor.cs index 10a4af92..224fdac4 100644 --- a/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithWebApiEndpointProcessor.cs +++ b/Brightcove.DataExchangeFramework/Processors/BasePipelineStepWithWebApiEndpointProcessor.cs @@ -22,100 +22,59 @@ namespace Brightcove.DataExchangeFramework.Processors { - public class BasePipelineStepWithWebApiEndpointProcessor : BasePipelineStepWithEndpointFromProcessor + public class BasePipelineStepWithWebApiEndpointProcessor : BasePipelineStepProcessor { protected WebApiSettings WebApiSettings { get; set; } + protected Endpoint EndpointFrom { get; set; } protected override void ProcessPipelineStep(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) { - base.ProcessPipelineStep(pipelineStep, pipelineContext, logger); - - if (pipelineContext.CriticalError) + if (pipelineStep == null) { - return; + throw new ArgumentNullException(nameof(pipelineStep)); } - - WebApiSettings = EndpointFrom.GetPlugin(); - - if (WebApiSettings == null) + if (pipelineContext == null) { - logger.Error( - "No web api settings specified on the endpoint. " + - "(pipeline step: {0})", - pipelineStep.Name); - - pipelineContext.CriticalError = true; - return; + throw new ArgumentNullException(nameof(pipelineContext)); } - - if (string.IsNullOrWhiteSpace(WebApiSettings.AccountId)) + if (logger == null) { - logger.Error( - "No account ID is specified on the endpoint. " + - "(pipeline step: {0})", - pipelineStep.Name); + throw new ArgumentNullException(nameof(logger)); + } + + EndpointSettings endpointSettings = pipelineStep.GetEndpointSettings(); - pipelineContext.CriticalError = true; + if (endpointSettings == null) + { + LogFatal("Pipeline step processing will abort because the pipeline step is missing endpoint settings."); return; } - if (string.IsNullOrWhiteSpace(WebApiSettings.ClientId)) - { - logger.Error( - "No client ID is specified on the endpoint. " + - "(pipeline step: {0})", - pipelineStep.Name); + EndpointFrom = endpointSettings.EndpointFrom; - pipelineContext.CriticalError = true; + if (EndpointFrom == null) + { + LogFatal("Pipeline step processing will abort because the pipeline step is missing an endpoint to read from."); return; } - if (string.IsNullOrWhiteSpace(WebApiSettings.ClientSecret)) - { - logger.Error( - "No client secret is specified on the endpoint. " + - "(pipeline step: {0})", - pipelineStep.Name); + WebApiSettings = GetPluginOrFail(EndpointFrom); - pipelineContext.CriticalError = true; + if(!WebApiSettings.Validate()) + { + LogFatal("Pipeline step processing will abort because the Brightcove web API settings are invalid: "+WebApiSettings.ValidationMessage); return; } - } - public void SetFolderSettings(string accountName, string folderName) - { - Sitecore.Data.Database masterDB = Sitecore.Configuration.Factory.GetDatabase("master"); - Sitecore.Data.Items.Item node = masterDB.GetItem($"/sitecore/media library/BrightCove/{accountName}/{folderName}"); - if (node == null) + try { - Sitecore.Data.Items.Item parentNode = masterDB.GetItem($"/sitecore/media library/BrightCove/{accountName}"); - Sitecore.Data.Items.Item folder = masterDB.GetItem("/sitecore/templates/Common/Folder"); - parentNode.Add(folderName, new TemplateItem(folder)); - - node = masterDB.GetItem("/sitecore/media library/BrightCove/BrightCove Account/"+ folderName); - using (new Sitecore.Data.Items.EditContext(node, SecurityCheck.Disable)) - { - IsBucketItemCheckBox(node).Checked = true; - } + ProcessPipelineStepInternal(pipelineStep, pipelineContext, logger); } - else + catch (Exception ex) { - using (new Sitecore.Data.Items.EditContext(node, SecurityCheck.Disable)) - { - if (!IsBucketItemCheck(node)) - IsBucketItemCheckBox(node).Checked = true; - } + LogFatal("An unexpected error occured running the internal pipeline step", ex); + pipelineContext.CriticalError = false; } } - - public bool IsBucketItemCheck(Item item) - { - return (((item != null) && (item.Fields[Sitecore.Buckets.Util.Constants.IsBucket] != null)) && item.Fields[Sitecore.Buckets.Util.Constants.IsBucket].Value.Equals("1")); - } - - public CheckboxField IsBucketItemCheckBox(Item item) - { - return item.Fields[Sitecore.Buckets.Util.Constants.IsBucket]; - } } } diff --git a/Brightcove.DataExchangeFramework/Processors/Get/GetExperiencesPipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/Get/GetExperiencesPipelineStepProcessor.cs new file mode 100644 index 00000000..377b0fff --- /dev/null +++ b/Brightcove.DataExchangeFramework/Processors/Get/GetExperiencesPipelineStepProcessor.cs @@ -0,0 +1,38 @@ +using Brightcove.Core.Services; +using Brightcove.DataExchangeFramework.Settings; +using Sitecore.Data.Fields; +using Sitecore.Data.Items; +using Sitecore.DataExchange.Contexts; +using Sitecore.DataExchange.Models; +using Sitecore.DataExchange.Plugins; +using Sitecore.SecurityModel; +using Sitecore.Services.Core.Diagnostics; +using System; +using System.Linq; + +namespace Brightcove.DataExchangeFramework.Processors +{ + class GetExperiencesPipelineStepProcessor : BasePipelineStepWithWebApiEndpointProcessor + { + BrightcoveService service; + + protected override void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) + { + try + { + service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + + var data = service.GetExperiences().Items; + var dataSettings = new IterableDataSettings(data); + + LogDebug("Read " + data.Count() + " experience model(s) from web API"); + + pipelineContext.AddPlugin(dataSettings); + } + catch (Exception ex) + { + LogError($"Failed to get the brightcove models because an unexpected error has occured", ex); + } + } + } +} diff --git a/Brightcove.DataExchangeFramework/Processors/Get/GetFoldersPipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/Get/GetFoldersPipelineStepProcessor.cs new file mode 100644 index 00000000..89a73471 --- /dev/null +++ b/Brightcove.DataExchangeFramework/Processors/Get/GetFoldersPipelineStepProcessor.cs @@ -0,0 +1,50 @@ +using Brightcove.Core.Models; +using Brightcove.Core.Services; +using Brightcove.DataExchangeFramework.Settings; +using Sitecore.DataExchange.Attributes; +using Sitecore.DataExchange.Contexts; +using Sitecore.DataExchange.Converters.PipelineSteps; +using Sitecore.DataExchange.Models; +using Sitecore.DataExchange.Plugins; +using Sitecore.DataExchange.Processors.PipelineSteps; +using Sitecore.DataExchange.Repositories; +using Sitecore.Services.Core.Diagnostics; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Brightcove.DataExchangeFramework.Processors +{ + public class GetFoldersPipelineStepProcessor : BasePipelineStepWithWebApiEndpointProcessor + { + BrightcoveService service; + + protected override void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) + { + try + { + service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + + var folders = service.GetFolders(); + + foreach (Folder folder in folders) + { + folder.LastSyncTime = DateTime.UtcNow; + } + + LogDebug("Read " + folders.Count() + " folder model(s) from web API"); + + var dataSettings = new IterableDataSettings(folders); + + pipelineContext.AddPlugin(dataSettings); + } + catch (Exception ex) + { + LogError($"Failed to get the brightcove models because an unexpected error has occured", ex); + } + } + } +} diff --git a/Brightcove.DataExchangeFramework/Processors/Get/GetLabelsPipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/Get/GetLabelsPipelineStepProcessor.cs new file mode 100644 index 00000000..23ad8534 --- /dev/null +++ b/Brightcove.DataExchangeFramework/Processors/Get/GetLabelsPipelineStepProcessor.cs @@ -0,0 +1,50 @@ +using Brightcove.Core.Models; +using Brightcove.Core.Services; +using Brightcove.DataExchangeFramework.Settings; +using Sitecore.DataExchange.Attributes; +using Sitecore.DataExchange.Contexts; +using Sitecore.DataExchange.Converters.PipelineSteps; +using Sitecore.DataExchange.Models; +using Sitecore.DataExchange.Plugins; +using Sitecore.DataExchange.Processors.PipelineSteps; +using Sitecore.DataExchange.Repositories; +using Sitecore.Services.Core.Diagnostics; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Brightcove.DataExchangeFramework.Processors +{ + public class GetLabelsPipelineStepProcessor : BasePipelineStepWithWebApiEndpointProcessor + { + BrightcoveService service; + + protected override void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) + { + try + { + service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + + var labels = service.GetLabels(); + + foreach (Label label in labels) + { + label.LastSyncTime = DateTime.UtcNow; + } + + LogDebug("Read " + labels.Count() + " label model(s) from web API"); + + var dataSettings = new IterableDataSettings(labels); + + pipelineContext.AddPlugin(dataSettings); + } + catch (Exception ex) + { + LogError($"Failed to get the brightcove models because an unexpected error has occured", ex); + } + } + } +} diff --git a/Brightcove.DataExchangeFramework/Processors/GetPlayListsPipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/Get/GetPlayListsPipelineStepProcessor.cs similarity index 54% rename from Brightcove.DataExchangeFramework/Processors/GetPlayListsPipelineStepProcessor.cs rename to Brightcove.DataExchangeFramework/Processors/Get/GetPlayListsPipelineStepProcessor.cs index 02328b0c..8eaf67b7 100644 --- a/Brightcove.DataExchangeFramework/Processors/GetPlayListsPipelineStepProcessor.cs +++ b/Brightcove.DataExchangeFramework/Processors/Get/GetPlayListsPipelineStepProcessor.cs @@ -21,31 +21,37 @@ namespace Brightcove.DataExchangeFramework.Processors class GetPlayListsPipelineStepProcessor : BasePipelineStepWithWebApiEndpointProcessor { BrightcoveService service; + int totalCount = 0; - protected override void ProcessPipelineStep(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) + protected override void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) { - base.ProcessPipelineStep(pipelineStep, pipelineContext, logger); - service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + try + { + service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + + totalCount = service.PlayListsCount(); + LogDebug("Read " + totalCount + " playlist model(s) from web API"); - var data = this.GetIterableData(WebApiSettings, pipelineStep); - var dataSettings = new IterableDataSettings(data); + var data = this.GetIterableData(WebApiSettings, pipelineStep); + var dataSettings = new IterableDataSettings(data); - pipelineContext.AddPlugin(dataSettings); + pipelineContext.AddPlugin(dataSettings); + } + catch (Exception ex) + { + LogError($"Failed to get the brightcove models because an unexpected error has occured", ex); + } } protected virtual IEnumerable GetIterableData(WebApiSettings settings, PipelineStep pipelineStep) { - int totalPlaylistsCount = service.PlayListsCount(); int limit = 100; - for(int offset = 0; offset < totalPlaylistsCount; offset += limit) + for (int offset = 0; offset < totalCount; offset += limit) { foreach(PlayList playList in service.GetPlayLists(offset, limit)) { - Logger.Debug($"Found the brightcove asset {playList.Id} (pipeline step: {pipelineStep.Name})"); - playList.LastSyncTime = DateTime.UtcNow; - yield return playList; } } diff --git a/Brightcove.DataExchangeFramework/Processors/Get/GetPlayersPipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/Get/GetPlayersPipelineStepProcessor.cs new file mode 100644 index 00000000..58e69a4e --- /dev/null +++ b/Brightcove.DataExchangeFramework/Processors/Get/GetPlayersPipelineStepProcessor.cs @@ -0,0 +1,44 @@ +using Brightcove.Core.Services; +using Brightcove.DataExchangeFramework.Settings; +using Sitecore.Data.Fields; +using Sitecore.Data.Items; +using Sitecore.DataExchange.Contexts; +using Sitecore.DataExchange.Models; +using Sitecore.DataExchange.Plugins; +using Sitecore.SecurityModel; +using Sitecore.Services.Core.Diagnostics; +using System; +using System.Linq; + +namespace Brightcove.DataExchangeFramework.Processors +{ + class GetPlayersPipelineStepProcessor : BasePipelineStepWithWebApiEndpointProcessor + { + BrightcoveService service; + + protected override void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) + { + try + { + service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + + var data = service.GetPlayers().Items; + + foreach (var player in data) + { + player.LastSyncTime = DateTime.UtcNow; + } + + var dataSettings = new IterableDataSettings(data); + + LogDebug("Read " + data.Count() + " player model(s) from web API"); + + pipelineContext.AddPlugin(dataSettings); + } + catch (Exception ex) + { + LogError($"Failed to get the brightcove models because an unexpected error has occured", ex); + } + } + } +} diff --git a/Brightcove.DataExchangeFramework/Processors/GetVideosPipelineStepProcessor.cs b/Brightcove.DataExchangeFramework/Processors/Get/GetVideosPipelineStepProcessor.cs similarity index 56% rename from Brightcove.DataExchangeFramework/Processors/GetVideosPipelineStepProcessor.cs rename to Brightcove.DataExchangeFramework/Processors/Get/GetVideosPipelineStepProcessor.cs index 07d8487f..152bf2a9 100644 --- a/Brightcove.DataExchangeFramework/Processors/GetVideosPipelineStepProcessor.cs +++ b/Brightcove.DataExchangeFramework/Processors/Get/GetVideosPipelineStepProcessor.cs @@ -23,32 +23,37 @@ namespace Brightcove.DataExchangeFramework.Processors public class GetVideosPipelineStepProcessor : BasePipelineStepWithWebApiEndpointProcessor { BrightcoveService service; + int totalCount = 0; - protected override void ProcessPipelineStep(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) + protected override void ProcessPipelineStepInternal(PipelineStep pipelineStep = null, PipelineContext pipelineContext = null, ILogger logger = null) { - base.ProcessPipelineStep(pipelineStep, pipelineContext, logger); + try + { + service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); - service = new BrightcoveService(WebApiSettings.AccountId, WebApiSettings.ClientId, WebApiSettings.ClientSecret); + totalCount = service.VideosCount(); + LogDebug("Read " + totalCount + " video model(s) from web API"); - var data = GetIterableData(pipelineStep); - var dataSettings = new IterableDataSettings(data); + var data = GetIterableData(pipelineStep); + var dataSettings = new IterableDataSettings(data); - pipelineContext.AddPlugin(dataSettings); + pipelineContext.AddPlugin(dataSettings); + } + catch (Exception ex) + { + LogError($"Failed to get the brightcove models because an unexpected error has occured", ex); + } } protected virtual IEnumerable