Skip to content

Commit

Permalink
V10.2.X-1.0 (#26)
Browse files Browse the repository at this point in the history
* Update the videos/playlists pull pipelines to automatically refresh the search index to prevent a race condition (#14)

Co-authored-by: Cody Rodgers <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* v10.1.X-37 (#21)

* Fix bug which prevents the user from embedding media in the Siteocre RTE in certain scenarios

* Add support for syncing video scheduling/status information

* Reserialize content

* Add some help text to the new scheduling fields

---------

Co-authored-by: Cody Rodgers <[email protected]>

* Update the embed generator to include an optional alt-text field for iframe accessibility support

* Update all Brightcove templates/items to be unpublishable to prevent unnecessary performance hits

* Update the pull pipeline processors to use the ItemModelRepository and cleanup unnecessary DB requests

* Update the pull pipelines to set and use a new global last sync timestamp

* Update the push pipelines to use the new last sync time

* Update the video push pipeline to suppor the new last sync time field

* Update the value reader/writers to include consistent exception handling

* Update playlist/video page size to 1000

* Update the resolve asset item pipeline to dedup content items

* Add the new clean pipeline batch

* Add retry logic to the brightcove service

* Fix loadPlayer script

* Content Updates

* Fix various bugs

---------

Co-authored-by: Cody Rodgers <[email protected]>
  • Loading branch information
codrod and rdacrodgers authored Nov 11, 2024
1 parent c2b931a commit 6deace4
Show file tree
Hide file tree
Showing 193 changed files with 3,024 additions and 1,731 deletions.
2 changes: 2 additions & 0 deletions Brightcove.Core/EmbedGenerator/Models/EmbedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class EmbedModel

public string Language { get; set; } = "";

public string Title { get; set; } = "";

public EmbedModel()
{

Expand Down
5 changes: 4 additions & 1 deletion Brightcove.Core/Models/Experience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ namespace Brightcove.Core.Models
/// </summary>
public class Experience : Asset
{
[JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty("createdAt", NullValueHandling = NullValueHandling.Ignore)]
public DateTime CreationDate { get; set; }

[JsonProperty("updatedAt", NullValueHandling = NullValueHandling.Ignore)]
public new DateTime? LastModifiedDate { get; set; }

[JsonProperty("publishedUrl", NullValueHandling = NullValueHandling.Ignore)]
public string Url { get; set; }

Expand Down
3 changes: 3 additions & 0 deletions Brightcove.Core/Models/Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class Video : Asset
[JsonProperty("schedule", NullValueHandling = NullValueHandling.Ignore)]
public VideoSchedule Schedule { get; set; }

[JsonProperty("variants", NullValueHandling = NullValueHandling.Ignore)]
public List<VideoVariant> Variants { get; set; }

public Video ShallowCopy()
{
return (Video)this.MemberwiseClone();
Expand Down
1 change: 1 addition & 0 deletions Brightcove.Core/Services/BrightcoveHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class BrightcoveHttpClient
static BrightcoveHttpClient()
{
Instance = new HttpClient();
Instance.Timeout = TimeSpan.FromSeconds(30);
}
}
}
38 changes: 28 additions & 10 deletions Brightcove.Core/Services/BrightcoveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public class BrightcoveService
{
readonly static HttpClient client = BrightcoveHttpClient.Instance;

int retryMax = 3;
int retryAttempt = 0;

readonly string cmsBaseUrl = "https://cms.api.brightcove.com/v1/accounts";
readonly string ingestBaseUrl = "https://ingest.api.brightcove.com/v1/accounts";
readonly string playersBaseUrl = "https://players.api.brightcove.com/v1/accounts";
Expand Down Expand Up @@ -306,6 +309,7 @@ public Video UpdateVideo(Video video)
Video newVideo = video.ShallowCopy();
newVideo.Id = null;
newVideo.Images = null;
newVideo.Variants = null;

string content = JsonConvert.SerializeObject(newVideo);

Expand Down Expand Up @@ -519,12 +523,12 @@ public PlayerList GetPlayers()
return players;
}

public ExperienceList GetExperiences()
public ExperienceList GetExperiences(string query = "", string sort = "")
{
HttpRequestMessage request = new HttpRequestMessage();

request.Method = HttpMethod.Get;
request.RequestUri = new Uri($"{experienceBaseUrl}/{accountId}/experiences");
request.RequestUri = new Uri($"{experienceBaseUrl}/{accountId}/experiences?query={query}&sort={sort}");

HttpResponseMessage response = SendRequest(request);

Expand Down Expand Up @@ -719,12 +723,12 @@ public bool TryGetPlaylist(string playlistId, out PlayList playlist)
return true;
}

public int VideosCount()
public int VideosCount(string query = "")
{
HttpRequestMessage request = new HttpRequestMessage();

request.Method = HttpMethod.Get;
request.RequestUri = new Uri($"{cmsBaseUrl}/{accountId}/counts/videos");
request.RequestUri = new Uri($"{cmsBaseUrl}/{accountId}/counts/videos?query={query}");

HttpResponseMessage response = SendRequest(request);
Count count = JsonConvert.DeserializeObject<Count>(response.Content.ReadAsString());
Expand All @@ -747,16 +751,30 @@ public int PlayListsCount()

private HttpResponseMessage SendRequest(HttpRequestMessage request)
{
request.Headers.Authorization = authenticationService.CreateAuthenticationHeader();
try
{
request.Headers.Authorization = authenticationService.CreateAuthenticationHeader();

HttpResponseMessage response = client.Send(request);
HttpResponseMessage response = client.Send(request);

if (!response.IsSuccessStatusCode)
{
throw new HttpStatusException(request, response);
if (!response.IsSuccessStatusCode)
{
throw new HttpStatusException(request, response);
}

return response;
}
catch(Exception ex)
{
if(retryAttempt < retryMax)
{
retryAttempt++;
return SendRequest(request);
}

return response;
retryAttempt = 0;
throw ex;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,13 @@
<Reference Include="System.Xml.ReaderWriter" />
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\PipelineStep\ApplyMappingPipelineStepConverter.cs" />
<Compile Include="Converters\PipelineStep\PipelineStepWithEndpointFromConverter.cs" />
<Compile Include="Converters\NullableEnumValueReaderConverter.cs" />
<Compile Include="Converters\PipelineStep\SyncPipelineStepConverter.cs" />
<Compile Include="Converters\PipelineStep\ReadAssetItemsPipelineStepConverter.cs" />
<Compile Include="Converters\PipelineStep\UpdatePipelineStepConverter.cs" />
<Compile Include="Converters\PipelineStep\UpdateAssetItemPipelineStepConverter.cs" />
<Compile Include="Converters\PipelineStep\UpdateVideoPipelineStepConverter.cs" />
<Compile Include="Converters\ValueAccessor\LabelsPropertyValueAccessorConverter.cs" />
<Compile Include="Converters\ValueAccessor\FolderPropertyValueAccessorConverter.cs" />
<Compile Include="Converters\ValueAccessor\DateTimePropertyValueAccessorConverter.cs" />
Expand All @@ -435,6 +438,8 @@
<Compile Include="Converters\ValueAccessor\ChainedPropertyValueAccessorConverter.cs" />
<Compile Include="Converters\PipelineStep\ResolveOrUpdateAssetModelPipelineStepConverter.cs" />
<Compile Include="Extensions\ItemModelExtensions.cs" />
<Compile Include="Helpers\BrightcoveSyncSettingsHelper.cs" />
<Compile Include="Helpers\IItemModelRepositoryHelper.cs" />
<Compile Include="Helpers\ItemUpdater.cs" />
<Compile Include="Helpers\Mapper.cs" />
<Compile Include="Processors\BasePipelineStepProcessor.cs" />
Expand All @@ -449,18 +454,23 @@
<Compile Include="Processors\Get\GetVideosPipelineStepProcessor.cs" />
<Compile Include="Processors\Resolve\ResolveFolderModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Resolve\ResolveLabelModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Resolve\ResolvePlayerModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Resolve\ResolvePlayListModelPipelineStepProcessor.cs" />
<Compile Include="Processors\ApplyMappingPipelineStepProcessor.cs" />
<Compile Include="Processors\Sync\ResetSyncPipelineStepProcessor.cs" />
<Compile Include="Processors\Sync\FinishSyncPipelineStepProcessor.cs" />
<Compile Include="Processors\Sync\VerifySyncPipelineStepProcessor.cs" />
<Compile Include="Processors\Sync\StartSyncPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdateAssetItemPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdateLabelModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdateFolderModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdatePlaylistModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdatePlayerModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdateVideoItemProcessor.cs" />
<Compile Include="Processors\Update\UpdateVideoItemPipelineStepProcessor.cs" />
<Compile Include="Processors\Update\UpdateVideoModelPipelineStepProcessor.cs" />
<Compile Include="Processors\Resolve\ResolveVideoModelPipelineStepProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SearchResults\AssetSearchResult.cs" />
<Compile Include="Settings\EndpointsSettings.cs" />
<Compile Include="Settings\BrightcoveSyncSettings.cs" />
<Compile Include="Settings\MappingSettings.cs" />
<Compile Include="Settings\ResolveAssetItemSettings.cs" />
<Compile Include="Settings\ResolveAssetModelSettings.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Brightcove.DataExchangeFramework.Settings;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.DataExchange.ApplyMapping;
using Sitecore.DataExchange.Attributes;
using Sitecore.DataExchange.Models;
using Sitecore.DataExchange.Providers.Sc.Converters.PipelineSteps;
using Sitecore.DataExchange.Repositories;
using Sitecore.Services.Core.Model;
using System;

namespace Brightcove.DataExchangeFramework.Converters
{
[SupportedIds("{AB4AF4DF-D282-4CD1-8268-FA12A9E457A3}")]
public class ApplyMappingPipelineStepConverter : ApplyMappingStepConverter
{
public ApplyMappingPipelineStepConverter(IItemModelRepository repository) : base(repository) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)

if (endpointId != null)
{
Item endpointItem = Sitecore.Context.ContentDatabase.GetItem(new ID(endpointId));
ItemModel endpointItem = ItemModelRepository.Get(endpointId);

if(endpointItem != null)
{
resolveAssetItemSettings.AcccountItemId = endpointItem["Account"];
resolveAssetItemSettings.AcccountItemId = this.GetStringValue(endpointItem, "Account") ?? "";
resolveAssetItemSettings.RelativePath = this.GetStringValue(source, "RelativePath") ?? "";

Database database = Sitecore.Configuration.Factory.GetDatabase(ItemModelRepository.DatabaseName);
resolveAssetItemSettings.AccountItem = database.GetItem(resolveAssetItemSettings.AcccountItemId);
resolveAssetItemSettings.ParentItem = database.GetItem(resolveAssetItemSettings.AccountItem?.Paths?.Path + "/" + resolveAssetItemSettings.RelativePath);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)

if (endpointId != null)
{
Item endpointItem = Sitecore.Context.ContentDatabase.GetItem(new ID(endpointId));
ItemModel endpointItem = ItemModelRepository.Get(endpointId);

if (endpointItem != null)
{
resolveAssetItemSettings.AcccountItemId = endpointItem["Account"];
resolveAssetItemSettings.AcccountItemId = this.GetStringValue(endpointItem, "Account") ?? "";
resolveAssetItemSettings.RelativePath = this.GetStringValue(source, "RelativePath") ?? "";

Database database = Sitecore.Configuration.Factory.GetDatabase(ItemModelRepository.DatabaseName);
resolveAssetItemSettings.AccountItem = database.GetItem(resolveAssetItemSettings.AcccountItemId);
resolveAssetItemSettings.ParentItem = database.GetItem(resolveAssetItemSettings.AccountItem?.Paths?.Path + "/" + resolveAssetItemSettings.RelativePath);
}
}

//We need to store the resolve asset item plugin in the global Sitecore.DataExchangeContext so it
//can be used in the VideoIdsPropertyValueReader
if (Sitecore.DataExchange.Context.GetPlugin<ResolveAssetItemSettings>() == null)
{
Sitecore.DataExchange.Context.Plugins.Add(resolveAssetItemSettings);
}

pipelineStep.AddPlugin<ResolveAssetItemSettings>(resolveAssetItemSettings);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Brightcove.DataExchangeFramework.Settings;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.DataExchange.Attributes;
using Sitecore.DataExchange.Converters.PipelineSteps;
using Sitecore.DataExchange.Models;
using Sitecore.DataExchange.Providers.Sc.Converters.PipelineSteps;
using Sitecore.DataExchange.Repositories;
using Sitecore.Services.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Brightcove.DataExchangeFramework.Converters
{
public class SyncPipelineStepConverter : BasePipelineStepConverter
{
public SyncPipelineStepConverter(IItemModelRepository repository) : base(repository)
{

}

protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
{
Guid endpointId = this.GetGuidValue(source, "EndpointFrom");
BrightcoveSyncSettings settings = new BrightcoveSyncSettings();

if (endpointId != null)
{
ItemModel endpointItem = ItemModelRepository.Get(endpointId);

if(endpointItem != null)
{
string accountId = this.GetStringValue(endpointItem, "Account") ?? "";
settings.AccountItem = ItemModelRepository.Get(accountId);
}
}

pipelineStep.AddPlugin(settings);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Brightcove.DataExchangeFramework.Settings;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.DataExchange.ApplyMapping;
using Sitecore.DataExchange.Attributes;
using Sitecore.DataExchange.Models;
using Sitecore.DataExchange.Providers.Sc.Converters.PipelineSteps;
using Sitecore.DataExchange.Repositories;
using Sitecore.Services.Core.Model;
using System;

namespace Brightcove.DataExchangeFramework.Converters
{
[SupportedIds("{F4AF37B2-F92D-4E49-A017-3D7489E23910}")]
public class UpdateAssetItemPipelineStepConverter : UpdateSitecoreItemStepConverter
{
public UpdateAssetItemPipelineStepConverter(IItemModelRepository repository) : base(repository) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using Brightcove.DataExchangeFramework.Settings;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.DataExchange.Attributes;
using Sitecore.DataExchange.Converters.PipelineSteps;
using Sitecore.DataExchange.DataAccess;
using Sitecore.DataExchange.Models;
using Sitecore.DataExchange.Plugins;
using Sitecore.DataExchange.Providers.Sc.Converters.PipelineSteps;
using Sitecore.DataExchange.Repositories;
using Sitecore.Services.Core.Model;
using System;

namespace Brightcove.DataExchangeFramework.Converters
{
[SupportedIds("{D79A5F5C-9A5E-4B1C-B884-8E3B97CACA2D}", "{F598D123-2FE9-45D3-99E2-3E4B5063190A}")]
public class UpdateVideoPipelineStepConverter : BasePipelineStepConverter
{
public UpdateVideoPipelineStepConverter(IItemModelRepository repository) : base(repository) { }

protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
{
MappingSettings mappingSettings = new MappingSettings()
{
ModelMappingSets = this.ConvertReferencesToModels<IMappingSet>(source, "ModelMappingSets"),
VariantMappingSets = this.ConvertReferencesToModels<IMappingSet>(source, "VariantMappingSets"),
SourceObjectLocation = this.GetGuidValue(source, "SourceObjectLocation"),
TargetObjectLocation = this.GetGuidValue(source, "TargetObjectLocation")
};

pipelineStep.AddPlugin<MappingSettings>(mappingSettings);

BrightcoveEndpointSettings endpointSettings = new BrightcoveEndpointSettings()
{
BrightcoveEndpoint = this.ConvertReferenceToModel<Endpoint>(source, "BrightcoveEndpoint"),
SitecoreEndpoint = this.ConvertReferenceToModel<Endpoint>(source, "SitecoreEndpoint")
};

pipelineStep.AddPlugin<BrightcoveEndpointSettings>(endpointSettings);

Guid endpointId = this.GetGuidValue(source, "BrightcoveEndpoint");

if(endpointId == null)
{
return;
}

ItemModel endpointModel = ItemModelRepository.Get(endpointId);

if(endpointModel == null)
{
return;
}

Guid accountItemId = this.GetGuidValue(endpointModel, "Account");

if(accountItemId == null)
{
return;
}

ItemModel accountItem = ItemModelRepository.Get(accountItemId);

if(accountItem == null)
{
return;
}

WebApiSettings webApiSettings = new WebApiSettings();

if (accountItem != null)
{
webApiSettings.AccountId = this.GetStringValue(accountItem, "AccountId") ?? "";
webApiSettings.ClientId = this.GetStringValue(accountItem, "ClientId") ?? "";
webApiSettings.ClientSecret = this.GetStringValue(accountItem, "ClientSecret") ?? "";
}

endpointSettings.BrightcoveEndpoint.AddPlugin(webApiSettings);
}
}
}
Loading

0 comments on commit 6deace4

Please sign in to comment.