Skip to content

Instantly share code, notes, and snippets.

View pmedcraft's full-sized avatar

Phil Medcraft pmedcraft

View GitHub Profile
@pmedcraft
pmedcraft / core-service-java-proxy-using-jaxws-maven-plugin.xml
Last active March 2, 2017 21:03
Getting the Java proxy for the SDL Web (Tridion) Core Service using the jaxws-maven-plugin
<dependencies>
<!-- This is for the JAXWS WsImport -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.8</version>
</dependency>
</dependencies>
<build>
@pmedcraft
pmedcraft / core-service-adding-components-to-workflow.java
Last active March 2, 2017 21:02
Adding a list of SDL Web (Tridion) components to Workflow using the SDL Web Core Service in Java
protected void doWorkflow(List<IdentifiableObjectData> updatedComponents) throws Exception {
if (updatedComponents.isEmpty())
return;
try {
// Build the array of components
ArrayOfstring arrayOfComponents = new ArrayOfstring();
for (final IdentifiableObjectData component : updatedComponents) {
arrayOfComponents.getString().add(component.getId().getValue());
}
@pmedcraft
pmedcraft / app-settings-sdlweb-to-sdlmediamanager-migration.xml
Last active March 2, 2017 21:00
C# application settings for SDL Web (Tridion) to SDL Media Manager asset migration tool
<appSettings>
<!-- Properties used by the Core Service -->
<add key="HostName" value="hostname-to-the-sdlweb-cme-server.com" />
<add key="ImpersonationUserDomain" value="the-domain"/>
<add key="ImpersonationUserName" value="the-username" />
<add key="ImpersonationUserPassword" value="********" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
<!-- Properties used by the Media Manager integration -->
<add key="IssuerName" value="http://localhost:89/IWSTrust13" />
<add key="MediaManagerWebServiceAddress" value="https://customerdomain.sdlmedia.com/WebServices/MediaManager2011.svc" />
@pmedcraft
pmedcraft / DownloadFromTridion.cs
Last active March 2, 2017 20:59
C# method for downloading a multimedia asset from SDL Web (Tridion)
private static Dictionary<string, string> DownloadFromTridion(StreamDownloadClient streamDownloadClient, ComponentData multimediaComponent)
{
Dictionary<string, string> downloadInfo = null;
// Prepare file for download in local file system
string originalFileName = Path.GetFileName(multimediaComponent.BinaryContent.Filename);
string downloadFile = Options.MigrationSupportDirectory + originalFileName;
FileStream fs = File.Create(downloadFile);
try
@pmedcraft
pmedcraft / UploadToMediaManager.cs
Created March 3, 2017 12:51
C# methods for uploading a multimedia asset to SDL Media Manager
private static Dictionary<string, object> UploadToMediaManager(IMediaManager2011 mediaManagerClient,
Dictionary<string, string> downloadInfo, long mediaManagerFolderId, long assetTypeId,
long outletId, long[] tags)
{
// Upload to Media Manager
UploadInfoData uploadInfoData = new UploadInfoData
{
Author = "Migration Upload Tool",
MakeAvailableForWebPublishing = true,
ProgramCreation = ProgramCreationOptions.OneProgramPerItem,
@pmedcraft
pmedcraft / ecl-net-tcp-binding.xml
Created March 3, 2017 18:16
SDL Web (Tridion) netTcpBinding for the SessionAwareEclServiceClient
<netTcpBinding>
<binding name="EclNetTcpBinding" maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</netTcpBinding>
@pmedcraft
pmedcraft / ecl-binary-endpoint.xml
Created March 3, 2017 18:20
SDL Web (Tridion) endpoint for the SessionAwareEclServiceClient
<client>
<endpoint name="EclBinaryEndpoint"
address="net.tcp://localhost:2660/ExternalContentLibrary/2012/netTcp"
binding="netTcpBinding"
bindingConfiguration="EclNetTcpBinding"
contract="Tridion.ExternalContentLibrary.Service.Client.ISessionAwareEclService"/>
</client>
@pmedcraft
pmedcraft / update-where-using-components-with-ecl-stub-relationship.cs
Created March 3, 2017 18:50
C# code to replace the relationship between a provided SDL Web (Tridion) component and all its "where using" components with a reference (stub) to an asset originating from SDL Media Manager
private static void UpdateWhereUsingComponents(ICoreService coreServiceClient, SessionAwareEclServiceClient eclClient, ComponentData componentData, Dictionary<string, object> uploadInfo)
{
Dictionary<string, string> stubInfo = null;
try
{
stubInfo = eclClient.CreateOrGetStubUris(new List<string> { "ecl:5-mm-" + uploadInfo["distributionId"] + "-dist-file" });
}
catch(Exception exception)
{
log.Error("Error generating stub for image " + componentData.Id);
@pmedcraft
pmedcraft / MediaManagerHelper.cs
Created March 8, 2017 12:12
C# helper class for connecting to SDL Media Manager
using Migration.MediaManager;
using System.ServiceModel;
using System.IdentityModel.Tokens;
using System.Configuration;
using System.ServiceModel.Security;
using System.IdentityModel.Protocols.WSTrust;
namespace Migration.Helpers
{
public class MediaManagerHelper
@pmedcraft
pmedcraft / App.config
Last active March 23, 2017 17:43
Extracts of an App.config file from an application connecting to SDL Media Manager
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="IssuerName" value="http://localhost:89/IWSTrust13" />
<add key="MediaManagerWebServiceAddress" value="https://TENANTNAME.sdlmedia.com/WebServices/MediaManager2011.svc" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.serviceModel>
<bindings>
<ws2007FederationHttpBinding>